[BACK]Return to mld6.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / netinet6

Annotation of src/sys/netinet6/mld6.c, Revision 1.83

1.83    ! ozaki-r     1: /*     $NetBSD: mld6.c,v 1.82 2017/02/22 07:46:00 ozaki-r Exp $        */
1.13      itojun      2: /*     $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $   */
1.3       thorpej     3:
1.2       itojun      4: /*
                      5:  * Copyright (C) 1998 WIDE Project.
                      6:  * All rights reserved.
1.13      itojun      7:  *
1.2       itojun      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. Neither the name of the project nor the names of its contributors
                     17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
1.13      itojun     19:  *
1.2       itojun     20:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  */
                     32:
                     33: /*
                     34:  * Copyright (c) 1992, 1993
                     35:  *     The Regents of the University of California.  All rights reserved.
                     36:  *
                     37:  * This code is derived from software contributed to Berkeley by
                     38:  * Stephen Deering of Stanford University.
                     39:  *
                     40:  * Redistribution and use in source and binary forms, with or without
                     41:  * modification, are permitted provided that the following conditions
                     42:  * are met:
                     43:  * 1. Redistributions of source code must retain the above copyright
                     44:  *    notice, this list of conditions and the following disclaimer.
                     45:  * 2. Redistributions in binary form must reproduce the above copyright
                     46:  *    notice, this list of conditions and the following disclaimer in the
                     47:  *    documentation and/or other materials provided with the distribution.
1.23      agc        48:  * 3. Neither the name of the University nor the names of its contributors
                     49:  *    may be used to endorse or promote products derived from this software
                     50:  *    without specific prior written permission.
                     51:  *
                     52:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     53:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     54:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     55:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     56:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     57:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     58:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     59:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     60:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     61:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     62:  * SUCH DAMAGE.
                     63:  *
                     64:  *     @(#)igmp.c      8.1 (Berkeley) 7/19/93
                     65:  */
                     66:
                     67: /*
                     68:  * Copyright (c) 1988 Stephen Deering.
                     69:  *
                     70:  * This code is derived from software contributed to Berkeley by
                     71:  * Stephen Deering of Stanford University.
                     72:  *
                     73:  * Redistribution and use in source and binary forms, with or without
                     74:  * modification, are permitted provided that the following conditions
                     75:  * are met:
                     76:  * 1. Redistributions of source code must retain the above copyright
                     77:  *    notice, this list of conditions and the following disclaimer.
                     78:  * 2. Redistributions in binary form must reproduce the above copyright
                     79:  *    notice, this list of conditions and the following disclaimer in the
                     80:  *    documentation and/or other materials provided with the distribution.
1.2       itojun     81:  * 3. All advertising materials mentioning features or use of this software
                     82:  *    must display the following acknowledgement:
                     83:  *     This product includes software developed by the University of
                     84:  *     California, Berkeley and its contributors.
                     85:  * 4. Neither the name of the University nor the names of its contributors
                     86:  *    may be used to endorse or promote products derived from this software
                     87:  *    without specific prior written permission.
                     88:  *
                     89:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     90:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     91:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     92:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     93:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     94:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     95:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     96:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     97:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     98:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     99:  * SUCH DAMAGE.
                    100:  *
                    101:  *     @(#)igmp.c      8.1 (Berkeley) 7/19/93
                    102:  */
1.16      lukem     103:
                    104: #include <sys/cdefs.h>
1.83    ! ozaki-r   105: __KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.82 2017/02/22 07:46:00 ozaki-r Exp $");
1.2       itojun    106:
1.63      pooka     107: #ifdef _KERNEL_OPT
1.2       itojun    108: #include "opt_inet.h"
1.75      knakahar  109: #include "opt_net_mpsafe.h"
1.63      pooka     110: #endif
1.2       itojun    111:
                    112: #include <sys/param.h>
                    113: #include <sys/systm.h>
                    114: #include <sys/mbuf.h>
                    115: #include <sys/socket.h>
1.45      ad        116: #include <sys/socketvar.h>
1.2       itojun    117: #include <sys/syslog.h>
1.31      rpaulo    118: #include <sys/sysctl.h>
                    119: #include <sys/kernel.h>
                    120: #include <sys/callout.h>
1.55      tls       121: #include <sys/cprng.h>
1.2       itojun    122:
                    123: #include <net/if.h>
                    124:
                    125: #include <netinet/in.h>
                    126: #include <netinet/in_var.h>
1.31      rpaulo    127: #include <netinet6/in6_var.h>
1.10      itojun    128: #include <netinet/ip6.h>
1.2       itojun    129: #include <netinet6/ip6_var.h>
1.29      rpaulo    130: #include <netinet6/scope6_var.h>
1.10      itojun    131: #include <netinet/icmp6.h>
1.44      thorpej   132: #include <netinet6/icmp6_private.h>
1.2       itojun    133: #include <netinet6/mld6_var.h>
                    134:
1.7       itojun    135: #include <net/net_osdep.h>
                    136:
1.31      rpaulo    137:
                    138: /*
1.2       itojun    139:  * Protocol constants
                    140:  */
                    141:
                    142: /*
                    143:  * time between repetitions of a node's initial report of interest in a
                    144:  * multicast address(in seconds)
                    145:  */
1.22      itojun    146: #define MLD_UNSOLICITED_REPORT_INTERVAL        10
1.2       itojun    147:
                    148: static struct ip6_pktopts ip6_opts;
                    149:
1.31      rpaulo    150: static void mld_start_listening(struct in6_multi *);
                    151: static void mld_stop_listening(struct in6_multi *);
                    152:
                    153: static struct mld_hdr * mld_allocbuf(struct mbuf **, int, struct in6_multi *,
                    154:        int);
                    155: static void mld_sendpkt(struct in6_multi *, int, const struct in6_addr *);
                    156: static void mld_starttimer(struct in6_multi *);
                    157: static void mld_stoptimer(struct in6_multi *);
                    158: static u_long mld_timerresid(struct in6_multi *);
1.2       itojun    159:
                    160: void
1.42      matt      161: mld_init(void)
1.2       itojun    162: {
                    163:        static u_int8_t hbh_buf[8];
                    164:        struct ip6_hbh *hbh = (struct ip6_hbh *)hbh_buf;
                    165:        u_int16_t rtalert_code = htons((u_int16_t)IP6OPT_RTALERT_MLD);
                    166:
                    167:        /* ip6h_nxt will be fill in later */
1.11      itojun    168:        hbh->ip6h_len = 0;      /* (8 >> 3) - 1 */
1.2       itojun    169:
                    170:        /* XXX: grotty hard coding... */
                    171:        hbh_buf[2] = IP6OPT_PADN;       /* 2 byte padding */
                    172:        hbh_buf[3] = 0;
                    173:        hbh_buf[4] = IP6OPT_RTALERT;
                    174:        hbh_buf[5] = IP6OPT_RTALERT_LEN - 2;
1.50      tsutsui   175:        memcpy(&hbh_buf[6], (void *)&rtalert_code, sizeof(u_int16_t));
1.2       itojun    176:
                    177:        ip6_opts.ip6po_hbh = hbh;
                    178:        /* We will specify the hoplimit by a multicast option. */
                    179:        ip6_opts.ip6po_hlim = -1;
1.62      roy       180:        ip6_opts.ip6po_prefer_tempaddr = IP6PO_TEMPADDR_NOTPREFER;
1.2       itojun    181: }
                    182:
1.31      rpaulo    183: static void
1.38      christos  184: mld_starttimer(struct in6_multi *in6m)
1.31      rpaulo    185: {
                    186:        struct timeval now;
                    187:
1.61      ozaki-r   188:        KASSERT(in6m->in6m_timer != IN6M_TIMER_UNDEF);
                    189:
1.31      rpaulo    190:        microtime(&now);
                    191:        in6m->in6m_timer_expire.tv_sec = now.tv_sec + in6m->in6m_timer / hz;
                    192:        in6m->in6m_timer_expire.tv_usec = now.tv_usec +
                    193:            (in6m->in6m_timer % hz) * (1000000 / hz);
                    194:        if (in6m->in6m_timer_expire.tv_usec > 1000000) {
                    195:                in6m->in6m_timer_expire.tv_sec++;
                    196:                in6m->in6m_timer_expire.tv_usec -= 1000000;
                    197:        }
                    198:
                    199:        /* start or restart the timer */
1.41      joerg     200:        callout_schedule(&in6m->in6m_timer_ch, in6m->in6m_timer);
1.31      rpaulo    201: }
                    202:
                    203: static void
1.38      christos  204: mld_stoptimer(struct in6_multi *in6m)
1.31      rpaulo    205: {
                    206:        if (in6m->in6m_timer == IN6M_TIMER_UNDEF)
                    207:                return;
                    208:
1.41      joerg     209:        callout_stop(&in6m->in6m_timer_ch);
1.31      rpaulo    210:
                    211:        in6m->in6m_timer = IN6M_TIMER_UNDEF;
                    212: }
                    213:
                    214: static void
1.41      joerg     215: mld_timeo(void *arg)
1.31      rpaulo    216: {
1.41      joerg     217:        struct in6_multi *in6m = arg;
1.45      ad        218:
1.80      ozaki-r   219:        /* XXX NOMPSAFE still need softnet_lock */
1.45      ad        220:        mutex_enter(softnet_lock);
                    221:        KERNEL_LOCK(1, NULL);
1.31      rpaulo    222:
1.61      ozaki-r   223:        if (in6m->in6m_timer == IN6M_TIMER_UNDEF)
                    224:                goto out;
                    225:
1.31      rpaulo    226:        in6m->in6m_timer = IN6M_TIMER_UNDEF;
                    227:
                    228:        switch (in6m->in6m_state) {
                    229:        case MLD_REPORTPENDING:
                    230:                mld_start_listening(in6m);
                    231:                break;
                    232:        default:
                    233:                mld_sendpkt(in6m, MLD_LISTENER_REPORT, NULL);
                    234:                break;
                    235:        }
                    236:
1.61      ozaki-r   237: out:
1.45      ad        238:        KERNEL_UNLOCK_ONE(NULL);
                    239:        mutex_exit(softnet_lock);
1.31      rpaulo    240: }
                    241:
                    242: static u_long
1.38      christos  243: mld_timerresid(struct in6_multi *in6m)
1.31      rpaulo    244: {
                    245:        struct timeval now, diff;
                    246:
                    247:        microtime(&now);
                    248:
                    249:        if (now.tv_sec > in6m->in6m_timer_expire.tv_sec ||
                    250:            (now.tv_sec == in6m->in6m_timer_expire.tv_sec &&
                    251:            now.tv_usec > in6m->in6m_timer_expire.tv_usec)) {
                    252:                return (0);
                    253:        }
                    254:        diff = in6m->in6m_timer_expire;
                    255:        diff.tv_sec -= now.tv_sec;
                    256:        diff.tv_usec -= now.tv_usec;
                    257:        if (diff.tv_usec < 0) {
                    258:                diff.tv_sec--;
                    259:                diff.tv_usec += 1000000;
                    260:        }
                    261:
                    262:        /* return the remaining time in milliseconds */
1.47      adrianp   263:        return diff.tv_sec * 1000 + diff.tv_usec / 1000;
1.31      rpaulo    264: }
                    265:
                    266: static void
1.38      christos  267: mld_start_listening(struct in6_multi *in6m)
1.2       itojun    268: {
1.29      rpaulo    269:        struct in6_addr all_in6;
                    270:
1.2       itojun    271:        /*
1.11      itojun    272:         * RFC2710 page 10:
1.2       itojun    273:         * The node never sends a Report or Done for the link-scope all-nodes
                    274:         * address.
                    275:         * MLD messages are never sent for multicast addresses whose scope is 0
                    276:         * (reserved) or 1 (node-local).
                    277:         */
1.29      rpaulo    278:        all_in6 = in6addr_linklocal_allnodes;
                    279:        if (in6_setscope(&all_in6, in6m->in6m_ifp, NULL)) {
                    280:                /* XXX: this should not happen! */
                    281:                in6m->in6m_timer = 0;
                    282:                in6m->in6m_state = MLD_OTHERLISTENER;
                    283:        }
                    284:        if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &all_in6) ||
1.2       itojun    285:            IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) < IPV6_ADDR_SCOPE_LINKLOCAL) {
1.31      rpaulo    286:                in6m->in6m_timer = IN6M_TIMER_UNDEF;
1.22      itojun    287:                in6m->in6m_state = MLD_OTHERLISTENER;
1.2       itojun    288:        } else {
1.31      rpaulo    289:                mld_sendpkt(in6m, MLD_LISTENER_REPORT, NULL);
1.55      tls       290:                in6m->in6m_timer = cprng_fast32() %
1.31      rpaulo    291:                    (MLD_UNSOLICITED_REPORT_INTERVAL * hz);
1.22      itojun    292:                in6m->in6m_state = MLD_IREPORTEDLAST;
1.31      rpaulo    293:
                    294:                mld_starttimer(in6m);
1.2       itojun    295:        }
                    296: }
                    297:
1.31      rpaulo    298: static void
1.38      christos  299: mld_stop_listening(struct in6_multi *in6m)
1.2       itojun    300: {
1.29      rpaulo    301:        struct in6_addr allnode, allrouter;
                    302:
                    303:        allnode = in6addr_linklocal_allnodes;
                    304:        if (in6_setscope(&allnode, in6m->in6m_ifp, NULL)) {
                    305:                /* XXX: this should not happen! */
                    306:                return;
                    307:        }
                    308:        allrouter = in6addr_linklocal_allrouters;
                    309:        if (in6_setscope(&allrouter, in6m->in6m_ifp, NULL)) {
                    310:                /* XXX impossible */
                    311:                return;
                    312:        }
1.2       itojun    313:
1.22      itojun    314:        if (in6m->in6m_state == MLD_IREPORTEDLAST &&
1.29      rpaulo    315:            (!IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &allnode)) &&
                    316:            IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) >
                    317:            IPV6_ADDR_SCOPE_INTFACELOCAL) {
1.31      rpaulo    318:                mld_sendpkt(in6m, MLD_LISTENER_DONE, &allrouter);
1.29      rpaulo    319:        }
1.2       itojun    320: }
                    321:
                    322: void
1.38      christos  323: mld_input(struct mbuf *m, int off)
1.2       itojun    324: {
1.52      dholland  325:        struct ip6_hdr *ip6;
1.22      itojun    326:        struct mld_hdr *mldh;
1.66      ozaki-r   327:        struct ifnet *ifp;
1.31      rpaulo    328:        struct in6_multi *in6m = NULL;
1.29      rpaulo    329:        struct in6_addr mld_addr, all_in6;
1.47      adrianp   330:        u_long timer = 0;       /* timer value in the MLD query header */
1.83    ! ozaki-r   331:        struct psref psref;
1.2       itojun    332:
1.83    ! ozaki-r   333:        ifp = m_get_rcvif_psref(m, &psref);
1.81      ozaki-r   334:        if (__predict_false(ifp == NULL))
                    335:                goto out;
1.22      itojun    336:        IP6_EXTHDR_GET(mldh, struct mld_hdr *, m, off, sizeof(*mldh));
1.13      itojun    337:        if (mldh == NULL) {
1.44      thorpej   338:                ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
1.66      ozaki-r   339:                goto out_nodrop;
1.13      itojun    340:        }
                    341:
1.2       itojun    342:        /* source address validation */
1.13      itojun    343:        ip6 = mtod(m, struct ip6_hdr *);/* in case mpullup */
1.2       itojun    344:        if (!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src)) {
1.31      rpaulo    345:                /*
                    346:                 * RFC3590 allows the IPv6 unspecified address as the source
                    347:                 * address of MLD report and done messages.  However, as this
                    348:                 * same document says, this special rule is for snooping
                    349:                 * switches and the RFC requires routers to discard MLD packets
                    350:                 * with the unspecified source address.  The RFC only talks
                    351:                 * about hosts receiving an MLD query or report in Security
                    352:                 * Considerations, but this is probably the correct intention.
                    353:                 * RFC3590 does not talk about other cases than link-local and
                    354:                 * the unspecified source addresses, but we believe the same
                    355:                 * rule should be applied.
                    356:                 * As a result, we only allow link-local addresses as the
                    357:                 * source address; otherwise, simply discard the packet.
                    358:                 */
1.18      itojun    359: #if 0
1.31      rpaulo    360:                /*
                    361:                 * XXX: do not log in an input path to avoid log flooding,
                    362:                 * though RFC3590 says "SHOULD log" if the source of a query
                    363:                 * is the unspecified address.
                    364:                 */
1.78      ryo       365:                char ip6bufs[INET6_ADDRSTRLEN];
                    366:                char ip6bufm[INET6_ADDRSTRLEN];
1.31      rpaulo    367:                log(LOG_INFO,
1.22      itojun    368:                    "mld_input: src %s is not link-local (grp=%s)\n",
1.79      christos  369:                    IN6_PRINT(ip6bufs,&ip6->ip6_src),
                    370:                    IN6_PRINT(ip6bufm, &mldh->mld_addr));
1.18      itojun    371: #endif
1.66      ozaki-r   372:                goto out;
1.2       itojun    373:        }
                    374:
                    375:        /*
1.29      rpaulo    376:         * make a copy for local work (in6_setscope() may modify the 1st arg)
                    377:         */
                    378:        mld_addr = mldh->mld_addr;
                    379:        if (in6_setscope(&mld_addr, ifp, NULL)) {
                    380:                /* XXX: this should not happen! */
1.66      ozaki-r   381:                goto out;
1.29      rpaulo    382:        }
                    383:
                    384:        /*
1.31      rpaulo    385:         * In the MLD specification, there are 3 states and a flag.
1.2       itojun    386:         *
                    387:         * In Non-Listener state, we simply don't have a membership record.
                    388:         * In Delaying Listener state, our timer is running (in6m->in6m_timer)
1.31      rpaulo    389:         * In Idle Listener state, our timer is not running
                    390:         * (in6m->in6m_timer==IN6M_TIMER_UNDEF)
1.2       itojun    391:         *
1.22      itojun    392:         * The flag is in6m->in6m_state, it is set to MLD_OTHERLISTENER if
                    393:         * we have heard a report from another member, or MLD_IREPORTEDLAST
1.2       itojun    394:         * if we sent the last report.
                    395:         */
1.22      itojun    396:        switch (mldh->mld_type) {
1.74      ozaki-r   397:        case MLD_LISTENER_QUERY: {
1.7       itojun    398:                if (ifp->if_flags & IFF_LOOPBACK)
                    399:                        break;
                    400:
1.29      rpaulo    401:                if (!IN6_IS_ADDR_UNSPECIFIED(&mld_addr) &&
                    402:                    !IN6_IS_ADDR_MULTICAST(&mld_addr))
1.7       itojun    403:                        break;  /* print error or log stat? */
1.29      rpaulo    404:
                    405:                all_in6 = in6addr_linklocal_allnodes;
                    406:                if (in6_setscope(&all_in6, ifp, NULL)) {
                    407:                        /* XXX: this should not happen! */
                    408:                        break;
                    409:                }
1.2       itojun    410:
1.7       itojun    411:                /*
1.11      itojun    412:                 * - Start the timers in all of our membership records
                    413:                 *   that the query applies to for the interface on
                    414:                 *   which the query arrived excl. those that belong
                    415:                 *   to the "all-nodes" group (ff02::1).
                    416:                 * - Restart any timer that is already running but has
1.30      rpaulo    417:                 *   a value longer than the requested timeout.
1.11      itojun    418:                 * - Use the value specified in the query message as
                    419:                 *   the maximum timeout.
                    420:                 */
1.31      rpaulo    421:                timer = ntohs(mldh->mld_maxdelay);
                    422:
1.83    ! ozaki-r   423:                LIST_FOREACH(in6m, &ifp->if_multiaddrs, in6m_entry) {
1.29      rpaulo    424:                        if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &all_in6) ||
1.7       itojun    425:                            IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) <
                    426:                            IPV6_ADDR_SCOPE_LINKLOCAL)
                    427:                                continue;
1.2       itojun    428:
1.31      rpaulo    429:                        if (in6m->in6m_state == MLD_REPORTPENDING)
                    430:                                continue; /* we are not yet ready */
                    431:
                    432:                        if (!IN6_IS_ADDR_UNSPECIFIED(&mld_addr) &&
                    433:                            !IN6_ARE_ADDR_EQUAL(&mld_addr, &in6m->in6m_addr))
                    434:                                continue;
                    435:
                    436:                        if (timer == 0) {
                    437:                                /* send a report immediately */
                    438:                                mld_stoptimer(in6m);
                    439:                                mld_sendpkt(in6m, MLD_LISTENER_REPORT, NULL);
                    440:                                in6m->in6m_state = MLD_IREPORTEDLAST;
                    441:                        } else if (in6m->in6m_timer == IN6M_TIMER_UNDEF ||
1.47      adrianp   442:                            mld_timerresid(in6m) > timer) {
                    443:                                in6m->in6m_timer =
1.55      tls       444:                                   1 + (cprng_fast32() % timer) * hz / 1000;
1.31      rpaulo    445:                                mld_starttimer(in6m);
1.7       itojun    446:                        }
                    447:                }
1.29      rpaulo    448:                break;
1.74      ozaki-r   449:            }
1.2       itojun    450:
1.22      itojun    451:        case MLD_LISTENER_REPORT:
1.2       itojun    452:                /*
1.11      itojun    453:                 * For fast leave to work, we have to know that we are the
                    454:                 * last person to send a report for this group.  Reports
                    455:                 * can potentially get looped back if we are a multicast
                    456:                 * router, so discard reports sourced by me.
                    457:                 * Note that it is impossible to check IFF_LOOPBACK flag of
                    458:                 * ifp for this purpose, since ip6_mloopback pass the physical
                    459:                 * interface to looutput.
                    460:                 */
1.7       itojun    461:                if (m->m_flags & M_LOOP) /* XXX: grotty flag, but efficient */
                    462:                        break;
                    463:
1.22      itojun    464:                if (!IN6_IS_ADDR_MULTICAST(&mldh->mld_addr))
1.7       itojun    465:                        break;
                    466:
                    467:                /*
1.11      itojun    468:                 * If we belong to the group being reported, stop
                    469:                 * our timer for that group.
                    470:                 */
1.82      ozaki-r   471:                in6m = in6_lookup_multi(&mld_addr, ifp);
1.7       itojun    472:                if (in6m) {
1.31      rpaulo    473:                        mld_stoptimer(in6m); /* transit to idle state */
1.22      itojun    474:                        in6m->in6m_state = MLD_OTHERLISTENER; /* clear flag */
1.7       itojun    475:                }
                    476:                break;
                    477:        default:                /* this is impossible */
1.18      itojun    478: #if 0
1.19      itojun    479:                /*
                    480:                 * this case should be impossible because of filtering in
                    481:                 * icmp6_input().  But we explicitly disabled this part
                    482:                 * just in case.
                    483:                 */
1.31      rpaulo    484:                log(LOG_ERR, "mld_input: illegal type(%d)", mldh->mld_type);
1.18      itojun    485: #endif
1.7       itojun    486:                break;
1.2       itojun    487:        }
1.11      itojun    488:
1.66      ozaki-r   489: out:
1.11      itojun    490:        m_freem(m);
1.66      ozaki-r   491: out_nodrop:
1.83    ! ozaki-r   492:        m_put_rcvif_psref(ifp, &psref);
1.2       itojun    493: }
                    494:
                    495: static void
1.38      christos  496: mld_sendpkt(struct in6_multi *in6m, int type,
                    497:        const struct in6_addr *dst)
1.2       itojun    498: {
1.31      rpaulo    499:        struct mbuf *mh;
1.22      itojun    500:        struct mld_hdr *mldh;
1.31      rpaulo    501:        struct ip6_hdr *ip6 = NULL;
1.2       itojun    502:        struct ip6_moptions im6o;
1.31      rpaulo    503:        struct in6_ifaddr *ia = NULL;
1.2       itojun    504:        struct ifnet *ifp = in6m->in6m_ifp;
1.19      itojun    505:        int ignflags;
1.74      ozaki-r   506:        struct psref psref;
                    507:        int bound;
1.2       itojun    508:
                    509:        /*
                    510:         * At first, find a link local address on the outgoing interface
                    511:         * to use as the source address of the MLD packet.
1.19      itojun    512:         * We do not reject tentative addresses for MLD report to deal with
                    513:         * the case where we first join a link-local address.
1.2       itojun    514:         */
1.19      itojun    515:        ignflags = (IN6_IFF_NOTREADY|IN6_IFF_ANYCAST) & ~IN6_IFF_TENTATIVE;
1.74      ozaki-r   516:        bound = curlwp_bind();
                    517:        ia = in6ifa_ifpforlinklocal_psref(ifp, ignflags, &psref);
                    518:        if (ia == NULL) {
                    519:                curlwp_bindx(bound);
1.2       itojun    520:                return;
1.74      ozaki-r   521:        }
                    522:        if ((ia->ia6_flags & IN6_IFF_TENTATIVE)) {
                    523:                ia6_release(ia, &psref);
1.19      itojun    524:                ia = NULL;
1.74      ozaki-r   525:        }
1.2       itojun    526:
1.31      rpaulo    527:        /* Allocate two mbufs to store IPv6 header and MLD header */
                    528:        mldh = mld_allocbuf(&mh, sizeof(struct mld_hdr), in6m, type);
1.74      ozaki-r   529:        if (mldh == NULL) {
                    530:                ia6_release(ia, &psref);
                    531:                curlwp_bindx(bound);
1.2       itojun    532:                return;
1.74      ozaki-r   533:        }
1.2       itojun    534:
1.31      rpaulo    535:        /* fill src/dst here */
                    536:        ip6 = mtod(mh, struct ip6_hdr *);
                    537:        ip6->ip6_src = ia ? ia->ia_addr.sin6_addr : in6addr_any;
                    538:        ip6->ip6_dst = dst ? *dst : in6m->in6m_addr;
1.74      ozaki-r   539:        ia6_release(ia, &psref);
                    540:        curlwp_bindx(bound);
1.2       itojun    541:
1.22      itojun    542:        mldh->mld_addr = in6m->in6m_addr;
1.29      rpaulo    543:        in6_clearscope(&mldh->mld_addr); /* XXX */
1.22      itojun    544:        mldh->mld_cksum = in6_cksum(mh, IPPROTO_ICMPV6, sizeof(struct ip6_hdr),
                    545:            sizeof(struct mld_hdr));
1.2       itojun    546:
                    547:        /* construct multicast option */
1.31      rpaulo    548:        memset(&im6o, 0, sizeof(im6o));
1.68      ozaki-r   549:        im6o.im6o_multicast_if_index = if_get_index(ifp);
1.2       itojun    550:        im6o.im6o_multicast_hlim = 1;
                    551:
                    552:        /*
                    553:         * Request loopback of the report if we are acting as a multicast
                    554:         * router, so that the process-level routing daemon can hear it.
                    555:         */
                    556:        im6o.im6o_multicast_loop = (ip6_mrouter != NULL);
                    557:
                    558:        /* increment output statictics */
1.44      thorpej   559:        ICMP6_STATINC(ICMP6_STAT_OUTHIST + type);
1.15      itojun    560:        icmp6_ifstat_inc(ifp, ifs6_out_msg);
1.17      itojun    561:        switch (type) {
1.22      itojun    562:        case MLD_LISTENER_QUERY:
1.15      itojun    563:                icmp6_ifstat_inc(ifp, ifs6_out_mldquery);
                    564:                break;
1.22      itojun    565:        case MLD_LISTENER_REPORT:
1.15      itojun    566:                icmp6_ifstat_inc(ifp, ifs6_out_mldreport);
                    567:                break;
1.22      itojun    568:        case MLD_LISTENER_DONE:
1.15      itojun    569:                icmp6_ifstat_inc(ifp, ifs6_out_mlddone);
                    570:                break;
1.7       itojun    571:        }
1.19      itojun    572:
1.27      perry     573:        ip6_output(mh, &ip6_opts, NULL, ia ? 0 : IPV6_UNSPECSRC,
1.53      plunky    574:            &im6o, NULL, NULL);
1.2       itojun    575: }
1.31      rpaulo    576:
                    577: static struct mld_hdr *
1.34      christos  578: mld_allocbuf(struct mbuf **mh, int len, struct in6_multi *in6m,
1.33      christos  579:     int type)
1.31      rpaulo    580: {
                    581:        struct mbuf *md;
                    582:        struct mld_hdr *mldh;
                    583:        struct ip6_hdr *ip6;
                    584:
                    585:        /*
                    586:         * Allocate mbufs to store ip6 header and MLD header.
                    587:         * We allocate 2 mbufs and make chain in advance because
                    588:         * it is more convenient when inserting the hop-by-hop option later.
                    589:         */
                    590:        MGETHDR(*mh, M_DONTWAIT, MT_HEADER);
                    591:        if (*mh == NULL)
                    592:                return NULL;
                    593:        MGET(md, M_DONTWAIT, MT_DATA);
                    594:        if (md == NULL) {
                    595:                m_free(*mh);
                    596:                *mh = NULL;
                    597:                return NULL;
                    598:        }
                    599:        (*mh)->m_next = md;
                    600:        md->m_next = NULL;
                    601:
1.65      ozaki-r   602:        m_reset_rcvif((*mh));
1.31      rpaulo    603:        (*mh)->m_pkthdr.len = sizeof(struct ip6_hdr) + len;
                    604:        (*mh)->m_len = sizeof(struct ip6_hdr);
                    605:        MH_ALIGN(*mh, sizeof(struct ip6_hdr));
                    606:
                    607:        /* fill in the ip6 header */
                    608:        ip6 = mtod(*mh, struct ip6_hdr *);
                    609:        memset(ip6, 0, sizeof(*ip6));
                    610:        ip6->ip6_flow = 0;
                    611:        ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
                    612:        ip6->ip6_vfc |= IPV6_VERSION;
                    613:        /* ip6_plen will be set later */
                    614:        ip6->ip6_nxt = IPPROTO_ICMPV6;
                    615:        /* ip6_hlim will be set by im6o.im6o_multicast_hlim */
                    616:        /* ip6_src/dst will be set by mld_sendpkt() or mld_sendbuf() */
                    617:
                    618:        /* fill in the MLD header as much as possible */
                    619:        md->m_len = len;
                    620:        mldh = mtod(md, struct mld_hdr *);
                    621:        memset(mldh, 0, len);
                    622:        mldh->mld_type = type;
                    623:        return mldh;
                    624: }
                    625:
                    626: /*
                    627:  * Add an address to the list of IP6 multicast addresses for a given interface.
                    628:  */
                    629: struct in6_multi *
1.38      christos  630: in6_addmulti(struct in6_addr *maddr6, struct ifnet *ifp,
                    631:        int *errorp, int timer)
1.31      rpaulo    632: {
1.54      dyoung    633:        struct  sockaddr_in6 sin6;
1.31      rpaulo    634:        struct  in6_multi *in6m;
                    635:        int     s = splsoftnet();
                    636:
                    637:        *errorp = 0;
                    638:
                    639:        /*
                    640:         * See if address already in list.
                    641:         */
1.82      ozaki-r   642:        in6m = in6_lookup_multi(maddr6, ifp);
1.31      rpaulo    643:        if (in6m != NULL) {
                    644:                /*
                    645:                 * Found it; just increment the refrence count.
                    646:                 */
                    647:                in6m->in6m_refcount++;
                    648:        } else {
                    649:                /*
                    650:                 * New address; allocate a new multicast record
                    651:                 * and link it into the interface's multicast list.
                    652:                 */
                    653:                in6m = (struct in6_multi *)
1.51      dyoung    654:                        malloc(sizeof(*in6m), M_IPMADDR, M_NOWAIT|M_ZERO);
1.31      rpaulo    655:                if (in6m == NULL) {
                    656:                        splx(s);
                    657:                        *errorp = ENOBUFS;
                    658:                        return (NULL);
                    659:                }
                    660:
                    661:                in6m->in6m_addr = *maddr6;
                    662:                in6m->in6m_ifp = ifp;
                    663:                in6m->in6m_refcount = 1;
                    664:                in6m->in6m_timer = IN6M_TIMER_UNDEF;
1.64      joerg     665:                callout_init(&in6m->in6m_timer_ch, CALLOUT_MPSAFE);
                    666:                callout_setfunc(&in6m->in6m_timer_ch, mld_timeo, in6m);
                    667:
1.74      ozaki-r   668:                /* FIXME NOMPSAFE: need to lock */
1.83    ! ozaki-r   669:                LIST_INSERT_HEAD(&ifp->if_multiaddrs, in6m, in6m_entry);
1.31      rpaulo    670:
                    671:                /*
                    672:                 * Ask the network driver to update its multicast reception
                    673:                 * filter appropriately for the new address.
                    674:                 */
1.54      dyoung    675:                sockaddr_in6_init(&sin6, maddr6, 0, 0, 0);
                    676:                *errorp = if_mcast_op(ifp, SIOCADDMULTI, sin6tosa(&sin6));
1.31      rpaulo    677:                if (*errorp) {
1.64      joerg     678:                        callout_destroy(&in6m->in6m_timer_ch);
1.31      rpaulo    679:                        LIST_REMOVE(in6m, in6m_entry);
                    680:                        free(in6m, M_IPMADDR);
                    681:                        splx(s);
                    682:                        return (NULL);
                    683:                }
                    684:
1.32      rpaulo    685:                in6m->in6m_timer = timer;
1.31      rpaulo    686:                if (in6m->in6m_timer > 0) {
                    687:                        in6m->in6m_state = MLD_REPORTPENDING;
                    688:                        mld_starttimer(in6m);
                    689:
                    690:                        splx(s);
                    691:                        return (in6m);
                    692:                }
                    693:
                    694:                /*
                    695:                 * Let MLD6 know that we have joined a new IP6 multicast
                    696:                 * group.
                    697:                 */
                    698:                mld_start_listening(in6m);
                    699:        }
                    700:        splx(s);
                    701:        return (in6m);
                    702: }
                    703:
                    704: /*
                    705:  * Delete a multicast address record.
                    706:  */
                    707: void
1.38      christos  708: in6_delmulti(struct in6_multi *in6m)
1.31      rpaulo    709: {
1.54      dyoung    710:        struct  sockaddr_in6 sin6;
1.31      rpaulo    711:        struct  in6_ifaddr *ia;
                    712:        int     s = splsoftnet();
                    713:
                    714:        mld_stoptimer(in6m);
                    715:
                    716:        if (--in6m->in6m_refcount == 0) {
1.73      ozaki-r   717:                int _s;
                    718:
1.31      rpaulo    719:                /*
                    720:                 * No remaining claims to this record; let MLD6 know
                    721:                 * that we are leaving the multicast group.
                    722:                 */
                    723:                mld_stop_listening(in6m);
                    724:
                    725:                /*
                    726:                 * Unlink from list.
                    727:                 */
1.83    ! ozaki-r   728:                /* FIXME NOMPSAFE: need to lock */
1.31      rpaulo    729:                LIST_REMOVE(in6m, in6m_entry);
                    730:
                    731:                /*
                    732:                 * Delete all references of this multicasting group from
                    733:                 * the membership arrays
                    734:                 */
1.73      ozaki-r   735:                _s = pserialize_read_enter();
1.70      ozaki-r   736:                IN6_ADDRLIST_READER_FOREACH(ia) {
1.31      rpaulo    737:                        struct in6_multi_mship *imm;
1.35      dyoung    738:                        LIST_FOREACH(imm, &ia->ia6_memberships, i6mm_chain) {
1.31      rpaulo    739:                                if (imm->i6mm_maddr == in6m)
                    740:                                        imm->i6mm_maddr = NULL;
                    741:                        }
                    742:                }
1.73      ozaki-r   743:                pserialize_read_exit(_s);
1.31      rpaulo    744:
                    745:                /*
                    746:                 * Notify the network driver to update its multicast
                    747:                 * reception filter.
                    748:                 */
1.54      dyoung    749:                sockaddr_in6_init(&sin6, &in6m->in6m_addr, 0, 0, 0);
                    750:                if_mcast_op(in6m->in6m_ifp, SIOCDELMULTI, sin6tosa(&sin6));
1.61      ozaki-r   751:
                    752:                /* Tell mld_timeo we're halting the timer */
                    753:                in6m->in6m_timer = IN6M_TIMER_UNDEF;
1.80      ozaki-r   754:                if (mutex_owned(softnet_lock))
                    755:                        callout_halt(&in6m->in6m_timer_ch, softnet_lock);
                    756:                else
                    757:                        callout_halt(&in6m->in6m_timer_ch, NULL);
1.41      joerg     758:                callout_destroy(&in6m->in6m_timer_ch);
1.61      ozaki-r   759:
1.31      rpaulo    760:                free(in6m, M_IPMADDR);
                    761:        }
                    762:        splx(s);
                    763: }
                    764:
1.83    ! ozaki-r   765: /*
        !           766:  * Look up the in6_multi record for a given IP6 multicast address
        !           767:  * on a given interface. If no matching record is found, "in6m"
        !           768:  * returns NULL.
        !           769:  */
        !           770: struct in6_multi *
        !           771: in6_lookup_multi(const struct in6_addr *addr, const struct ifnet *ifp)
        !           772: {
        !           773:        struct in6_multi *in6m;
        !           774:
        !           775:        /* XXX NOMPSAFE */
        !           776:        LIST_FOREACH(in6m, &ifp->if_multiaddrs, in6m_entry) {
        !           777:                if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, addr))
        !           778:                        break;
        !           779:        }
        !           780:        return in6m;
        !           781: }
        !           782:
        !           783: /*
        !           784:  * Purge in6_multi records associated to the interface.
        !           785:  */
        !           786: void
        !           787: in6_purge_multi(struct ifnet *ifp)
        !           788: {
        !           789:        struct in6_multi *in6m, *next;
        !           790:
        !           791:        /* XXX NOMPSAFE */
        !           792:        LIST_FOREACH_SAFE(in6m, &ifp->if_multiaddrs, in6m_entry, next) {
        !           793:                in6_delmulti(in6m);
        !           794:        }
        !           795: }
1.31      rpaulo    796:
                    797: struct in6_multi_mship *
1.38      christos  798: in6_joingroup(struct ifnet *ifp, struct in6_addr *addr,
                    799:        int *errorp, int timer)
1.31      rpaulo    800: {
                    801:        struct in6_multi_mship *imm;
                    802:
1.51      dyoung    803:        imm = malloc(sizeof(*imm), M_IPMADDR, M_NOWAIT|M_ZERO);
                    804:        if (imm == NULL) {
1.31      rpaulo    805:                *errorp = ENOBUFS;
                    806:                return NULL;
                    807:        }
                    808:
1.32      rpaulo    809:        imm->i6mm_maddr = in6_addmulti(addr, ifp, errorp, timer);
1.31      rpaulo    810:        if (!imm->i6mm_maddr) {
1.36      dyoung    811:                /* *errorp is already set */
1.31      rpaulo    812:                free(imm, M_IPMADDR);
                    813:                return NULL;
                    814:        }
                    815:        return imm;
                    816: }
                    817:
                    818: int
1.38      christos  819: in6_leavegroup(struct in6_multi_mship *imm)
1.31      rpaulo    820: {
                    821:
                    822:        if (imm->i6mm_maddr) {
                    823:                in6_delmulti(imm->i6mm_maddr);
                    824:        }
                    825:        free(imm, M_IPMADDR);
                    826:        return 0;
                    827: }
                    828:
                    829: /*
1.83    ! ozaki-r   830:  * DEPRECATED: keep it just to avoid breaking old sysctl users.
1.31      rpaulo    831:  */
1.57      joerg     832: static int
                    833: in6_mkludge_sysctl(SYSCTLFN_ARGS)
                    834: {
                    835:
                    836:        if (namelen != 1)
                    837:                return EINVAL;
1.83    ! ozaki-r   838:        *oldlenp = 0;
        !           839:        return 0;
1.57      joerg     840: }
                    841:
                    842: static int
                    843: in6_multicast_sysctl(SYSCTLFN_ARGS)
                    844: {
                    845:        struct ifnet *ifp;
                    846:        struct ifaddr *ifa;
1.83    ! ozaki-r   847:        struct in6_ifaddr *ia6;
1.57      joerg     848:        struct in6_multi *in6m;
                    849:        uint32_t tmp;
                    850:        int error;
                    851:        size_t written;
1.74      ozaki-r   852:        struct psref psref, psref_ia;
                    853:        int bound, s;
1.57      joerg     854:
                    855:        if (namelen != 1)
                    856:                return EINVAL;
                    857:
1.67      ozaki-r   858:        bound = curlwp_bind();
                    859:        ifp = if_get_byindex(name[0], &psref);
                    860:        if (ifp == NULL) {
                    861:                curlwp_bindx(bound);
1.57      joerg     862:                return ENODEV;
1.67      ozaki-r   863:        }
1.57      joerg     864:
                    865:        if (oldp == NULL) {
                    866:                *oldlenp = 0;
1.74      ozaki-r   867:                s = pserialize_read_enter();
1.71      ozaki-r   868:                IFADDR_READER_FOREACH(ifa, ifp) {
1.83    ! ozaki-r   869:                        LIST_FOREACH(in6m, &ifp->if_multiaddrs, in6m_entry) {
1.57      joerg     870:                                *oldlenp += 2 * sizeof(struct in6_addr) +
                    871:                                    sizeof(uint32_t);
                    872:                        }
                    873:                }
1.74      ozaki-r   874:                pserialize_read_exit(s);
1.67      ozaki-r   875:                if_put(ifp, &psref);
                    876:                curlwp_bindx(bound);
1.57      joerg     877:                return 0;
                    878:        }
                    879:
                    880:        error = 0;
                    881:        written = 0;
1.74      ozaki-r   882:        s = pserialize_read_enter();
1.71      ozaki-r   883:        IFADDR_READER_FOREACH(ifa, ifp) {
1.57      joerg     884:                if (ifa->ifa_addr->sa_family != AF_INET6)
                    885:                        continue;
1.74      ozaki-r   886:
                    887:                ifa_acquire(ifa, &psref_ia);
                    888:                pserialize_read_exit(s);
                    889:
1.83    ! ozaki-r   890:                ia6 = ifatoia6(ifa);
        !           891:                LIST_FOREACH(in6m, &ifp->if_multiaddrs, in6m_entry) {
1.57      joerg     892:                        if (written + 2 * sizeof(struct in6_addr) +
                    893:                            sizeof(uint32_t) > *oldlenp)
                    894:                                goto done;
1.83    ! ozaki-r   895:                        /*
        !           896:                         * XXX return the first IPv6 address to keep backward
        !           897:                         * compatibility, however now multicast addresses
        !           898:                         * don't belong to any IPv6 addresses so it should be
        !           899:                         * unnecessary.
        !           900:                         */
        !           901:                        error = sysctl_copyout(l, &ia6->ia_addr.sin6_addr,
1.57      joerg     902:                            oldp, sizeof(struct in6_addr));
                    903:                        if (error)
                    904:                                goto done;
                    905:                        oldp = (char *)oldp + sizeof(struct in6_addr);
                    906:                        written += sizeof(struct in6_addr);
                    907:                        error = sysctl_copyout(l, &in6m->in6m_addr,
                    908:                            oldp, sizeof(struct in6_addr));
                    909:                        if (error)
                    910:                                goto done;
                    911:                        oldp = (char *)oldp + sizeof(struct in6_addr);
                    912:                        written += sizeof(struct in6_addr);
                    913:                        tmp = in6m->in6m_refcount;
                    914:                        error = sysctl_copyout(l, &tmp, oldp, sizeof(tmp));
                    915:                        if (error)
                    916:                                goto done;
                    917:                        oldp = (char *)oldp + sizeof(tmp);
                    918:                        written += sizeof(tmp);
                    919:                }
1.74      ozaki-r   920:
                    921:                s = pserialize_read_enter();
                    922:                ifa_release(ifa, &psref_ia);
1.83    ! ozaki-r   923:
        !           924:                break;
1.57      joerg     925:        }
1.74      ozaki-r   926:        pserialize_read_exit(s);
1.57      joerg     927: done:
1.74      ozaki-r   928:        ifa_release(ifa, &psref_ia);
1.67      ozaki-r   929:        if_put(ifp, &psref);
                    930:        curlwp_bindx(bound);
1.57      joerg     931:        *oldlenp = written;
                    932:        return error;
                    933: }
                    934:
1.76      ozaki-r   935: void
                    936: in6_sysctl_multicast_setup(struct sysctllog **clog)
1.57      joerg     937: {
                    938:
                    939:        sysctl_createv(clog, 0, NULL, NULL,
                    940:                       CTLFLAG_PERMANENT,
1.59      joerg     941:                       CTLTYPE_NODE, "inet6", NULL,
                    942:                       NULL, 0, NULL, 0,
                    943:                       CTL_NET, PF_INET6, CTL_EOL);
                    944:
                    945:        sysctl_createv(clog, 0, NULL, NULL,
                    946:                       CTLFLAG_PERMANENT,
1.57      joerg     947:                       CTLTYPE_NODE, "multicast",
                    948:                       SYSCTL_DESCR("Multicast information"),
                    949:                       in6_multicast_sysctl, 0, NULL, 0,
                    950:                       CTL_NET, PF_INET6, CTL_CREATE, CTL_EOL);
                    951:
                    952:        sysctl_createv(clog, 0, NULL, NULL,
                    953:                       CTLFLAG_PERMANENT,
                    954:                       CTLTYPE_NODE, "multicast_kludge",
                    955:                       SYSCTL_DESCR("multicast kludge information"),
                    956:                       in6_mkludge_sysctl, 0, NULL, 0,
                    957:                       CTL_NET, PF_INET6, CTL_CREATE, CTL_EOL);
                    958: }

CVSweb <webmaster@jp.NetBSD.org>