[ovs-dev] [PATCH] dpif-netlink-rtnl: Set suitable value to ovs geneve and vxlan interfaces' mtu.

Eric Garver e at erig.me
Tue Oct 17 20:33:31 UTC 2017


On Tue, Oct 17, 2017 at 05:53:37PM +0800, JunhanYan wrote:
> From af5c8a50141c7e1a7723a7f992a9e71ad531274d Mon Sep 17 00:00:00 2001
> From: JunhanYan <juyan at redhat.com>
> Date: Tue, 17 Oct 2017 17:26:20 +0800
> Subject: [PATCH] In ovs mtu of ovs geneve interface genev_sys_6081 is always
>  0xffff, mtu of vxlan vxlan_sys_4789 is good for ipv4 vxlan, but for ipv6
>  vxlan, it is still 65470 as ipv4 vxlan, it's not resonable.
> 
> For vxlan, linux kernel do some work for the mtu, so the mtu of
> ipv4 vxlan looks good.
> This patch fixed this issue in ovs, for the udp tunnel,
> calculate the tunnel interface in ovs, and send the final
> value to the kernel from rtnetlink.
> 
> Signed-off-by: JunhanYan <juyan at redhat.com>

Hi,

Thanks for the patch. It's worth noting that newer kernels will clamp
the MTU value.

> ---
>  lib/dpif-netlink-rtnl.c | 19 ++++++++++++++++++-
>  lib/packets.h           |  6 ++++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c
> index 0c32e7d..d1b227a 100644
> --- a/lib/dpif-netlink-rtnl.c
> +++ b/lib/dpif-netlink-rtnl.c
> @@ -58,6 +58,12 @@ VLOG_DEFINE_THIS_MODULE(dpif_netlink_rtnl);
>  #define IFLA_GENEVE_UDP_ZERO_CSUM6_RX 10
>  #endif
> 
> +#define IP_MAX_MTU      0xFFF0U
> +/* IP header + UDP + VXLAN/GENEVE + Ethernet header */
> +#define UDP_TNL_HEADROOM (20 + 8 + 8 + 14)
> +/* IPv6 header + UDP + VXLAN/GENEVE + Ethernet header */
> +#define UDP6_TNL_HEADROOM (40 + 8 + 8 + 14)
> +
>  static const struct nl_policy rtlink_policy[] = {
>      [IFLA_LINKINFO] = { .type = NL_A_NESTED },
>  };
> @@ -281,13 +287,24 @@ dpif_netlink_rtnl_create(const struct
> netdev_tunnel_config *tnl_cfg,

This patch fails to apply because git-am barfs here. This line belongs
on the line above it - likely because your email client wrapped it.
You'll have better results using git-send-email.

>      struct ifinfomsg *ifinfo;
>      struct ofpbuf request;
>      int err;
> +    uint16_t tnl_mtu;
> 
>      ofpbuf_init(&request, 0);
>      nl_msg_put_nlmsghdr(&request, 0, RTM_NEWLINK, flags);
>      ifinfo = ofpbuf_put_zeros(&request, sizeof(struct ifinfomsg));
>      ifinfo->ifi_change = ifinfo->ifi_flags = IFF_UP;
>      nl_msg_put_string(&request, IFLA_IFNAME, name);
> -    nl_msg_put_u32(&request, IFLA_MTU, UINT16_MAX);
> +    /* set mtu for udp tunnel*/
> +    if (type == OVS_VPORT_TYPE_VXLAN || type == OVS_VPORT_TYPE_GENEVE){

./utilities/checkpatch.py complains about the curly brace here. There
should be a space.

> +       if (in6_addr_is_mapped_ipv4(&tnl_cfg->ipv6_dst)){

ditto.

> +           tnl_mtu = IP_MAX_MTU - UDP_TNL_HEADROOM;
> +       }else{

ditto.

> +           tnl_mtu = IP_MAX_MTU - UDP6_TNL_HEADROOM;
> +       }
> +    }else{

ditto.

> +           tnl_mtu = UINT16_MAX;
> +    }
> +    nl_msg_put_u32(&request, IFLA_MTU, tnl_mtu);
>      linkinfo_off = nl_msg_start_nested(&request, IFLA_LINKINFO);
>      nl_msg_put_string(&request, IFLA_INFO_KIND, kind);
>      infodata_off = nl_msg_start_nested(&request, IFLA_INFO_DATA);
> diff --git a/lib/packets.h b/lib/packets.h
> index 705d0b2..9d56b42 100644
> --- a/lib/packets.h
> +++ b/lib/packets.h
> @@ -1115,6 +1115,12 @@ in6_addr_get_mapped_ipv4(const struct in6_addr *addr)
>      }
>  }
> 
> +static inline bool
> +in6_addr_is_mapped_ipv4(const struct in6_addr *ipv6_addr)
> +{
> +    return IN6_IS_ADDR_V4MAPPED(ipv6_addr);
> +}

I don't see why this inline is necessary. Can you use
IN6_IS_ADDR_V4MAPPED() directly?

> +
>  static inline void
>  in6_addr_solicited_node(struct in6_addr *addr, const struct in6_addr *ip6)
>  {
> -- 
> 2.9.3
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev


More information about the dev mailing list