aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2020-06-03 13:02:31 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2020-06-03 13:02:31 +0000
commitdd4490fdab598b56c40619e1bbb51b2da4420518 (patch)
tree47920abadf4288ebffb4fb58e422cebd3241cb4c /sys/net
parent693d10a29176e9128d5d09bbd74c9205addc091b (diff)
downloadsrc-dd4490fdab598b56c40619e1bbb51b2da4420518.tar.gz
src-dd4490fdab598b56c40619e1bbb51b2da4420518.zip
Add if_reassing 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_reassing method. Reported by: John W. O'Brien <john saltant com> MFC after: 1 week
Notes
Notes: svn path=/head/; revision=361749
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_gif.c21
-rw-r--r--sys/net/if_gre.c21
-rw-r--r--sys/net/if_ipsec.c21
-rw-r--r--sys/net/if_me.c21
4 files changed, 84 insertions, 0 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 94e88615d3bb..4b238a2e10da 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -104,6 +104,9 @@ void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m, int af);
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_t params)
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));
@@ -160,6 +166,21 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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)
{
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index bd940b579393..aa3e4062b060 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -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,6 +186,9 @@ gre_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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));
@@ -190,6 +196,21 @@ gre_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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)
{
diff --git a/sys/net/if_ipsec.c b/sys/net/if_ipsec.c
index 737d840bbac7..d863b26eaff9 100644
--- a/sys/net/if_ipsec.c
+++ b/sys/net/if_ipsec.c
@@ -170,6 +170,9 @@ static int ipsec_set_addresses(struct ifnet *, struct sockaddr *,
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 *);
@@ -201,12 +204,30 @@ ipsec_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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)
{
diff --git a/sys/net/if_me.c b/sys/net/if_me.c
index 7a9e88e034cf..aafc07c2b203 100644
--- a/sys/net/if_me.c
+++ b/sys/net/if_me.c
@@ -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,6 +203,9 @@ me_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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));
@@ -207,6 +213,21 @@ me_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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)
{