aleksandr.fedorov_itglobal.com updated this revision to Diff 59753.
aleksandr.fedorov_itglobal.com added a comment.


  VXLAN encapsulate ethernet frames within UDP/IP packets. So, we can calculate 
maximum overhead for IPv4:
  
  - IP_MAXPACKET = 65K - constant from netinet/ip.h.
  - Maximum IP header length IP_MAX_HDR_LEN (There is no suitable constant for 
it.) = 60 as the Internet Header Length field is the unsigned 4-bit number of 
32-bit words - 15 * 32 = 480 bit = 60 bytes.
  - sizeof(struct udphdr) = 8 bytes.
  - sizeof(struct vxlan_header) = 8 bytes.
  - Inner frame ETHER_HDR_LEN = 14 bytes.
  - Inner frame ETHER_CRC_LEN = 4 bytes.
  - Inner frame ETHER_VLAN_ENCAP_LEN = 4 bytes.
  
  The result VXLAN_MAX_MTU = IP_MAXPACKET - IP_MAX_HDR_LEN - sizeof(struct 
udphdr) - sizeof(struct vxlan_header) - ETHER_HDR_LEN - ETHER_CRC_LEN - 
ETHER_VLAN_ENCAP_LEN = 65535 - 60 - 8 - 8 - 14 - 4 - 4 = 65437
  So overhead is 98 bytes.
  
  Unfortunately for IPv6, the maximum header length is not fixed and can be 
extended in the future. It is usually 40 bytes.
  
  Revision changes:
  
  - Calculate VXLAN_MAX_MTU using existing constants.

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D19422?vs=59684&id=59753

CHANGES SINCE LAST ACTION
  https://reviews.freebsd.org/D19422/new/

REVISION DETAIL
  https://reviews.freebsd.org/D19422

AFFECTED FILES
  sys/net/if_vxlan.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: aleksandr.fedorov_itglobal.com, bryanv, hrs, #network, rgrimes, krion, jhb
Cc: evgueni.gavrilov_itglobal.com, olevole_olevole.ru, ae, freebsd-net-list, 
krzysztof.galazka_intel.com
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -84,6 +84,15 @@
 	int				 vxlsomc_users;
 };
 
+/*
+ * The maximum MTU of encapsulated ethernet frame within IPv4/UDP packet.
+ */
+#define VXLAN_MAX_MTU	(IP_MAXPACKET - \
+		60 /* Maximum IPv4 header len */ - \
+		sizeof(struct udphdr) - \
+		sizeof(struct vxlan_header) - \
+		ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)
+
 #define VXLAN_SO_MC_MAX_GROUPS		32
 
 #define VXLAN_SO_VNI_HASH_SHIFT		6
@@ -2247,10 +2256,11 @@
 	ifr = (struct ifreq *) data;
 	ifd = (struct ifdrv *) data;
 
+	error = 0;
+
 	switch (cmd) {
 	case SIOCADDMULTI:
 	case SIOCDELMULTI:
-		error = 0;
 		break;
 
 	case SIOCGDRVSPEC:
@@ -2267,6 +2277,13 @@
 		error = ifmedia_ioctl(ifp, ifr, &sc->vxl_media, cmd);
 		break;
 
+	case SIOCSIFMTU:
+		if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > VXLAN_MAX_MTU)
+			error = EINVAL;
+		else
+			ifp->if_mtu = ifr->ifr_mtu;
+		break;
+
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		break;
@@ -2747,8 +2764,8 @@
 	ifp->if_ioctl = vxlan_ioctl;
 	ifp->if_transmit = vxlan_transmit;
 	ifp->if_qflush = vxlan_qflush;
-	ifp->if_capabilities |= IFCAP_LINKSTATE;
-	ifp->if_capenable |= IFCAP_LINKSTATE;
+	ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU;
+	ifp->if_capenable |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU;
 
 	ifmedia_init(&sc->vxl_media, 0, vxlan_media_change, vxlan_media_status);
 	ifmedia_add(&sc->vxl_media, IFM_ETHER | IFM_AUTO, 0, NULL);

_______________________________________________
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to