svn commit: r269699 - in head/sys: net netinet netinet6 netipsec netpfil/pf sys

Kevin Lo kevlo at FreeBSD.org
Fri Aug 8 01:57:19 UTC 2014


Author: kevlo
Date: Fri Aug  8 01:57:15 2014
New Revision: 269699
URL: http://svnweb.freebsd.org/changeset/base/269699

Log:
  Merge 'struct ip6protosw' and 'struct protosw' into one.  Now we have
  only one protocol switch structure that is shared between ipv4 and ipv6.
  
  Phabric:	D476
  Reviewed by:	jhb

Modified:
  head/sys/net/if_stf.c
  head/sys/net/if_stf.h
  head/sys/netinet/igmp.c
  head/sys/netinet/igmp_var.h
  head/sys/netinet/in_gif.c
  head/sys/netinet/in_gif.h
  head/sys/netinet/ip_carp.c
  head/sys/netinet/ip_carp.h
  head/sys/netinet/ip_divert.c
  head/sys/netinet/ip_encap.c
  head/sys/netinet/ip_encap.h
  head/sys/netinet/ip_gre.c
  head/sys/netinet/ip_gre.h
  head/sys/netinet/ip_icmp.c
  head/sys/netinet/ip_icmp.h
  head/sys/netinet/ip_input.c
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/ip_var.h
  head/sys/netinet/pim_var.h
  head/sys/netinet/raw_ip.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_var.h
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_var.h
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet/udp_var.h
  head/sys/netinet6/in6_gif.c
  head/sys/netinet6/in6_proto.c
  head/sys/netinet6/ip6_forward.c
  head/sys/netinet6/ip6_input.c
  head/sys/netinet6/ip6_mroute.c
  head/sys/netinet6/ip6_var.h
  head/sys/netinet6/ip6protosw.h
  head/sys/netinet6/raw_ip6.c
  head/sys/netipsec/ipsec.h
  head/sys/netipsec/ipsec_input.c
  head/sys/netipsec/xform.h
  head/sys/netipsec/xform_ipip.c
  head/sys/netpfil/pf/if_pfsync.c
  head/sys/sys/protosw.h

Modified: head/sys/net/if_stf.c
==============================================================================
--- head/sys/net/if_stf.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/net/if_stf.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -678,23 +678,23 @@ stf_checkaddr6(sc, in6, inifp)
 	return 0;
 }
 
-void
-in_stf_input(m, off)
-	struct mbuf *m;
-	int off;
+int
+in_stf_input(struct mbuf **mp, int *offp, int proto)
 {
-	int proto;
 	struct stf_softc *sc;
 	struct ip *ip;
 	struct ip6_hdr *ip6;
+	struct mbuf *m;
 	u_int8_t otos, itos;
 	struct ifnet *ifp;
+	int off;
 
-	proto = mtod(m, struct ip *)->ip_p;
+	m = *mp;
+	off = *offp;
 
 	if (proto != IPPROTO_IPV6) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	ip = mtod(m, struct ip *);
@@ -703,7 +703,7 @@ in_stf_input(m, off)
 
 	if (sc == NULL || (STF2IFP(sc)->if_flags & IFF_UP) == 0) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	ifp = STF2IFP(sc);
@@ -719,7 +719,7 @@ in_stf_input(m, off)
 	if (stf_checkaddr4(sc, &ip->ip_dst, NULL) < 0 ||
 	    stf_checkaddr4(sc, &ip->ip_src, m->m_pkthdr.rcvif) < 0) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	otos = ip->ip_tos;
@@ -728,7 +728,7 @@ in_stf_input(m, off)
 	if (m->m_len < sizeof(*ip6)) {
 		m = m_pullup(m, sizeof(*ip6));
 		if (!m)
-			return;
+			return (IPPROTO_DONE);
 	}
 	ip6 = mtod(m, struct ip6_hdr *);
 
@@ -739,7 +739,7 @@ in_stf_input(m, off)
 	if (stf_checkaddr6(sc, &ip6->ip6_dst, NULL) < 0 ||
 	    stf_checkaddr6(sc, &ip6->ip6_src, m->m_pkthdr.rcvif) < 0) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
@@ -774,6 +774,7 @@ in_stf_input(m, off)
 	ifp->if_ibytes += m->m_pkthdr.len;
 	M_SETFIB(m, ifp->if_fib);
 	netisr_dispatch(NETISR_IPV6, m);
+	return (IPPROTO_DONE);
 }
 
 /* ARGSUSED */

Modified: head/sys/net/if_stf.h
==============================================================================
--- head/sys/net/if_stf.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/net/if_stf.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -33,6 +33,6 @@
 #ifndef _NET_IF_STF_H_
 #define _NET_IF_STF_H_
 
-void in_stf_input(struct mbuf *, int);
+int in_stf_input(struct mbuf **, int *, int);
 
 #endif /* _NET_IF_STF_H_ */

Modified: head/sys/netinet/igmp.c
==============================================================================
--- head/sys/netinet/igmp.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/igmp.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -1424,26 +1424,29 @@ out_locked:
 	return (0);
 }
 
-void
-igmp_input(struct mbuf *m, int off)
+int
+igmp_input(struct mbuf **mp, int *offp, int proto)
 {
 	int iphlen;
 	struct ifnet *ifp;
 	struct igmp *igmp;
 	struct ip *ip;
+	struct mbuf *m;
 	int igmplen;
 	int minlen;
 	int queryver;
 
 	CTR3(KTR_IGMPV3, "%s: called w/mbuf (%p,%d)", __func__, m, off);
 
+	m = *mp;
 	ifp = m->m_pkthdr.rcvif;
+	*mp = NULL;
 
 	IGMPSTAT_INC(igps_rcv_total);
 
 	ip = mtod(m, struct ip *);
-	iphlen = off;
-	igmplen = ntohs(ip->ip_len) - off;
+	iphlen = *offp;
+	igmplen = ntohs(ip->ip_len) - iphlen;
 
 	/*
 	 * Validate lengths.
@@ -1451,7 +1454,7 @@ igmp_input(struct mbuf *m, int off)
 	if (igmplen < IGMP_MINLEN) {
 		IGMPSTAT_INC(igps_rcv_tooshort);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	/*
@@ -1466,7 +1469,7 @@ igmp_input(struct mbuf *m, int off)
 	if ((m->m_flags & M_EXT || m->m_len < minlen) &&
 	    (m = m_pullup(m, minlen)) == 0) {
 		IGMPSTAT_INC(igps_rcv_tooshort);
-		return;
+		return (IPPROTO_DONE);
 	}
 	ip = mtod(m, struct ip *);
 
@@ -1479,7 +1482,7 @@ igmp_input(struct mbuf *m, int off)
 	if (in_cksum(m, igmplen)) {
 		IGMPSTAT_INC(igps_rcv_badsum);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 	m->m_data -= iphlen;
 	m->m_len += iphlen;
@@ -1492,7 +1495,7 @@ igmp_input(struct mbuf *m, int off)
 	if (igmp->igmp_type != IGMP_DVMRP && ip->ip_ttl != 1) {
 		IGMPSTAT_INC(igps_rcv_badttl);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	switch (igmp->igmp_type) {
@@ -1507,7 +1510,7 @@ igmp_input(struct mbuf *m, int off)
 		} else {
 			IGMPSTAT_INC(igps_rcv_tooshort);
 			m_freem(m);
-			return;
+			return (IPPROTO_DONE);
 		}
 
 		switch (queryver) {
@@ -1517,7 +1520,7 @@ igmp_input(struct mbuf *m, int off)
 				break;
 			if (igmp_input_v1_query(ifp, ip, igmp) != 0) {
 				m_freem(m);
-				return;
+				return (IPPROTO_DONE);
 			}
 			break;
 
@@ -1527,7 +1530,7 @@ igmp_input(struct mbuf *m, int off)
 				break;
 			if (igmp_input_v2_query(ifp, ip, igmp) != 0) {
 				m_freem(m);
-				return;
+				return (IPPROTO_DONE);
 			}
 			break;
 
@@ -1546,7 +1549,7 @@ igmp_input(struct mbuf *m, int off)
 				srclen = sizeof(struct in_addr) * nsrc;
 				if (nsrc * sizeof(in_addr_t) > srclen) {
 					IGMPSTAT_INC(igps_rcv_tooshort);
-					return;
+					return (IPPROTO_DONE);
 				}
 				/*
 				 * m_pullup() may modify m, so pullup in
@@ -1558,13 +1561,13 @@ igmp_input(struct mbuf *m, int off)
 				     m->m_len < igmpv3len) &&
 				    (m = m_pullup(m, igmpv3len)) == NULL) {
 					IGMPSTAT_INC(igps_rcv_tooshort);
-					return;
+					return (IPPROTO_DONE);
 				}
 				igmpv3 = (struct igmpv3 *)(mtod(m, uint8_t *)
 				    + iphlen);
 				if (igmp_input_v3_query(ifp, ip, igmpv3) != 0) {
 					m_freem(m);
-					return;
+					return (IPPROTO_DONE);
 				}
 			}
 			break;
@@ -1576,7 +1579,7 @@ igmp_input(struct mbuf *m, int off)
 			break;
 		if (igmp_input_v1_report(ifp, ip, igmp) != 0) {
 			m_freem(m);
-			return;
+			return (IPPROTO_DONE);
 		}
 		break;
 
@@ -1587,7 +1590,7 @@ igmp_input(struct mbuf *m, int off)
 			IGMPSTAT_INC(igps_rcv_nora);
 		if (igmp_input_v2_report(ifp, ip, igmp) != 0) {
 			m_freem(m);
-			return;
+			return (IPPROTO_DONE);
 		}
 		break;
 
@@ -1608,7 +1611,8 @@ igmp_input(struct mbuf *m, int off)
 	 * Pass all valid IGMP packets up to any process(es) listening on a
 	 * raw IGMP socket.
 	 */
-	rip_input(m, off);
+	*mp = m;
+	return (rip_input(mp, offp, proto));
 }
 
 

Modified: head/sys/netinet/igmp_var.h
==============================================================================
--- head/sys/netinet/igmp_var.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/igmp_var.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -205,7 +205,7 @@ struct igmp_ifinfo *
 	igmp_domifattach(struct ifnet *);
 void	igmp_domifdetach(struct ifnet *);
 void	igmp_ifdetach(struct ifnet *);
-void	igmp_input(struct mbuf *, int);
+int	igmp_input(struct mbuf **, int *, int);
 void	igmp_slowtimo(void);
 
 SYSCTL_DECL(_net_inet_igmp);

Modified: head/sys/netinet/in_gif.c
==============================================================================
--- head/sys/netinet/in_gif.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/in_gif.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -81,7 +81,7 @@ struct protosw in_gif_protosw = {
 	.pr_protocol =		0/* IPPROTO_IPV[46] */,
 	.pr_flags =		PR_ATOMIC|PR_ADDR,
 	.pr_input =		in_gif_input,
-	.pr_output =		(pr_output_t*)rip_output,
+	.pr_output =		(pr_output_t *)rip_output,
 	.pr_ctloutput =		rip_ctloutput,
 	.pr_usrreqs =		&rip_usrreqs
 };
@@ -270,31 +270,34 @@ in_gif_output(struct ifnet *ifp, int fam
 	return (error);
 }
 
-void
-in_gif_input(struct mbuf *m, int off)
+int
+in_gif_input(struct mbuf **mp, int *offp, int proto)
 {
+	struct mbuf *m;
 	struct ifnet *gifp = NULL;
 	struct gif_softc *sc;
 	struct ip *ip;
 	int af;
+	int off;
 	u_int8_t otos;
-	int proto;
 
+	m = *mp;
 	ip = mtod(m, struct ip *);
-	proto = ip->ip_p;
+	off = *offp;
+	*mp = NULL;
 
 	sc = (struct gif_softc *)encap_getarg(m);
 	if (sc == NULL) {
 		m_freem(m);
 		KMOD_IPSTAT_INC(ips_nogif);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	gifp = GIF2IFP(sc);
 	if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
 		m_freem(m);
 		KMOD_IPSTAT_INC(ips_nogif);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	otos = ip->ip_tos;
@@ -309,14 +312,14 @@ in_gif_input(struct mbuf *m, int off)
 		if (m->m_len < sizeof(*ip)) {
 			m = m_pullup(m, sizeof(*ip));
 			if (!m)
-				return;
+				return (IPPROTO_DONE);
 		}
 		ip = mtod(m, struct ip *);
 		if (ip_ecn_egress((gifp->if_flags & IFF_LINK1) ?
 				  ECN_ALLOWED : ECN_NOCARE,
 				  &otos, &ip->ip_tos) == 0) {
 			m_freem(m);
-			return;
+			return (IPPROTO_DONE);
 		}
 		break;
 	    }
@@ -331,7 +334,7 @@ in_gif_input(struct mbuf *m, int off)
 		if (m->m_len < sizeof(*ip6)) {
 			m = m_pullup(m, sizeof(*ip6));
 			if (!m)
-				return;
+				return (IPPROTO_DONE);
 		}
 		ip6 = mtod(m, struct ip6_hdr *);
 		itos = oitos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
@@ -339,7 +342,7 @@ in_gif_input(struct mbuf *m, int off)
 				  ECN_ALLOWED : ECN_NOCARE,
 				  &otos, &itos) == 0) {
 			m_freem(m);
-			return;
+			return (IPPROTO_DONE);
 		}
 		if (itos != oitos) {
 			ip6->ip6_flow &= ~htonl(0xff << 20);
@@ -355,10 +358,10 @@ in_gif_input(struct mbuf *m, int off)
 	default:
 		KMOD_IPSTAT_INC(ips_nogif);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 	gif_input(m, af, gifp);
-	return;
+	return (IPPROTO_DONE);
 }
 
 /*

Modified: head/sys/netinet/in_gif.h
==============================================================================
--- head/sys/netinet/in_gif.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/in_gif.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -36,7 +36,7 @@
 #define GIF_TTL		30
 
 struct gif_softc;
-void in_gif_input(struct mbuf *, int);
+int in_gif_input(struct mbuf **, int *, int);
 int in_gif_output(struct ifnet *, int, struct mbuf *);
 int gif_encapcheck4(const struct mbuf *, int, int, void *);
 int in_gif_attach(struct gif_softc *);

Modified: head/sys/netinet/ip_carp.c
==============================================================================
--- head/sys/netinet/ip_carp.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_carp.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$");
 #ifdef INET6
 #include <netinet/icmp6.h>
 #include <netinet/ip6.h>
-#include <netinet6/ip6protosw.h>
 #include <netinet6/in6_var.h>
 #include <netinet6/ip6_var.h>
 #include <netinet6/scope6_var.h>
@@ -435,18 +434,22 @@ carp_hmac_verify(struct carp_softc *sc, 
  * but it seems more efficient this way or not possible otherwise.
  */
 #ifdef INET
-void
-carp_input(struct mbuf *m, int hlen)
+int
+carp_input(struct mbuf **mp, int *offp, int proto)
 {
+	struct mbuf *m = *mp;
 	struct ip *ip = mtod(m, struct ip *);
 	struct carp_header *ch;
 	int iplen, len;
 
+	iplen = *offp;
+	*mp = NULL;
+
 	CARPSTATS_INC(carps_ipackets);
 
 	if (!V_carp_allow) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	/* verify that the IP TTL is 255.  */
@@ -456,7 +459,7 @@ carp_input(struct mbuf *m, int hlen)
 		    ip->ip_ttl,
 		    m->m_pkthdr.rcvif->if_xname);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	iplen = ip->ip_hl << 2;
@@ -467,14 +470,14 @@ carp_input(struct mbuf *m, int hlen)
 		    "on %s\n", __func__, m->m_len - sizeof(struct ip),
 		    m->m_pkthdr.rcvif->if_xname);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	if (iplen + sizeof(*ch) < m->m_len) {
 		if ((m = m_pullup(m, iplen + sizeof(*ch))) == NULL) {
 			CARPSTATS_INC(carps_hdrops);
 			CARP_DEBUG("%s: pullup failed\n", __func__);
-			return;
+			return (IPPROTO_DONE);
 		}
 		ip = mtod(m, struct ip *);
 	}
@@ -491,12 +494,12 @@ carp_input(struct mbuf *m, int hlen)
 		    m->m_pkthdr.len,
 		    m->m_pkthdr.rcvif->if_xname);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	if ((m = m_pullup(m, len)) == NULL) {
 		CARPSTATS_INC(carps_hdrops);
-		return;
+		return (IPPROTO_DONE);
 	}
 	ip = mtod(m, struct ip *);
 	ch = (struct carp_header *)((char *)ip + iplen);
@@ -508,11 +511,12 @@ carp_input(struct mbuf *m, int hlen)
 		CARP_DEBUG("%s: checksum failed on %s\n", __func__,
 		    m->m_pkthdr.rcvif->if_xname);
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 	m->m_data -= iplen;
 
 	carp_input_c(m, ch, AF_INET);
+	return (IPPROTO_DONE);
 }
 #endif
 
@@ -2058,13 +2062,13 @@ static struct protosw in_carp_protosw = 
 
 #ifdef INET6
 extern	struct domain inet6domain;
-static struct ip6protosw in6_carp_protosw = {
+static struct protosw in6_carp_protosw = {
 	.pr_type =		SOCK_RAW,
 	.pr_domain =		&inet6domain,
 	.pr_protocol =		IPPROTO_CARP,
 	.pr_flags =		PR_ATOMIC|PR_ADDR,
 	.pr_input =		carp6_input,
-	.pr_output =		rip6_output,
+	.pr_output =		(pr_output_t *)rip6_output,
 	.pr_ctloutput =		rip6_ctloutput,
 	.pr_usrreqs =		&rip6_usrreqs
 };

Modified: head/sys/netinet/ip_carp.h
==============================================================================
--- head/sys/netinet/ip_carp.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_carp.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -140,7 +140,7 @@ int		carp_ioctl(struct ifreq *, u_long, 
 int		carp_attach(struct ifaddr *, int);
 void		carp_detach(struct ifaddr *);
 void		carp_carpdev_state(struct ifnet *);
-void		carp_input (struct mbuf *, int);
+int		carp_input(struct mbuf **, int *, int);
 int		carp6_input (struct mbuf **, int *, int);
 int		carp_output (struct ifnet *, struct mbuf *,
 		    const struct sockaddr *);

Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_divert.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -173,12 +173,14 @@ div_destroy(void)
  * IPPROTO_DIVERT is not in the real IP protocol number space; this
  * function should never be called.  Just in case, drop any packets.
  */
-static void
-div_input(struct mbuf *m, int off)
+static int
+div_input(struct mbuf **mp, int *offp, int proto)
 {
+	struct mbuf *m = *mp;
 
 	KMOD_IPSTAT_INC(ips_noproto);
 	m_freem(m);
+	return (IPPROTO_DONE);
 }
 
 /*

Modified: head/sys/netinet/ip_encap.c
==============================================================================
--- head/sys/netinet/ip_encap.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_encap.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -84,7 +84,6 @@ __FBSDID("$FreeBSD$");
 #ifdef INET6
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
-#include <netinet6/ip6protosw.h>
 #endif
 
 #include <machine/stdarg.h>
@@ -115,18 +114,20 @@ encap_init(void)
 }
 
 #ifdef INET
-void
-encap4_input(struct mbuf *m, int off)
+int
+encap4_input(struct mbuf **mp, int *offp, int proto)
 {
 	struct ip *ip;
-	int proto;
+	struct mbuf *m;
 	struct sockaddr_in s, d;
 	const struct protosw *psw;
 	struct encaptab *ep, *match;
-	int prio, matchprio;
+	int matchprio, off, prio;
 
+	m = *mp;
+	off = *offp;
 	ip = mtod(m, struct ip *);
-	proto = ip->ip_p;
+	*mp = NULL;
 
 	bzero(&s, sizeof(s));
 	s.sin_family = AF_INET;
@@ -188,14 +189,16 @@ encap4_input(struct mbuf *m, int off)
 		psw = match->psw;
 		if (psw && psw->pr_input) {
 			encap_fillarg(m, match);
-			(*psw->pr_input)(m, off);
+			*mp = m;
+			(*psw->pr_input)(mp, offp, proto);
 		} else
 			m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	/* last resort: inject to raw socket */
-	rip_input(m, off);
+	*mp = m;
+	return (rip_input(mp, offp, proto));
 }
 #endif
 
@@ -206,7 +209,7 @@ encap6_input(struct mbuf **mp, int *offp
 	struct mbuf *m = *mp;
 	struct ip6_hdr *ip6;
 	struct sockaddr_in6 s, d;
-	const struct ip6protosw *psw;
+	const struct protosw *psw;
 	struct encaptab *ep, *match;
 	int prio, matchprio;
 
@@ -252,7 +255,7 @@ encap6_input(struct mbuf **mp, int *offp
 
 	if (match) {
 		/* found a match */
-		psw = (const struct ip6protosw *)match->psw;
+		psw = match->psw;
 		if (psw && psw->pr_input) {
 			encap_fillarg(m, match);
 			return (*psw->pr_input)(mp, offp, proto);

Modified: head/sys/netinet/ip_encap.h
==============================================================================
--- head/sys/netinet/ip_encap.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_encap.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -49,7 +49,7 @@ struct encaptab {
 };
 
 void	encap_init(void);
-void	encap4_input(struct mbuf *, int);
+int	encap4_input(struct mbuf **, int *, int);
 int	encap6_input(struct mbuf **, int *, int);
 const struct encaptab *encap_attach(int, int, const struct sockaddr *,
 	const struct sockaddr *, const struct sockaddr *,

Modified: head/sys/netinet/ip_gre.c
==============================================================================
--- head/sys/netinet/ip_gre.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_gre.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -92,12 +92,15 @@ static struct mbuf *gre_input2(struct mb
  * IPPROTO_GRE and a local destination address).
  * This really is simple
  */
-void
-gre_input(struct mbuf *m, int off)
+int
+gre_input(struct mbuf **mp, int *offp, int proto)
 {
-	int proto;
+	struct mbuf *m;
+	int off;
 
-	proto = (mtod(m, struct ip *))->ip_p;
+	m = *mp;
+	off = *offp;
+	*mp = NULL;
 
 	m = gre_input2(m, off, proto);
 
@@ -105,8 +108,11 @@ gre_input(struct mbuf *m, int off)
 	 * If no matching tunnel that is up is found. We inject
 	 * the mbuf to raw ip socket to see if anyone picks it up.
 	 */
-	if (m != NULL)
-		rip_input(m, off);
+	if (m != NULL) {
+		*mp = m;
+		rip_input(mp, offp, proto);
+	}
+	return (IPPROTO_DONE);
 }
 
 /*
@@ -213,24 +219,26 @@ gre_input2(struct mbuf *m ,int hlen, u_c
  * between IP header and payload
  */
 
-void
-gre_mobile_input(struct mbuf *m, int hlen)
+int
+gre_mobile_input(struct mbuf **mp, int *offp, int proto)
 {
 	struct ip *ip;
 	struct mobip_h *mip;
+	struct mbuf *m;
 	struct gre_softc *sc;
 	int msiz;
 
+	m = *mp;
 	if ((sc = gre_lookup(m, IPPROTO_MOBILE)) == NULL) {
 		/* No matching tunnel or tunnel is down. */
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	if (m->m_len < sizeof(*mip)) {
 		m = m_pullup(m, sizeof(*mip));
 		if (m == NULL)
-			return;
+			return (IPPROTO_DONE);
 	}
 	ip = mtod(m, struct ip *);
 	mip = mtod(m, struct mobip_h *);
@@ -247,7 +255,7 @@ gre_mobile_input(struct mbuf *m, int hle
 	if (m->m_len < (ip->ip_hl << 2) + msiz) {
 		m = m_pullup(m, (ip->ip_hl << 2) + msiz);
 		if (m == NULL)
-			return;
+			return (IPPROTO_DONE);
 		ip = mtod(m, struct ip *);
 		mip = mtod(m, struct mobip_h *);
 	}
@@ -257,7 +265,7 @@ gre_mobile_input(struct mbuf *m, int hle
 
 	if (gre_in_cksum((u_int16_t *)&mip->mh, msiz) != 0) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	bcopy((caddr_t)(ip) + (ip->ip_hl << 2) + msiz, (caddr_t)(ip) +
@@ -282,12 +290,13 @@ gre_mobile_input(struct mbuf *m, int hle
 
 	if ((GRE2IFP(sc)->if_flags & IFF_MONITOR) != 0) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	m->m_pkthdr.rcvif = GRE2IFP(sc);
 
 	netisr_queue(NETISR_IP, m);
+	return (IPPROTO_DONE);
 }
 
 /*

Modified: head/sys/netinet/ip_gre.h
==============================================================================
--- head/sys/netinet/ip_gre.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_gre.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -31,6 +31,6 @@
  */
 
 #ifdef _KERNEL
-void gre_input(struct mbuf *, int);
-void gre_mobile_input(struct mbuf *, int);
+int gre_input(struct mbuf **, int *, int);
+int gre_mobile_input(struct mbuf **, int *, int);
 #endif /* _KERNEL */

Modified: head/sys/netinet/ip_icmp.c
==============================================================================
--- head/sys/netinet/ip_icmp.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_icmp.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -358,19 +358,22 @@ freeit:
 /*
  * Process a received ICMP message.
  */
-void
-icmp_input(struct mbuf *m, int off)
+int
+icmp_input(struct mbuf **mp, int *offp, int proto)
 {
 	struct icmp *icp;
 	struct in_ifaddr *ia;
+	struct mbuf *m = *mp;
 	struct ip *ip = mtod(m, struct ip *);
 	struct sockaddr_in icmpsrc, icmpdst, icmpgw;
-	int hlen = off;
-	int icmplen = ntohs(ip->ip_len) - off;
+	int hlen = *offp;
+	int icmplen = ntohs(ip->ip_len) - *offp;
 	int i, code;
 	void (*ctlfunc)(int, struct sockaddr *, void *);
 	int fibnum;
 
+	*mp = NULL;
+
 	/*
 	 * Locate icmp structure in mbuf, and check
 	 * that not corrupted and of at least minimum length.
@@ -390,7 +393,7 @@ icmp_input(struct mbuf *m, int off)
 	i = hlen + min(icmplen, ICMP_ADVLENMIN);
 	if (m->m_len < i && (m = m_pullup(m, i)) == NULL)  {
 		ICMPSTAT_INC(icps_tooshort);
-		return;
+		return (IPPROTO_DONE);
 	}
 	ip = mtod(m, struct ip *);
 	m->m_len -= hlen;
@@ -602,7 +605,7 @@ reflect:
 		ICMPSTAT_INC(icps_reflect);
 		ICMPSTAT_INC(icps_outhist[icp->icmp_type]);
 		icmp_reflect(m);
-		return;
+		return (IPPROTO_DONE);
 
 	case ICMP_REDIRECT:
 		if (V_log_redirect) {
@@ -679,11 +682,13 @@ reflect:
 	}
 
 raw:
-	rip_input(m, off);
-	return;
+	*mp = m;
+	rip_input(mp, offp, proto);
+	return (IPPROTO_DONE);
 
 freeit:
 	m_freem(m);
+	return (IPPROTO_DONE);
 }
 
 /*

Modified: head/sys/netinet/ip_icmp.h
==============================================================================
--- head/sys/netinet/ip_icmp.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_icmp.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -207,7 +207,7 @@ struct icmp {
 
 #ifdef _KERNEL
 void	icmp_error(struct mbuf *, int, int, uint32_t, int);
-void	icmp_input(struct mbuf *, int);
+int	icmp_input(struct mbuf **, int *, int);
 int	ip_next_mtu(int, int);
 #endif
 

Modified: head/sys/netinet/ip_input.c
==============================================================================
--- head/sys/netinet/ip_input.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_input.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -726,7 +726,7 @@ ours:
 	 */
 	IPSTAT_INC(ips_delivered);
 
-	(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
+	(*inetsw[ip_protox[ip->ip_p]].pr_input)(&m, &hlen, ip->ip_p);
 	return;
 bad:
 	m_freem(m);
@@ -1715,13 +1715,18 @@ ip_rsvp_done(void)
 	return 0;
 }
 
-void
-rsvp_input(struct mbuf *m, int off)	/* XXX must fixup manually */
+int
+rsvp_input(struct mbuf **mp, int *offp, int proto)
 {
+	struct mbuf *m;
+
+	m = *mp;
+	*mp = NULL;
 
 	if (rsvp_input_p) { /* call the real one if loaded */
-		rsvp_input_p(m, off);
-		return;
+		*mp = m;
+		rsvp_input_p(mp, offp, proto);
+		return (IPPROTO_DONE);
 	}
 
 	/* Can still get packets with rsvp_on = 0 if there is a local member
@@ -1731,13 +1736,15 @@ rsvp_input(struct mbuf *m, int off)	/* X
 	
 	if (!V_rsvp_on) {
 		m_freem(m);
-		return;
+		return (IPPROTO_DONE);
 	}
 
 	if (V_ip_rsvpd != NULL) { 
-		rip_input(m, off);
-		return;
+		*mp = m;
+		rip_input(mp, offp, proto);
+		return (IPPROTO_DONE);
 	}
 	/* Drop the packet */
 	m_freem(m);
+	return (IPPROTO_DONE);
 }

Modified: head/sys/netinet/ip_mroute.c
==============================================================================
--- head/sys/netinet/ip_mroute.c	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_mroute.c	Fri Aug  8 01:57:15 2014	(r269699)
@@ -247,7 +247,7 @@ static const struct protosw in_pim_proto
 	.pr_protocol =		IPPROTO_PIM,
 	.pr_flags =		PR_ATOMIC|PR_ADDR|PR_LASTHDR,
 	.pr_input =		pim_input,
-	.pr_output =		(pr_output_t*)rip_output,
+	.pr_output =		(pr_output_t *)rip_output,
 	.pr_ctloutput =		rip_ctloutput,
 	.pr_usrreqs =		&rip_usrreqs
 };
@@ -1718,12 +1718,16 @@ X_ip_rsvp_force_done(struct socket *so _
 
 }
 
-static void
-X_rsvp_input(struct mbuf *m, int off __unused)
+static int
+X_rsvp_input(struct mbuf **mp, int *offp, int proto)
 {
+	struct mbuf *m;
 
+	m = *mp;
+	*mp = NULL;
 	if (!V_rsvp_on)
 		m_freem(m);
+	return (IPPROTO_DONE);
 }
 
 /*
@@ -2556,15 +2560,19 @@ pim_encapcheck(const struct mbuf *m, int
  * (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, int iphlen)
+int
+pim_input(struct mbuf **mp, int *offp, int proto)
 {
+    struct mbuf *m = *mp;
     struct ip *ip = mtod(m, struct ip *);
     struct pim *pim;
+    int iphlen = *offp;
     int minlen;
     int datalen = ntohs(ip->ip_len) - iphlen;
     int ip_tos;
 
+    *mp = NULL;
+
     /* Keep statistics */
     PIMSTAT_INC(pims_rcv_total_msgs);
     PIMSTAT_ADD(pims_rcv_total_bytes, datalen);
@@ -2577,7 +2585,7 @@ pim_input(struct mbuf *m, int iphlen)
 	CTR3(KTR_IPMF, "%s: short packet (%d) from %s",
 	    __func__, datalen, inet_ntoa(ip->ip_src));
 	m_freem(m);
-	return;
+	return (IPPROTO_DONE);
     }
 
     /*
@@ -2595,7 +2603,7 @@ pim_input(struct mbuf *m, int iphlen)
      */
     if (m->m_len < minlen && (m = m_pullup(m, minlen)) == 0) {
 	CTR1(KTR_IPMF, "%s: m_pullup() failed", __func__);
-	return;
+	return (IPPROTO_DONE);
     }
 
     /* m_pullup() may have given us a new mbuf so reset ip. */
@@ -2620,7 +2628,7 @@ pim_input(struct mbuf *m, int iphlen)
 	PIMSTAT_INC(pims_rcv_badsum);
 	CTR1(KTR_IPMF, "%s: invalid checksum", __func__);
 	m_freem(m);
-	return;
+	return (IPPROTO_DONE);
     }
 
     /* PIM version check */
@@ -2629,7 +2637,7 @@ pim_input(struct mbuf *m, int iphlen)
 	CTR3(KTR_IPMF, "%s: bad version %d expect %d", __func__,
 	    (int)PIM_VT_V(pim->pim_vt), PIM_VERSION);
 	m_freem(m);
-	return;
+	return (IPPROTO_DONE);
     }
 
     /* restore mbuf back to the outer IP */
@@ -2654,7 +2662,7 @@ pim_input(struct mbuf *m, int iphlen)
 	    CTR2(KTR_IPMF, "%s: register vif not set: %d", __func__,
 		(int)V_reg_vif_num);
 	    m_freem(m);
-	    return;
+	    return (IPPROTO_DONE);
 	}
 	/* XXX need refcnt? */
 	vifp = V_viftable[V_reg_vif_num].v_ifp;
@@ -2668,7 +2676,7 @@ pim_input(struct mbuf *m, int iphlen)
 	    PIMSTAT_INC(pims_rcv_badregisters);
 	    CTR1(KTR_IPMF, "%s: register packet size too small", __func__);
 	    m_freem(m);
-	    return;
+	    return (IPPROTO_DONE);
 	}
 
 	reghdr = (u_int32_t *)(pim + 1);
@@ -2682,7 +2690,7 @@ pim_input(struct mbuf *m, int iphlen)
 	    PIMSTAT_INC(pims_rcv_badregisters);
 	    CTR1(KTR_IPMF, "%s: bad encap ip version", __func__);
 	    m_freem(m);
-	    return;
+	    return (IPPROTO_DONE);
 	}
 
 	/* verify the inner packet is destined to a mcast group */
@@ -2691,7 +2699,7 @@ pim_input(struct mbuf *m, int iphlen)
 	    CTR2(KTR_IPMF, "%s: bad encap ip dest %s", __func__,
 		inet_ntoa(encap_ip->ip_dst));
 	    m_freem(m);
-	    return;
+	    return (IPPROTO_DONE);
 	}
 
 	/* If a NULL_REGISTER, pass it to the daemon */
@@ -2730,7 +2738,7 @@ pim_input(struct mbuf *m, int iphlen)
 	if (mcp == NULL) {
 	    CTR1(KTR_IPMF, "%s: m_copy() failed", __func__);
 	    m_freem(m);
-	    return;
+	    return (IPPROTO_DONE);
 	}
 
 	/* Keep statistics */
@@ -2766,9 +2774,10 @@ pim_input_to_daemon:
      * 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, iphlen);
+    *mp = m;
+    rip_input(mp, offp, proto);
 
-    return;
+    return (IPPROTO_DONE);
 }
 
 static int

Modified: head/sys/netinet/ip_var.h
==============================================================================
--- head/sys/netinet/ip_var.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/ip_var.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -234,15 +234,15 @@ void	rip_init(void);
 #ifdef VIMAGE
 void	rip_destroy(void);
 #endif
-void	rip_input(struct mbuf *, int);
+int	rip_input(struct mbuf **, int *, int);
 int	rip_output(struct mbuf *, struct socket *, u_long);
-void	ipip_input(struct mbuf *, int);
-void	rsvp_input(struct mbuf *, int);
+int	ipip_input(struct mbuf **, int *, int);
+int	rsvp_input(struct mbuf **, int *, int);
 int	ip_rsvp_init(struct socket *);
 int	ip_rsvp_done(void);
 extern int	(*ip_rsvp_vif)(struct socket *, struct sockopt *);
 extern void	(*ip_rsvp_force_done)(struct socket *);
-extern void	(*rsvp_input_p)(struct mbuf *m, int off);
+extern int	(*rsvp_input_p)(struct mbuf **, int *, int);
 
 VNET_DECLARE(struct pfil_head, inet_pfil_hook);	/* packet filter hooks */
 #define	V_inet_pfil_hook	VNET(inet_pfil_hook)

Modified: head/sys/netinet/pim_var.h
==============================================================================
--- head/sys/netinet/pim_var.h	Fri Aug  8 01:23:43 2014	(r269698)
+++ head/sys/netinet/pim_var.h	Fri Aug  8 01:57:15 2014	(r269699)
@@ -72,7 +72,7 @@ struct pimstat {
 
 #ifdef _KERNEL
 
-void pim_input(struct mbuf *, int);
+int pim_input(struct mbuf **, int *, int);
 SYSCTL_DECL(_net_inet_pim);
 #endif
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list