Deleted Added
full compact
ip6_mroute.c (196019) ip6_mroute.c (207369)
1/*-
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 65 unchanged lines hidden (view full) ---

74 * Modified by Van Jacobson, LBL, January 1993
75 * Modified by Ajit Thyagarajan, PARC, August 1993
76 * Modified by Bill Fenner, PARC, April 1994
77 *
78 * MROUTING Revision: 3.5.1.2 + PIM-SMv2 (pimd) Support
79 */
80
81#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 65 unchanged lines hidden (view full) ---

74 * Modified by Van Jacobson, LBL, January 1993
75 * Modified by Ajit Thyagarajan, PARC, August 1993
76 * Modified by Bill Fenner, PARC, April 1994
77 *
78 * MROUTING Revision: 3.5.1.2 + PIM-SMv2 (pimd) Support
79 */
80
81#include <sys/cdefs.h>
82__FBSDID("$FreeBSD: head/sys/netinet6/ip6_mroute.c 196019 2009-08-01 19:26:27Z rwatson $");
82__FBSDID("$FreeBSD: head/sys/netinet6/ip6_mroute.c 207369 2010-04-29 11:52:42Z bz $");
83
84#include "opt_inet.h"
85#include "opt_inet6.h"
86
87#include <sys/param.h>
88#include <sys/callout.h>
89#include <sys/errno.h>
90#include <sys/kernel.h>

--- 34 unchanged lines hidden (view full) ---

125
126static MALLOC_DEFINE(M_MRTABLE6, "mf6c", "multicast forwarding cache entry");
127
128/* XXX: this is a very common idiom; move to <sys/mbuf.h> ? */
129#define M_HASCL(m) ((m)->m_flags & M_EXT)
130
131static int ip6_mdq(struct mbuf *, struct ifnet *, struct mf6c *);
132static void phyint_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
83
84#include "opt_inet.h"
85#include "opt_inet6.h"
86
87#include <sys/param.h>
88#include <sys/callout.h>
89#include <sys/errno.h>
90#include <sys/kernel.h>

--- 34 unchanged lines hidden (view full) ---

125
126static MALLOC_DEFINE(M_MRTABLE6, "mf6c", "multicast forwarding cache entry");
127
128/* XXX: this is a very common idiom; move to <sys/mbuf.h> ? */
129#define M_HASCL(m) ((m)->m_flags & M_EXT)
130
131static int ip6_mdq(struct mbuf *, struct ifnet *, struct mf6c *);
132static void phyint_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
133static void pim6_init(void);
134static int register_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
135static int set_pim6(int *);
136static int socket_send(struct socket *, struct mbuf *,
137 struct sockaddr_in6 *);
138
139extern int in6_mcast_loop;
140extern struct domain inet6domain;
141
142static const struct encaptab *pim6_encap_cookie;
143static const struct ip6protosw in6_pim_protosw = {
144 .pr_type = SOCK_RAW,
145 .pr_domain = &inet6domain,
146 .pr_protocol = IPPROTO_PIM,
147 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
148 .pr_input = pim6_input,
149 .pr_output = rip6_output,
150 .pr_ctloutput = rip6_ctloutput,
133static int register_send(struct ip6_hdr *, struct mif6 *, struct mbuf *);
134static int set_pim6(int *);
135static int socket_send(struct socket *, struct mbuf *,
136 struct sockaddr_in6 *);
137
138extern int in6_mcast_loop;
139extern struct domain inet6domain;
140
141static const struct encaptab *pim6_encap_cookie;
142static const struct ip6protosw in6_pim_protosw = {
143 .pr_type = SOCK_RAW,
144 .pr_domain = &inet6domain,
145 .pr_protocol = IPPROTO_PIM,
146 .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
147 .pr_input = pim6_input,
148 .pr_output = rip6_output,
149 .pr_ctloutput = rip6_ctloutput,
151 .pr_init = pim6_init,
152 .pr_usrreqs = &rip6_usrreqs
153};
154static int pim6_encapcheck(const struct mbuf *, int, int, void *);
155
150 .pr_usrreqs = &rip6_usrreqs
151};
152static int pim6_encapcheck(const struct mbuf *, int, int, void *);
153
156static VNET_DEFINE(int, ip6_mrouter_ver);
154static VNET_DEFINE(int, ip6_mrouter_ver) = 0;
157#define V_ip6_mrouter_ver VNET(ip6_mrouter_ver)
158
159SYSCTL_DECL(_net_inet6);
160SYSCTL_DECL(_net_inet6_ip6);
161SYSCTL_NODE(_net_inet6, IPPROTO_PIM, pim, CTLFLAG_RW, 0, "PIM");
162
163static struct mrt6stat mrt6stat;
164SYSCTL_STRUCT(_net_inet6_ip6, OID_AUTO, mrt6stat, CTLFLAG_RW,

--- 42 unchanged lines hidden (view full) ---

207#define MIF6_LOCK() mtx_lock(&mif6_mtx)
208#define MIF6_UNLOCK() mtx_unlock(&mif6_mtx)
209#define MIF6_LOCK_ASSERT() mtx_assert(&mif6_mtx, MA_OWNED)
210#define MIF6_LOCK_INIT() \
211 mtx_init(&mif6_mtx, "IPv6 multicast interfaces", NULL, MTX_DEF)
212#define MIF6_LOCK_DESTROY() mtx_destroy(&mif6_mtx)
213
214#ifdef MRT6DEBUG
155#define V_ip6_mrouter_ver VNET(ip6_mrouter_ver)
156
157SYSCTL_DECL(_net_inet6);
158SYSCTL_DECL(_net_inet6_ip6);
159SYSCTL_NODE(_net_inet6, IPPROTO_PIM, pim, CTLFLAG_RW, 0, "PIM");
160
161static struct mrt6stat mrt6stat;
162SYSCTL_STRUCT(_net_inet6_ip6, OID_AUTO, mrt6stat, CTLFLAG_RW,

--- 42 unchanged lines hidden (view full) ---

205#define MIF6_LOCK() mtx_lock(&mif6_mtx)
206#define MIF6_UNLOCK() mtx_unlock(&mif6_mtx)
207#define MIF6_LOCK_ASSERT() mtx_assert(&mif6_mtx, MA_OWNED)
208#define MIF6_LOCK_INIT() \
209 mtx_init(&mif6_mtx, "IPv6 multicast interfaces", NULL, MTX_DEF)
210#define MIF6_LOCK_DESTROY() mtx_destroy(&mif6_mtx)
211
212#ifdef MRT6DEBUG
215static VNET_DEFINE(u_int, mrt6debug); /* debug level */
213static VNET_DEFINE(u_int, mrt6debug) = 0; /* debug level */
216#define V_mrt6debug VNET(mrt6debug)
217#define DEBUG_MFC 0x02
218#define DEBUG_FORWARD 0x04
219#define DEBUG_EXPIRE 0x08
220#define DEBUG_XMIT 0x10
221#define DEBUG_REG 0x20
222#define DEBUG_PIM 0x40
223#endif

--- 109 unchanged lines hidden (view full) ---

333static struct callout expire_upcalls_ch;
334
335int X_ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
336int X_ip6_mrouter_done(void);
337int X_ip6_mrouter_set(struct socket *, struct sockopt *);
338int X_ip6_mrouter_get(struct socket *, struct sockopt *);
339int X_mrt6_ioctl(u_long, caddr_t);
340
214#define V_mrt6debug VNET(mrt6debug)
215#define DEBUG_MFC 0x02
216#define DEBUG_FORWARD 0x04
217#define DEBUG_EXPIRE 0x08
218#define DEBUG_XMIT 0x10
219#define DEBUG_REG 0x20
220#define DEBUG_PIM 0x40
221#endif

--- 109 unchanged lines hidden (view full) ---

331static struct callout expire_upcalls_ch;
332
333int X_ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
334int X_ip6_mrouter_done(void);
335int X_ip6_mrouter_set(struct socket *, struct sockopt *);
336int X_ip6_mrouter_get(struct socket *, struct sockopt *);
337int X_mrt6_ioctl(u_long, caddr_t);
338
341static void
342pim6_init(void)
343{
344
345#ifdef MRT6DEBUG
346 V_mrt6debug = 0; /* debug level */
347#endif
348}
349
350/*
351 * Handle MRT setsockopt commands to modify the multicast routing tables.
352 */
353int
354X_ip6_mrouter_set(struct socket *so, struct sockopt *sopt)
355{
356 int error = 0;
357 int optval;

--- 170 unchanged lines hidden (view full) ---

528
529/*
530 * Enable multicast routing
531 */
532static int
533ip6_mrouter_init(struct socket *so, int v, int cmd)
534{
535
339/*
340 * Handle MRT setsockopt commands to modify the multicast routing tables.
341 */
342int
343X_ip6_mrouter_set(struct socket *so, struct sockopt *sopt)
344{
345 int error = 0;
346 int optval;

--- 170 unchanged lines hidden (view full) ---

517
518/*
519 * Enable multicast routing
520 */
521static int
522ip6_mrouter_init(struct socket *so, int v, int cmd)
523{
524
536 V_ip6_mrouter_ver = 0;
537
538#ifdef MRT6DEBUG
525#ifdef MRT6DEBUG
539 V_mrt6debug = 0;
540
541 if (V_mrt6debug)
542 log(LOG_DEBUG,
543 "ip6_mrouter_init: so_type = %d, pr_protocol = %d\n",
544 so->so_type, so->so_proto->pr_protocol);
545#endif
546
547 if (so->so_type != SOCK_RAW ||
548 so->so_proto->pr_protocol != IPPROTO_ICMPV6)

--- 1530 unchanged lines hidden ---
526 if (V_mrt6debug)
527 log(LOG_DEBUG,
528 "ip6_mrouter_init: so_type = %d, pr_protocol = %d\n",
529 so->so_type, so->so_proto->pr_protocol);
530#endif
531
532 if (so->so_type != SOCK_RAW ||
533 so->so_proto->pr_protocol != IPPROTO_ICMPV6)

--- 1530 unchanged lines hidden ---