On Tue, Jun 10, 2014 at 4:47 PM, Jesse Gross <je...@nicira.com> wrote:
> In some cases, the names of tunnel protocols are longer than the
> maximum allowed after concatenating port numbers. This truncates
> names to the correct size rather than assert-failing on the assumption
> that collisions between names of protocols are rather rate.
>
> Signed-off-by: Jesse Gross <je...@nicira.com>
Looks good.

Acked-by: Pravin B Shelar <pshe...@nicira.com>

> ---
>  lib/netdev-vport.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
> index c214bf7..4dca091 100644
> --- a/lib/netdev-vport.c
> +++ b/lib/netdev-vport.c
> @@ -151,14 +151,12 @@ netdev_vport_get_dpif_port(const struct netdev *netdev,
>          const char *type = netdev_get_type(netdev);
>
>          /*
> -         * Note: IFNAMSIZ is 16 bytes long. The maximum length of a VXLAN
> -         * or LISP port name below is 15 or 14 bytes respectively. Still,
> -         * assert here on the size of strlen(type) in case that changes
> -         * in the future.
> +         * Note: IFNAMSIZ is 16 bytes long. If the length of the type plus
> +         * the rest of the name is greater than this, trucate the type to
> +         * fit. The probability of collisions seems quite low.
>           */
>          BUILD_ASSERT(NETDEV_VPORT_NAME_BUFSIZE >= IFNAMSIZ);
> -        ovs_assert(strlen(type) + 10 < IFNAMSIZ);
> -        snprintf(namebuf, bufsize, "%s_sys_%d", type,
> +        snprintf(namebuf, bufsize, "%.5s_sys_%d", type,
>                   ntohs(vport->tnl_cfg.dst_port));
>          return namebuf;
>      } else {
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to