diff options
author | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-12-22 11:04:45 +0000 |
---|---|---|
committer | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-12-22 11:04:45 +0000 |
commit | 5dfd6621d53984c68fbbab49fef4d0a582e80bee (patch) | |
tree | 2a69f909b8f242e36873f254579e0d60482abf77 /sys | |
parent | 458d6d0543bbd443e750c9e3271f8e694228a490 (diff) |
Remove PIM support from the multicast stack.
ok mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/netinet/in.h | 4 | ||||
-rw-r--r-- | sys/netinet/in_proto.c | 12 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.c | 663 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.h | 12 | ||||
-rw-r--r-- | sys/netinet/pim.h | 122 | ||||
-rw-r--r-- | sys/netinet/pim_var.h | 83 | ||||
-rw-r--r-- | sys/netinet6/in6.h | 4 | ||||
-rw-r--r-- | sys/netinet6/in6_proto.c | 13 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 400 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.h | 3 | ||||
-rw-r--r-- | sys/netinet6/pim6.h | 69 | ||||
-rw-r--r-- | sys/netinet6/pim6_var.h | 71 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 3 |
14 files changed, 16 insertions, 1446 deletions
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC index 14732076e9b..ab20737b81b 100644 --- a/sys/conf/GENERIC +++ b/sys/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.236 2016/11/29 09:08:34 mpi Exp $ +# $OpenBSD: GENERIC,v 1.237 2016/12/22 11:04:44 rzalamena Exp $ # # Machine-independent option; used by all architectures for their # GENERIC kernel @@ -58,7 +58,6 @@ option PPP_BSDCOMP # PPP BSD compression option PPP_DEFLATE option PIPEX # Ppp IP EXtension, for npppd option MROUTING # Multicast router -#option PIM # Protocol Independent Multicast option MPLS # Multi-Protocol Label Switching #option BFD # Bi-directional Forwarding Detection 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_ */ diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 524e836c43e..1a1278b7870 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.91 2016/10/03 12:33:21 mpi Exp $ */ +/* $OpenBSD: in6.h,v 1.92 2016/12/22 11:04:44 rzalamena Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -511,7 +511,7 @@ ifatoia6(struct ifaddr *ifa) { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ - { "pim6", CTLTYPE_NODE }, \ + { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 8e78a604bb5..30fabede281 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.86 2016/06/01 11:11:44 jca Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.87 2016/12/22 11:04:44 rzalamena Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -91,10 +91,6 @@ #include <netinet/ip_esp.h> #include <netinet/ip_ipip.h> -#ifdef PIM -#include <netinet6/pim6_var.h> -#endif - #include <netinet6/in6_var.h> #include <netinet6/nd6.h> #include <netinet6/ip6protosw.h> @@ -218,13 +214,6 @@ struct ip6protosw inet6sw[] = { 0, 0, 0, 0, }, #endif /* GIF */ -#ifdef PIM -{ SOCK_RAW, &inet6domain, IPPROTO_PIM, PR_ATOMIC|PR_ADDR, - pim6_input, rip6_output, 0, rip6_ctloutput, - rip6_usrreq, - 0, 0, 0, 0, pim6_sysctl -}, -#endif /* PIM */ #if NCARP > 0 { SOCK_RAW, &inet6domain, IPPROTO_CARP, PR_ATOMIC|PR_ADDR, carp6_proto_input, rip6_output, 0, rip6_ctloutput, diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index e988aed79f5..ee60d887074 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -77,7 +77,7 @@ * Modified by Ajit Thyagarajan, PARC, August 1993 * Modified by Bill Fenner, PARC, April 1994 * - * MROUTING Revision: 3.5.1.2 + PIM-SMv2 (pimd) Support + * MROUTING Revision: 3.5.1.2 */ #include <sys/param.h> @@ -105,16 +105,6 @@ #include <netinet6/ip6_var.h> #include <netinet6/ip6_mroute.h> -#ifdef PIM -#include <netinet/pim.h> -#include <netinet6/pim6_var.h> - -int set_pim6(int *); -int get_pim6(struct mbuf *); -int socket6_send(struct socket *, struct mbuf *, struct sockaddr_in6 *); -int register_send(struct ip6_hdr *, struct mif6 *, struct mbuf *); -#endif - int ip6_mdq(struct mbuf *, struct ifnet *, struct mf6c *); void phyint_send6(struct ip6_hdr *, struct mif6 *, struct mbuf *); @@ -124,7 +114,7 @@ void phyint_send6(struct ip6_hdr *, struct mif6 *, struct mbuf *); */ struct socket *ip6_mrouter = NULL; int ip6_mrouter_ver = 0; -int ip6_mrtproto = IPPROTO_PIM; /* for netstat only */ +int ip6_mrtproto; /* for netstat only */ struct mrt6stat mrt6stat; #define NO_RTE_FOUND 0x1 @@ -151,11 +141,6 @@ static mifi_t nummifs = 0; static mifi_t reg_mif_num = (mifi_t)-1; unsigned int reg_mif_idx; -#ifdef PIM -struct pim6stat pim6stat; -static int pim6; -#endif - /* * Hash function for a source, group entry */ @@ -251,12 +236,6 @@ ip6_mrouter_set(int cmd, struct socket *so, struct mbuf *m) if (m == NULL || m->m_len < sizeof(struct mf6cctl)) return (EINVAL); return (del_m6fc(mtod(m, struct mf6cctl *))); -#ifdef PIM - case MRT6_PIM: - if (m == NULL || m->m_len < sizeof(int)) - return (EINVAL); - return (set_pim6(mtod(m, int *))); -#endif default: return (EOPNOTSUPP); } @@ -274,10 +253,6 @@ ip6_mrouter_get(int cmd, struct socket *so, struct mbuf **mp) *mp = m_get(M_WAIT, MT_SOOPTS); switch (cmd) { -#ifdef PIM - case MRT6_PIM: - return get_pim6(*mp); -#endif default: return EOPNOTSUPP; } @@ -439,34 +414,6 @@ mrt6_sysctl_mfc(void *oldp, size_t *oldlenp) return (0); } -#ifdef PIM -/* - * Get PIM processiong global - */ -int -get_pim6(struct mbuf *m) -{ - int *i; - - i = mtod(m, int *); - - *i = pim6; - - return 0; -} - -int -set_pim6(int *i) -{ - if ((*i != 1) && (*i != 0)) - return EINVAL; - - pim6 = *i; - - return 0; -} -#endif - /* * Enable multicast routing */ @@ -490,10 +437,6 @@ ip6_mrouter_init(struct socket *so, int v, int cmd) arc4random_buf(&mf6chashkey, sizeof(mf6chashkey)); bzero((caddr_t)n6expire, sizeof(n6expire)); -#ifdef PIM - pim6 = 0;/* used for stubbing out/in pim stuff */ -#endif - timeout_set(&expire_upcalls6_ch, expire_upcalls6, NULL); timeout_add(&expire_upcalls6_ch, EXPIRE_TIMEOUT); @@ -544,10 +487,6 @@ ip6_mrouter_done(void) bzero((caddr_t)mif6table, sizeof(mif6table)); nummifs = 0; -#ifdef PIM - pim6 = 0; /* used to stub out/in pim specific code */ -#endif - timeout_del(&expire_upcalls6_ch); /* @@ -629,27 +568,6 @@ add_m6if(struct mif6ctl *mifcp) if (mifp->m6_ifp) return EADDRINUSE; /* XXX: is it appropriate? */ -#ifdef PIM - if (mifcp->mif6c_flags & MIFF_REGISTER) { - if (reg_mif_num == (mifi_t)-1) { - ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT|M_ZERO); - if (ifp == NULL) - return (ENOMEM); - snprintf(ifp->if_xname, sizeof(ifp->if_xname), - "register_mif"); - ifp->if_flags |= IFF_LOOPBACK; - if_attach(ifp); - if_alloc_sadl(ifp); - - reg_mif_num = mifcp->mif6c_mifi; - reg_mif_idx = ifp->if_index; - mifcp->mif6c_pifi = ifp->if_index; - } - - ifp = if_get(reg_mif_idx); - KASSERT(ifp != NULL); - } else -#endif { ifp = if_get(mifcp->mif6c_pifi); if (ifp == NULL) @@ -1241,73 +1159,6 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) /* came in the wrong interface */ mrt6stat.mrt6s_wrong_if++; rt->mf6c_wrong_if++; -#ifdef PIM - /* - * If we are doing PIM processing, and we are forwarding - * packets on this interface, send a message to the - * routing daemon. - */ - /* have to make sure this is a valid mif */ - if (mifi < nummifs && mif6table[mifi].m6_ifp) { - mifi_t iif; - - if (pim6 && (m->m_flags & M_LOOP) == 0) { - /* - * Check the M_LOOP flag to avoid an - * unnecessary PIM assert. - * XXX: M_LOOP is an ad-hoc hack... - */ - struct sockaddr_in6 sin6; - - struct mbuf *mm; - struct mrt6msg *im; - - mm = m_copym(m, 0, sizeof(struct ip6_hdr), - M_NOWAIT); - if (mm && - (M_READONLY(mm) || - mm->m_len < sizeof(struct ip6_hdr))) - mm = m_pullup(mm, sizeof(struct ip6_hdr)); - if (mm == NULL) - return ENOBUFS; - - im = NULL; - switch (ip6_mrouter_ver) { - case MRT6_INIT: - im = mtod(mm, struct mrt6msg *); - im->im6_msgtype = MRT6MSG_WRONGMIF; - im->im6_mbz = 0; - break; - default: - m_freem(mm); - return EINVAL; - } - - for (mifp = mif6table, iif = 0; - iif < nummifs && mifp && - mifp->m6_ifp != ifp; - mifp++, iif++) - ; - - (void)memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_len = sizeof(sin6); - sin6.sin6_family = AF_INET6; - switch (ip6_mrouter_ver) { - case MRT6_INIT: - im->im6_mif = iif; - sin6.sin6_addr = im->im6_src; - break; - } - - mrt6stat.mrt6s_upcalls++; - - if (socket6_send(ip6_mrouter, mm, &sin6) < 0) { - ++mrt6stat.mrt6s_upq_sockfull; - return ENOBUFS; - } - } - } -#endif /* PIM */ return 0; } /* if wrong iif */ @@ -1335,8 +1186,6 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) /* * check if the outgoing packet is going to break * a scope boundary. - * XXX For packets through PIM register tunnel - * interface, we believe a routing daemon. */ if ((mif6table[rt->mf6c_parent].m6_flags & MIFF_REGISTER) == 0 && @@ -1353,11 +1202,6 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) mifp->m6_pkt_out++; mifp->m6_bytes_out += plen; -#ifdef PIM - if (mifp->m6_flags & MIFF_REGISTER) - register_send(ip6, mifp, m); - else -#endif phyint_send6(ip6, mifp, m); } } @@ -1443,246 +1287,6 @@ phyint_send6(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) splx(s); } -#ifdef PIM -int -register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m) -{ - struct mbuf *mm; - int i, len = m->m_pkthdr.len; - struct sockaddr_in6 sin6; - struct mrt6msg *im6; - - ++pim6stat.pim6s_snd_registers; - - /* Make a copy of the packet to send to the user level process */ - MGETHDR(mm, M_DONTWAIT, MT_HEADER); - if (mm == NULL) - return ENOBUFS; - mm->m_data += max_linkhdr; - mm->m_len = sizeof(struct ip6_hdr); - - if ((mm->m_next = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) { - m_freem(mm); - return ENOBUFS; - } - i = MHLEN - M_LEADINGSPACE(mm); - if (i > len) - i = len; - mm = m_pullup(mm, i); - if (mm == NULL) - return ENOBUFS; -/* TODO: check it! */ - mm->m_pkthdr.len = len + sizeof(struct ip6_hdr); - - /* - * Send message to routing daemon - */ - (void)memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_len = sizeof(sin6); - sin6.sin6_family = AF_INET6; - sin6.sin6_addr = ip6->ip6_src; - - im6 = mtod(mm, struct mrt6msg *); - im6->im6_msgtype = MRT6MSG_WHOLEPKT; - im6->im6_mbz = 0; - - im6->im6_mif = mif - mif6table; - - /* iif info is not given for reg. encap.n */ - mrt6stat.mrt6s_upcalls++; - - if (socket6_send(ip6_mrouter, mm, &sin6) < 0) { - ++mrt6stat.mrt6s_upq_sockfull; - return ENOBUFS; - } - return 0; -} - -/* - * PIM sparse mode hook - * Receives the pim control messages, and passes them up to the listening - * socket, using rip6_input. - * The only message processed is the REGISTER pim message; the pim header - * is stripped off, and the inner packet is passed to register_mforward. - */ -int -pim6_input(struct mbuf **mp, int *offp, int proto) -{ - struct pim *pim; /* pointer to a pim struct */ - struct ip6_hdr *ip6; - int pimlen; - struct mbuf *m = *mp; - int minlen; - int off = *offp; - - ++pim6stat.pim6s_rcv_total; - - ip6 = mtod(m, struct ip6_hdr *); - pimlen = m->m_pkthdr.len - *offp; - - /* - * Validate lengths - */ - if (pimlen < PIM_MINLEN) { - ++pim6stat.pim6s_rcv_tooshort; - m_freem(m); - return (IPPROTO_DONE); - } - - /* - * if the packet is at least as big as a REGISTER, go ahead - * and grab the PIM REGISTER header size, to avoid another - * possible m_pullup() later. - * - * PIM_MINLEN == pimhdr + u_int32 == 8 - * PIM6_REG_MINLEN == pimhdr + reghdr + eip6hdr == 4 + 4 + 40 - */ - minlen = (pimlen >= PIM6_REG_MINLEN) ? PIM6_REG_MINLEN : PIM_MINLEN; - - /* - * Make sure that the IP6 and PIM headers in contiguous memory, and - * possibly the PIM REGISTER header - */ - IP6_EXTHDR_GET(pim, struct pim *, m, off, minlen); - if (pim == NULL) { - pim6stat.pim6s_rcv_tooshort++; - return IPPROTO_DONE; - } - - /* PIM version check */ - if (pim->pim_ver != PIM_VERSION) { - ++pim6stat.pim6s_rcv_badversion; - m_freem(m); - return (IPPROTO_DONE); - } - -#define PIM6_CHECKSUM -#ifdef PIM6_CHECKSUM - { - int cksumlen; - - /* - * Validate checksum. - * If PIM REGISTER, exclude the data packet - */ - if (pim->pim_type == PIM_REGISTER) - cksumlen = PIM_MINLEN; - else - cksumlen = pimlen; - - if (in6_cksum(m, IPPROTO_PIM, off, cksumlen)) { - ++pim6stat.pim6s_rcv_badsum; - m_freem(m); - return (IPPROTO_DONE); - } - } -#endif /* PIM_CHECKSUM */ - - if (pim->pim_type == PIM_REGISTER) { - /* - * since this is a REGISTER, we'll make a copy of the register - * headers ip6+pim+u_int32_t+encap_ip6, to be passed up to the - * routing daemon. - */ - static struct sockaddr_in6 dst = { sizeof(dst), AF_INET6 }; - - struct mbuf *mcp; - struct ip6_hdr *eip6; - u_int32_t *reghdr; - - ++pim6stat.pim6s_rcv_registers; - - if ((reg_mif_num >= nummifs) || (reg_mif_num == (mifi_t) -1)) { - m_freem(m); - return (IPPROTO_DONE); - } - - reghdr = (u_int32_t *)(pim + 1); - - if ((ntohl(*reghdr) & PIM_NULL_REGISTER)) - goto pim6_input_to_daemon; - - /* - * Validate length - */ - if (pimlen < PIM6_REG_MINLEN) { - ++pim6stat.pim6s_rcv_tooshort; - ++pim6stat.pim6s_rcv_badregisters; - m_freem(m); - return (IPPROTO_DONE); - } - - eip6 = (struct ip6_hdr *) (reghdr + 1); - /* verify the version number of the inner packet */ - if ((eip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) { - ++pim6stat.pim6s_rcv_badregisters; - m_freem(m); - return (IPPROTO_NONE); - } - - /* verify the inner packet is destined to a mcast group */ - if (!IN6_IS_ADDR_MULTICAST(&eip6->ip6_dst)) { - ++pim6stat.pim6s_rcv_badregisters; - m_freem(m); - return (IPPROTO_DONE); - } - - /* - * make a copy of the whole header to pass to the daemon later. - */ - mcp = m_copym(m, 0, off + PIM6_REG_MINLEN, M_NOWAIT); - if (mcp == NULL) { - m_freem(m); - return (IPPROTO_DONE); - } - - /* - * forward the inner ip6 packet; point m_data at the inner ip6. - */ - m_adj(m, off + PIM_MINLEN); - if_input_local(mif6table[reg_mif_num].m6_ifp, m, - dst.sin6_family); - - /* prepare the register head to send to the mrouting daemon */ - m = mcp; - } - - /* - * 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 - * encapsulator ip6 header, pim header, register header and the - * encapsulated ip6 header. - */ - pim6_input_to_daemon: - rip6_input(&m, offp, proto); - return (IPPROTO_DONE); -} - -/* - * Sysctl for pim6 variables. - */ -int -pim6_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 PIM6CTL_STATS: - if (newp != NULL) - return (EPERM); - return (sysctl_struct(oldp, oldlenp, newp, newlen, - &pim6stat, sizeof(pim6stat))); - - default: - return (ENOPROTOOPT); - } - /* NOTREACHED */ -} -#endif /* PIM */ - u_int32_t _mf6chash(const struct in6_addr *a, const struct in6_addr *g) { diff --git a/sys/netinet6/ip6_mroute.h b/sys/netinet6/ip6_mroute.h index 5062d08ce13..5b1d7df7f50 100644 --- a/sys/netinet6/ip6_mroute.h +++ b/sys/netinet6/ip6_mroute.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_mroute.h,v 1.16 2015/06/08 22:19:28 krw Exp $ */ +/* $OpenBSD: ip6_mroute.h,v 1.17 2016/12/22 11:04:44 rzalamena Exp $ */ /* $KAME: ip6_mroute.h,v 1.17 2001/02/10 02:05:52 itojun Exp $ */ /* @@ -53,7 +53,6 @@ #define MRT6_DEL_MIF 103 /* delete multicast interface */ #define MRT6_ADD_MFC 104 /* insert forwarding cache entry */ #define MRT6_DEL_MFC 105 /* delete forwarding cache entry */ -#define MRT6_PIM 107 /* enable pim code */ #define MRT6_INIT 108 /* initialize forwarder (mrt6msg) */ /* diff --git a/sys/netinet6/pim6.h b/sys/netinet6/pim6.h deleted file mode 100644 index c5581977ce5..00000000000 --- a/sys/netinet6/pim6.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $OpenBSD: pim6.h,v 1.4 2013/10/21 10:05:18 deraadt Exp $ */ -/* $KAME: pim6.h,v 1.3 2000/03/25 07:23:58 sumikawa Exp $ */ - -/* - * Copyright (C) 1998 WIDE Project. - * 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. - */ -/* - * Protocol Independent Multicast (PIM) definitions - * - * Written by Ahmed Helmy, SGI, July 1996 - * - * MULTICAST - */ - -/* - * PIM packet header - */ -#define PIM_VERSION 2 -struct pim { -#if _BYTE_ORDER == LITTLE_ENDIAN - u_int pim_type:4, /* the PIM message type, currently they are: - * Hello, Register, Register-Stop, Join/Prune, - * Bootstrap, Assert, Graft (PIM-DM only), - * Graft-Ack (PIM-DM only), C-RP-Adv - */ - pim_ver:4; /* PIM version number; 2 for PIMv2 */ -#else - u_int pim_ver:4, /* PIM version */ - pim_type:4; /* PIM type */ -#endif - u_char pim_rsv; /* Reserved */ - u_short pim_cksum; /* IP style check sum */ -}; - -#define PIM_MINLEN 8 /* The header min. length is 8 */ -#define PIM6_REG_MINLEN (PIM_MINLEN+40) /* Register message + inner IP6 header */ - -/* - * Message types - */ -#define PIM_REGISTER 1 /* PIM Register type is 1 */ - -/* second bit in reg_head is the null bit */ -#define PIM_NULL_REGISTER 0x40000000 diff --git a/sys/netinet6/pim6_var.h b/sys/netinet6/pim6_var.h deleted file mode 100644 index 9df921325f8..00000000000 --- a/sys/netinet6/pim6_var.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: pim6_var.h,v 1.11 2013/10/24 11:47:33 deraadt Exp $ */ -/* $KAME: pim6_var.h,v 1.8 2000/06/06 08:07:43 jinmei Exp $ */ - -/* - * Copyright (C) 1998 WIDE Project. - * 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. - */ - -#ifndef _NETINET6_PIM6_VAR_H_ -#define _NETINET6_PIM6_VAR_H_ - -/* - * Protocol Independent Multicast (PIM), - * implementation-specific definitions. - * - * Written by George Edmond Eddy (Rusty), ISI, February 1998 - * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 - */ - -struct pim6stat { - u_int64_t pim6s_rcv_total; /* total PIM messages received */ - u_int64_t pim6s_rcv_tooshort; /* received with too few bytes */ - u_int64_t pim6s_rcv_badsum; /* received with bad checksum */ - u_int64_t pim6s_rcv_badversion; /* received bad PIM version */ - u_int64_t pim6s_rcv_registers; /* received registers */ - u_int64_t pim6s_rcv_badregisters; /* received invalid registers */ - u_int64_t pim6s_snd_registers; /* sent registers */ -}; - -/* - * Names for PIM6 sysctl objects - */ -#define PIM6CTL_STATS 1 /* PIM6 stats */ -#define PIM6CTL_MAXID 2 - -#define PIM6CTL_NAMES { \ - { 0, 0 }, \ - { "stats", CTLTYPE_NODE }, \ -} - -#ifdef _KERNEL -extern struct pim6stat pim6stat; -int pim6_input(struct mbuf **, int *, int); -int pim6_sysctl(int *, u_int, void *, size_t *, void *, size_t); -#endif /* _KERNEL */ - -#endif /* _NETINET6_PIM6_VAR_H_ */ diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 8445d7827d1..58cb0e34ab7 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.100 2016/12/19 08:36:50 mpi Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.101 2016/12/22 11:04:44 rzalamena Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -528,7 +528,6 @@ rip6_ctloutput(int op, struct socket *so, int level, int optname, case MRT6_DEL_MIF: case MRT6_ADD_MFC: case MRT6_DEL_MFC: - case MRT6_PIM: if (op == PRCO_SETOPT) { error = ip6_mrouter_set(optname, so, *mp); if (*mp) |