Hi,
If I change the IPv4 pr_input function to the way IPv6 is implemented,
I can get rid of struct ip6protosw and some wrapper functions. I
think it more consistent to have less different structures.
Most conversions are mechanical. Where the IPv4 and IPv6 fucntions
were identical, I removed one of them.
The divert_input functions cannot be called anyway so I removed
them.
ok?
bluhm
Index: net/if_etherip.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_etherip.c,v
retrieving revision 1.13
diff -u -p -r1.13 if_etherip.c
--- net/if_etherip.c 25 Jan 2017 17:34:31 -0000 1.13
+++ net/if_etherip.c 26 Jan 2017 14:49:14 -0000
@@ -404,9 +404,10 @@ ip_etherip_output(struct ifnet *ifp, str
return ip_output(m, NULL, NULL, IP_RAWOUTPUT, NULL, NULL, 0);
}
-void
-ip_etherip_input(struct mbuf *m, int off, int proto)
+int
+ip_etherip_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct etherip_softc *sc;
const struct ip *ip;
@@ -419,13 +420,13 @@ ip_etherip_input(struct mbuf *m, int off
if (ip->ip_p != IPPROTO_ETHERIP) {
m_freem(m);
ipstat_inc(ips_noproto);
- return;
+ return IPPROTO_DONE;
}
if (!etherip_allow) {
m_freem(m);
etheripstat.etherip_pdrops++;
- return;
+ return IPPROTO_DONE;
}
LIST_FOREACH(sc, ðerip_softc_list, sc_entry) {
@@ -452,26 +453,26 @@ ip_etherip_input(struct mbuf *m, int off
* This is tricky but the path will be removed soon when
* implementation of etherip is removed from gif(4).
*/
- etherip_input(m, off, proto);
+ return etherip_input(mp, offp, proto);
#else
etheripstat.etherip_noifdrops++;
m_freem(m);
+ return IPPROTO_DONE;
#endif /* NGIF */
- return;
}
- m_adj(m, off);
+ m_adj(m, *offp);
m = m_pullup(m, sizeof(struct etherip_header));
if (m == NULL) {
etheripstat.etherip_adrops++;
- return;
+ return IPPROTO_DONE;
}
eip = mtod(m, struct etherip_header *);
if (eip->eip_ver != ETHERIP_VERSION || eip->eip_pad) {
etheripstat.etherip_adrops++;
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
etheripstat.etherip_ipackets++;
@@ -482,7 +483,7 @@ ip_etherip_input(struct mbuf *m, int off
m = m_pullup(m, sizeof(struct ether_header));
if (m == NULL) {
etheripstat.etherip_adrops++;
- return;
+ return IPPROTO_DONE;
}
m->m_flags &= ~(M_BCAST|M_MCAST);
@@ -492,6 +493,7 @@ ip_etherip_input(struct mbuf *m, int off
ml_enqueue(&ml, m);
if_input(ifp, &ml);
+ return IPPROTO_DONE;
}
#ifdef INET6
@@ -569,7 +571,6 @@ ip6_etherip_input(struct mbuf **mp, int
{
struct mbuf *m = *mp;
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
- int off = *offp;
struct etherip_softc *sc;
const struct ip6_hdr *ip6;
struct etherip_header *eip;
@@ -612,7 +613,7 @@ ip6_etherip_input(struct mbuf **mp, int
* This is tricky but the path will be removed soon when
* implementation of etherip is removed from gif(4).
*/
- return etherip_input6(mp, offp, proto);
+ return etherip_input(mp, offp, proto);
#else
etheripstat.etherip_noifdrops++;
m_freem(m);
@@ -620,7 +621,7 @@ ip6_etherip_input(struct mbuf **mp, int
#endif /* NGIF */
}
- m_adj(m, off);
+ m_adj(m, *offp);
m = m_pullup(m, sizeof(struct etherip_header));
if (m == NULL) {
etheripstat.etherip_adrops++;
@@ -652,10 +653,8 @@ ip6_etherip_input(struct mbuf **mp, int
ml_enqueue(&ml, m);
if_input(ifp, &ml);
-
return IPPROTO_DONE;
}
-
#endif /* INET6 */
int
Index: net/if_etherip.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_etherip.h,v
retrieving revision 1.3
diff -u -p -r1.3 if_etherip.h
--- net/if_etherip.h 25 Jan 2017 17:34:31 -0000 1.3
+++ net/if_etherip.h 26 Jan 2017 14:48:34 -0000
@@ -73,7 +73,7 @@ struct etherip_header {
int ip_etherip_sysctl(int *, uint, void *, size_t *, void *, size_t);
int ip_etherip_output(struct ifnet *, struct mbuf *);
-void ip_etherip_input(struct mbuf *, int, int);
+int ip_etherip_input(struct mbuf **, int *, int);
#ifdef INET6
int ip6_etherip_output(struct ifnet *, struct mbuf *);
Index: net/if_gif.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_gif.c,v
retrieving revision 1.90
diff -u -p -r1.90 if_gif.c
--- net/if_gif.c 25 Jan 2017 17:34:31 -0000 1.90
+++ net/if_gif.c 26 Jan 2017 14:24:08 -0000
@@ -715,9 +715,10 @@ in_gif_output(struct ifnet *ifp, int fam
return 0;
}
-void
-in_gif_input(struct mbuf *m, int off, int proto)
+int
+in_gif_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct gif_softc *sc;
struct ifnet *gifp = NULL;
struct ip *ip;
@@ -756,13 +757,12 @@ in_gif_input(struct mbuf *m, int off, in
gifp->if_ipackets++;
gifp->if_ibytes += m->m_pkthdr.len;
/* We have a configured GIF */
- ipip_input(m, off, gifp, ip->ip_p);
- return;
+ return ipip_input(mp, offp, gifp, proto);
}
inject:
- ip4_input(m, off, proto); /* No GIF interface was configured */
- return;
+ /* No GIF interface was configured */
+ return ip4_input(mp, offp, proto);
}
#ifdef INET6
@@ -883,13 +883,11 @@ int in6_gif_input(struct mbuf **mp, int
m->m_pkthdr.ph_ifidx = gifp->if_index;
gifp->if_ipackets++;
gifp->if_ibytes += m->m_pkthdr.len;
- ipip_input(m, *offp, gifp, proto);
- return IPPROTO_DONE;
+ return ipip_input(mp, offp, gifp, proto);
}
inject:
/* No GIF tunnel configured */
- ip4_input6(&m, offp, proto);
- return IPPROTO_DONE;
+ return ip4_input(mp, offp, proto);
}
#endif /* INET6 */
Index: net/if_gif.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_gif.h,v
retrieving revision 1.15
diff -u -p -r1.15 if_gif.h
--- net/if_gif.h 25 Jan 2017 17:34:31 -0000 1.15
+++ net/if_gif.h 26 Jan 2017 14:15:10 -0000
@@ -49,7 +49,7 @@ extern LIST_HEAD(gif_softc_head, gif_sof
int gif_encap(struct ifnet *, struct mbuf **, sa_family_t);
-void in_gif_input(struct mbuf *, int, int);
+int in_gif_input(struct mbuf **, int *, int);
int in6_gif_input(struct mbuf **, int *, int);
#endif /* _NET_IF_GIF_H_ */
Index: net/if_pfsync.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_pfsync.c,v
retrieving revision 1.243
diff -u -p -r1.243 if_pfsync.c
--- net/if_pfsync.c 25 Jan 2017 17:34:31 -0000 1.243
+++ net/if_pfsync.c 26 Jan 2017 15:28:48 -0000
@@ -634,16 +634,15 @@ pfsync_state_import(struct pfsync_state
return (error);
}
-void
-pfsync_input(struct mbuf *m, int iphlen, int proto)
+int
+pfsync_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *n, *m = *mp;
struct pfsync_softc *sc = pfsyncif;
struct ip *ip = mtod(m, struct ip *);
- struct mbuf *mp;
struct pfsync_header *ph;
struct pfsync_subheader subh;
-
- int offset, offp, len, count, mlen, flags = 0;
+ int offset, noff, len, count, mlen, flags = 0;
pfsyncstats.pfsyncs_ipackets++;
@@ -668,12 +667,12 @@ pfsync_input(struct mbuf *m, int iphlen,
}
offset = ip->ip_hl << 2;
- mp = m_pulldown(m, offset, sizeof(*ph), &offp);
- if (mp == NULL) {
+ n = m_pulldown(m, offset, sizeof(*ph), &noff);
+ if (n == NULL) {
pfsyncstats.pfsyncs_hdrops++;
- return;
+ return IPPROTO_DONE;
}
- ph = (struct pfsync_header *)(mp->m_data + offp);
+ ph = (struct pfsync_header *)(n->m_data + noff);
/* verify the version */
if (ph->version != PFSYNC_VERSION) {
@@ -714,13 +713,13 @@ pfsync_input(struct mbuf *m, int iphlen,
goto done;
}
- mp = m_pulldown(m, offset, mlen * count, &offp);
- if (mp == NULL) {
+ n = m_pulldown(m, offset, mlen * count, &noff);
+ if (n == NULL) {
pfsyncstats.pfsyncs_badlen++;
- return;
+ return IPPROTO_DONE;
}
- if (pfsync_acts[subh.action].in(mp->m_data + offp,
+ if (pfsync_acts[subh.action].in(n->m_data + noff,
mlen, count, flags) != 0)
goto done;
@@ -729,6 +728,7 @@ pfsync_input(struct mbuf *m, int iphlen,
done:
m_freem(m);
+ return IPPROTO_DONE;
}
int
Index: net/if_pfsync.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_pfsync.h,v
retrieving revision 1.50
diff -u -p -r1.50 if_pfsync.h
--- net/if_pfsync.h 25 Jan 2017 17:34:31 -0000 1.50
+++ net/if_pfsync.h 26 Jan 2017 15:20:00 -0000
@@ -286,7 +286,7 @@ struct pfsyncreq {
#define PFSYNC_S_DEFER 0xfe
#define PFSYNC_S_NONE 0xff
-void pfsync_input(struct mbuf *, int, int);
+int pfsync_input(struct mbuf **, int *, int);
int pfsync_sysctl(int *, u_int, void *, size_t *,
void *, size_t);
Index: netinet/igmp.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/igmp.c,v
retrieving revision 1.61
diff -u -p -r1.61 igmp.c
--- netinet/igmp.c 25 Jan 2017 17:34:31 -0000 1.61
+++ netinet/igmp.c 26 Jan 2017 14:08:04 -0000
@@ -107,7 +107,7 @@ void igmp_checktimer(struct ifnet *);
void igmp_sendpkt(struct ifnet *, struct in_multi *, int, in_addr_t);
int rti_fill(struct in_multi *);
struct router_info * rti_find(struct ifnet *);
-void igmp_input_if(struct ifnet *, struct mbuf *, int, int);
+int igmp_input_if(struct ifnet *, struct mbuf **, int *, int);
int igmp_sysctl_igmpstat(void *, size_t *, void *);
void
@@ -208,26 +208,29 @@ rti_delete(struct ifnet *ifp)
}
}
-void
-igmp_input(struct mbuf *m, int iphlen, int proto)
+int
+igmp_input(struct mbuf **mp, int *offp, int proto)
{
struct ifnet *ifp;
igmpstat_inc(igps_rcv_total);
- ifp = if_get(m->m_pkthdr.ph_ifidx);
+ ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(m);
- return;
+ m_freem(*mp);
+ return IPPROTO_DONE;
}
- igmp_input_if(ifp, m, iphlen, proto);
+ proto = igmp_input_if(ifp, mp, offp, proto);
if_put(ifp);
+ return proto;
}
-void
-igmp_input_if(struct ifnet *ifp, struct mbuf *m, int iphlen, int proto)
+int
+igmp_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
+ int iphlen = *offp;
struct ip *ip = mtod(m, struct ip *);
struct igmp *igmp;
int igmplen;
@@ -246,13 +249,13 @@ igmp_input_if(struct ifnet *ifp, struct
if (igmplen < IGMP_MINLEN) {
igmpstat_inc(igps_rcv_tooshort);
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
minlen = iphlen + IGMP_MINLEN;
if ((m->m_flags & M_EXT || m->m_len < minlen) &&
(m = m_pullup(m, minlen)) == NULL) {
igmpstat_inc(igps_rcv_tooshort);
- return;
+ return IPPROTO_DONE;
}
/*
@@ -264,7 +267,7 @@ igmp_input_if(struct ifnet *ifp, struct
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;
@@ -282,7 +285,7 @@ igmp_input_if(struct ifnet *ifp, struct
rti = rti_find(ifp);
if (rti == NULL) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
rti->rti_type = IGMP_v1_ROUTER;
rti->rti_age = 0;
@@ -290,7 +293,7 @@ igmp_input_if(struct ifnet *ifp, struct
if (ip->ip_dst.s_addr != INADDR_ALLHOSTS_GROUP) {
igmpstat_inc(igps_rcv_badqueries);
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/*
@@ -315,7 +318,7 @@ igmp_input_if(struct ifnet *ifp, struct
if (!IN_MULTICAST(ip->ip_dst.s_addr)) {
igmpstat_inc(igps_rcv_badqueries);
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
timer = igmp->igmp_code * PR_FASTHZ / IGMP_TIMER_SCALE;
@@ -372,7 +375,7 @@ igmp_input_if(struct ifnet *ifp, struct
igmp->igmp_group.s_addr != ip->ip_dst.s_addr) {
igmpstat_inc(igps_rcv_badreports);
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/*
@@ -438,7 +441,7 @@ igmp_input_if(struct ifnet *ifp, struct
igmp->igmp_group.s_addr != ip->ip_dst.s_addr) {
igmpstat_inc(igps_rcv_badreports);
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/*
@@ -487,7 +490,7 @@ igmp_input_if(struct ifnet *ifp, struct
* Pass all valid IGMP packets up to any process(es) listening
* on a raw IGMP socket.
*/
- rip_input(m, iphlen, proto);
+ return rip_input(mp, offp, proto);
}
void
Index: netinet/igmp_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/igmp_var.h,v
retrieving revision 1.11
diff -u -p -r1.11 igmp_var.h
--- netinet/igmp_var.h 25 Jan 2017 17:34:31 -0000 1.11
+++ netinet/igmp_var.h 26 Jan 2017 14:06:02 -0000
@@ -110,7 +110,7 @@ igmpstat_inc(enum igmpstat_counters c)
#define IGMP_RANDOM_DELAY(X) (arc4random_uniform(X) + 1)
void igmp_init(void);
-void igmp_input(struct mbuf *, int, int);
+int igmp_input(struct mbuf **, int *, int);
void igmp_joingroup(struct in_multi *);
void igmp_leavegroup(struct in_multi *);
void igmp_fasttimo(void);
Index: netinet/in_proto.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_proto.c,v
retrieving revision 1.71
diff -u -p -r1.71 in_proto.c
--- netinet/in_proto.c 22 Dec 2016 11:04:44 -0000 1.71
+++ netinet/in_proto.c 26 Jan 2017 15:33:40 -0000
@@ -289,7 +289,7 @@ struct protosw inetsw[] = {
#endif /* NPFSYNC > 0 */
#if NPF > 0
{ SOCK_RAW, &inetdomain, IPPROTO_DIVERT, PR_ATOMIC|PR_ADDR,
- divert_input, 0, 0, rip_ctloutput,
+ 0, 0, 0, rip_ctloutput,
divert_usrreq,
divert_init, 0, 0, 0, divert_sysctl
},
Index: netinet/ip_carp.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_carp.c,v
retrieving revision 1.300
diff -u -p -r1.300 ip_carp.c
--- netinet/ip_carp.c 25 Jan 2017 17:34:31 -0000 1.300
+++ netinet/ip_carp.c 26 Jan 2017 15:17:01 -0000
@@ -214,7 +214,10 @@ int carp_hmac_verify(struct carp_vhost_e
int carp_input(struct ifnet *, struct mbuf *, void *);
void carp_proto_input_c(struct ifnet *, struct mbuf *,
struct carp_header *, int, sa_family_t);
-void carp_proto_input_if(struct ifnet *, struct mbuf *, int);
+int carp_proto_input_if(struct ifnet *, struct mbuf **, int *, int);
+#ifdef INET6
+int carp6_proto_input_if(struct ifnet *, struct mbuf **, int *, int);
+#endif
void carpattach(int);
void carpdetach(struct carp_softc *);
int carp_prepare_ad(struct mbuf *, struct carp_vhost_entry *,
@@ -411,19 +414,20 @@ carp_hmac_verify(struct carp_vhost_entry
return (1);
}
-void
-carp_proto_input(struct mbuf *m, int hlen, int proto)
+int
+carp_proto_input(struct mbuf **mp, int *offp, int proto)
{
struct ifnet *ifp;
- ifp = if_get(m->m_pkthdr.ph_ifidx);
+ ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(m);
- return;
+ m_freem(*mp);
+ return IPPROTO_DONE;
}
- carp_proto_input_if(ifp, m, hlen);
+ proto = carp_proto_input_if(ifp, mp, offp, proto);
if_put(ifp);
+ return proto;
}
/*
@@ -431,9 +435,10 @@ carp_proto_input(struct mbuf *m, int hle
* we have rearranged checks order compared to the rfc,
* but it seems more efficient this way or not possible otherwise.
*/
-void
-carp_proto_input_if(struct ifnet *ifp, struct mbuf *m, int hlen)
+int
+carp_proto_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct ip *ip = mtod(m, struct ip *);
struct carp_softc *sc = NULL;
struct carp_header *ch;
@@ -443,7 +448,7 @@ carp_proto_input_if(struct ifnet *ifp, s
if (!carp_opts[CARPCTL_ALLOW]) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
ismulti = IN_MULTICAST(ip->ip_dst.s_addr);
@@ -456,7 +461,7 @@ carp_proto_input_if(struct ifnet *ifp, s
("packet received on non-carp interface: %s",
ifp->if_xname));
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/* verify that the IP TTL is 255. */
@@ -465,7 +470,7 @@ carp_proto_input_if(struct ifnet *ifp, s
CARP_LOG(LOG_NOTICE, sc, ("received ttl %d != %d on %s",
ip->ip_ttl, CARP_DFLTTL, ifp->if_xname));
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/*
@@ -479,12 +484,12 @@ carp_proto_input_if(struct ifnet *ifp, s
CARP_LOG(LOG_INFO, sc, ("packet too short %d on %s",
m->m_pkthdr.len, ifp->if_xname));
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
if ((m = m_pullup(m, len)) == NULL) {
carpstats.carps_hdrops++;
- return;
+ return IPPROTO_DONE;
}
ip = mtod(m, struct ip *);
ch = (struct carp_header *)(mtod(m, caddr_t) + iplen);
@@ -496,38 +501,35 @@ carp_proto_input_if(struct ifnet *ifp, s
CARP_LOG(LOG_INFO, sc, ("checksum failed on %s",
ifp->if_xname));
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
m->m_data -= iplen;
carp_proto_input_c(ifp, m, ch, ismulti, AF_INET);
+ return IPPROTO_DONE;
}
#ifdef INET6
-int carp6_proto_input_if(struct ifnet *, struct mbuf *, int *);
-
int
carp6_proto_input(struct mbuf **mp, int *offp, int proto)
{
- struct mbuf *m = *mp;
struct ifnet *ifp;
- int rv;
- ifp = if_get(m->m_pkthdr.ph_ifidx);
+ ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(m);
- return (IPPROTO_DONE);
+ m_freem(*mp);
+ return IPPROTO_DONE;
}
- rv = carp6_proto_input_if(ifp, m, offp);
+ proto = carp6_proto_input_if(ifp, mp, offp, proto);
if_put(ifp);
-
- return (rv);
+ return proto;
}
int
-carp6_proto_input_if(struct ifnet *ifp, struct mbuf *m, int *offp)
+carp6_proto_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct carp_softc *sc = NULL;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct carp_header *ch;
@@ -537,7 +539,7 @@ carp6_proto_input_if(struct ifnet *ifp,
if (!carp_opts[CARPCTL_ALLOW]) {
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/* check if received on a valid carp interface */
@@ -546,7 +548,7 @@ carp6_proto_input_if(struct ifnet *ifp,
CARP_LOG(LOG_INFO, sc, ("packet received on non-carp interface:
%s",
ifp->if_xname));
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/* verify that the IP TTL is 255 */
@@ -555,7 +557,7 @@ carp6_proto_input_if(struct ifnet *ifp,
CARP_LOG(LOG_NOTICE, sc, ("received ttl %d != %d on %s",
ip6->ip6_hlim, CARP_DFLTTL, ifp->if_xname));
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
/* verify that we have a complete carp packet */
@@ -563,7 +565,7 @@ carp6_proto_input_if(struct ifnet *ifp,
if ((m = m_pullup(m, *offp + sizeof(*ch))) == NULL) {
carpstats.carps_badlen++;
CARP_LOG(LOG_INFO, sc, ("packet size %u too small", len));
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
ch = (struct carp_header *)(mtod(m, caddr_t) + *offp);
@@ -574,12 +576,12 @@ carp6_proto_input_if(struct ifnet *ifp,
CARP_LOG(LOG_INFO, sc, ("checksum failed, on %s",
ifp->if_xname));
m_freem(m);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
m->m_data -= *offp;
carp_proto_input_c(ifp, m, ch, 1, AF_INET6);
- return (IPPROTO_DONE);
+ return IPPROTO_DONE;
}
#endif /* INET6 */
Index: netinet/ip_carp.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_carp.h,v
retrieving revision 1.39
diff -u -p -r1.39 ip_carp.h
--- netinet/ip_carp.h 25 Jan 2017 17:34:31 -0000 1.39
+++ netinet/ip_carp.h 26 Jan 2017 15:13:48 -0000
@@ -163,7 +163,7 @@ struct carpreq {
#ifdef _KERNEL
void carp_ifdetach (struct ifnet *);
-void carp_proto_input (struct mbuf *, int, int);
+int carp_proto_input(struct mbuf **, int *, int);
void carp_carpdev_state(void *);
void carp_group_demote_adj(struct ifnet *, int, char *);
int carp6_proto_input(struct mbuf **, int *, int);
Index: netinet/ip_divert.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.c,v
retrieving revision 1.42
diff -u -p -r1.42 ip_divert.c
--- netinet/ip_divert.c 25 Jan 2017 17:34:31 -0000 1.42
+++ netinet/ip_divert.c 26 Jan 2017 15:33:04 -0000
@@ -71,12 +71,6 @@ divert_init(void)
in_pcbinit(&divbtable, divbhashsize);
}
-void
-divert_input(struct mbuf *m, int iphlen, int proto)
-{
- m_freem(m);
-}
-
int
divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
struct mbuf *control)
Index: netinet/ip_ether.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ether.c,v
retrieving revision 1.82
diff -u -p -r1.82 ip_ether.c
--- netinet/ip_ether.c 25 Jan 2017 17:34:31 -0000 1.82
+++ netinet/ip_ether.c 26 Jan 2017 14:33:58 -0000
@@ -86,51 +86,16 @@ struct etheripstat etheripstat;
/*
* etherip_input gets called when we receive an encapsulated packet.
- * Only a wrapper for the IPv4 case.
*/
-void
-etherip_input(struct mbuf *m, int iphlen, int proto)
-{
- struct ip *ip;
-
- ip = mtod(m, struct ip *);
-
- switch (ip->ip_p) {
-#if NBRIDGE > 0
- case IPPROTO_ETHERIP:
- /* If we do not accept EtherIP explicitly, drop. */
- if (!etherip_allow && (m->m_flags & (M_AUTH|M_CONF)) == 0) {
- DPRINTF(("etherip_input(): dropped due to policy\n"));
- etheripstat.etherip_pdrops++;
- m_freem(m);
- return;
- }
- etherip_decap(m, iphlen);
- return;
-#endif
-#ifdef MPLS
- case IPPROTO_MPLS:
- mplsip_decap(m, iphlen);
- return;
-#endif
- default:
- DPRINTF(("etherip_input(): dropped, unhandled protocol\n"));
- etheripstat.etherip_pdrops++;
- m_freem(m);
- return;
- }
-}
-
-#ifdef INET6
int
-etherip_input6(struct mbuf **mp, int *offp, int proto)
+etherip_input(struct mbuf **mp, int *offp, int proto)
{
switch (proto) {
#if NBRIDGE > 0
case IPPROTO_ETHERIP:
/* If we do not accept EtherIP explicitly, drop. */
if (!etherip_allow && ((*mp)->m_flags & (M_AUTH|M_CONF)) == 0) {
- DPRINTF(("etherip_input6(): dropped due to policy\n"));
+ DPRINTF(("etherip_input(): dropped due to policy\n"));
etheripstat.etherip_pdrops++;
m_freem(*mp);
return IPPROTO_DONE;
@@ -144,13 +109,12 @@ etherip_input6(struct mbuf **mp, int *of
return IPPROTO_DONE;
#endif
default:
- DPRINTF(("etherip_input6(): dropped, unhandled protocol\n"));
+ DPRINTF(("etherip_input(): dropped, unhandled protocol\n"));
etheripstat.etherip_pdrops++;
m_freem(*mp);
return IPPROTO_DONE;
}
}
-#endif
#if NBRIDGE > 0
void
Index: netinet/ip_ether.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ether.h,v
retrieving revision 1.19
diff -u -p -r1.19 ip_ether.h
--- netinet/ip_ether.h 25 Jan 2017 17:34:31 -0000 1.19
+++ netinet/ip_ether.h 26 Jan 2017 14:42:20 -0000
@@ -72,10 +72,7 @@ struct etherip_header {
struct tdb;
int etherip_output(struct mbuf *, struct tdb *, struct mbuf **, int);
-void etherip_input(struct mbuf *, int, int);
-#ifdef INET6
-int etherip_input6(struct mbuf **, int *, int);
-#endif
+int etherip_input(struct mbuf **, int *, int);
int etherip_sysctl(int *, u_int, void *, size_t *, void *, size_t);
extern int etherip_allow;
Index: netinet/ip_gre.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_gre.c,v
retrieving revision 1.61
diff -u -p -r1.61 ip_gre.c
--- netinet/ip_gre.c 25 Jan 2017 17:34:31 -0000 1.61
+++ netinet/ip_gre.c 26 Jan 2017 13:50:31 -0000
@@ -215,14 +215,16 @@ gre_input2(struct mbuf *m, int hlen, int
* routine is called whenever IP gets a packet with proto type
* IPPROTO_GRE and a local destination address).
*/
-void
-gre_input(struct mbuf *m, int hlen, int proto)
+int
+gre_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
+ int hlen = *offp;
int ret;
if (!gre_allow) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
#ifdef PIPEX
@@ -231,7 +233,7 @@ gre_input(struct mbuf *m, int hlen, int
if ((session = pipex_pptp_lookup_session(m)) != NULL) {
if (pipex_pptp_input(m, session) == NULL)
- return;
+ return IPPROTO_DONE;
}
}
#endif
@@ -245,7 +247,8 @@ gre_input(struct mbuf *m, int hlen, int
* but we're not set to accept them.
*/
if (!ret)
- rip_input(m, hlen, proto);
+ return rip_input(mp, offp, proto);
+ return IPPROTO_DONE;
}
/*
@@ -255,9 +258,10 @@ gre_input(struct mbuf *m, int hlen, int
* between IP header and payload.
*/
-void
-gre_mobile_input(struct mbuf *m, int hlen, int proto)
+int
+gre_mobile_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct ip *ip;
struct mobip_h *mip;
struct gre_softc *sc;
@@ -266,19 +270,19 @@ gre_mobile_input(struct mbuf *m, int hle
if (!ip_mobile_allow) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
if ((sc = gre_lookup(m, proto)) == 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 *);
@@ -298,7 +302,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 *);
}
@@ -308,7 +312,7 @@ gre_mobile_input(struct mbuf *m, int hle
if (gre_in_cksum((u_short *) &mip->mh, msiz) != 0) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
memmove(ip + (ip->ip_hl << 2), ip + (ip->ip_hl << 2) + msiz,
@@ -331,6 +335,7 @@ gre_mobile_input(struct mbuf *m, int hle
#endif
niq_enqueue(&ipintrq, m);
+ return IPPROTO_DONE;
}
/*
Index: netinet/ip_gre.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_gre.h,v
retrieving revision 1.10
diff -u -p -r1.10 ip_gre.h
--- netinet/ip_gre.h 25 Jan 2017 17:34:31 -0000 1.10
+++ netinet/ip_gre.h 26 Jan 2017 13:49:55 -0000
@@ -64,12 +64,10 @@
}
#ifdef _KERNEL
-void gre_input(struct mbuf *, int, int);
-void gre_mobile_input(struct mbuf *, int, int);
-
+int gre_input(struct mbuf **, int *, int);
+int gre_mobile_input(struct mbuf **, int *, int);
int ipmobile_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int gre_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int gre_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct
mbuf *, struct proc *);
-
#endif /* _KERNEL */
#endif /* _NETINET_IP_GRE_H_ */
Index: netinet/ip_icmp.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.161
diff -u -p -r1.161 ip_icmp.c
--- netinet/ip_icmp.c 26 Jan 2017 13:03:47 -0000 1.161
+++ netinet/ip_icmp.c 26 Jan 2017 14:02:11 -0000
@@ -128,7 +128,7 @@ int *icmpctl_vars[ICMPCTL_MAXID] = ICMPC
void icmp_mtudisc_timeout(struct rtentry *, struct rttimer *);
int icmp_ratelimit(const struct in_addr *, const int, const int);
void icmp_redirect_timeout(struct rtentry *, struct rttimer *);
-void icmp_input_if(struct ifnet *, struct mbuf *, int, int);
+int icmp_input_if(struct ifnet *, struct mbuf **, int *, int);
void
icmp_init(void)
@@ -303,24 +303,27 @@ icmp_error(struct mbuf *n, int type, int
/*
* Process a received ICMP message.
*/
-void
-icmp_input(struct mbuf *m, int hlen, int proto)
+int
+icmp_input(struct mbuf **mp, int *offp, int proto)
{
struct ifnet *ifp;
- ifp = if_get(m->m_pkthdr.ph_ifidx);
+ ifp = if_get((*mp)->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
- m_freem(m);
- return;
+ m_freem(*mp);
+ return IPPROTO_DONE;
}
- icmp_input_if(ifp, m, hlen, proto);
+ proto = icmp_input_if(ifp, mp, offp, proto);
if_put(ifp);
+ return proto;
}
-void
-icmp_input_if(struct ifnet *ifp, struct mbuf *m, int hlen, int proto)
+int
+icmp_input_if(struct ifnet *ifp, struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
+ int hlen = *offp;
struct icmp *icp;
struct ip *ip = mtod(m, struct ip *);
struct sockaddr_in sin;
@@ -351,7 +354,7 @@ icmp_input_if(struct ifnet *ifp, struct
i = hlen + min(icmplen, ICMP_ADVLENMIN);
if (m->m_len < i && (m = m_pullup(m, i)) == NULL) {
icmpstat.icps_tooshort++;
- return;
+ return IPPROTO_DONE;
}
ip = mtod(m, struct ip *);
if (in4_cksum(m, 0, hlen, icmplen)) {
@@ -474,7 +477,7 @@ icmp_input_if(struct ifnet *ifp, struct
if ((m = m_pullup(m, (ip->ip_hl << 2) +
ICMP_V6ADVLEN(icp))) == NULL) {
icmpstat.icps_tooshort++;
- return;
+ return IPPROTO_DONE;
}
ip = mtod(m, struct ip *);
icp = (struct icmp *)
@@ -588,7 +591,7 @@ reflect:
icmpstat.icps_outhist[icp->icmp_type]++;
if (!icmp_reflect(m, &opts, NULL))
icmp_send(m, opts);
- return;
+ return IPPROTO_DONE;
case ICMP_REDIRECT:
{
@@ -680,11 +683,11 @@ reflect:
}
raw:
- rip_input(m, hlen, proto);
- return;
+ return rip_input(mp, offp, proto);
freeit:
m_freem(m);
+ return IPPROTO_DONE;
}
/*
Index: netinet/ip_icmp.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_icmp.h,v
retrieving revision 1.28
diff -u -p -r1.28 ip_icmp.h
--- netinet/ip_icmp.h 25 Jan 2017 17:34:31 -0000 1.28
+++ netinet/ip_icmp.h 26 Jan 2017 14:00:01 -0000
@@ -232,7 +232,7 @@ struct icmp_ext_obj_hdr {
struct mbuf *
icmp_do_error(struct mbuf *, int, int, u_int32_t, int);
void icmp_error(struct mbuf *, int, int, u_int32_t, int);
-void icmp_input(struct mbuf *, int, int);
+int icmp_input(struct mbuf **, int *, int);
void icmp_init(void);
int icmp_reflect(struct mbuf *, struct mbuf **, struct in_ifaddr *);
void icmp_send(struct mbuf *, struct mbuf *);
Index: netinet/ip_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.292
diff -u -p -r1.292 ip_input.c
--- netinet/ip_input.c 25 Jan 2017 17:34:31 -0000 1.292
+++ netinet/ip_input.c 26 Jan 2017 13:17:37 -0000
@@ -584,7 +584,7 @@ found:
* Switch out to protocol's input routine.
*/
ipstat_inc(ips_delivered);
- (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen, ip->ip_p);
+ (*inetsw[ip_protox[ip->ip_p]].pr_input)(&m, &hlen, ip->ip_p);
return;
bad:
m_freem(m);
Index: netinet/ip_ipip.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipip.c,v
retrieving revision 1.70
diff -u -p -r1.70 ip_ipip.c
--- netinet/ip_ipip.c 25 Jan 2017 17:34:31 -0000 1.70
+++ netinet/ip_ipip.c 26 Jan 2017 14:29:09 -0000
@@ -86,45 +86,21 @@ int ipip_allow = 0;
struct ipipstat ipipstat;
-#ifdef INET6
/*
- * Really only a wrapper for ipip_input(), for use with IPv6.
+ * Really only a wrapper for ipip_input(), for use with pr_input.
*/
int
-ip4_input6(struct mbuf **mp, int *offp, int proto)
+ip4_input(struct mbuf **mp, int *offp, int proto)
{
/* If we do not accept IP-in-IP explicitly, drop. */
if (!ipip_allow && ((*mp)->m_flags & (M_AUTH|M_CONF)) == 0) {
- DPRINTF(("ip4_input6(): dropped due to policy\n"));
+ DPRINTF(("ip4_input(): dropped due to policy\n"));
ipipstat.ipips_pdrops++;
m_freem(*mp);
return IPPROTO_DONE;
}
- ipip_input(*mp, *offp, NULL, proto);
- return IPPROTO_DONE;
-}
-#endif /* INET6 */
-
-/*
- * Really only a wrapper for ipip_input(), for use with IPv4.
- */
-void
-ip4_input(struct mbuf *m, int iphlen, int proto)
-{
- struct ip *ip;
-
- /* If we do not accept IP-in-IP explicitly, drop. */
- if (!ipip_allow && (m->m_flags & (M_AUTH|M_CONF)) == 0) {
- DPRINTF(("ip4_input(): dropped due to policy\n"));
- ipipstat.ipips_pdrops++;
- m_freem(m);
- return;
- }
-
- ip = mtod(m, struct ip *);
-
- ipip_input(m, iphlen, NULL, ip->ip_p);
+ return ipip_input(mp, offp, NULL, proto);
}
/*
@@ -135,9 +111,11 @@ ip4_input(struct mbuf *m, int iphlen, in
* tunnel.
*/
-void
-ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp, int proto)
+int
+ipip_input(struct mbuf **mp, int *offp, struct ifnet *gifp, int proto)
{
+ struct mbuf *m = *mp;
+ int iphlen = *offp;
struct sockaddr_in *sin;
struct ifnet *ifp;
struct niqueue *ifq = NULL;
@@ -167,7 +145,7 @@ ipip_input(struct mbuf *m, int iphlen, s
default:
ipipstat.ipips_family++;
m_freem(m);
- return /* EAFNOSUPPORT */;
+ return IPPROTO_DONE;
}
/* Bring the IP header in the first mbuf, if not there already */
@@ -175,7 +153,7 @@ ipip_input(struct mbuf *m, int iphlen, s
if ((m = m_pullup(m, hlen)) == NULL) {
DPRINTF(("ipip_input(): m_pullup() failed\n"));
ipipstat.ipips_hdrops++;
- return;
+ return IPPROTO_DONE;
}
}
@@ -203,7 +181,7 @@ ipip_input(struct mbuf *m, int iphlen, s
if (m->m_pkthdr.len < sizeof(struct ip)) {
ipipstat.ipips_hdrops++;
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
switch (proto) {
@@ -219,7 +197,7 @@ ipip_input(struct mbuf *m, int iphlen, s
default:
ipipstat.ipips_family++;
m_freem(m);
- return; /* EAFNOSUPPORT */
+ return IPPROTO_DONE;
}
/*
@@ -229,7 +207,7 @@ ipip_input(struct mbuf *m, int iphlen, s
if ((m = m_pullup(m, hlen)) == NULL) {
DPRINTF(("ipip_input(): m_pullup() failed\n"));
ipipstat.ipips_hdrops++;
- return;
+ return IPPROTO_DONE;
}
}
@@ -253,7 +231,7 @@ ipip_input(struct mbuf *m, int iphlen, s
DPRINTF(("ipip_input(): ip_ecn_egress() failed"));
ipipstat.ipips_pdrops++;
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
/* re-calculate the checksum if ip_tos was changed */
if (itos != ipo->ip_tos) {
@@ -273,7 +251,7 @@ ipip_input(struct mbuf *m, int iphlen, s
DPRINTF(("ipip_input(): ip_ecn_egress() failed"));
ipipstat.ipips_pdrops++;
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
ip6->ip6_flow &= ~htonl(0xff << 20);
ip6->ip6_flow |= htonl((u_int32_t) itos << 20);
@@ -316,7 +294,7 @@ ipip_input(struct mbuf *m, int iphlen, s
ipipstat.ipips_spoof++;
m_freem(m);
rtfree(rt);
- return;
+ return IPPROTO_DONE;
}
rtfree(rt);
} else {
@@ -361,8 +339,8 @@ ipip_input(struct mbuf *m, int iphlen, s
ipipstat.ipips_qfull++;
DPRINTF(("ipip_input(): packet dropped because of full "
"queue\n"));
- return;
}
+ return IPPROTO_DONE;
}
int
Index: netinet/ip_ipsp.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_ipsp.h,v
retrieving revision 1.176
diff -u -p -r1.176 ip_ipsp.h
--- netinet/ip_ipsp.h 26 Jan 2017 13:03:47 -0000 1.176
+++ netinet/ip_ipsp.h 26 Jan 2017 15:00:55 -0000
@@ -475,14 +475,10 @@ int ipe4_attach(void);
int ipe4_init(struct tdb *, struct xformsw *, struct ipsecinit *);
int ipe4_zeroize(struct tdb *);
void ipe4_input(struct mbuf *, int, int);
-void ipip_input(struct mbuf *, int, struct ifnet *, int);
+int ipip_input(struct mbuf **, int *, struct ifnet *, int);
int ipip_output(struct mbuf *, struct tdb *, struct mbuf **, int, int);
-void ip4_input(struct mbuf *, int, int);
-
-#ifdef INET6
-int ip4_input6(struct mbuf **, int *, int);
-#endif /* INET6 */
+int ip4_input(struct mbuf **, int *, int);
/* XF_AH */
int ah_attach(void);
@@ -492,7 +488,7 @@ int ah_input(struct mbuf *, struct tdb *
int ah_output(struct mbuf *, struct tdb *, struct mbuf **, int, int);
int ah_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-void ah4_input(struct mbuf *, int, int);
+int ah4_input(struct mbuf **, int *, int);
void ah4_ctlinput(int, struct sockaddr *, u_int, void *);
void udpencap_ctlinput(int, struct sockaddr *, u_int, void *);
@@ -508,7 +504,7 @@ int esp_input(struct mbuf *, struct tdb
int esp_output(struct mbuf *, struct tdb *, struct mbuf **, int, int);
int esp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-void esp4_input(struct mbuf *, int, int);
+int esp4_input(struct mbuf **, int *, int);
void esp4_ctlinput(int, struct sockaddr *, u_int, void *);
#ifdef INET6
@@ -522,9 +518,7 @@ int ipcomp_zeroize(struct tdb *);
int ipcomp_input(struct mbuf *, struct tdb *, int, int);
int ipcomp_output(struct mbuf *, struct tdb *, struct mbuf **, int, int);
int ipcomp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-
-void ipcomp4_input(struct mbuf *, int, int);
-
+int ipcomp4_input(struct mbuf **, int *, int);
#ifdef INET6
int ipcomp6_input(struct mbuf **, int *, int);
#endif /* INET6 */
Index: netinet/ip_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.66
diff -u -p -r1.66 ip_var.h
--- netinet/ip_var.h 25 Jan 2017 17:34:31 -0000 1.66
+++ netinet/ip_var.h 26 Jan 2017 13:51:03 -0000
@@ -252,7 +252,7 @@ void ipv4_input(struct mbuf *);
void ip_forward(struct mbuf *, struct ifnet *, struct rtentry *, int);
int rip_ctloutput(int, struct socket *, int, int, struct mbuf **);
void rip_init(void);
-void rip_input(struct mbuf *, int, int);
+int rip_input(struct mbuf **, int *, int);
int rip_output(struct mbuf *, ...);
int rip_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
Index: netinet/ipsec_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ipsec_input.c,v
retrieving revision 1.140
diff -u -p -r1.140 ipsec_input.c
--- netinet/ipsec_input.c 26 Jan 2017 13:03:47 -0000 1.140
+++ netinet/ipsec_input.c 26 Jan 2017 15:02:40 -0000
@@ -148,7 +148,7 @@ ipsec_common_input(struct mbuf *m, int s
(sproto == IPPROTO_IPCOMP && !ipcomp_enable)) {
switch (af) {
case AF_INET:
- rip_input(m, skip, sproto);
+ rip_input(&m, &skip, sproto);
break;
#ifdef INET6
case AF_INET6:
@@ -696,12 +696,12 @@ ipcomp_sysctl(int *name, u_int namelen,
}
/* IPv4 AH wrapper. */
-void
-ah4_input(struct mbuf *m, int skip, int proto)
+int
+ah4_input(struct mbuf **mp, int *offp, int proto)
{
- ipsec_common_input(m, skip, offsetof(struct ip, ip_p), AF_INET,
- IPPROTO_AH, 0);
- return;
+ ipsec_common_input(*mp, *offp, offsetof(struct ip, ip_p), AF_INET,
+ proto, 0);
+ return IPPROTO_DONE;
}
/* IPv4 AH callback. */
@@ -736,11 +736,12 @@ ah4_ctlinput(int cmd, struct sockaddr *s
}
/* IPv4 ESP wrapper. */
-void
-esp4_input(struct mbuf *m, int skip, int proto)
+int
+esp4_input(struct mbuf **mp, int *offp, int proto)
{
- ipsec_common_input(m, skip, offsetof(struct ip, ip_p), AF_INET,
- IPPROTO_ESP, 0);
+ ipsec_common_input(*mp, *offp, offsetof(struct ip, ip_p), AF_INET,
+ proto, 0);
+ return IPPROTO_DONE;
}
/* IPv4 ESP callback. */
@@ -762,11 +763,12 @@ esp4_input_cb(struct mbuf *m, ...)
}
/* IPv4 IPCOMP wrapper */
-void
-ipcomp4_input(struct mbuf *m, int skip, int proto)
+int
+ipcomp4_input(struct mbuf **mp, int *offp, int proto)
{
- ipsec_common_input(m, skip, offsetof(struct ip, ip_p), AF_INET,
- IPPROTO_IPCOMP, 0);
+ ipsec_common_input(*mp, *offp, offsetof(struct ip, ip_p), AF_INET,
+ proto, 0);
+ return IPPROTO_DONE;
}
/* IPv4 IPCOMP callback */
Index: netinet/raw_ip.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.93
diff -u -p -r1.93 raw_ip.c
--- netinet/raw_ip.c 25 Jan 2017 17:34:31 -0000 1.93
+++ netinet/raw_ip.c 26 Jan 2017 14:02:55 -0000
@@ -115,9 +115,10 @@ rip_init(void)
struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
-void
-rip_input(struct mbuf *m, int hlen, int proto)
+int
+rip_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
struct ip *ip = mtod(m, struct ip *);
struct inpcb *inp, *last = NULL;
struct mbuf *opts = NULL;
@@ -198,6 +199,7 @@ rip_input(struct mbuf *m, int hlen, int
counters[ips_delivered]--;
counters_leave(&ref, ipcounters);
}
+ return IPPROTO_DONE;
}
/*
Index: netinet/tcp_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.336
diff -u -p -r1.336 tcp_input.c
--- netinet/tcp_input.c 25 Jan 2017 17:34:31 -0000 1.336
+++ netinet/tcp_input.c 26 Jan 2017 13:32:14 -0000
@@ -351,24 +351,15 @@ tcp_flush_queue(struct tcpcb *tp)
return (flags);
}
-#ifdef INET6
-int
-tcp6_input(struct mbuf **mp, int *offp, int proto)
-{
- struct mbuf *m = *mp;
-
- tcp_input(m, *offp, proto);
- return IPPROTO_DONE;
-}
-#endif
-
/*
* TCP input routine, follows pages 65-76 of the
* protocol specification dated September, 1981 very closely.
*/
-void
-tcp_input(struct mbuf *m, int iphlen, int proto)
+int
+tcp_input(struct mbuf **mp, int *offp, int proto)
{
+ struct mbuf *m = *mp;
+ int iphlen = *offp;
struct ip *ip;
struct inpcb *inp = NULL;
u_int8_t *optp = NULL;
@@ -424,7 +415,7 @@ tcp_input(struct mbuf *m, int iphlen, in
break;
default:
m_freem(m);
- return; /*EAFNOSUPPORT*/
+ return IPPROTO_DONE;
}
/*
@@ -436,7 +427,7 @@ tcp_input(struct mbuf *m, int iphlen, in
#ifdef DIAGNOSTIC
if (iphlen < sizeof(struct ip)) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
#endif /* DIAGNOSTIC */
break;
@@ -445,20 +436,20 @@ tcp_input(struct mbuf *m, int iphlen, in
#ifdef DIAGNOSTIC
if (iphlen < sizeof(struct ip6_hdr)) {
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
#endif /* DIAGNOSTIC */
break;
#endif
default:
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
IP6_EXTHDR_GET(th, struct tcphdr *, m, iphlen, sizeof(*th));
if (!th) {
tcpstat.tcps_rcvshort++;
- return;
+ return IPPROTO_DONE;
}
tlen = m->m_pkthdr.len - iphlen;
@@ -552,7 +543,7 @@ tcp_input(struct mbuf *m, int iphlen, in
IP6_EXTHDR_GET(th, struct tcphdr *, m, iphlen, off);
if (!th) {
tcpstat.tcps_rcvshort++;
- return;
+ return IPPROTO_DONE;
}
optlen = off - sizeof(struct tcphdr);
optp = (u_int8_t *)(th + 1);
@@ -874,7 +865,7 @@ findpcb:
tcpstat.tcps_dropsyn++;
goto drop;
}
- return;
+ return IPPROTO_DONE;
}
}
}
@@ -1067,7 +1058,7 @@ findpcb:
if (so->so_snd.sb_cc ||
tp->t_flags & TF_NEEDOUTPUT)
(void) tcp_output(tp);
- return;
+ return IPPROTO_DONE;
}
} else if (th->th_ack == tp->snd_una &&
TAILQ_EMPTY(&tp->t_segq) &&
@@ -1114,7 +1105,7 @@ findpcb:
tp->t_flags &= ~TF_BLOCKOUTPUT;
if (tp->t_flags & (TF_ACKNOW|TF_NEEDOUTPUT))
(void) tcp_output(tp);
- return;
+ return IPPROTO_DONE;
}
}
@@ -2167,7 +2158,7 @@ dodata:
/* XXX */
*/
if (tp->t_flags & (TF_ACKNOW|TF_NEEDOUTPUT))
(void) tcp_output(tp);
- return;
+ return IPPROTO_DONE;
badsyn:
/*
@@ -2195,7 +2186,7 @@ dropafterack:
m_freem(m);
tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
- return;
+ return IPPROTO_DONE;
dropwithreset_ratelim:
/*
@@ -2229,7 +2220,7 @@ dropwithreset:
(tcp_seq)0, TH_RST|TH_ACK, m->m_pkthdr.ph_rtableid);
}
m_freem(m);
- return;
+ return IPPROTO_DONE;
drop:
/*
@@ -2251,7 +2242,7 @@ drop:
}
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
int
Index: netinet/tcp_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_var.h,v
retrieving revision 1.119
diff -u -p -r1.119 tcp_var.h
--- netinet/tcp_var.h 26 Jan 2017 13:03:47 -0000 1.119
+++ netinet/tcp_var.h 26 Jan 2017 13:26:46 -0000
@@ -610,10 +610,7 @@ struct tcpcb *
int tcp_dooptions(struct tcpcb *, u_char *, int, struct tcphdr *,
struct mbuf *, int, struct tcp_opt_info *, u_int);
void tcp_init(void);
-#ifdef INET6
-int tcp6_input(struct mbuf **, int *, int);
-#endif
-void tcp_input(struct mbuf *, int, int);
+int tcp_input(struct mbuf **, int *, int);
int tcp_mss(struct tcpcb *, int);
void tcp_mss_update(struct tcpcb *);
u_int tcp_hdrsz(struct tcpcb *);
Index: netinet/udp_usrreq.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.228
diff -u -p -r1.228 udp_usrreq.c
--- netinet/udp_usrreq.c 26 Jan 2017 13:03:47 -0000 1.228
+++ netinet/udp_usrreq.c 26 Jan 2017 13:25:14 -0000
@@ -147,20 +147,11 @@ udp_init(void)
in_pcbinit(&udbtable, UDB_INITIAL_HASH_SIZE);
}
-#ifdef INET6
int
-udp6_input(struct mbuf **mp, int *offp, int proto)
+udp_input(struct mbuf **mp, int *offp, int proto)
{
struct mbuf *m = *mp;
-
- udp_input(m, *offp, proto);
- return IPPROTO_DONE;
-}
-#endif
-
-void
-udp_input(struct mbuf *m, int iphlen, int proto)
-{
+ int iphlen = *offp;
struct ip *ip;
struct udphdr *uh;
struct inpcb *inp = NULL;
@@ -218,7 +209,7 @@ udp_input(struct mbuf *m, int iphlen, in
IP6_EXTHDR_GET(uh, struct udphdr *, m, iphlen, sizeof(struct udphdr));
if (!uh) {
udpstat_inc(udps_hdrops);
- return;
+ return IPPROTO_DONE;
}
/* Check for illegal destination port 0 */
@@ -324,7 +315,7 @@ udp_input(struct mbuf *m, int iphlen, in
if (m->m_pkthdr.len - skip < sizeof(u_int32_t)) {
/* packet too short */
m_freem(m);
- return;
+ return IPPROTO_DONE;
}
m_copydata(m, skip, sizeof(u_int32_t), (caddr_t) &spi);
/*
@@ -334,7 +325,7 @@ udp_input(struct mbuf *m, int iphlen, in
if (spi != 0) {
if ((m = m_pullup(m, skip)) == NULL) {
udpstat_inc(udps_hdrops);
- return;
+ return IPPROTO_DONE;
}
/* remove the UDP header */
@@ -346,7 +337,7 @@ udp_input(struct mbuf *m, int iphlen, in
espstat.esps_udpencin++;
ipsec_common_input(m, skip, protoff,
srcsa.sa.sa_family, IPPROTO_ESP, 1);
- return;
+ return IPPROTO_DONE;
}
}
#endif
@@ -396,7 +387,7 @@ udp_input(struct mbuf *m, int iphlen, in
!(m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) &&
#endif
vxlan_lookup(m, uh, iphlen, &srcsa.sa, &dstsa.sa) != 0)
- return;
+ return IPPROTO_DONE;
#endif
if (m->m_flags & (M_BCAST|M_MCAST)) {
@@ -548,7 +539,7 @@ udp_input(struct mbuf *m, int iphlen, in
goto bad;
}
sorwakeup(last->inp_socket);
- return;
+ return IPPROTO_DONE;
}
/*
* Locate pcb for datagram.
@@ -601,7 +592,7 @@ udp_input(struct mbuf *m, int iphlen, in
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT,
0, 0);
}
- return;
+ return IPPROTO_DONE;
}
}
KASSERT(sotoinpcb(inp->inp_socket) == inp);
@@ -686,7 +677,8 @@ udp_input(struct mbuf *m, int iphlen, in
if ((m = pipex_l2tp_input(m, off, session,
ipsecflowinfo)) == NULL) {
m_freem(opts);
- return; /* the packet is handled by PIPEX */
+ /* the packet is handled by PIPEX */
+ return IPPROTO_DONE;
}
}
}
@@ -699,10 +691,11 @@ udp_input(struct mbuf *m, int iphlen, in
goto bad;
}
sorwakeup(inp->inp_socket);
- return;
+ return IPPROTO_DONE;
bad:
m_freem(m);
m_freem(opts);
+ return IPPROTO_DONE;
}
/*
Index: netinet/udp_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/udp_var.h,v
retrieving revision 1.30
diff -u -p -r1.30 udp_var.h
--- netinet/udp_var.h 26 Jan 2017 13:03:47 -0000 1.30
+++ netinet/udp_var.h 26 Jan 2017 13:20:08 -0000
@@ -138,11 +138,10 @@ extern struct udpstat udpstat;
#ifdef INET6
void udp6_ctlinput(int, struct sockaddr *, u_int, void *);
-int udp6_input(struct mbuf **, int *, int);
#endif /* INET6 */
void udp_ctlinput(int, struct sockaddr *, u_int, void *);
void udp_init(void);
-void udp_input(struct mbuf *, int, int);
+int udp_input(struct mbuf **, int *, int);
#ifdef INET6
int udp6_output(struct inpcb *, struct mbuf *, struct mbuf *,
struct mbuf *);
Index: netinet6/in6_proto.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_proto.c,v
retrieving revision 1.87
diff -u -p -r1.87 in6_proto.c
--- netinet6/in6_proto.c 22 Dec 2016 11:04:44 -0000 1.87
+++ netinet6/in6_proto.c 26 Jan 2017 15:36:34 -0000
@@ -121,7 +121,7 @@
*/
u_char ip6_protox[IPPROTO_MAX];
-struct ip6protosw inet6sw[] = {
+struct protosw inet6sw[] = {
{ 0, &inet6domain, IPPROTO_IPV6, 0,
0, 0, 0, 0,
0,
@@ -129,13 +129,13 @@ struct ip6protosw inet6sw[] = {
ip6_sysctl,
},
{ SOCK_DGRAM, &inet6domain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR|PR_SPLICE,
- udp6_input, 0, udp6_ctlinput, ip6_ctloutput,
+ udp_input, 0, udp6_ctlinput, ip6_ctloutput,
udp_usrreq, 0,
0, 0, 0,
udp_sysctl,
},
{ SOCK_STREAM, &inet6domain, IPPROTO_TCP,
PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE,
- tcp6_input, 0, tcp6_ctlinput, tcp_ctloutput,
+ tcp_input, 0, tcp6_ctlinput, tcp_ctloutput,
tcp_usrreq,
0, 0, 0, 0,
tcp_sysctl,
@@ -188,7 +188,7 @@ struct ip6protosw inet6sw[] = {
#endif /* IPSEC */
#if NGIF > 0
{ SOCK_RAW, &inet6domain, IPPROTO_ETHERIP,PR_ATOMIC|PR_ADDR,
- etherip_input6, rip6_output, 0, rip6_ctloutput,
+ etherip_input, rip6_output, 0, rip6_ctloutput,
rip6_usrreq,
0, 0, 0, 0, etherip_sysctl
},
@@ -204,12 +204,12 @@ struct ip6protosw inet6sw[] = {
},
#else /* NGIF */
{ SOCK_RAW, &inet6domain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
- ip4_input6, rip6_output, 0, rip6_ctloutput,
+ ip4_input, rip6_output, 0, rip6_ctloutput,
rip6_usrreq, /* XXX */
0, 0, 0, 0, ipip_sysctl
},
{ SOCK_RAW, &inet6domain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR,
- ip4_input6, rip6_output, 0, rip6_ctloutput,
+ ip4_input, rip6_output, 0, rip6_ctloutput,
rip6_usrreq, /* XXX */
0, 0, 0, 0,
},
@@ -223,7 +223,7 @@ struct ip6protosw inet6sw[] = {
#endif /* NCARP */
#if NPF > 0
{ SOCK_RAW, &inet6domain, IPPROTO_DIVERT, PR_ATOMIC|PR_ADDR,
- divert6_input, 0, 0, rip6_ctloutput,
+ 0, 0, 0, rip6_ctloutput,
divert6_usrreq,
divert6_init, 0, 0, 0,
divert6_sysctl
},
Index: netinet6/ip6_divert.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_divert.c,v
retrieving revision 1.43
diff -u -p -r1.43 ip6_divert.c
--- netinet6/ip6_divert.c 19 Dec 2016 08:36:50 -0000 1.43
+++ netinet6/ip6_divert.c 26 Jan 2017 15:33:16 -0000
@@ -74,14 +74,6 @@ divert6_init(void)
}
int
-divert6_input(struct mbuf **mp, int *offp, int proto)
-{
- m_freem(*mp);
-
- return (0);
-}
-
-int
divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
struct mbuf *control)
{
Index: netinet6/ip6_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.174
diff -u -p -r1.174 ip6_input.c
--- netinet6/ip6_input.c 27 Dec 2016 18:45:01 -0000 1.174
+++ netinet6/ip6_input.c 26 Jan 2017 15:36:19 -0000
@@ -138,16 +138,16 @@ static struct task ip6send_task =
void
ip6_init(void)
{
- struct ip6protosw *pr;
+ struct protosw *pr;
int i;
- pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
+ pr = pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
if (pr == NULL)
panic("ip6_init");
for (i = 0; i < IPPROTO_MAX; i++)
ip6_protox[i] = pr - inet6sw;
- for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
- pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
+ for (pr = inet6domain.dom_protosw;
+ pr < inet6domain.dom_protoswNPROTOSW; pr++)
if (pr->pr_domain->dom_family == PF_INET6 &&
pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW &&
pr->pr_protocol < IPPROTO_MAX)
@@ -920,8 +920,8 @@ ip6_unknown_opt(u_int8_t *optp, struct m
/*
* Create the "control" list for this pcb.
*
- * The routine will be called from upper layer handlers like tcp6_input().
- * Thus the routine assumes that the caller (tcp6_input) have already
+ * The routine will be called from upper layer handlers like udp_input().
+ * Thus the routine assumes that the caller (udp_input) have already
* called IP6_EXTHDR_CHECK() and all the extension headers are located in the
* very first mbuf on the mbuf chain.
* We may want to add some infinite loop prevention or sanity checks for
safety.
Index: netinet6/ip6protosw.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6protosw.h,v
retrieving revision 1.11
diff -u -p -r1.11 ip6protosw.h
--- netinet6/ip6protosw.h 26 Jan 2017 13:03:47 -0000 1.11
+++ netinet6/ip6protosw.h 26 Jan 2017 15:35:30 -0000
@@ -109,39 +109,9 @@ struct ip6ctlparam {
u_int8_t ip6c_nxt; /* final next header field */
};
-struct ip6protosw {
- short pr_type; /* socket type used for */
- struct domain *pr_domain; /* domain protocol a member of */
- short pr_protocol; /* protocol number */
- short pr_flags; /* see below */
-
-/* protocol-protocol hooks */
- /* input to protocol (from below) */
- int (*pr_input)(struct mbuf **, int *, int);
- /* output to protocol (from above) */
- int (*pr_output)(struct mbuf *, ...);
- /* control input (from below) */
- void (*pr_ctlinput)(int, struct sockaddr *, u_int, void *);
- /* control output (from above) */
- int (*pr_ctloutput)(int, struct socket *, int, int, struct mbuf **);
-
-/* user-protocol hook */
- /* user request: see list below */
- int (*pr_usrreq)(struct socket *, int, struct mbuf *,
- struct mbuf *, struct mbuf *, struct proc *);
-
-/* utility hooks */
- void (*pr_init)(void); /* initialization hook */
- void (*pr_fasttimo)(void); /* fast timeout (200ms) */
- void (*pr_slowtimo)(void); /* slow timeout (500ms) */
- void (*pr_drain)(void); /* flush any excess space possible */
- /* sysctl for protocol */
- int (*pr_sysctl)(int *, u_int, void *, size_t *, void *, size_t);
-};
-
#ifdef _KERNEL
extern u_char ip6_protox[];
-extern struct ip6protosw inet6sw[];
+extern struct protosw inet6sw[];
#endif
#endif /* !_NETINET6_IP6PROTOSW_H_ */
Index: sys/protosw.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/sys/protosw.h,v
retrieving revision 1.20
diff -u -p -r1.20 protosw.h
--- sys/protosw.h 26 Jan 2017 13:03:47 -0000 1.20
+++ sys/protosw.h 26 Jan 2017 13:12:45 -0000
@@ -69,7 +69,7 @@ struct protosw {
/* protocol-protocol hooks */
/* input to protocol (from below) */
- void (*pr_input)(struct mbuf *, int, int);
+ int (*pr_input)(struct mbuf **, int *, int);
/* output to protocol (from above) */
int (*pr_output)(struct mbuf *, ...);
/* control input (from below) */