summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorrzalamena <rzalamena@openbsd.org>2016-12-22 11:04:44 +0000
committerrzalamena <rzalamena@openbsd.org>2016-12-22 11:04:44 +0000
commitd1dc8a2b73b1919ad7c87f5e2eb974b31733d7cc (patch)
tree13d3fbaa5b383022cc5b7e20c2b0ca23359d5fef /sys/netinet
parentUse makefs to build bsd.rd; build & boot tested by mpi (diff)
downloadwireguard-openbsd-d1dc8a2b73b1919ad7c87f5e2eb974b31733d7cc.tar.xz
wireguard-openbsd-d1dc8a2b73b1919ad7c87f5e2eb974b31733d7cc.zip
Remove PIM support from the multicast stack.
ok mpi@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in.h4
-rw-r--r--sys/netinet/in_proto.c12
-rw-r--r--sys/netinet/ip_mroute.c663
-rw-r--r--sys/netinet/ip_mroute.h12
-rw-r--r--sys/netinet/pim.h122
-rw-r--r--sys/netinet/pim_var.h83
6 files changed, 8 insertions, 888 deletions
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 4b2b0f54f55..997478c4f21 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.119 2016/09/04 17:05:24 claudio Exp $ */
+/* $OpenBSD: in.h,v 1.120 2016/12/22 11:04:44 rzalamena Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -487,7 +487,7 @@ struct ip_mreq {
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
- { "pim", CTLTYPE_NODE }, \
+ { 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index d7de5402875..ea67e5cb113 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_proto.c,v 1.70 2015/12/03 21:57:59 mpi Exp $ */
+/* $OpenBSD: in_proto.c,v 1.71 2016/12/22 11:04:44 rzalamena Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@@ -119,9 +119,6 @@
#endif
#include <netinet/igmp_var.h>
-#ifdef PIM
-#include <netinet/pim_var.h>
-#endif
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
@@ -247,13 +244,6 @@ struct protosw inetsw[] = {
rip_usrreq,
igmp_init, igmp_fasttimo, igmp_slowtimo, 0, igmp_sysctl
},
-#ifdef PIM
-{ SOCK_RAW, &inetdomain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR,
- pim_input, rip_output, 0, rip_ctloutput,
- rip_usrreq,
- 0, 0, 0, 0, pim_sysctl
-},
-#endif /* PIM */
#ifdef IPSEC
{ SOCK_RAW, &inetdomain, IPPROTO_AH, PR_ATOMIC|PR_ADDR,
ah4_input, rip_output, ah4_ctlinput, rip_ctloutput,
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index e48ded852a4..42238ba09f4 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.100 2016/12/21 12:05:01 mpi Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.101 2016/12/22 11:04:44 rzalamena Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -53,14 +53,9 @@
* Modified by Pavlin Radoslavov, ICSI, October 2002
*
* MROUTING Revision: 1.2
- * and PIM-SMv2 and PIM-DM support, advanced API support,
- * bandwidth metering and signaling
+ * advanced API support, bandwidth metering and signaling
*/
-#ifdef PIM
-#define _PIM_VT 1
-#endif
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -87,11 +82,6 @@
#include <netinet/igmp_var.h>
#include <netinet/ip_mroute.h>
-#ifdef PIM
-#include <netinet/pim.h>
-#include <netinet/pim_var.h>
-#endif
-
#define M_PULLUP(m, len) \
do { \
if ((m) && ((m)->m_flags & M_EXT || (m)->m_len < (len))) \
@@ -147,70 +137,6 @@ int ip_mdq(struct mbuf *, struct ifnet *, struct mfc *);
void phyint_send(struct ip *, struct vif *, struct mbuf *);
void send_packet(struct vif *, struct mbuf *);
-#ifdef PIM
-int pim_register_send(struct ip *, struct vif *,
- struct mbuf *, struct mfc *, unsigned int);
-int pim_register_send_rp(struct ip *, struct vif *,
- struct mbuf *, struct mfc *, unsigned int);
-int pim_register_send_upcall(struct ip *, struct vif *,
- struct mbuf *, struct mfc *, unsigned int);
-struct mbuf *pim_register_prepare(struct ip *, struct mbuf *);
-int set_assert(struct mbuf *);
-int get_assert(struct mbuf *);
-
-struct pimstat pimstat;
-
-/*
- * Note: the PIM Register encapsulation adds the following in front of a
- * data packet:
- *
- * struct pim_encap_hdr {
- * struct ip ip;
- * struct pim_encap_pimhdr pim;
- * }
- *
- */
-struct pim_encap_pimhdr {
- struct pim pim;
- uint32_t flags;
-};
-#define PIM_ENCAP_TTL 64
-
-static struct ip pim_encap_iphdr = {
-#if BYTE_ORDER == LITTLE_ENDIAN
- sizeof(struct ip) >> 2,
- IPVERSION,
-#else
- IPVERSION,
- sizeof(struct ip) >> 2,
-#endif
- 0, /* tos */
- sizeof(struct ip), /* total length */
- 0, /* id */
- 0, /* frag offset */
- PIM_ENCAP_TTL,
- IPPROTO_PIM,
- 0, /* checksum */
-};
-
-static struct pim_encap_pimhdr pim_encap_pimhdr = {
- {
- PIM_MAKE_VT(PIM_VERSION, PIM_REGISTER), /* PIM vers and message type */
- 0, /* reserved */
- 0, /* checksum */
- },
- 0 /* flags */
-};
-
-static struct ifnet multicast_register_if;
-static vifi_t reg_vif_num = VIFI_INVALID;
-
-/*
- * whether or not special PIM assert processing is enabled.
- */
-static int pim_assert;
-#endif /* PIM */
-
static vifi_t numvifs = 0;
/*
@@ -224,7 +150,6 @@ static vifi_t numvifs = 0;
* recorded in `mrt_api_support'.
*/
static const u_int32_t mrt_api_support = (MRT_MFC_FLAGS_DISABLE_WRONGVIF |
- MRT_MFC_FLAGS_BORDER_VIF |
MRT_MFC_RP);
static u_int32_t mrt_api_config = 0;
@@ -309,11 +234,6 @@ ip_mrouter_set(struct socket *so, int optname, struct mbuf **mp)
case MRT_DEL_MFC:
error = del_mfc(so, *mp);
break;
-#ifdef PIM
- case MRT_ASSERT:
- error = set_assert(*mp);
- break;
-#endif
case MRT_API_CONFIG:
error = set_api_config(so, *mp);
break;
@@ -344,11 +264,6 @@ ip_mrouter_get(struct socket *so, int optname, struct mbuf **mp)
case MRT_VERSION:
error = get_version(*mp);
break;
-#ifdef PIM
- case MRT_ASSERT:
- error = get_assert(*mp);
- break;
-#endif
case MRT_API_SUPPORT:
error = get_api_support(*mp);
break;
@@ -651,37 +566,6 @@ get_version(struct mbuf *m)
return (0);
}
-#ifdef PIM
-/*
- * Set PIM assert processing global
- */
-int
-set_assert(struct mbuf *m)
-{
- int *i;
-
- if (m == NULL || m->m_len < sizeof(int))
- return (EINVAL);
-
- i = mtod(m, int *);
- pim_assert = !!*i;
- return (0);
-}
-
-/*
- * Get PIM assert processing global
- */
-int
-get_assert(struct mbuf *m)
-{
- int *i = mtod(m, int *);
-
- *i = pim_assert;
- m->m_len = sizeof(int);
- return (0);
-}
-#endif
-
/*
* Configure API capabilities
*/
@@ -702,19 +586,12 @@ set_api_config(struct socket *so, struct mbuf *m)
* We can set the API capabilities only if it is the first operation
* after MRT_INIT. I.e.:
* - there are no vifs installed
- * - pim_assert is not enabled
* - the MFC table is empty
*/
if (numvifs > 0) {
*apival = 0;
return (EPERM);
}
-#ifdef PIM
- if (pim_assert) {
- *apival = 0;
- return (EPERM);
- }
-#endif
for (i = 0; i < MFCTBLSIZ; i++) {
if (mfchashtbl[rtableid] == NULL)
break;
@@ -799,16 +676,6 @@ add_vif(struct socket *so, struct mbuf *m)
/* Tunnels are no longer supported use gif(4) instead. */
if (vifcp->vifc_flags & VIFF_TUNNEL)
return (EOPNOTSUPP);
-
-#ifdef PIM
- if (vifcp->vifc_flags & VIFF_REGISTER) {
- /*
- * XXX: Because VIFF_REGISTER does not really need a valid
- * local interface (e.g. it could be 127.0.0.2), we don't
- * check its address.
- */
- } else
-#endif
{
inp = sotoinpcb(so);
sin.sin_addr = vifcp->vifc_lcl_addr;
@@ -817,18 +684,6 @@ add_vif(struct socket *so, struct mbuf *m)
return (EADDRNOTAVAIL);
}
-#ifdef PIM
- if (vifcp->vifc_flags & VIFF_REGISTER) {
- ifp = &multicast_register_if;
- if (reg_vif_num == VIFI_INVALID) {
- memset(ifp, 0, sizeof(*ifp));
- snprintf(ifp->if_xname, sizeof ifp->if_xname,
- "register_vif");
- ifp->if_flags = IFF_LOOPBACK;
- reg_vif_num = vifcp->vifc_vifi;
- }
- } else
-#endif
{
/* Use the physical interface associated with the address. */
ifp = ifa->ifa_ifp;
@@ -875,11 +730,6 @@ reset_vif(struct vif *vifp)
struct ifnet *ifp;
struct ifreq ifr;
-#ifdef PIM
- if (vifp->v_flags & VIFF_REGISTER) {
- reg_vif_num = VIFI_INVALID;
- } else
-#endif
{
memset(&ifr, 0, sizeof(ifr));
satosin(&ifr.ifr_addr)->sin_len = sizeof(struct sockaddr_in);
@@ -1465,72 +1315,6 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt)
/* came in the wrong interface */
++mrtstat.mrts_wrong_if;
++rt->mfc_wrong_if;
-#ifdef PIM
- /*
- * If we are doing PIM assert processing, send a message
- * to the routing daemon.
- *
- * XXX: A PIM-SM router needs the WRONGVIF detection so it
- * can complete the SPT switch, regardless of the type
- * of interface (broadcast media, GRE tunnel, etc).
- */
- if (pim_assert && (vifi < numvifs) && viftable[vifi].v_ifp) {
- struct timeval now;
- u_int32_t delta;
-
- if (ifp == &multicast_register_if)
- pimstat.pims_rcv_registers_wrongiif++;
-
- /* Get vifi for the incoming packet */
- for (vifi = 0;
- vifi < numvifs && viftable[vifi].v_ifp != ifp;
- vifi++)
- ;
- if (vifi >= numvifs) {
- /* The iif is not found: ignore the packet. */
- return (0);
- }
-
- if (rt->mfc_flags[vifi] &
- MRT_MFC_FLAGS_DISABLE_WRONGVIF) {
- /* WRONGVIF disabled: ignore the packet */
- return (0);
- }
-
- microtime(&now);
-
- TV_DELTA(rt->mfc_last_assert, now, delta);
-
- if (delta > ASSERT_MSG_TIME) {
- unsigned int rtableid = ifp->if_rdomain;
- struct igmpmsg *im;
- int hlen = ip->ip_hl << 2;
- struct mbuf *mm = m_copym(m, 0, hlen, M_NOWAIT);
-
- M_PULLUP(mm, hlen);
- if (mm == NULL)
- return (ENOBUFS);
-
- rt->mfc_last_assert = now;
-
- im = mtod(mm, struct igmpmsg *);
- im->im_msgtype = IGMPMSG_WRONGVIF;
- im->im_mbz = 0;
- im->im_vif = vifi;
-
- mrtstat.mrts_upcalls++;
-
- sin.sin_addr = im->im_src;
- if (socket_send(ip_mrouter[rtableid], mm,
- &sin) < 0) {
- log(LOG_WARNING, "ip_mforward: "
- "ip_mrouter socket queue full\n");
- ++mrtstat.mrts_upq_sockfull;
- return (ENOBUFS);
- }
- }
- }
-#endif
return (0);
}
@@ -1556,11 +1340,6 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt)
(ip->ip_ttl > rt->mfc_ttls[vifi])) {
vifp->v_pkt_out++;
vifp->v_bytes_out += plen;
-#ifdef PIM
- if (vifp->v_flags & VIFF_REGISTER)
- pim_register_send(ip, vifp, m, rt, rtableid);
- else
-#endif
phyint_send(ip, vifp, m);
}
@@ -1604,441 +1383,3 @@ send_packet(struct vif *vifp, struct mbuf *m)
ip_output(m, NULL, NULL, IP_FORWARDING, &imo, NULL, 0);
splx(s);
}
-
-#ifdef PIM
-/*
- * Send the packet up to the user daemon, or eventually do kernel encapsulation
- */
-int
-pim_register_send(struct ip *ip, struct vif *vifp,
- struct mbuf *m, struct mfc *rt, unsigned int rtableid)
-{
- struct mbuf *mb_copy, *mm;
-
- mb_copy = pim_register_prepare(ip, m);
- if (mb_copy == NULL)
- return (ENOBUFS);
-
- /*
- * Send all the fragments. Note that the mbuf for each fragment
- * is freed by the sending machinery.
- */
- for (mm = mb_copy; mm; mm = mb_copy) {
- mb_copy = mm->m_nextpkt;
- mm->m_nextpkt = NULL;
- mm = m_pullup(mm, sizeof(struct ip));
- if (mm != NULL) {
- ip = mtod(mm, struct ip *);
- if ((mrt_api_config & MRT_MFC_RP) &&
- !in_nullhost(rt->mfc_rp)) {
- pim_register_send_rp(ip, vifp, mm, rt,
- rtableid);
- } else {
- pim_register_send_upcall(ip, vifp, mm, rt,
- rtableid);
- }
- }
- }
-
- return (0);
-}
-
-/*
- * Return a copy of the data packet that is ready for PIM Register
- * encapsulation.
- * XXX: Note that in the returned copy the IP header is a valid one.
- */
-struct mbuf *
-pim_register_prepare(struct ip *ip, struct mbuf *m)
-{
- struct mbuf *mb_copy = NULL;
- int mtu;
-
- in_proto_cksum_out(m, NULL);
-
- /*
- * Copy the old packet & pullup its IP header into the
- * new mbuf so we can modify it.
- */
- mb_copy = m_copym(m, 0, M_COPYALL, M_NOWAIT);
- if (mb_copy == NULL)
- return (NULL);
- mb_copy = m_pullup(mb_copy, ip->ip_hl << 2);
- if (mb_copy == NULL)
- return (NULL);
-
- /* take care of the TTL */
- ip = mtod(mb_copy, struct ip *);
- --ip->ip_ttl;
-
- /* Compute the MTU after the PIM Register encapsulation */
- mtu = 0xffff - sizeof(pim_encap_iphdr) - sizeof(pim_encap_pimhdr);
-
- if (ntohs(ip->ip_len) <= mtu) {
- /* Turn the IP header into a valid one */
- ip->ip_sum = 0;
- ip->ip_sum = in_cksum(mb_copy, ip->ip_hl << 2);
- } else {
- /* Fragment the packet */
- if (ip_fragment(mb_copy, NULL, mtu) != 0) {
- /* XXX: mb_copy was freed by ip_fragment() */
- return (NULL);
- }
- }
- return (mb_copy);
-}
-
-/*
- * Send an upcall with the data packet to the user-level process.
- */
-int
-pim_register_send_upcall(struct ip *ip, struct vif *vifp,
- struct mbuf *mb_copy, struct mfc *rt, unsigned int rtableid)
-{
- struct mbuf *mb_first;
- int len = ntohs(ip->ip_len);
- struct igmpmsg *im;
- struct sockaddr_in k_igmpsrc = { sizeof k_igmpsrc, AF_INET };
-
- /* Add a new mbuf with an upcall header */
- MGETHDR(mb_first, M_DONTWAIT, MT_HEADER);
- if (mb_first == NULL) {
- m_freem(mb_copy);
- return (ENOBUFS);
- }
- mb_first->m_data += max_linkhdr;
- mb_first->m_pkthdr.len = len + sizeof(struct igmpmsg);
- mb_first->m_len = sizeof(struct igmpmsg);
- mb_first->m_next = mb_copy;
-
- /* Send message to routing daemon */
- im = mtod(mb_first, struct igmpmsg *);
- im->im_msgtype = IGMPMSG_WHOLEPKT;
- im->im_mbz = 0;
- im->im_vif = vifp - viftable;
- im->im_src = ip->ip_src;
- im->im_dst = ip->ip_dst;
-
- k_igmpsrc.sin_addr = ip->ip_src;
-
- mrtstat.mrts_upcalls++;
-
- if (socket_send(ip_mrouter[rtableid], mb_first, &k_igmpsrc) < 0) {
- ++mrtstat.mrts_upq_sockfull;
- return (ENOBUFS);
- }
-
- /* Keep statistics */
- pimstat.pims_snd_registers_msgs++;
- pimstat.pims_snd_registers_bytes += len;
-
- return (0);
-}
-
-/*
- * Encapsulate the data packet in PIM Register message and send it to the RP.
- */
-int
-pim_register_send_rp(struct ip *ip, struct vif *vifp,
- struct mbuf *mb_copy, struct mfc *rt, unsigned int rtableid)
-{
- struct mbuf *mb_first;
- struct ip *ip_outer;
- struct pim_encap_pimhdr *pimhdr;
- int len = ntohs(ip->ip_len);
- vifi_t vifi = rt->mfc_parent;
-
- if ((vifi >= numvifs) || in_nullhost(viftable[vifi].v_lcl_addr)) {
- m_freem(mb_copy);
- return (EADDRNOTAVAIL); /* The iif vif is invalid */
- }
-
- /* Add a new mbuf with the encapsulating header */
- MGETHDR(mb_first, M_DONTWAIT, MT_HEADER);
- if (mb_first == NULL) {
- m_freem(mb_copy);
- return (ENOBUFS);
- }
- mb_first->m_data += max_linkhdr;
- mb_first->m_len = sizeof(pim_encap_iphdr) + sizeof(pim_encap_pimhdr);
- mb_first->m_next = mb_copy;
-
- mb_first->m_pkthdr.len = len + mb_first->m_len;
-
- /* Fill in the encapsulating IP and PIM header */
- ip_outer = mtod(mb_first, struct ip *);
- *ip_outer = pim_encap_iphdr;
- ip_outer->ip_id = htons(ip_randomid());
- ip_outer->ip_len = htons(len + sizeof(pim_encap_iphdr) +
- sizeof(pim_encap_pimhdr));
- ip_outer->ip_src = viftable[vifi].v_lcl_addr;
- ip_outer->ip_dst = rt->mfc_rp;
- /*
- * Copy the inner header TOS to the outer header, and take care of the
- * IP_DF bit.
- */
- ip_outer->ip_tos = ip->ip_tos;
- if (ntohs(ip->ip_off) & IP_DF)
- ip_outer->ip_off |= htons(IP_DF);
- pimhdr = (struct pim_encap_pimhdr *)((caddr_t)ip_outer
- + sizeof(pim_encap_iphdr));
- *pimhdr = pim_encap_pimhdr;
- /* If the iif crosses a border, set the Border-bit */
- if (rt->mfc_flags[vifi] & MRT_MFC_FLAGS_BORDER_VIF & mrt_api_config)
- pimhdr->flags |= htonl(PIM_BORDER_REGISTER);
-
- mb_first->m_data += sizeof(pim_encap_iphdr);
- pimhdr->pim.pim_cksum = in_cksum(mb_first, sizeof(pim_encap_pimhdr));
- mb_first->m_data -= sizeof(pim_encap_iphdr);
-
- send_packet(vifp, mb_first);
-
- /* Keep statistics */
- pimstat.pims_snd_registers_msgs++;
- pimstat.pims_snd_registers_bytes += len;
-
- return (0);
-}
-
-/*
- * PIM-SMv2 and PIM-DM messages processing.
- * Receives and verifies the PIM control messages, and passes them
- * up to the listening socket, using rip_input().
- * The only message with special processing is the PIM_REGISTER message
- * (used by PIM-SM): the PIM header is stripped off, and the inner packet
- * is passed to if_simloop().
- */
-void
-pim_input(struct mbuf *m, ...)
-{
- struct ip *ip = mtod(m, struct ip *);
- struct pim *pim;
- int minlen;
- int datalen;
- int ip_tos;
- int iphlen;
- va_list ap;
-
- va_start(ap, m);
- iphlen = va_arg(ap, int);
- va_end(ap);
-
- datalen = ntohs(ip->ip_len) - iphlen;
-
- /* Keep statistics */
- pimstat.pims_rcv_total_msgs++;
- pimstat.pims_rcv_total_bytes += datalen;
-
- /* Validate lengths */
- if (datalen < PIM_MINLEN) {
- pimstat.pims_rcv_tooshort++;
- log(LOG_ERR, "pim_input: packet size too small %d from %lx\n",
- datalen, (u_long)ip->ip_src.s_addr);
- m_freem(m);
- return;
- }
-
- /*
- * If the packet is at least as big as a REGISTER, go agead
- * and grab the PIM REGISTER header size, to avoid another
- * possible m_pullup() later.
- *
- * PIM_MINLEN == pimhdr + u_int32_t == 4 + 4 = 8
- * PIM_REG_MINLEN == pimhdr + reghdr + encap_iphdr == 4 + 4 + 20 = 28
- */
- minlen = iphlen + (datalen >= PIM_REG_MINLEN ?
- PIM_REG_MINLEN : PIM_MINLEN);
- /*
- * Get the IP and PIM headers in contiguous memory, and
- * possibly the PIM REGISTER header.
- */
- if ((m->m_flags & M_EXT || m->m_len < minlen) &&
- (m = m_pullup(m, minlen)) == NULL) {
- log(LOG_ERR, "pim_input: m_pullup failure\n");
- return;
- }
- /* m_pullup() may have given us a new mbuf so reset ip. */
- ip = mtod(m, struct ip *);
- ip_tos = ip->ip_tos;
-
- /* adjust mbuf to point to the PIM header */
- m->m_data += iphlen;
- m->m_len -= iphlen;
- pim = mtod(m, struct pim *);
-
- /*
- * Validate checksum. If PIM REGISTER, exclude the data packet.
- *
- * XXX: some older PIMv2 implementations don't make this distinction,
- * so for compatibility reason perform the checksum over part of the
- * message, and if error, then over the whole message.
- */
- if (PIM_VT_T(pim->pim_vt) == PIM_REGISTER &&
- in_cksum(m, PIM_MINLEN) == 0) {
- /* do nothing, checksum okay */
- } else if (in_cksum(m, datalen)) {
- pimstat.pims_rcv_badsum++;
- m_freem(m);
- return;
- }
-
- /* PIM version check */
- if (PIM_VT_V(pim->pim_vt) < PIM_VERSION) {
- pimstat.pims_rcv_badversion++;
- log(LOG_ERR, "pim_input: incorrect version %d, expecting %d\n",
- PIM_VT_V(pim->pim_vt), PIM_VERSION);
- m_freem(m);
- return;
- }
-
- /* restore mbuf back to the outer IP */
- m->m_data -= iphlen;
- m->m_len += iphlen;
-
- if (PIM_VT_T(pim->pim_vt) == PIM_REGISTER) {
- /*
- * Since this is a REGISTER, we'll make a copy of the register
- * headers ip + pim + u_int32 + encap_ip, to be passed up to the
- * routing daemon.
- */
- int s;
- struct sockaddr_in dst = { sizeof(dst), AF_INET };
- struct mbuf *mcp;
- struct ip *encap_ip;
- u_int32_t *reghdr;
- struct ifnet *vifp;
-
- s = splsoftnet();
- if ((reg_vif_num >= numvifs) || (reg_vif_num == VIFI_INVALID)) {
- splx(s);
- m_freem(m);
- return;
- }
- /* XXX need refcnt? */
- vifp = viftable[reg_vif_num].v_ifp;
- splx(s);
-
- /* Validate length */
- if (datalen < PIM_REG_MINLEN) {
- pimstat.pims_rcv_tooshort++;
- pimstat.pims_rcv_badregisters++;
- log(LOG_ERR, "pim_input: register packet size "
- "too small %d from %lx\n",
- datalen, (u_long)ip->ip_src.s_addr);
- m_freem(m);
- return;
- }
-
- reghdr = (u_int32_t *)(pim + 1);
- encap_ip = (struct ip *)(reghdr + 1);
-
- /* verify the version number of the inner packet */
- if (encap_ip->ip_v != IPVERSION) {
- pimstat.pims_rcv_badregisters++;
- m_freem(m);
- return;
- }
-
- /* verify the inner packet is destined to a mcast group */
- if (!IN_MULTICAST(encap_ip->ip_dst.s_addr)) {
- pimstat.pims_rcv_badregisters++;
- m_freem(m);
- return;
- }
-
- /* If a NULL_REGISTER, pass it to the daemon */
- if ((ntohl(*reghdr) & PIM_NULL_REGISTER))
- goto pim_input_to_daemon;
-
- /*
- * Copy the TOS from the outer IP header to the inner
- * IP header.
- */
- if (encap_ip->ip_tos != ip_tos) {
- /* Outer TOS -> inner TOS */
- encap_ip->ip_tos = ip_tos;
- /* Recompute the inner header checksum. Sigh... */
-
- /* adjust mbuf to point to the inner IP header */
- m->m_data += (iphlen + PIM_MINLEN);
- m->m_len -= (iphlen + PIM_MINLEN);
-
- encap_ip->ip_sum = 0;
- encap_ip->ip_sum = in_cksum(m, encap_ip->ip_hl << 2);
-
- /* restore mbuf to point back to the outer IP header */
- m->m_data -= (iphlen + PIM_MINLEN);
- m->m_len += (iphlen + PIM_MINLEN);
- }
-
- /*
- * Decapsulate the inner IP packet and loopback to forward it
- * as a normal multicast packet. Also, make a copy of the
- * outer_iphdr + pimhdr + reghdr + encap_iphdr
- * to pass to the daemon later, so it can take the appropriate
- * actions (e.g., send back PIM_REGISTER_STOP).
- * XXX: here m->m_data points to the outer IP header.
- */
- mcp = m_copym(m, 0, iphlen + PIM_REG_MINLEN, M_NOWAIT);
- if (mcp == NULL) {
- log(LOG_ERR, "pim_input: pim register: could not "
- "copy register head\n");
- m_freem(m);
- return;
- }
-
- /* Keep statistics */
- /* XXX: registers_bytes include only the encap. mcast pkt */
- pimstat.pims_rcv_registers_msgs++;
- pimstat.pims_rcv_registers_bytes += ntohs(encap_ip->ip_len);
-
- /* forward the inner ip packet; point m_data at the inner ip. */
- m_adj(m, iphlen + PIM_MINLEN);
-
- /* NB: vifp was collected above; can it change on us? */
- if_input_local(vifp, m, dst.sin_family);
-
- /* prepare the register head to send to the mrouting daemon */
- m = mcp;
- }
-
-pim_input_to_daemon:
- /*
- * Pass the PIM message up to the daemon; if it is a Register message,
- * pass the 'head' only up to the daemon. This includes the
- * outer IP header, PIM header, PIM-Register header and the
- * inner IP header.
- * XXX: the outer IP header pkt size of a Register is not adjust to
- * reflect the fact that the inner multicast data is truncated.
- */
- rip_input(m);
-
- return;
-}
-
-/*
- * Sysctl for pim variables.
- */
-int
-pim_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
- void *newp, size_t newlen)
-{
- /* All sysctl names at this level are terminal. */
- if (namelen != 1)
- return (ENOTDIR);
-
- switch (name[0]) {
- case PIMCTL_STATS:
- if (newp != NULL)
- return (EPERM);
- return (sysctl_struct(oldp, oldlenp, newp, newlen,
- &pimstat, sizeof(pimstat)));
-
- default:
- return (ENOPROTOOPT);
- }
- /* NOTREACHED */
-}
-
-
-#endif /* PIM */
diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h
index 40af4fc153d..b3a73ea42ca 100644
--- a/sys/netinet/ip_mroute.h
+++ b/sys/netinet/ip_mroute.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.h,v 1.23 2016/12/20 09:33:13 rzalamena Exp $ */
+/* $OpenBSD: ip_mroute.h,v 1.24 2016/12/22 11:04:44 rzalamena Exp $ */
/* $NetBSD: ip_mroute.h,v 1.23 2004/04/21 17:49:46 itojun Exp $ */
#ifndef _NETINET_IP_MROUTE_H_
@@ -15,8 +15,7 @@
* Modified by Pavlin Radoslavov, ICSI, October 2002.
*
* MROUTING Revision: 1.2
- * and PIM-SMv2 and PIM-DM support, advanced API support,
- * bandwidth metering and signaling.
+ * advanced API support, bandwidth metering and signaling.
*/
#include <sys/queue.h>
@@ -33,7 +32,6 @@
#define MRT_DEL_MFC 105 /* delete forwarding cache entry */
#define MRT_VERSION 106 /* get kernel version number */
#define MRT_ASSERT 107 /* enable assert processing */
-#define MRT_PIM MRT_ASSERT /* enable PIM processing */
#define MRT_API_SUPPORT 109 /* supported MRT API */
#define MRT_API_CONFIG 110 /* config MRT API */
@@ -55,7 +53,6 @@ typedef u_int16_t vifi_t; /* type of a vif index */
#define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */
#define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */
-#define VIFF_REGISTER 0x4 /* used for PIM Register encap/decap */
/*
* Argument structure for MRT_ADD_VIF.
@@ -103,11 +100,9 @@ struct mfcctl2 {
* for the mfcc_flags field.
*/
#define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */
-#define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */
#define MRT_MFC_RP (1 << 8) /* enable RP address */
#define MRT_MFC_BW_UPCALL (1 << 9) /* enable bw upcalls */
-#define MRT_MFC_FLAGS_ALL (MRT_MFC_FLAGS_DISABLE_WRONGVIF | \
- MRT_MFC_FLAGS_BORDER_VIF)
+#define MRT_MFC_FLAGS_ALL (MRT_MFC_FLAGS_DISABLE_WRONGVIF)
#define MRT_API_FLAGS_ALL (MRT_MFC_FLAGS_ALL | \
MRT_MFC_RP | \
MRT_MFC_BW_UPCALL)
@@ -283,7 +278,6 @@ struct igmpmsg {
u_int8_t im_msgtype; /* what type of message */
#define IGMPMSG_NOCACHE 1 /* no MFC in the kernel */
#define IGMPMSG_WRONGVIF 2 /* packet came from wrong interface */
-#define IGMPMSG_WHOLEPKT 3 /* PIM pkt for user level encap. */
#define IGMPMSG_BW_UPCALL 4 /* BW monitoring upcall */
u_int8_t im_mbz; /* must be zero */
u_int8_t im_vif; /* vif rec'd on */
diff --git a/sys/netinet/pim.h b/sys/netinet/pim.h
deleted file mode 100644
index df5c1dca3ec..00000000000
--- a/sys/netinet/pim.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* $OpenBSD: pim.h,v 1.2 2006/04/27 02:19:32 tedu Exp $ */
-/* $NetBSD: pim.h,v 1.1 2004/09/04 23:32:29 manu Exp $ */
-
-/*
- * Copyright (c) 1996-2000
- * University of Southern California/Information Sciences Institute.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim.h,v 1.2 2004/03/08 07:45:32 hsu Exp $
- */
-
-#ifndef _NETINET_PIM_H_
-#define _NETINET_PIM_H_
-
-/*
- * Protocol Independent Multicast (PIM) definitions.
- * RFC 2362, June 1998.
- *
- * Written by Ahmed Helmy, USC/SGI, July 1996.
- * Modified by George Edmond Eddy (Rusty), ISI, February 1998.
- * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000.
- */
-
-#include <sys/types.h>
-
-#ifndef _PIM_VT
-#ifndef _BYTE_ORDER
-# error _BYTE_ORDER is not defined!
-#endif
-#if (_BYTE_ORDER != _BIG_ENDIAN) && (_BYTE_ORDER != _LITTLE_ENDIAN)
-# error _BYTE_ORDER must be defined to either _BIG_ENDIAN or _LITTLE_ENDIAN
-#endif
-#endif /* ! _PIM_VT */
-
-/*
- * PIM packet header
- */
-struct pim {
-#ifdef _PIM_VT
- uint8_t pim_vt; /* PIM version and message type */
-#else /* ! _PIM_VT */
-#if _BYTE_ORDER == _BIG_ENDIAN
- u_int pim_vers:4, /* PIM protocol version */
- pim_type:4; /* PIM message type */
-#endif
-#if _BYTE_ORDER == _LITTLE_ENDIAN
- u_int pim_type:4, /* PIM message type */
- pim_vers:4; /* PIM protocol version */
-#endif
-#endif /* ! _PIM_VT */
- uint8_t pim_reserved; /* Reserved */
- uint16_t pim_cksum; /* IP-style checksum */
-};
-/* KAME-related name backward compatibility */
-#define pim_ver pim_vers
-#define pim_rsv pim_reserved
-
-#ifdef _PIM_VT
-#define PIM_MAKE_VT(v, t) (0xff & (((v) << 4) | (0x0f & (t))))
-#define PIM_VT_V(x) (((x) >> 4) & 0x0f)
-#define PIM_VT_T(x) ((x) & 0x0f)
-#endif /* _PIM_VT */
-
-#define PIM_VERSION 2
-#define PIM_MINLEN 8 /* PIM message min. length */
-#define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */
-#define PIM6_REG_MINLEN (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */
-
-/*
- * PIM message types
- */
-#define PIM_HELLO 0x0 /* PIM-SM and PIM-DM */
-#define PIM_REGISTER 0x1 /* PIM-SM only */
-#define PIM_REGISTER_STOP 0x2 /* PIM-SM only */
-#define PIM_JOIN_PRUNE 0x3 /* PIM-SM and PIM-DM */
-#define PIM_BOOTSTRAP 0x4 /* PIM-SM only */
-#define PIM_ASSERT 0x5 /* PIM-SM and PIM-DM */
-#define PIM_GRAFT 0x6 /* PIM-DM only */
-#define PIM_GRAFT_ACK 0x7 /* PIM-DM only */
-#define PIM_CAND_RP_ADV 0x8 /* PIM-SM only */
-#define PIM_ALL_DF_ELECTION 0xa /* Bidir-PIM-SM only */
-
-/*
- * PIM-Register message flags
- */
-#define PIM_BORDER_REGISTER 0x80000000U /* The Border bit (host-order) */
-#define PIM_NULL_REGISTER 0x40000000U /* The Null-Register bit (host-order)*/
-
-/*
- * All-PIM-Routers IPv4 and IPv6 multicast addresses
- */
-#define INADDR_ALLPIM_ROUTERS_GROUP (uint32_t)0xe000000dU /* 224.0.0.13 */
-#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS "ff02::d"
-#define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT \
- {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}}
-
-#endif /* _NETINET_PIM_H_ */
diff --git a/sys/netinet/pim_var.h b/sys/netinet/pim_var.h
deleted file mode 100644
index bddc04a1ff6..00000000000
--- a/sys/netinet/pim_var.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* $OpenBSD: pim_var.h,v 1.3 2007/12/14 18:33:41 deraadt Exp $ */
-/* $NetBSD: pim_var.h,v 1.1 2004/09/04 23:32:29 manu Exp $ */
-
-/*
- * Copyright (c) 1998-2000
- * University of Southern California/Information Sciences Institute.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: /repoman/r/ncvs/src/sys/netinet/pim_var.h,v 1.1 2003/08/07 18:17:43 hsu Exp $
- */
-
-#ifndef _NETINET_PIM_VAR_H_
-#define _NETINET_PIM_VAR_H_
-
-/*
- * Protocol Independent Multicast (PIM),
- * kernel variables and implementation-specific definitions.
- *
- * Written by George Edmond Eddy (Rusty), ISI, February 1998.
- * Modified by Pavlin Radoslavov, USC/ISI, May 1998, Aug 1999, October 2000.
- * Modified by Hitoshi Asaeda, WIDE, August 1998.
- */
-
-/*
- * PIM statistics kept in the kernel
- */
-struct pimstat {
- u_int64_t pims_rcv_total_msgs; /* total PIM messages received */
- u_int64_t pims_rcv_total_bytes; /* total PIM bytes received */
- u_int64_t pims_rcv_tooshort; /* rcvd with too few bytes */
- u_int64_t pims_rcv_badsum; /* rcvd with bad checksum */
- u_int64_t pims_rcv_badversion; /* rcvd bad PIM version */
- u_int64_t pims_rcv_registers_msgs; /* rcvd regs. msgs (data only) */
- u_int64_t pims_rcv_registers_bytes; /* rcvd regs. bytes (data only) */
- u_int64_t pims_rcv_registers_wrongiif; /* rcvd regs. on wrong iif */
- u_int64_t pims_rcv_badregisters; /* rcvd invalid registers */
- u_int64_t pims_snd_registers_msgs; /* sent regs. msgs (data only) */
- u_int64_t pims_snd_registers_bytes; /* sent regs. bytes (data only) */
-};
-
-/*
- * Names for PIM sysctl objects
- */
-#define PIMCTL_STATS 1 /* statistics (read-only) */
-#define PIMCTL_MAXID 2
-
-#define PIMCTL_NAMES { \
- { 0, 0 }, \
- { "stats", CTLTYPE_STRUCT }, \
-}
-
-#ifdef _KERNEL
-extern struct pimstat pimstat;
-
-void pim_input(struct mbuf *, ...);
-int pim_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-#endif
-
-#endif /* _NETINET_PIM_VAR_H_ */