1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-07 13:14:51 +00:00

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
This commit is contained in:
Andrey V. Elsukov 2020-06-03 13:02:31 +00:00
parent 693d10a291
commit dd4490fdab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361749
4 changed files with 84 additions and 0 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{