1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

Add the check that current VNET is ready and access to srchash is allowed.

This change is similar to r339646. The callback that checks for appearing
and disappearing of tunnel ingress address can be called during VNET
teardown. To prevent access to already freed memory, add check to the
callback and epoch_wait() call to be sure that callback has finished its
work.

MFC after:	20 days
This commit is contained in:
Andrey V. Elsukov 2018-10-23 13:11:45 +00:00
parent ccd8660b86
commit 8796e291f8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339649
5 changed files with 21 additions and 5 deletions

View File

@ -161,6 +161,7 @@ me_hashinit(void)
static void
vnet_me_init(const void *unused __unused)
{
V_me_cloner = if_clone_simple(mename, me_clone_create,
me_clone_destroy, 0);
}
@ -173,6 +174,8 @@ vnet_me_uninit(const void *unused __unused)
if (V_me_hashtbl != NULL) {
free(V_me_hashtbl, M_IFME);
V_me_hashtbl = NULL;
ME_WAIT();
free(V_me_srchashtbl, M_IFME);
}
if_clone_detach(V_me_cloner);
@ -363,7 +366,8 @@ me_srcaddr(void *arg __unused, const struct sockaddr *sa,
const struct sockaddr_in *sin;
struct me_softc *sc;
if (V_me_srchashtbl == NULL)
/* Check that VNET is ready */
if (V_me_hashtbl == NULL)
return;
MPASS(in_epoch(net_epoch_preempt));

View File

@ -148,7 +148,8 @@ in_gif_srcaddr(void *arg __unused, const struct sockaddr *sa,
const struct sockaddr_in *sin;
struct gif_softc *sc;
if (V_ipv4_srchashtbl == NULL)
/* Check that VNET is ready */
if (V_ipv4_hashtbl == NULL)
return;
MPASS(in_epoch(net_epoch_preempt));
@ -457,6 +458,8 @@ in_gif_uninit(void)
}
if (V_ipv4_hashtbl != NULL) {
gif_hashdestroy(V_ipv4_hashtbl);
V_ipv4_hashtbl = NULL;
GIF_WAIT();
gif_hashdestroy(V_ipv4_srchashtbl);
}
}

View File

@ -167,7 +167,8 @@ in_gre_srcaddr(void *arg __unused, const struct sockaddr *sa,
const struct sockaddr_in *sin;
struct gre_softc *sc;
if (V_ipv4_srchashtbl == NULL)
/* Check that VNET is ready */
if (V_ipv4_hashtbl == NULL)
return;
MPASS(in_epoch(net_epoch_preempt));
@ -350,6 +351,8 @@ in_gre_uninit(void)
}
if (V_ipv4_hashtbl != NULL) {
gre_hashdestroy(V_ipv4_hashtbl);
V_ipv4_hashtbl = NULL;
GRE_WAIT();
gre_hashdestroy(V_ipv4_srchashtbl);
}
}

View File

@ -153,7 +153,8 @@ in6_gif_srcaddr(void *arg __unused, const struct sockaddr *sa, int event)
const struct sockaddr_in6 *sin;
struct gif_softc *sc;
if (V_ipv6_srchashtbl == NULL)
/* Check that VNET is ready */
if (V_ipv6_hashtbl == NULL)
return;
MPASS(in_epoch(net_epoch_preempt));
@ -480,6 +481,8 @@ in6_gif_uninit(void)
}
if (V_ipv6_hashtbl != NULL) {
gif_hashdestroy(V_ipv6_hashtbl);
V_ipv6_hashtbl = NULL;
GIF_WAIT();
gif_hashdestroy(V_ipv6_srchashtbl);
}
}

View File

@ -160,7 +160,8 @@ in6_gre_srcaddr(void *arg __unused, const struct sockaddr *sa,
const struct sockaddr_in6 *sin;
struct gre_softc *sc;
if (V_ipv6_srchashtbl == NULL)
/* Check that VNET is ready */
if (V_ipv6_hashtbl == NULL)
return;
MPASS(in_epoch(net_epoch_preempt));
@ -338,6 +339,8 @@ in6_gre_uninit(void)
}
if (V_ipv6_hashtbl != NULL) {
gre_hashdestroy(V_ipv6_hashtbl);
V_ipv6_hashtbl = NULL;
GRE_WAIT();
gre_hashdestroy(V_ipv6_srchashtbl);
}
}