From owner-svn-src-stable@freebsd.org Wed Jun 10 13:06:14 2020 Return-Path: Delivered-To: svn-src-stable@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 D1449333F9C; Wed, 10 Jun 2020 13:06:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49hnLG57Qwz3yMh; Wed, 10 Jun 2020 13:06:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB1BF272B0; Wed, 10 Jun 2020 13:06:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05AD6EtD063945; Wed, 10 Jun 2020 13:06:14 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05AD6Dmf063941; Wed, 10 Jun 2020 13:06:13 GMT (envelope-from ae@FreeBSD.org) Message-Id: <202006101306.05AD6Dmf063941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 10 Jun 2020 13:06:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362009 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 362009 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2020 13:06:14 -0000 Author: ae Date: Wed Jun 10 13:06:13 2020 New Revision: 362009 URL: https://svnweb.freebsd.org/changeset/base/362009 Log: MFC r361749: Add if_reassign method to all tunneling interfaces. After r339550 tunneling interfaces have started handle appearing and disappearing of ingress IP address on the host system. When such interfaces are moving into VNET jail, they lose ability to properly handle ifaddr_event_ext event. And this leads to need to reconfigure tunnel to make it working again. Since moving an interface into VNET jail leads to removing of all IP addresses, it looks consistent, that tunnel configuration should also be cleared. This is what will do if_reassign method. Reported by: John W. O'Brien Modified: stable/12/sys/net/if_gif.c stable/12/sys/net/if_gre.c stable/12/sys/net/if_ipsec.c stable/12/sys/net/if_me.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if_gif.c ============================================================================== --- stable/12/sys/net/if_gif.c Wed Jun 10 09:31:37 2020 (r362008) +++ stable/12/sys/net/if_gif.c Wed Jun 10 13:06:13 2020 (r362009) @@ -104,6 +104,9 @@ void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struc void (*ng_gif_attach_p)(struct ifnet *ifp); void (*ng_gif_detach_p)(struct ifnet *ifp); +#ifdef VIMAGE +static void gif_reassign(struct ifnet *, struct vnet *, char *); +#endif static void gif_delete_tunnel(struct gif_softc *); static int gif_ioctl(struct ifnet *, u_long, caddr_t); static int gif_transmit(struct ifnet *, struct mbuf *); @@ -150,6 +153,9 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr GIF2IFP(sc)->if_transmit = gif_transmit; GIF2IFP(sc)->if_qflush = gif_qflush; GIF2IFP(sc)->if_output = gif_output; +#ifdef VIMAGE + GIF2IFP(sc)->if_reassign = gif_reassign; +#endif GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE; GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE; if_attach(GIF2IFP(sc)); @@ -159,6 +165,21 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr return (0); } + +#ifdef VIMAGE +static void +gif_reassign(struct ifnet *ifp, struct vnet *new_vnet __unused, + char *unused __unused) +{ + struct gif_softc *sc; + + sx_xlock(&gif_ioctl_sx); + sc = ifp->if_softc; + if (sc != NULL) + gif_delete_tunnel(sc); + sx_xunlock(&gif_ioctl_sx); +} +#endif /* VIMAGE */ static void gif_clone_destroy(struct ifnet *ifp) Modified: stable/12/sys/net/if_gre.c ============================================================================== --- stable/12/sys/net/if_gre.c Wed Jun 10 09:31:37 2020 (r362008) +++ stable/12/sys/net/if_gre.c Wed Jun 10 13:06:13 2020 (r362009) @@ -107,6 +107,9 @@ static void gre_clone_destroy(struct ifnet *); VNET_DEFINE_STATIC(struct if_clone *, gre_cloner); #define V_gre_cloner VNET(gre_cloner) +#ifdef VIMAGE +static void gre_reassign(struct ifnet *, struct vnet *, char *); +#endif static void gre_qflush(struct ifnet *); static int gre_transmit(struct ifnet *, struct mbuf *); static int gre_ioctl(struct ifnet *, u_long, caddr_t); @@ -183,12 +186,30 @@ gre_clone_create(struct if_clone *ifc, int unit, caddr GRE2IFP(sc)->if_ioctl = gre_ioctl; GRE2IFP(sc)->if_transmit = gre_transmit; GRE2IFP(sc)->if_qflush = gre_qflush; +#ifdef VIMAGE + GRE2IFP(sc)->if_reassign = gre_reassign; +#endif GRE2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE; GRE2IFP(sc)->if_capenable |= IFCAP_LINKSTATE; if_attach(GRE2IFP(sc)); bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t)); return (0); } + +#ifdef VIMAGE +static void +gre_reassign(struct ifnet *ifp, struct vnet *new_vnet __unused, + char *unused __unused) +{ + struct gre_softc *sc; + + sx_xlock(&gre_ioctl_sx); + sc = ifp->if_softc; + if (sc != NULL) + gre_delete_tunnel(sc); + sx_xunlock(&gre_ioctl_sx); +} +#endif /* VIMAGE */ static void gre_clone_destroy(struct ifnet *ifp) Modified: stable/12/sys/net/if_ipsec.c ============================================================================== --- stable/12/sys/net/if_ipsec.c Wed Jun 10 09:31:37 2020 (r362008) +++ stable/12/sys/net/if_ipsec.c Wed Jun 10 13:06:13 2020 (r362009) @@ -169,6 +169,9 @@ static int ipsec_set_addresses(struct ifnet *, struct static int ipsec_set_reqid(struct ipsec_softc *, uint32_t); static void ipsec_set_running(struct ipsec_softc *); +#ifdef VIMAGE +static void ipsec_reassign(struct ifnet *, struct vnet *, char *); +#endif static void ipsec_srcaddr(void *, const struct sockaddr *, int); static int ipsec_ioctl(struct ifnet *, u_long, caddr_t); static int ipsec_transmit(struct ifnet *, struct mbuf *); @@ -200,11 +203,29 @@ ipsec_clone_create(struct if_clone *ifc, int unit, cad ifp->if_transmit = ipsec_transmit; ifp->if_qflush = ipsec_qflush; ifp->if_output = ipsec_output; +#ifdef VIMAGE + ifp->if_reassign = ipsec_reassign; +#endif if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(uint32_t)); return (0); } + +#ifdef VIMAGE +static void +ipsec_reassign(struct ifnet *ifp, struct vnet *new_vnet __unused, + char *unused __unused) +{ + struct ipsec_softc *sc; + + sx_xlock(&ipsec_ioctl_sx); + sc = ifp->if_softc; + if (sc != NULL) + ipsec_delete_tunnel(sc); + sx_xunlock(&ipsec_ioctl_sx); +} +#endif /* VIMAGE */ static void ipsec_clone_destroy(struct ifnet *ifp) Modified: stable/12/sys/net/if_me.c ============================================================================== --- stable/12/sys/net/if_me.c Wed Jun 10 09:31:37 2020 (r362008) +++ stable/12/sys/net/if_me.c Wed Jun 10 13:06:13 2020 (r362009) @@ -113,6 +113,9 @@ static void me_clone_destroy(struct ifnet *); VNET_DEFINE_STATIC(struct if_clone *, me_cloner); #define V_me_cloner VNET(me_cloner) +#ifdef VIMAGE +static void me_reassign(struct ifnet *, struct vnet *, char *); +#endif static void me_qflush(struct ifnet *); static int me_transmit(struct ifnet *, struct mbuf *); static int me_ioctl(struct ifnet *, u_long, caddr_t); @@ -200,12 +203,30 @@ me_clone_create(struct if_clone *ifc, int unit, caddr_ ME2IFP(sc)->if_ioctl = me_ioctl; ME2IFP(sc)->if_transmit = me_transmit; ME2IFP(sc)->if_qflush = me_qflush; +#ifdef VIMAGE + ME2IFP(sc)->if_reassign = me_reassign; +#endif ME2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE; ME2IFP(sc)->if_capenable |= IFCAP_LINKSTATE; if_attach(ME2IFP(sc)); bpfattach(ME2IFP(sc), DLT_NULL, sizeof(u_int32_t)); return (0); } + +#ifdef VIMAGE +static void +me_reassign(struct ifnet *ifp, struct vnet *new_vnet __unused, + char *unused __unused) +{ + struct me_softc *sc; + + sx_xlock(&me_ioctl_sx); + sc = ifp->if_softc; + if (sc != NULL) + me_delete_tunnel(sc); + sx_xunlock(&me_ioctl_sx); +} +#endif /* VIMAGE */ static void me_clone_destroy(struct ifnet *ifp)