summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-09-05 15:47:40 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-09-05 15:47:40 +0000
commita8d6d30c3721721ee27fc2af72389bf52ee845d1 (patch)
treed9541f00ce01d2b0c0574e7504ff01535ee13fa5
parentc259ade4b4a1594c8470894d5b6fe2be84379d1f (diff)
Move mld6 address variables from data to stack memory to make them
MP safe. Due to the KAME scope address hack, the link-local all nodes and all routers IPv6 addresses cannot be const. OK benno@
-rw-r--r--sys/netinet6/mld6.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 205d7cc297f..15502939c30 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mld6.c,v 1.59 2022/09/04 06:49:11 jsg Exp $ */
+/* $OpenBSD: mld6.c,v 1.60 2022/09/05 15:47:39 bluhm Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
@@ -85,9 +85,6 @@
static struct ip6_pktopts ip6_opts;
int mld6_timers_are_running; /* [N] shortcut for fast timer */
-/* XXX: These are necessary for KAME's link-local hack */
-static struct in6_addr mld_all_nodes_linklocal = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
-static struct in6_addr mld_all_routers_linklocal = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
void mld6_checktimer(struct ifnet *);
static void mld6_sendpkt(struct in6_multi *, int, const struct in6_addr *);
@@ -118,6 +115,9 @@ mld6_init(void)
void
mld6_start_listening(struct in6_multi *in6m)
{
+ /* XXX: These are necessary for KAME's link-local hack */
+ struct in6_addr all_nodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+
/*
* RFC2710 page 10:
* The node never sends a Report or Done for the link-scope all-nodes
@@ -125,9 +125,10 @@ mld6_start_listening(struct in6_multi *in6m)
* MLD messages are never sent for multicast addresses whose scope is 0
* (reserved) or 1 (node-local).
*/
- mld_all_nodes_linklocal.s6_addr16[1] = htons(in6m->in6m_ifidx);/* XXX */
- if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld_all_nodes_linklocal) ||
- __IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) < __IPV6_ADDR_SCOPE_LINKLOCAL) {
+ all_nodes.s6_addr16[1] = htons(in6m->in6m_ifidx);
+ if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &all_nodes) ||
+ __IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) <
+ __IPV6_ADDR_SCOPE_LINKLOCAL) {
in6m->in6m_timer = 0;
in6m->in6m_state = MLD_OTHERLISTENER;
} else {
@@ -143,15 +144,19 @@ mld6_start_listening(struct in6_multi *in6m)
void
mld6_stop_listening(struct in6_multi *in6m)
{
- mld_all_nodes_linklocal.s6_addr16[1] = htons(in6m->in6m_ifidx);/* XXX */
- mld_all_routers_linklocal.s6_addr16[1] =
- htons(in6m->in6m_ifidx); /* XXX: necessary when mrouting */
+ /* XXX: These are necessary for KAME's link-local hack */
+ struct in6_addr all_nodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+ struct in6_addr all_routers = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+
+ all_nodes.s6_addr16[1] = htons(in6m->in6m_ifidx);
+ /* XXX: necessary when mrouting */
+ all_routers.s6_addr16[1] = htons(in6m->in6m_ifidx);
if (in6m->in6m_state == MLD_IREPORTEDLAST &&
- (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld_all_nodes_linklocal)) &&
- __IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) > __IPV6_ADDR_SCOPE_INTFACELOCAL)
- mld6_sendpkt(in6m, MLD_LISTENER_DONE,
- &mld_all_routers_linklocal);
+ (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &all_nodes)) &&
+ __IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) >
+ __IPV6_ADDR_SCOPE_INTFACELOCAL)
+ mld6_sendpkt(in6m, MLD_LISTENER_DONE, &all_routers);
}
void
@@ -163,6 +168,8 @@ mld6_input(struct mbuf *m, int off)
struct in6_multi *in6m;
struct ifmaddr *ifma;
int timer; /* timer value in the MLD query header */
+ /* XXX: These are necessary for KAME's link-local hack */
+ struct in6_addr all_nodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
IP6_EXTHDR_GET(mldh, struct mld_hdr *, m, off, sizeof(*mldh));
if (mldh == NULL) {
@@ -239,15 +246,13 @@ mld6_input(struct mbuf *m, int off)
timer = ntohs(mldh->mld_maxdelay)*PR_FASTHZ/MLD_TIMER_SCALE;
if (timer == 0 && mldh->mld_maxdelay)
timer = 1;
- mld_all_nodes_linklocal.s6_addr16[1] =
- htons(ifp->if_index); /* XXX */
+ all_nodes.s6_addr16[1] = htons(ifp->if_index);
TAILQ_FOREACH(ifma, &ifp->if_maddrlist, ifma_list) {
if (ifma->ifma_addr->sa_family != AF_INET6)
continue;
in6m = ifmatoin6m(ifma);
- if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr,
- &mld_all_nodes_linklocal) ||
+ if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &all_nodes) ||
__IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) <
__IPV6_ADDR_SCOPE_LINKLOCAL)
continue;