From owner-freebsd-net@freebsd.org Tue Nov 19 12:17:34 2019 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 99D621B0E38 for ; Tue, 19 Nov 2019 12:17:34 +0000 (UTC) (envelope-from misho@elwix.org) Received: from mail.elwix.net (ns.aitbg.com [84.242.154.175]) by mx1.freebsd.org (Postfix) with ESMTP id 47HPwF37KPz4PjX; Tue, 19 Nov 2019 12:17:32 +0000 (UTC) (envelope-from misho@elwix.org) Received: from meow.tbc.cloudsigma.com (unknown [91.92.71.51]) by mail.elwix.net (Postfix) with ESMTPSA id B0B5A4A1505E; Tue, 19 Nov 2019 14:17:24 +0200 (EET) Date: Tue, 19 Nov 2019 14:15:53 +0200 From: Michael Pounov To: freebsd-net@freebsd.org, bryanv@FreeBSD.org Subject: vxlan interface mtu when clonning Message-Id: <20191119141553.ca59c2aba580953f71e598ff@elwix.org> Organization: ELWIX X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Tue__19_Nov_2019_14_15_53_+0200_bs9x9ZGSCr6g9di8" X-Rspamd-Queue-Id: 47HPwF37KPz4PjX X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of misho@elwix.org has no SPF policy when checking 84.242.154.175) smtp.mailfrom=misho@elwix.org X-Spamd-Result: default: False [1.93 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.42)[-0.417,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MV_CASE(0.50)[]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; TO_DN_NONE(0.00)[]; AUTH_NA(1.00)[]; DMARC_NA(0.00)[elwix.org]; HAS_ORG_HEADER(0.00)[]; IP_SCORE(0.01)[country: BG(0.04)]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(0.84)[0.837,0]; R_SPF_NA(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:29580, ipnet:84.242.152.0/21, country:BG]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Nov 2019 12:17:34 -0000 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--