summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-01-29 19:58:48 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-01-29 19:58:48 +0000
commit7223f05e6c91ce56146299f9a2e6e9db93e3ade1 (patch)
tree09baa99c6aef8f55356208e1d462f18d67f4cdf9 /sys
parentc78b4b356cd1c3037a4bcfbe38220c894d5c1c26 (diff)
Change the IPv4 pr_input function to the way IPv6 is implemented,
to get rid of struct ip6protosw and some wrapper functions. It is more consistent to have less different structures. The divert_input functions cannot be called anyway, so remove them. OK visa@ mpi@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_etherip.c31
-rw-r--r--sys/net/if_etherip.h2
-rw-r--r--sys/net/if_gif.c20
-rw-r--r--sys/net/if_gif.h4
-rw-r--r--sys/net/if_pfsync.c28
-rw-r--r--sys/net/if_pfsync.h4
-rw-r--r--sys/netinet/igmp.c41
-rw-r--r--sys/netinet/igmp_var.h4
-rw-r--r--sys/netinet/in_proto.c4
-rw-r--r--sys/netinet/ip_carp.c68
-rw-r--r--sys/netinet/ip_carp.h4
-rw-r--r--sys/netinet/ip_divert.c8
-rw-r--r--sys/netinet/ip_ether.c44
-rw-r--r--sys/netinet/ip_ether.h7
-rw-r--r--sys/netinet/ip_gre.c31
-rw-r--r--sys/netinet/ip_gre.h8
-rw-r--r--sys/netinet/ip_icmp.c33
-rw-r--r--sys/netinet/ip_icmp.h4
-rw-r--r--sys/netinet/ip_input.c4
-rw-r--r--sys/netinet/ip_ipip.c58
-rw-r--r--sys/netinet/ip_ipsp.h18
-rw-r--r--sys/netinet/ip_var.h4
-rw-r--r--sys/netinet/ipsec_input.c32
-rw-r--r--sys/netinet/raw_ip.c8
-rw-r--r--sys/netinet/tcp_input.c45
-rw-r--r--sys/netinet/tcp_var.h7
-rw-r--r--sys/netinet/udp_usrreq.c35
-rw-r--r--sys/netinet/udp_var.h5
-rw-r--r--sys/netinet6/in6_proto.c16
-rw-r--r--sys/netinet6/ip6_divert.c10
-rw-r--r--sys/netinet6/ip6_input.c14
-rw-r--r--sys/netinet6/ip6protosw.h34
-rw-r--r--sys/sys/protosw.h4
33 files changed, 260 insertions, 379 deletions
diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index 6268b3d6541..16328a5e3d8 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_etherip.c,v 1.13 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: if_etherip.c,v 1.14 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
@@ -404,9 +404,10 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
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, int proto)
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, &etherip_softc_list, sc_entry) {
@@ -452,26 +453,26 @@ ip_etherip_input(struct mbuf *m, int off, int proto)
* 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, int proto)
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, int proto)
ml_enqueue(&ml, m);
if_input(ifp, &ml);
+ return IPPROTO_DONE;
}
#ifdef INET6
@@ -569,7 +571,6 @@ ip6_etherip_input(struct mbuf **mp, int *offp, int proto)
{
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 *offp, int proto)
* 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 *offp, int proto)
#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 *offp, int proto)
ml_enqueue(&ml, m);
if_input(ifp, &ml);
-
return IPPROTO_DONE;
}
-
#endif /* INET6 */
int
diff --git a/sys/net/if_etherip.h b/sys/net/if_etherip.h
index 11f17336463..c9269dc9da0 100644
--- a/sys/net/if_etherip.h
+++ b/sys/net/if_etherip.h
@@ -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 *);
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 4befe57b117..db617bda88b 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.90 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: if_gif.c,v 1.91 2017/01/29 19:58:47 bluhm Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -715,9 +715,10 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf **m0)
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, int proto)
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 *offp, int proto)
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 */
diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h
index 182fd84fd77..f7d4a09ad8d 100644
--- a/sys/net/if_gif.h
+++ b/sys/net/if_gif.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.h,v 1.15 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: if_gif.h,v 1.16 2017/01/29 19:58:47 bluhm Exp $ */
/* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */
/*
@@ -49,7 +49,7 @@ extern LIST_HEAD(gif_softc_head, gif_softc) gif_softc_list;
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_ */
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 7ab3e1f1eb7..c118d6fa76a 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.243 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.244 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -634,16 +634,15 @@ pfsync_state_import(struct pfsync_state *sp, int flags)
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, int proto)
}
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, int proto)
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, int proto)
done:
m_freem(m);
+ return IPPROTO_DONE;
}
int
diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h
index 2c31bc6c0ee..572720be7cd 100644
--- a/sys/net/if_pfsync.h
+++ b/sys/net/if_pfsync.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.h,v 1.50 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: if_pfsync.h,v 1.51 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -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);
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 5e4d2a26bd3..ea76ca0b39f 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.61 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: igmp.c,v 1.62 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
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 mbuf *m, int iphlen, int proto)
* 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
diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h
index 33e32b180b9..4aeaebc5f9e 100644
--- a/sys/netinet/igmp_var.h
+++ b/sys/netinet/igmp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp_var.h,v 1.11 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: igmp_var.h,v 1.12 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */
/*
@@ -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);
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index ea67e5cb113..4d124afdc36 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_proto.c,v 1.71 2016/12/22 11:04:44 rzalamena Exp $ */
+/* $OpenBSD: in_proto.c,v 1.72 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@@ -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
},
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index dc28054a35a..fe96a4519ee 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.300 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.301 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -214,7 +214,10 @@ int carp_hmac_verify(struct carp_vhost_entry *, u_int32_t *,
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 *vhe, u_int32_t counter[2],
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 hlen, int proto)
* 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, struct mbuf *m, int hlen)
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, struct mbuf *m, int hlen)
("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, struct mbuf *m, int hlen)
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, struct mbuf *m, int hlen)
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, struct mbuf *m, int hlen)
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, struct mbuf *m, int *offp)
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, struct mbuf *m, int *offp)
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, struct mbuf *m, int *offp)
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, struct mbuf *m, int *offp)
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, struct mbuf *m, int *offp)
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 */
diff --git a/sys/netinet/ip_carp.h b/sys/netinet/ip_carp.h
index 8ec1979135a..dc68fbaf732 100644
--- a/sys/netinet/ip_carp.h
+++ b/sys/netinet/ip_carp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.h,v 1.39 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_carp.h,v 1.40 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -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);
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 1bdf3bf75fa..327f4268acb 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.c,v 1.42 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.43 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -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)
diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c
index 7ccfa42575b..d8213651e08 100644
--- a/sys/netinet/ip_ether.c
+++ b/sys/netinet/ip_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.c,v 1.82 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.83 2017/01/29 19:58:47 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
@@ -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 *offp, int proto)
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
diff --git a/sys/netinet/ip_ether.h b/sys/netinet/ip_ether.h
index 4aa03c15f7c..89b244ee863 100644
--- a/sys/netinet/ip_ether.h
+++ b/sys/netinet/ip_ether.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.h,v 1.19 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_ether.h,v 1.20 2017/01/29 19:58:47 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@adk.gr)
*
@@ -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;
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c
index 4f480767882..9fed51128f6 100644
--- a/sys/netinet/ip_gre.c
+++ b/sys/netinet/ip_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_gre.c,v 1.61 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.62 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -215,14 +215,16 @@ gre_input2(struct mbuf *m, int hlen, int proto)
* 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 proto)
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 proto)
* 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 proto)
* 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 hlen, int proto)
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 hlen, int proto)
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 hlen, int proto)
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 hlen, int proto)
#endif
niq_enqueue(&ipintrq, m);
+ return IPPROTO_DONE;
}
/*
diff --git a/sys/netinet/ip_gre.h b/sys/netinet/ip_gre.h
index c4394519c25..338764dfb84 100644
--- a/sys/netinet/ip_gre.h
+++ b/sys/netinet/ip_gre.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_gre.h,v 1.10 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_gre.h,v 1.11 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_gre.h,v 1.3 1998/10/07 23:33:02 thorpej Exp $ */
/*
@@ -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_ */
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index b75ed391bb2..792195d9cc0 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.161 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.162 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -128,7 +128,7 @@ int *icmpctl_vars[ICMPCTL_MAXID] = ICMPCTL_VARS;
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 code, u_int32_t dest, int destmtu)
/*
* 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 mbuf *m, int hlen, int proto)
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 mbuf *m, int hlen, int proto)
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;
}
/*
diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h
index 54fed25106f..04b02c33d18 100644
--- a/sys/netinet/ip_icmp.h
+++ b/sys/netinet/ip_icmp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.h,v 1.28 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_icmp.h,v 1.29 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_icmp.h,v 1.10 1996/02/13 23:42:28 christos Exp $ */
/*
@@ -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 *);
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index dbb9eed2566..07d6219c1aa 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.292 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_input.c,v 1.293 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -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);
diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c
index 138e225ef8a..528c96bd984 100644
--- a/sys/netinet/ip_ipip.c
+++ b/sys/netinet/ip_ipip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.c,v 1.70 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.71 2017/01/29 19:58:47 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -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, int proto)
* 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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
default:
ipipstat.ipips_family++;
m_freem(m);
- return; /* EAFNOSUPPORT */
+ return IPPROTO_DONE;
}
/*
@@ -229,7 +207,7 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
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, struct ifnet *gifp, int proto)
ipipstat.ipips_qfull++;
DPRINTF(("ipip_input(): packet dropped because of full "
"queue\n"));
- return;
}
+ return IPPROTO_DONE;
}
int
diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h
index 823dd78105e..1b42b3e66e7 100644
--- a/sys/netinet/ip_ipsp.h
+++ b/sys/netinet/ip_ipsp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.h,v 1.176 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.177 2017/01/29 19:58:47 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -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, int);
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, int);
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 */
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 003c6a75bb2..f1fd4e20754 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_var.h,v 1.66 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: ip_var.h,v 1.67 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@@ -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 *);
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 116b7bc77e2..c5952707aaa 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.140 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.141 2017/01/29 19:58:47 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -148,7 +148,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto,
(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, void *oldp, size_t *oldlenp, void *newp,
}
/* 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 *sa, u_int rdomain, void *v)
}
/* 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 */
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 5a02613ca4f..a9d55bfc7ea 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.93 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.94 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -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 proto)
counters[ips_delivered]--;
counters_leave(&ref, ipcounters);
}
+ return IPPROTO_DONE;
}
/*
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index c16afb14e3b..ecbd0008044 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.336 2017/01/25 17:34:31 bluhm Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.337 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -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, int proto)
break;
default:
m_freem(m);
- return; /*EAFNOSUPPORT*/
+ return IPPROTO_DONE;
}
/*
@@ -436,7 +427,7 @@ tcp_input(struct mbuf *m, int iphlen, int proto)
#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, int proto)
#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, int proto)
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
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 34fba69a0a0..fdf468af7d5 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_var.h,v 1.119 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.120 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@@ -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 *);
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 5039c60214f..6d94c7c0917 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.228 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.229 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -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, int proto)
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, int proto)
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, int proto)
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, int proto)
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, int proto)
!(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, int proto)
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, int proto)
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, int proto)
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, int proto)
goto bad;
}
sorwakeup(inp->inp_socket);
- return;
+ return IPPROTO_DONE;
bad:
m_freem(m);
m_freem(opts);
+ return IPPROTO_DONE;
}
/*
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index b5689307ac2..1194da4c42f 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_var.h,v 1.30 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: udp_var.h,v 1.31 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
@@ -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 *);
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 30fabede281..6fc03970f08 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_proto.c,v 1.87 2016/12/22 11:04:44 rzalamena Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.88 2017/01/29 19:58:47 bluhm Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -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
},
diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c
index fd435358b12..4e8bfb04e07 100644
--- a/sys/netinet6/ip6_divert.c
+++ b/sys/netinet6/ip6_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.c,v 1.43 2016/12/19 08:36:50 mpi Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.44 2017/01/29 19:58:47 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -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)
{
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index f52ad6f2095..5e7949f1065 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.174 2016/12/27 18:45:01 bluhm Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.175 2017/01/29 19:58:47 bluhm Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -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 mbuf *m, int off)
/*
* 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.
diff --git a/sys/netinet6/ip6protosw.h b/sys/netinet6/ip6protosw.h
index 7ae41cca75c..9b118916ec2 100644
--- a/sys/netinet6/ip6protosw.h
+++ b/sys/netinet6/ip6protosw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6protosw.h,v 1.11 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: ip6protosw.h,v 1.12 2017/01/29 19:58:47 bluhm Exp $ */
/* $KAME: ip6protosw.h,v 1.22 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -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_ */
diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h
index 6f6704ce376..2bc8a45329e 100644
--- a/sys/sys/protosw.h
+++ b/sys/sys/protosw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: protosw.h,v 1.20 2017/01/26 13:03:47 bluhm Exp $ */
+/* $OpenBSD: protosw.h,v 1.21 2017/01/29 19:58:47 bluhm Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
@@ -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) */