Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Nov 2019 14:15:53 +0200
From:      Michael Pounov <misho@elwix.org>
To:        freebsd-net@freebsd.org, bryanv@FreeBSD.org
Subject:   vxlan interface mtu when clonning
Message-ID:  <20191119141553.ca59c2aba580953f71e598ff@elwix.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

--Multipart=_Tue__19_Nov_2019_14_15_53_+0200_bs9x9ZGSCr6g9di8
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi there

Do you thinking that is good idea to have ability for automatically adjust MTU of vxlan in clone phase?

When I doing clone/create of vxlan interface automatically doing adjust of vxlan MTU according multicast vxlandev interface.

If this is valuable for project can take it.

-- 
Michael Pounov
ELWIX - Embedded LightWeight unIX -

--Multipart=_Tue__19_Nov_2019_14_15_53_+0200_bs9x9ZGSCr6g9di8
Content-Type: text/x-diff;
 name="if_vxlan_clone.patch"
Content-Disposition: attachment;
 filename="if_vxlan_clone.patch"
Content-Transfer-Encoding: 7bit

--- if_vxlan.c	2019-11-19 13:57:56.046105000 +0200
+++ if_vxlan.c	2019-11-19 14:02:21.057692000 +0200
@@ -2725,8 +2725,9 @@
 vxlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 {
 	struct vxlan_softc *sc;
-	struct ifnet *ifp;
+	struct ifnet *ifp, *ifpp;
 	struct ifvxlanparam vxlp;
+	const short r4hdrs = 100;	/* Reasonable standard offset for MTU from vxlandev iface */
 	int error;
 
 	sc = malloc(sizeof(struct vxlan_softc), M_VXLAN, M_WAITOK | M_ZERO);
@@ -2776,6 +2777,22 @@
 
 	ifp->if_baudrate = 0;
 	ifp->if_hdrlen = 0;
+
+	if (vxlp.vxlp_with & VXLAN_PARAM_WITH_MULTICAST_IF) {
+		ifpp = ifunit_ref(sc->vxl_mc_ifname);
+		if (ifpp == NULL) {
+			if_printf(sc->vxl_ifp, "multicast interface %s does "
+			    "not exist\n", sc->vxl_mc_ifname);
+			goto fail;
+		}
+		if (ifpp->if_mtu <= r4hdrs) {
+			if_printf(sc->vxl_ifp, "multicast interface %s does "
+			    "not have sufficient MTU\n", sc->vxl_mc_ifname);
+			goto fail;
+		}
+
+		ifp->if_mtu = ifpp->if_mtu - r4hdrs;
+	}
 
 	return (0);
 

--Multipart=_Tue__19_Nov_2019_14_15_53_+0200_bs9x9ZGSCr6g9di8--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191119141553.ca59c2aba580953f71e598ff>