FreeBSD kernel IPv4 code
ip_mroute.c File Reference
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_mrouting.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/stddef.h>
#include <sys/condvar.h>
#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/kthread.h>
#include <sys/ktr.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
#include <sys/priv.h>
#include <sys/protosw.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sockio.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/taskqueue.h>
#include <sys/time.h>
#include <sys/counter.h>
#include <machine/atomic.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/igmp.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_mroute.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/pim.h>
#include <netinet/pim_var.h>
#include <netinet/udp.h>
#include <machine/in_cksum.h>
Include dependency graph for ip_mroute.c:

Go to the source code of this file.

Data Structures

struct  pim_encap_pimhdr
 

Macros

#define _PIM_VT   1
 
#define KTR_IPMF   KTR_INET
 
#define VIFI_INVALID   ((vifi_t) -1)
 
#define MRW_RLOCK()   rw_rlock(&mrouter_mtx)
 
#define MRW_WLOCK()   rw_wlock(&mrouter_mtx)
 
#define MRW_RUNLOCK()   rw_runlock(&mrouter_mtx)
 
#define MRW_WUNLOCK()   rw_wunlock(&mrouter_mtx)
 
#define MRW_UNLOCK()   rw_unlock(&mrouter_mtx)
 
#define MRW_LOCK_ASSERT()   rw_assert(&mrouter_mtx, RA_LOCKED)
 
#define MRW_WLOCK_ASSERT()   rw_assert(&mrouter_mtx, RA_WLOCKED)
 
#define MRW_LOCK_TRY_UPGRADE()   rw_try_upgrade(&mrouter_mtx)
 
#define MRW_WOWNED()   rw_wowned(&mrouter_mtx)
 
#define MRW_LOCK_INIT()    rw_init(&mrouter_mtx, "IPv4 multicast forwarding")
 
#define MRW_LOCK_DESTROY()   rw_destroy(&mrouter_mtx)
 
#define V_mfchash   VNET(mfchash)
 
#define MFCHASH(a, g)
 
#define MFCHASHSIZE   256
 
#define V_nexpire   VNET(nexpire)
 
#define V_mfchashtbl   VNET(mfchashtbl)
 
#define V_task_queue   VNET(task_queue)
 
#define V_task   VNET(task)
 
#define V_numvifs   VNET(numvifs)
 
#define V_viftable   VNET(viftable)
 
#define V_expire_upcalls_ch   VNET(expire_upcalls_ch)
 
#define V_buf_ring_mtx   VNET(buf_ring_mtx)
 
#define EXPIRE_TIMEOUT   (hz / 4) /* 4x / second */
 
#define UPCALL_EXPIRE   6 /* number of timeouts */
 
#define V_bw_upcalls_ch   VNET(bw_upcalls_ch)
 
#define V_bw_upcalls_ring   VNET(bw_upcalls_ring)
 
#define V_bw_upcalls_ring_mtx   VNET(bw_upcalls_ring_mtx)
 
#define BW_UPCALLS_PERIOD   (hz) /* periodical flush of bw upcalls */
 
#define PIM_ENCAP_TTL   64
 
#define V_reg_vif_num   VNET(reg_vif_num)
 
#define V_multicast_register_if   VNET(multicast_register_if)
 
#define MRT_API_VERSION   0x0305
 
#define V_mrt_api_config   VNET(mrt_api_config)
 
#define V_pim_assert_enabled   VNET(pim_assert_enabled)
 
#define TUNNEL_LEN   12 /* # bytes of IP option for tunnel encapsulation */
 
#define BW_TIMEVALCMP(tvp, uvp, cmp)   timevalcmp((tvp), (uvp), cmp)
 
#define BW_TIMEVALDECR(vvp, uvp)   timevalsub((vvp), (uvp))
 
#define BW_TIMEVALADD(vvp, uvp)   timevaladd((vvp), (uvp))
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_MRTABLE, "mroutetbl", "multicast forwarding cache")
 
 VNET_PCPUSTAT_DEFINE_STATIC (struct mrtstat, mrtstat)
 
 VNET_PCPUSTAT_SYSINIT (mrtstat)
 
 VNET_PCPUSTAT_SYSUNINIT (mrtstat)
 
 SYSCTL_VNET_PCPUSTAT (_net_inet_ip, OID_AUTO, mrtstat, struct mrtstat, mrtstat, "IPv4 Multicast Forwarding Statistics (struct mrtstat, " "netinet/ip_mroute.h)")
 
 VNET_DEFINE_STATIC (u_long, mfchash)
 
 VNET_DEFINE_STATIC (u_char *, nexpire)
 
 VNET_DEFINE_STATIC (LIST_HEAD(mfchashhdr, mfc) *, mfchashtbl)
 
 VNET_DEFINE_STATIC (struct taskqueue *, task_queue)
 
 VNET_DEFINE_STATIC (struct task, task)
 
 VNET_DEFINE_STATIC (vifi_t, numvifs)
 
 VNET_DEFINE_STATIC (struct vif *, viftable)
 
 VNET_DEFINE_STATIC (struct callout, expire_upcalls_ch)
 
 VNET_DEFINE_STATIC (struct mtx, buf_ring_mtx)
 
static MALLOC_DEFINE (M_BWMETER, "bwmeter", "multicast upcall bw meters")
 
 VNET_DEFINE_STATIC (struct callout, bw_upcalls_ch)
 
 VNET_DEFINE_STATIC (struct buf_ring *, bw_upcalls_ring)
 
 VNET_DEFINE_STATIC (struct mtx, bw_upcalls_ring_mtx)
 
 VNET_PCPUSTAT_DEFINE_STATIC (struct pimstat, pimstat)
 
 VNET_PCPUSTAT_SYSINIT (pimstat)
 
 VNET_PCPUSTAT_SYSUNINIT (pimstat)
 
 SYSCTL_NODE (_net_inet, IPPROTO_PIM, pim, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "PIM")
 
 SYSCTL_VNET_PCPUSTAT (_net_inet_pim, PIMCTL_STATS, stats, struct pimstat, pimstat, "PIM Statistics (struct pimstat, netinet/pim_var.h)")
 
 SYSCTL_ULONG (_net_inet_pim, OID_AUTO, squelch_wholepkt, CTLFLAG_RW, &pim_squelch_wholepkt, 0, "Disable IGMP_WHOLEPKT notifications if rendezvous point is unspecified")
 
static int pim_encapcheck (const struct mbuf *, int, int, void *)
 
static int pim_input (struct mbuf *, int, int, void *)
 
 VNET_DEFINE_STATIC (vifi_t, reg_vif_num)
 
 VNET_DEFINE_STATIC (struct ifnet *, multicast_register_if)
 
static u_long X_ip_mcast_src (int)
 
static int X_ip_mforward (struct ip *, struct ifnet *, struct mbuf *, struct ip_moptions *)
 
static int X_ip_mrouter_done (void)
 
static int X_ip_mrouter_get (struct socket *, struct sockopt *)
 
static int X_ip_mrouter_set (struct socket *, struct sockopt *)
 
static int X_legal_vif_num (int)
 
static int X_mrt_ioctl (u_long, caddr_t, int)
 
static int add_bw_upcall (struct bw_upcall *)
 
static int add_mfc (struct mfcctl2 *)
 
static int add_vif (struct vifctl *)
 
static void bw_meter_prepare_upcall (struct bw_meter *, struct timeval *)
 
static void bw_meter_geq_receive_packet (struct bw_meter *, int, struct timeval *)
 
static void bw_upcalls_send (void)
 
static int del_bw_upcall (struct bw_upcall *)
 
static int del_mfc (struct mfcctl2 *)
 
static int del_vif (vifi_t)
 
static int del_vif_locked (vifi_t, struct ifnet **)
 
static void expire_bw_upcalls_send (void *)
 
static void expire_mfc (struct mfc *)
 
static void expire_upcalls (void *)
 
static void free_bw_list (struct bw_meter *)
 
static int get_sg_cnt (struct sioc_sg_req *)
 
static int get_vif_cnt (struct sioc_vif_req *)
 
static void if_detached_event (void *, struct ifnet *)
 
static int ip_mdq (struct mbuf *, struct ifnet *, struct mfc *, vifi_t)
 
static int ip_mrouter_init (struct socket *, int)
 
static __inline struct mfcmfc_find (struct in_addr *, struct in_addr *)
 
static void phyint_send (struct ip *, struct vif *, struct mbuf *)
 
static struct mbuf * pim_register_prepare (struct ip *, struct mbuf *)
 
static int pim_register_send (struct ip *, struct vif *, struct mbuf *, struct mfc *)
 
static int pim_register_send_rp (struct ip *, struct vif *, struct mbuf *, struct mfc *)
 
static int pim_register_send_upcall (struct ip *, struct vif *, struct mbuf *, struct mfc *)
 
static void send_packet (struct vif *, struct mbuf *)
 
static int set_api_config (uint32_t *)
 
static int set_assert (int)
 
static int socket_send (struct socket *, struct mbuf *, struct sockaddr_in *)
 
 VNET_DEFINE_STATIC (uint32_t, mrt_api_config)
 
 VNET_DEFINE_STATIC (int, pim_assert_enabled)
 
static __inline struct mfcmfc_alloc (void)
 
static int X_mrt_ioctl (u_long cmd, caddr_t data, int fibnum __unused)
 
static void if_detached_event (void *arg __unused, struct ifnet *ifp)
 
static void ip_mrouter_upcall_thread (void *arg, int pending __unused)
 
static void update_mfc_params (struct mfc *rt, struct mfcctl2 *mfccp)
 
static void init_mfc_params (struct mfc *rt, struct mfcctl2 *mfccp)
 
static int X_ip_rsvp_vif (struct socket *so __unused, struct sockopt *sopt __unused)
 
static void X_ip_rsvp_force_done (struct socket *so __unused)
 
static int X_rsvp_input (struct mbuf **mp, int *offp, int proto)
 
static uint32_t compute_bw_meter_flags (struct bw_upcall *req)
 
static void expire_bw_meter_leq (void *arg)
 
static int pim_encapcheck (const struct mbuf *m __unused, int off __unused, int proto __unused, void *arg __unused)
 
static int pim_input (struct mbuf *m, int off, int proto, void *arg __unused)
 
static int sysctl_mfctable (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_net_inet_ip, OID_AUTO, mfctable, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_mfctable, "IPv4 Multicast Forwarding Table " "(struct *mfc[mfchashsize], netinet/ip_mroute.h)")
 
static int sysctl_viflist (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_net_inet_ip, OID_AUTO, viftable, CTLTYPE_OPAQUE|CTLFLAG_VNET|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_viflist, "S,vif[MAXVIFS]", "IPv4 Multicast Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)")
 
static void vnet_mroute_init (const void *unused __unused)
 
 VNET_SYSINIT (vnet_mroute_init, SI_SUB_PROTO_MC, SI_ORDER_ANY, vnet_mroute_init, NULL)
 
static void vnet_mroute_uninit (const void *unused __unused)
 
 VNET_SYSUNINIT (vnet_mroute_uninit, SI_SUB_PROTO_MC, SI_ORDER_MIDDLE, vnet_mroute_uninit, NULL)
 
static int ip_mroute_modevent (module_t mod, int type, void *unused)
 
 DECLARE_MODULE (ip_mroute, ip_mroutemod, SI_SUB_PROTO_MC, SI_ORDER_MIDDLE)
 

Variables

static struct rwlock mrouter_mtx
 
static int ip_mrouter_cnt
 
static int ip_mrouter_unloading
 
static u_long mfchashsize
 
static eventhandler_tag if_detach_event_tag = NULL
 
static u_long pim_squelch_wholepkt = 0
 
static const struct encaptabpim_encap_cookie
 
int in_mcast_loop
 
static const struct encap_config ipv4_encap_cfg
 
static struct ip pim_encap_iphdr
 
static struct pim_encap_pimhdr pim_encap_pimhdr
 
static const int mrt_api_version = MRT_API_VERSION
 
static const uint32_t mrt_api_support
 
static struct timeval pim_assert_interval = { 3, 0 }
 
static moduledata_t ip_mroutemod
 

Macro Definition Documentation

◆ _PIM_VT

#define _PIM_VT   1

Definition at line 78 of file ip_mroute.c.

◆ BW_TIMEVALADD

#define BW_TIMEVALADD (   vvp,
  uvp 
)    timevaladd((vvp), (uvp))

Definition at line 1811 of file ip_mroute.c.

◆ BW_TIMEVALCMP

#define BW_TIMEVALCMP (   tvp,
  uvp,
  cmp 
)    timevalcmp((tvp), (uvp), cmp)

Definition at line 1809 of file ip_mroute.c.

◆ BW_TIMEVALDECR

#define BW_TIMEVALDECR (   vvp,
  uvp 
)    timevalsub((vvp), (uvp))

Definition at line 1810 of file ip_mroute.c.

◆ BW_UPCALLS_PERIOD

#define BW_UPCALLS_PERIOD   (hz) /* periodical flush of bw upcalls */

Definition at line 218 of file ip_mroute.c.

◆ EXPIRE_TIMEOUT

#define EXPIRE_TIMEOUT   (hz / 4) /* 4x / second */

Definition at line 199 of file ip_mroute.c.

◆ KTR_IPMF

#define KTR_IPMF   KTR_INET

Definition at line 130 of file ip_mroute.c.

◆ MFCHASH

#define MFCHASH (   a,
 
)
Value:
((((a).s_addr >> 20) ^ ((a).s_addr >> 10) ^ (a).s_addr ^ \
((g).s_addr >> 20) ^ ((g).s_addr >> 10) ^ (g).s_addr) & V_mfchash)
#define V_mfchash
Definition: ip_mroute.c:170
union @45::@47 s_addr

Definition at line 171 of file ip_mroute.c.

◆ MFCHASHSIZE

#define MFCHASHSIZE   256

Definition at line 174 of file ip_mroute.c.

◆ MRT_API_VERSION

#define MRT_API_VERSION   0x0305

Definition at line 351 of file ip_mroute.c.

◆ MRW_LOCK_ASSERT

#define MRW_LOCK_ASSERT ( )    rw_assert(&mrouter_mtx, RA_LOCKED)

Definition at line 151 of file ip_mroute.c.

◆ MRW_LOCK_DESTROY

#define MRW_LOCK_DESTROY ( )    rw_destroy(&mrouter_mtx)

Definition at line 157 of file ip_mroute.c.

◆ MRW_LOCK_INIT

#define MRW_LOCK_INIT ( )     rw_init(&mrouter_mtx, "IPv4 multicast forwarding")

Definition at line 155 of file ip_mroute.c.

◆ MRW_LOCK_TRY_UPGRADE

#define MRW_LOCK_TRY_UPGRADE ( )    rw_try_upgrade(&mrouter_mtx)

Definition at line 153 of file ip_mroute.c.

◆ MRW_RLOCK

#define MRW_RLOCK ( )    rw_rlock(&mrouter_mtx)

Definition at line 146 of file ip_mroute.c.

◆ MRW_RUNLOCK

#define MRW_RUNLOCK ( )    rw_runlock(&mrouter_mtx)

Definition at line 148 of file ip_mroute.c.

◆ MRW_UNLOCK

#define MRW_UNLOCK ( )    rw_unlock(&mrouter_mtx)

Definition at line 150 of file ip_mroute.c.

◆ MRW_WLOCK

#define MRW_WLOCK ( )    rw_wlock(&mrouter_mtx)

Definition at line 147 of file ip_mroute.c.

◆ MRW_WLOCK_ASSERT

#define MRW_WLOCK_ASSERT ( )    rw_assert(&mrouter_mtx, RA_WLOCKED)

Definition at line 152 of file ip_mroute.c.

◆ MRW_WOWNED

#define MRW_WOWNED ( )    rw_wowned(&mrouter_mtx)

Definition at line 154 of file ip_mroute.c.

◆ MRW_WUNLOCK

#define MRW_WUNLOCK ( )    rw_wunlock(&mrouter_mtx)

Definition at line 149 of file ip_mroute.c.

◆ PIM_ENCAP_TTL

#define PIM_ENCAP_TTL   64

Definition at line 263 of file ip_mroute.c.

◆ TUNNEL_LEN

#define TUNNEL_LEN   12 /* # bytes of IP option for tunnel encapsulation */

Definition at line 1284 of file ip_mroute.c.

◆ UPCALL_EXPIRE

#define UPCALL_EXPIRE   6 /* number of timeouts */

Definition at line 200 of file ip_mroute.c.

◆ V_buf_ring_mtx

#define V_buf_ring_mtx   VNET(buf_ring_mtx)

Definition at line 197 of file ip_mroute.c.

◆ V_bw_upcalls_ch

#define V_bw_upcalls_ch   VNET(bw_upcalls_ch)

Definition at line 212 of file ip_mroute.c.

◆ V_bw_upcalls_ring

#define V_bw_upcalls_ring   VNET(bw_upcalls_ring)

Definition at line 214 of file ip_mroute.c.

◆ V_bw_upcalls_ring_mtx

#define V_bw_upcalls_ring_mtx   VNET(bw_upcalls_ring_mtx)

Definition at line 216 of file ip_mroute.c.

◆ V_expire_upcalls_ch

#define V_expire_upcalls_ch   VNET(expire_upcalls_ch)

Definition at line 194 of file ip_mroute.c.

◆ V_mfchash

#define V_mfchash   VNET(mfchash)

Definition at line 170 of file ip_mroute.c.

◆ V_mfchashtbl

#define V_mfchashtbl   VNET(mfchashtbl)

Definition at line 180 of file ip_mroute.c.

◆ V_mrt_api_config

#define V_mrt_api_config   VNET(mrt_api_config)

Definition at line 359 of file ip_mroute.c.

◆ V_multicast_register_if

#define V_multicast_register_if   VNET(multicast_register_if)

Definition at line 294 of file ip_mroute.c.

◆ V_nexpire

#define V_nexpire   VNET(nexpire)

Definition at line 178 of file ip_mroute.c.

◆ V_numvifs

#define V_numvifs   VNET(numvifs)

Definition at line 187 of file ip_mroute.c.

◆ V_pim_assert_enabled

#define V_pim_assert_enabled   VNET(pim_assert_enabled)

Definition at line 361 of file ip_mroute.c.

◆ V_reg_vif_num

#define V_reg_vif_num   VNET(reg_vif_num)

Definition at line 292 of file ip_mroute.c.

◆ V_task

#define V_task   VNET(task)

Definition at line 184 of file ip_mroute.c.

◆ V_task_queue

#define V_task_queue   VNET(task_queue)

Definition at line 182 of file ip_mroute.c.

◆ V_viftable

#define V_viftable   VNET(viftable)

Definition at line 189 of file ip_mroute.c.

◆ VIFI_INVALID

#define VIFI_INVALID   ((vifi_t) -1)

Definition at line 133 of file ip_mroute.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ add_bw_upcall()

◆ add_mfc()

◆ add_vif()

◆ bw_meter_geq_receive_packet()

static void bw_meter_geq_receive_packet ( struct bw_meter x,
int  plen,
struct timeval *  nowp 
)
static

◆ bw_meter_prepare_upcall()

◆ bw_upcalls_send()

static void bw_upcalls_send ( void  )
static

Definition at line 2167 of file ip_mroute.c.

References IGMPMSG_BW_UPCALL, MRTSTAT_INC, MRW_LOCK_ASSERT, socket_send(), V_bw_upcalls_ring, and V_ip_mrouter.

Referenced by expire_bw_upcalls_send(), and ip_mrouter_upcall_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_bw_meter_flags()

static uint32_t compute_bw_meter_flags ( struct bw_upcall req)
static

◆ DECLARE_MODULE()

DECLARE_MODULE ( ip_mroute  ,
ip_mroutemod  ,
SI_SUB_PROTO_MC  ,
SI_ORDER_MIDDLE   
)

◆ del_bw_upcall()

◆ del_mfc()

static int del_mfc ( struct mfcctl2 mfccp)
static

Definition at line 1218 of file ip_mroute.c.

References free_bw_list(), KTR_IPMF, mfc::mfc_bw_meter_geq, mfc::mfc_bw_meter_leq, mfc_find(), mfcctl2::mfcc_mcastgrp, mfcctl2::mfcc_origin, MRW_WLOCK, MRW_WUNLOCK, and in_addr::s_addr.

Referenced by X_ip_mrouter_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_vif()

static int del_vif ( vifi_t  vifi)
static

Definition at line 1040 of file ip_mroute.c.

References del_vif_locked(), MRW_WLOCK, and MRW_WUNLOCK.

Referenced by X_ip_mrouter_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_vif_locked()

static int del_vif_locked ( vifi_t  vifi,
struct ifnet **  ifp_free 
)
static

◆ expire_bw_meter_leq()

static void expire_bw_meter_leq ( void *  arg)
static

◆ expire_bw_upcalls_send()

static void expire_bw_upcalls_send ( void *  arg)
static

Definition at line 2220 of file ip_mroute.c.

References BW_UPCALLS_PERIOD, bw_upcalls_send(), expire_bw_upcalls_send(), and V_bw_upcalls_ch.

Referenced by expire_bw_upcalls_send(), and ip_mrouter_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expire_mfc()

static void expire_mfc ( struct mfc rt)
static

Definition at line 1095 of file ip_mroute.c.

References free_bw_list(), rtdetq::m, mfc::mfc_bw_meter_geq, mfc::mfc_bw_meter_leq, mfc::mfc_stall_ring, and MRW_WLOCK_ASSERT.

Referenced by expire_upcalls(), if_detached_event(), and X_ip_mrouter_done().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expire_upcalls()

static void expire_upcalls ( void *  arg)
static

Definition at line 1504 of file ip_mroute.c.

References expire_mfc(), EXPIRE_TIMEOUT, expire_upcalls(), KTR_IPMF, mfc::mfc_expire, mfc::mfc_mcastgrp, mfc::mfc_origin, mfc::mfc_stall_ring, mfchashsize, MRTSTAT_INC, in_addr::s_addr, V_expire_upcalls_ch, V_mfchashtbl, and V_nexpire.

Referenced by expire_upcalls(), and ip_mrouter_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_bw_list()

static void free_bw_list ( struct bw_meter list)
static

Definition at line 1974 of file ip_mroute.c.

References bw_meter::bm_flags, bw_meter::bm_meter_callout, bw_meter::bm_mfc_next, bw_meter::bm_spin, and BW_METER_LEQ.

Referenced by del_bw_upcall(), del_mfc(), and expire_mfc().

Here is the caller graph for this function:

◆ get_sg_cnt()

static int get_sg_cnt ( struct sioc_sg_req req)
static

Definition at line 577 of file ip_mroute.c.

References sioc_sg_req::bytecnt, sioc_sg_req::grp, mfc::mfc_byte_cnt, mfc_find(), mfc::mfc_pkt_cnt, mfc::mfc_wrong_if, MRW_RLOCK, MRW_RUNLOCK, sioc_sg_req::pktcnt, sioc_sg_req::src, and sioc_sg_req::wrong_if.

Referenced by X_mrt_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vif_cnt()

static int get_vif_cnt ( struct sioc_vif_req req)
static

Definition at line 599 of file ip_mroute.c.

References sioc_vif_req::ibytes, sioc_vif_req::icount, MRW_RLOCK, MRW_RUNLOCK, sioc_vif_req::obytes, sioc_vif_req::ocount, V_numvifs, V_viftable, and sioc_vif_req::vifi.

Referenced by X_mrt_ioctl().

Here is the caller graph for this function:

◆ if_detached_event() [1/2]

static void if_detached_event ( void *  ,
struct ifnet *   
)
static

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ if_detached_event() [2/2]

static void if_detached_event ( void *arg  __unused,
struct ifnet *  ifp 
)
static

Definition at line 621 of file ip_mroute.c.

References del_vif_locked(), expire_mfc(), mfc::mfc_parent, mfchashsize, MRW_WLOCK, MRW_WUNLOCK, V_ip_mrouter, V_mfchashtbl, V_numvifs, and V_viftable.

Here is the call graph for this function:

◆ init_mfc_params()

static void init_mfc_params ( struct mfc rt,
struct mfcctl2 mfccp 
)
static

Definition at line 1080 of file ip_mroute.c.

References mfc::mfc_byte_cnt, mfc::mfc_last_assert, mfc::mfc_mcastgrp, mfc::mfc_origin, mfc::mfc_pkt_cnt, mfc::mfc_wrong_if, mfcctl2::mfcc_mcastgrp, mfcctl2::mfcc_origin, and update_mfc_params().

Referenced by add_mfc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_mdq()

◆ ip_mroute_modevent()

◆ ip_mrouter_init()

static int ip_mrouter_init ( struct socket *  so,
int  version 
)
static

◆ ip_mrouter_upcall_thread()

static void ip_mrouter_upcall_thread ( void *  arg,
int pending  __unused 
)
static

Definition at line 671 of file ip_mroute.c.

References bw_upcalls_send(), MRW_WLOCK, and MRW_WUNLOCK.

Referenced by ip_mrouter_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE() [1/2]

static MALLOC_DEFINE ( M_BWMETER  ,
"bwmeter"  ,
"multicast upcall bw meters"   
)
static

◆ MALLOC_DEFINE() [2/2]

static MALLOC_DEFINE ( M_MRTABLE  ,
"mroutetbl"  ,
"multicast forwarding cache"   
)
static

◆ mfc_alloc()

static __inline struct mfc * mfc_alloc ( void  )
static

Definition at line 391 of file ip_mroute.c.

References MAX_UPQ, mfc::mfc_stall_ring, and V_buf_ring_mtx.

Referenced by add_mfc(), and X_ip_mforward().

Here is the caller graph for this function:

◆ mfc_find()

static __inline struct mfc * mfc_find ( struct in_addr o,
struct in_addr g 
)
static

Definition at line 369 of file ip_mroute.c.

References in_hosteq, mfc::mfc_mcastgrp, mfc::mfc_origin, mfc::mfc_stall_ring, MFCHASH, MRW_LOCK_ASSERT, and V_mfchashtbl.

Referenced by add_bw_upcall(), add_mfc(), del_bw_upcall(), del_mfc(), get_sg_cnt(), and X_ip_mforward().

Here is the caller graph for this function:

◆ phyint_send()

static void phyint_send ( struct ip ip,
struct vif vifp,
struct mbuf *  m 
)
static

Definition at line 1727 of file ip_mroute.c.

References ip::ip_hl, MRW_LOCK_ASSERT, and send_packet().

Referenced by ip_mdq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pim_encapcheck() [1/2]

static int pim_encapcheck ( const struct mbuf *  ,
int  ,
int  ,
void *   
)
static

◆ pim_encapcheck() [2/2]

static int pim_encapcheck ( const struct mbuf *m  __unused,
int off  __unused,
int proto  __unused,
void *arg  __unused 
)
static

Definition at line 2459 of file ip_mroute.c.

◆ pim_input() [1/2]

static int pim_input ( struct mbuf *  ,
int  ,
int  ,
void *   
)
static

◆ pim_input() [2/2]

static int pim_input ( struct mbuf *  m,
int  off,
int  proto,
void *arg  __unused 
)
static

◆ pim_register_prepare()

static struct mbuf * pim_register_prepare ( struct ip ip,
struct mbuf *  m 
)
static

Definition at line 2286 of file ip_mroute.c.

References in_delayed_cksum(), ip_fragment(), ip::ip_hl, ip::ip_len, ip::ip_sum, ip::ip_ttl, and pim_encap_iphdr.

Referenced by pim_register_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pim_register_send()

static int pim_register_send ( struct ip ip,
struct vif vifp,
struct mbuf *  m,
struct mfc rt 
)
static

Definition at line 2242 of file ip_mroute.c.

References in_nullhost, mfc::mfc_rp, MRT_MFC_RP, pim_register_prepare(), pim_register_send_rp(), pim_register_send_upcall(), pim_squelch_wholepkt, and V_mrt_api_config.

Referenced by ip_mdq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pim_register_send_rp()

static int pim_register_send_rp ( struct ip ip,
struct vif vifp,
struct mbuf *  mb_copy,
struct mfc rt 
)
static

◆ pim_register_send_upcall()

static int pim_register_send_upcall ( struct ip ip,
struct vif vifp,
struct mbuf *  mb_copy,
struct mfc rt 
)
static

Definition at line 2334 of file ip_mroute.c.

References IGMPMSG_WHOLEPKT, igmpmsg::im_dst, igmpmsg::im_mbz, igmpmsg::im_msgtype, igmpmsg::im_vif, ip::ip_dst, ip::ip_len, KTR_IPMF, MRTSTAT_INC, MRW_LOCK_ASSERT, PIMSTAT_ADD, PIMSTAT_INC, sockaddr_in::sin_addr, socket_send(), V_ip_mrouter, and V_viftable.

Referenced by pim_register_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_packet()

static void send_packet ( struct vif vifp,
struct mbuf *  m 
)
static

Definition at line 1749 of file ip_mroute.c.

References in_mcast_loop, IP_FORWARDING, ip_output(), KTR_IPMF, MRW_LOCK_ASSERT, vif::v_ifp, and V_viftable.

Referenced by phyint_send(), and pim_register_send_rp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_api_config()

int set_api_config ( uint32_t apival)
static

Definition at line 850 of file ip_mroute.c.

References mfchashsize, mrt_api_support, MRW_RLOCK, MRW_RUNLOCK, V_mfchashtbl, V_mrt_api_config, V_numvifs, and V_pim_assert_enabled.

Referenced by X_ip_mrouter_set().

Here is the caller graph for this function:

◆ set_assert()

static int set_assert ( int  i)
static

Definition at line 836 of file ip_mroute.c.

References V_pim_assert_enabled.

Referenced by X_ip_mrouter_set().

Here is the caller graph for this function:

◆ socket_send()

static int socket_send ( struct socket *  s,
struct mbuf *  mm,
struct sockaddr_in src 
)
static

Definition at line 1258 of file ip_mroute.c.

Referenced by bw_upcalls_send(), ip_mdq(), pim_register_send_upcall(), and X_ip_mforward().

Here is the caller graph for this function:

◆ sysctl_mfctable()

static int sysctl_mfctable ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2691 of file ip_mroute.c.

References mfchashsize, MRW_RLOCK, MRW_RUNLOCK, and V_mfchashtbl.

◆ SYSCTL_NODE() [1/2]

SYSCTL_NODE ( _net_inet  ,
IPPROTO_PIM  ,
pim  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"PIM"   
)

◆ SYSCTL_NODE() [2/2]

static SYSCTL_NODE ( _net_inet_ip  ,
OID_AUTO  ,
mfctable  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_mfctable  ,
"IPv4 Multicast Forwarding Table " "(struct *mfc[mfchashsize], netinet/ip_mroute.h)"   
)
static

◆ SYSCTL_PROC()

SYSCTL_PROC ( _net_inet_ip  ,
OID_AUTO  ,
viftable  ,
CTLTYPE_OPAQUE|CTLFLAG_VNET|CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_viflist  ,
S,
vif [MAXVIFS],
"IPv4 Multicast Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)"   
)

◆ SYSCTL_ULONG()

SYSCTL_ULONG ( _net_inet_pim  ,
OID_AUTO  ,
squelch_wholepkt  ,
CTLFLAG_RW  ,
pim_squelch_wholepkt,
,
"Disable IGMP_WHOLEPKT notifications if rendezvous point is unspecified"   
)

◆ sysctl_viflist()

static int sysctl_viflist ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2723 of file ip_mroute.c.

References MAXVIFS, MRW_RLOCK, MRW_RUNLOCK, and V_viftable.

◆ SYSCTL_VNET_PCPUSTAT() [1/2]

SYSCTL_VNET_PCPUSTAT ( _net_inet_ip  ,
OID_AUTO  ,
mrtstat  ,
struct mrtstat  ,
mrtstat  ,
"IPv4 Multicast Forwarding Statistics (struct mrtstat, " "netinet/ip_mroute.h)"   
)

◆ SYSCTL_VNET_PCPUSTAT() [2/2]

SYSCTL_VNET_PCPUSTAT ( _net_inet_pim  ,
PIMCTL_STATS  ,
stats  ,
struct pimstat  ,
pimstat  ,
"PIM Statistics (struct pimstat, netinet/pim_var.h)"   
)

◆ update_mfc_params()

static void update_mfc_params ( struct mfc rt,
struct mfcctl2 mfccp 
)
static

◆ VNET_DEFINE_STATIC() [1/16]

VNET_DEFINE_STATIC ( int  ,
pim_assert_enabled   
)

◆ VNET_DEFINE_STATIC() [2/16]

VNET_DEFINE_STATIC ( LIST_HEAD(mfchashhdr, mfc) *  ,
mfchashtbl   
)

◆ VNET_DEFINE_STATIC() [3/16]

VNET_DEFINE_STATIC ( struct buf_ring *  ,
bw_upcalls_ring   
)

◆ VNET_DEFINE_STATIC() [4/16]

VNET_DEFINE_STATIC ( struct callout  ,
bw_upcalls_ch   
)

◆ VNET_DEFINE_STATIC() [5/16]

VNET_DEFINE_STATIC ( struct callout  ,
expire_upcalls_ch   
)

◆ VNET_DEFINE_STATIC() [6/16]

VNET_DEFINE_STATIC ( struct ifnet *  ,
multicast_register_if   
)

◆ VNET_DEFINE_STATIC() [7/16]

VNET_DEFINE_STATIC ( struct mtx  ,
buf_ring_mtx   
)

◆ VNET_DEFINE_STATIC() [8/16]

VNET_DEFINE_STATIC ( struct mtx  ,
bw_upcalls_ring_mtx   
)

◆ VNET_DEFINE_STATIC() [9/16]

VNET_DEFINE_STATIC ( struct task  ,
task   
)

◆ VNET_DEFINE_STATIC() [10/16]

VNET_DEFINE_STATIC ( struct taskqueue *  ,
task_queue   
)

◆ VNET_DEFINE_STATIC() [11/16]

VNET_DEFINE_STATIC ( struct vif ,
viftable   
)

◆ VNET_DEFINE_STATIC() [12/16]

VNET_DEFINE_STATIC ( u_char *  ,
nexpire   
)

◆ VNET_DEFINE_STATIC() [13/16]

VNET_DEFINE_STATIC ( u_long  ,
mfchash   
)

◆ VNET_DEFINE_STATIC() [14/16]

VNET_DEFINE_STATIC ( uint32_t  ,
mrt_api_config   
)

◆ VNET_DEFINE_STATIC() [15/16]

VNET_DEFINE_STATIC ( vifi_t  ,
numvifs   
)

◆ VNET_DEFINE_STATIC() [16/16]

VNET_DEFINE_STATIC ( vifi_t  ,
reg_vif_num   
)

◆ vnet_mroute_init()

static void vnet_mroute_init ( const void *unused  __unused)
static

◆ vnet_mroute_uninit()

static void vnet_mroute_uninit ( const void *unused  __unused)
static

Definition at line 2768 of file ip_mroute.c.

References V_nexpire, V_task_queue, and V_viftable.

◆ VNET_PCPUSTAT_DEFINE_STATIC() [1/2]

VNET_PCPUSTAT_DEFINE_STATIC ( struct mrtstat  ,
mrtstat   
)

◆ VNET_PCPUSTAT_DEFINE_STATIC() [2/2]

VNET_PCPUSTAT_DEFINE_STATIC ( struct pimstat  ,
pimstat   
)

◆ VNET_PCPUSTAT_SYSINIT() [1/2]

VNET_PCPUSTAT_SYSINIT ( mrtstat  )

◆ VNET_PCPUSTAT_SYSINIT() [2/2]

VNET_PCPUSTAT_SYSINIT ( pimstat  )

◆ VNET_PCPUSTAT_SYSUNINIT() [1/2]

VNET_PCPUSTAT_SYSUNINIT ( mrtstat  )

◆ VNET_PCPUSTAT_SYSUNINIT() [2/2]

VNET_PCPUSTAT_SYSUNINIT ( pimstat  )

◆ VNET_SYSINIT()

VNET_SYSINIT ( vnet_mroute_init  ,
SI_SUB_PROTO_MC  ,
SI_ORDER_ANY  ,
vnet_mroute_init  ,
NULL   
)

◆ VNET_SYSUNINIT()

VNET_SYSUNINIT ( vnet_mroute_uninit  ,
SI_SUB_PROTO_MC  ,
SI_ORDER_MIDDLE  ,
vnet_mroute_uninit  ,
NULL   
)

◆ X_ip_mcast_src()

static u_long X_ip_mcast_src ( int  vifi)
static

Definition at line 1710 of file ip_mroute.c.

References INADDR_ANY, MRW_RLOCK, MRW_RUNLOCK, V_numvifs, and V_viftable.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_ip_mforward()

◆ X_ip_mrouter_done()

static int X_ip_mrouter_done ( void  )
static

◆ X_ip_mrouter_get()

static int X_ip_mrouter_get ( struct socket *  so,
struct sockopt *  sopt 
)
static

Definition at line 512 of file ip_mroute.c.

References MRT_API_CONFIG, mrt_api_support, MRT_API_SUPPORT, mrt_api_version, MRT_ASSERT, MRT_VERSION, V_mrt_api_config, and V_pim_assert_enabled.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_ip_mrouter_set()

static int X_ip_mrouter_set ( struct socket *  so,
struct sockopt *  sopt 
)
static

◆ X_ip_rsvp_force_done()

static void X_ip_rsvp_force_done ( struct socket *so  __unused)
static

Definition at line 1785 of file ip_mroute.c.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_ip_rsvp_vif()

static int X_ip_rsvp_vif ( struct socket *so  __unused,
struct sockopt *sopt  __unused 
)
static

Definition at line 1778 of file ip_mroute.c.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_legal_vif_num()

static int X_legal_vif_num ( int  vif)
static

Definition at line 1690 of file ip_mroute.c.

References MRW_RLOCK, MRW_RUNLOCK, and V_numvifs.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_mrt_ioctl() [1/2]

static int X_mrt_ioctl ( u_long  cmd,
caddr_t  data,
int fibnum  __unused 
)
static

Definition at line 545 of file ip_mroute.c.

References get_sg_cnt(), and get_vif_cnt().

Here is the call graph for this function:

◆ X_mrt_ioctl() [2/2]

static int X_mrt_ioctl ( u_long  ,
caddr_t  ,
int   
)
static

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

◆ X_rsvp_input()

static int X_rsvp_input ( struct mbuf **  mp,
int *  offp,
int  proto 
)
static

Definition at line 1791 of file ip_mroute.c.

References V_rsvp_on.

Referenced by ip_mroute_modevent().

Here is the caller graph for this function:

Variable Documentation

◆ if_detach_event_tag

eventhandler_tag if_detach_event_tag = NULL
static

Definition at line 191 of file ip_mroute.c.

Referenced by ip_mroute_modevent().

◆ in_mcast_loop

int in_mcast_loop
extern

Definition at line 188 of file in_mcast.c.

Referenced by send_packet().

◆ ip_mroutemod

moduledata_t ip_mroutemod
static
Initial value:
= {
"ip_mroute",
0
}
static int ip_mroute_modevent(module_t mod, int type, void *unused)
Definition: ip_mroute.c:2783

Definition at line 2878 of file ip_mroute.c.

◆ ip_mrouter_cnt

int ip_mrouter_cnt
static

Definition at line 159 of file ip_mroute.c.

Referenced by ip_mroute_modevent(), ip_mrouter_init(), and X_ip_mrouter_done().

◆ ip_mrouter_unloading

int ip_mrouter_unloading
static

Definition at line 160 of file ip_mroute.c.

Referenced by ip_mroute_modevent(), and ip_mrouter_init().

◆ ipv4_encap_cfg

const struct encap_config ipv4_encap_cfg
static
Initial value:
= {
.proto = IPPROTO_PIM,
.min_length = sizeof(struct ip) + PIM_MINLEN,
.exact_match = 8,
.check = pim_encapcheck,
.input = pim_input
}
static int pim_input(struct mbuf *, int, int, void *)
static int pim_encapcheck(const struct mbuf *, int, int, void *)
#define PIM_MINLEN
Definition: pim.h:88
Definition: ip.h:51

Definition at line 240 of file ip_mroute.c.

Referenced by ip_mroute_modevent().

◆ mfchashsize

◆ mrouter_mtx

struct rwlock mrouter_mtx
static

Definition at line 145 of file ip_mroute.c.

Referenced by add_bw_upcall(), and vnet_mroute_init().

◆ mrt_api_support

const uint32_t mrt_api_support
static
Initial value:
#define MRT_MFC_FLAGS_BORDER_VIF
Definition: ip_mroute.h:141
#define MRT_MFC_BW_UPCALL
Definition: ip_mroute.h:143
#define MRT_MFC_FLAGS_DISABLE_WRONGVIF
Definition: ip_mroute.h:140
#define MRT_MFC_RP
Definition: ip_mroute.h:142

Definition at line 354 of file ip_mroute.c.

Referenced by set_api_config(), and X_ip_mrouter_get().

◆ mrt_api_version

const int mrt_api_version = MRT_API_VERSION
static

Definition at line 353 of file ip_mroute.c.

Referenced by X_ip_mrouter_get().

◆ pim_assert_interval

struct timeval pim_assert_interval = { 3, 0 }
static

Definition at line 362 of file ip_mroute.c.

Referenced by ip_mdq().

◆ pim_encap_cookie

const struct encaptab* pim_encap_cookie
static

Definition at line 234 of file ip_mroute.c.

Referenced by ip_mroute_modevent().

◆ pim_encap_iphdr

struct ip pim_encap_iphdr
static
Initial value:
= {
sizeof(struct ip) >> 2,
0,
sizeof(struct ip),
0,
0,
IPPROTO_PIM,
0,
}
#define IPVERSION
Definition: ip.h:46
#define PIM_ENCAP_TTL
Definition: ip_mroute.c:263

Definition at line 265 of file ip_mroute.c.

Referenced by pim_register_prepare(), and pim_register_send_rp().

◆ pim_encap_pimhdr

Initial value:
= {
{
PIM_MAKE_VT(PIM_VERSION, PIM_REGISTER),
0,
0,
},
0
}
#define PIM_VERSION
Definition: pim.h:87
#define PIM_REGISTER
Definition: pim.h:96

Definition at line 282 of file ip_mroute.c.

Referenced by pim_register_send_rp().

◆ pim_squelch_wholepkt

u_long pim_squelch_wholepkt = 0
static

Definition at line 229 of file ip_mroute.c.

Referenced by ip_mroute_modevent(), and pim_register_send().