that was meant to be an ok :)

Sebastian Benoit(be...@openbsd.org) on 2022.09.02 22:04:41 +0200:
> Alexander Bluhm(alexander.bl...@gmx.net) on 2022.09.02 20:38:04 +0200:
> > Hi,
> > 
> > Due to the KAME scope address hack, the link-local all nodes and
> > routers IPv6 addresses cannot be const.  So move memory from data
> > to stack to make variables MP safe.
> > 
> > ok?
> > 
> > bluhm
> > 
> > Index: netinet6/mld6.c
> > ===================================================================
> > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/mld6.c,v
> > retrieving revision 1.58
> > diff -u -p -r1.58 mld6.c
> > --- netinet6/mld6.c 22 Aug 2022 21:02:44 -0000      1.58
> > +++ netinet6/mld6.c 2 Sep 2022 17:43:06 -0000
> > @@ -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 *i
> >      * 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 *i
> >  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;
> > 
> 

Reply via email to