Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jul 2019 16:10:21 +0000 (UTC)
From:      Kirill Ponomarev <krion@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350293 - head/sys/net
Message-ID:  <201907241610.x6OGALkO088982@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: krion (ports committer)
Date: Wed Jul 24 16:10:20 2019
New Revision: 350293
URL: https://svnweb.freebsd.org/changeset/base/350293

Log:
  Allow set MTU more than 1500 bytes.
  
  Submitted by:	Alexandr Fedorov <aleksandr.fedorov_itglobal_dot_com>
  Approved by:	jhb, rgrimes
  Sponsored by:	ITGlobal.com
  Differential Revision:	https://reviews.freebsd.org/D19422

Modified:
  head/sys/net/if_vxlan.c

Modified: head/sys/net/if_vxlan.c
==============================================================================
--- head/sys/net/if_vxlan.c	Wed Jul 24 15:18:05 2019	(r350292)
+++ head/sys/net/if_vxlan.c	Wed Jul 24 16:10:20 2019	(r350293)
@@ -84,6 +84,15 @@ struct vxlan_socket_mc_info {
 	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 @@ vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t dat
 	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 @@ vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t dat
 		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 @@ vxlan_clone_create(struct if_clone *ifc, int unit, cad
 	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);



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