svn commit: r339649 - in head/sys: net netinet netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Tue Oct 23 13:11:47 UTC 2018
Author: ae
Date: Tue Oct 23 13:11:45 2018
New Revision: 339649
URL: https://svnweb.freebsd.org/changeset/base/339649
Log:
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
Modified:
head/sys/net/if_me.c
head/sys/netinet/in_gif.c
head/sys/netinet/ip_gre.c
head/sys/netinet6/in6_gif.c
head/sys/netinet6/ip6_gre.c
Modified: head/sys/net/if_me.c
==============================================================================
--- head/sys/net/if_me.c Tue Oct 23 13:07:03 2018 (r339648)
+++ head/sys/net/if_me.c Tue Oct 23 13:11:45 2018 (r339649)
@@ -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 *
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));
Modified: head/sys/netinet/in_gif.c
==============================================================================
--- head/sys/netinet/in_gif.c Tue Oct 23 13:07:03 2018 (r339648)
+++ head/sys/netinet/in_gif.c Tue Oct 23 13:11:45 2018 (r339649)
@@ -148,7 +148,8 @@ in_gif_srcaddr(void *arg __unused, const struct sockad
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);
}
}
Modified: head/sys/netinet/ip_gre.c
==============================================================================
--- head/sys/netinet/ip_gre.c Tue Oct 23 13:07:03 2018 (r339648)
+++ head/sys/netinet/ip_gre.c Tue Oct 23 13:11:45 2018 (r339649)
@@ -167,7 +167,8 @@ in_gre_srcaddr(void *arg __unused, const struct sockad
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);
}
}
Modified: head/sys/netinet6/in6_gif.c
==============================================================================
--- head/sys/netinet6/in6_gif.c Tue Oct 23 13:07:03 2018 (r339648)
+++ head/sys/netinet6/in6_gif.c Tue Oct 23 13:11:45 2018 (r339649)
@@ -153,7 +153,8 @@ in6_gif_srcaddr(void *arg __unused, const struct socka
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);
}
}
Modified: head/sys/netinet6/ip6_gre.c
==============================================================================
--- head/sys/netinet6/ip6_gre.c Tue Oct 23 13:07:03 2018 (r339648)
+++ head/sys/netinet6/ip6_gre.c Tue Oct 23 13:11:45 2018 (r339649)
@@ -160,7 +160,8 @@ in6_gre_srcaddr(void *arg __unused, const struct socka
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);
}
}
More information about the svn-src-all
mailing list