Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_mroute.c
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/syslog.h> | #include <sys/syslog.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/counter.h> | #include <sys/counter.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_types.h> | |||||
#include <net/netisr.h> | #include <net/netisr.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/igmp.h> | #include <netinet/igmp.h> | ||||
#include <netinet/in_systm.h> | #include <netinet/in_systm.h> | ||||
#include <netinet/in_var.h> | #include <netinet/in_var.h> | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | static struct pim_encap_pimhdr pim_encap_pimhdr = { | ||||
0, /* reserved */ | 0, /* reserved */ | ||||
0, /* checksum */ | 0, /* checksum */ | ||||
}, | }, | ||||
0 /* flags */ | 0 /* flags */ | ||||
}; | }; | ||||
VNET_DEFINE_STATIC(vifi_t, reg_vif_num) = VIFI_INVALID; | VNET_DEFINE_STATIC(vifi_t, reg_vif_num) = VIFI_INVALID; | ||||
#define V_reg_vif_num VNET(reg_vif_num) | #define V_reg_vif_num VNET(reg_vif_num) | ||||
VNET_DEFINE_STATIC(struct ifnet, multicast_register_if); | VNET_DEFINE_STATIC(struct ifnet *, multicast_register_if); | ||||
#define V_multicast_register_if VNET(multicast_register_if) | #define V_multicast_register_if VNET(multicast_register_if) | ||||
/* | /* | ||||
* Private variables. | * Private variables. | ||||
*/ | */ | ||||
static u_long X_ip_mcast_src(int); | static u_long X_ip_mcast_src(int); | ||||
static int X_ip_mforward(struct ip *, struct ifnet *, struct mbuf *, | static int X_ip_mforward(struct ip *, struct ifnet *, struct mbuf *, | ||||
▲ Show 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | add_vif(struct vifctl *vifcp) | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
} | } | ||||
if ((vifcp->vifc_flags & VIFF_TUNNEL) != 0) { | if ((vifcp->vifc_flags & VIFF_TUNNEL) != 0) { | ||||
CTR1(KTR_IPMF, "%s: tunnels are no longer supported", __func__); | CTR1(KTR_IPMF, "%s: tunnels are no longer supported", __func__); | ||||
MRW_WUNLOCK(); | MRW_WUNLOCK(); | ||||
return EOPNOTSUPP; | return EOPNOTSUPP; | ||||
} else if (vifcp->vifc_flags & VIFF_REGISTER) { | } else if (vifcp->vifc_flags & VIFF_REGISTER) { | ||||
ifp = &V_multicast_register_if; | ifp = V_multicast_register_if = if_alloc(IFT_LOOP); | ||||
CTR2(KTR_IPMF, "%s: add register vif for ifp %p", __func__, ifp); | CTR2(KTR_IPMF, "%s: add register vif for ifp %p", __func__, ifp); | ||||
if (V_reg_vif_num == VIFI_INVALID) { | if (V_reg_vif_num == VIFI_INVALID) { | ||||
if_initname(&V_multicast_register_if, "register_vif", 0); | if_initname(V_multicast_register_if, "register_vif", 0); | ||||
V_multicast_register_if.if_flags = IFF_LOOPBACK; | |||||
V_reg_vif_num = vifcp->vifc_vifi; | V_reg_vif_num = vifcp->vifc_vifi; | ||||
} | } | ||||
} else { /* Make sure the interface supports multicast */ | } else { /* Make sure the interface supports multicast */ | ||||
if ((ifp->if_flags & IFF_MULTICAST) == 0) { | if ((ifp->if_flags & IFF_MULTICAST) == 0) { | ||||
MRW_WUNLOCK(); | MRW_WUNLOCK(); | ||||
return EOPNOTSUPP; | return EOPNOTSUPP; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | return EINVAL; | ||||
vifp = &V_viftable[vifi]; | vifp = &V_viftable[vifi]; | ||||
if (in_nullhost(vifp->v_lcl_addr)) { | if (in_nullhost(vifp->v_lcl_addr)) { | ||||
return EADDRNOTAVAIL; | return EADDRNOTAVAIL; | ||||
} | } | ||||
if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) | if (!(vifp->v_flags & (VIFF_TUNNEL | VIFF_REGISTER))) | ||||
if_allmulti(vifp->v_ifp, 0); | if_allmulti(vifp->v_ifp, 0); | ||||
if (vifp->v_flags & VIFF_REGISTER) | if (vifp->v_flags & VIFF_REGISTER) { | ||||
V_reg_vif_num = VIFI_INVALID; | V_reg_vif_num = VIFI_INVALID; | ||||
if_free(V_multicast_register_if); | |||||
V_multicast_register_if = NULL; | |||||
} | |||||
mtx_destroy(&vifp->v_spin); | mtx_destroy(&vifp->v_spin); | ||||
bzero((caddr_t)vifp, sizeof (*vifp)); | bzero((caddr_t)vifp, sizeof (*vifp)); | ||||
CTR2(KTR_IPMF, "%s: delete vif %d", __func__, (int)vifi); | CTR2(KTR_IPMF, "%s: delete vif %d", __func__, (int)vifi); | ||||
/* Adjust numvifs down */ | /* Adjust numvifs down */ | ||||
▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Lines | ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) | ||||
* to the routing daemon. | * to the routing daemon. | ||||
* | * | ||||
* XXX: A PIM-SM router needs the WRONGVIF detection so it | * XXX: A PIM-SM router needs the WRONGVIF detection so it | ||||
* can complete the SPT switch, regardless of the type | * can complete the SPT switch, regardless of the type | ||||
* of the iif (broadcast media, GRE tunnel, etc). | * of the iif (broadcast media, GRE tunnel, etc). | ||||
*/ | */ | ||||
if (V_pim_assert_enabled && (vifi < V_numvifs) && | if (V_pim_assert_enabled && (vifi < V_numvifs) && | ||||
V_viftable[vifi].v_ifp) { | V_viftable[vifi].v_ifp) { | ||||
if (ifp == &V_multicast_register_if) | if (ifp == V_multicast_register_if) | ||||
PIMSTAT_INC(pims_rcv_registers_wrongiif); | PIMSTAT_INC(pims_rcv_registers_wrongiif); | ||||
/* Get vifi for the incoming packet */ | /* Get vifi for the incoming packet */ | ||||
for (vifi = 0; vifi < V_numvifs && V_viftable[vifi].v_ifp != ifp; | for (vifi = 0; vifi < V_numvifs && V_viftable[vifi].v_ifp != ifp; | ||||
vifi++) | vifi++) | ||||
; | ; | ||||
if (vifi >= V_numvifs) | if (vifi >= V_numvifs) | ||||
return 0; /* The iif is not found: ignore the packet. */ | return 0; /* The iif is not found: ignore the packet. */ | ||||
▲ Show 20 Lines • Show All 1,288 Lines • Show Last 20 Lines |