summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-04-10 13:58:21 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-04-10 13:58:21 +0000
commit250513adf3ae568c024bafdf3e845f1276740ad4 (patch)
tree77683efc78bd0dba266f3daef8e373a90f87e85d /sys/netinet
parenteef7b0919e36bece6c9cf91b19a2f5062a1acaa2 (diff)
replace the use of ifqueues for most input queues serviced by netisr
with niqueues. this change is so big because there's a lot of code that takes pointers to different input queues (eg, ether_input picks between ipv4, ipv6, pppoe, arp, and mpls input queues) and falls through to code to enqueue packets against the pointer. if i changed only one of the input queues id have to add sepearate code paths, one for ifqueues and one for niqueues in each of these places by flipping all these input queues at once i can keep the currently common code common. testing by mpi@ sthen@ and rafael zalamena ok mpi@ sthen@ claudio@ henning@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/if_ether.c16
-rw-r--r--sys/netinet/if_ether.h4
-rw-r--r--sys/netinet/in.h4
-rw-r--r--sys/netinet/ip_divert.c12
-rw-r--r--sys/netinet/ip_ether.c16
-rw-r--r--sys/netinet/ip_gre.c20
-rw-r--r--sys/netinet/ip_input.c24
-rw-r--r--sys/netinet/ip_ipip.c22
-rw-r--r--sys/netinet/ipsec_input.c39
9 files changed, 37 insertions, 120 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 1a66993b4dd..43a88e8843e 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.149 2015/03/24 12:58:43 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.150 2015/04/10 13:58:20 dlg Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -57,6 +57,7 @@
#include <net/if_dl.h>
#include <net/route.h>
#include <net/if_types.h>
+#include <net/netisr.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
@@ -97,7 +98,8 @@ void in_arpinput(struct mbuf *);
LIST_HEAD(, llinfo_arp) llinfo_arp;
struct pool arp_pool; /* pool for llinfo_arp structures */
-struct ifqueue arpintrq;
+/* XXX hate magic numbers */
+struct niqueue arpintrq = NIQUEUE_INITIALIZER(50, NETISR_ARP);
int arp_inuse, arp_allocated;
int arp_maxtries = 5;
int arpinit_done;
@@ -159,7 +161,6 @@ arp_rtrequest(int req, struct rtentry *rt)
arpinit_done = 1;
pool_init(&arp_pool, sizeof(struct llinfo_arp), 0, 0, 0, "arp",
NULL);
- IFQ_SET_MAXLEN(&arpintrq, 50); /* XXX hate magic numbers */
/*
* We generate expiration times from time.tv_sec
* so avoid accidently creating permanent routes.
@@ -497,14 +498,9 @@ arpintr(void)
{
struct mbuf *m;
struct arphdr *ar;
- int s, len;
+ int len;
- for (;;) {
- s = splnet();
- IF_DEQUEUE(&arpintrq, m);
- splx(s);
- if (m == NULL)
- break;
+ while ((m = niq_dequeue(&arpintrq)) != NULL) {
#ifdef DIAGNOSTIC
if ((m->m_flags & M_PKTHDR) == 0)
panic("arpintr");
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h
index 96760712c62..aa7394da822 100644
--- a/sys/netinet/if_ether.h
+++ b/sys/netinet/if_ether.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.h,v 1.55 2015/03/24 12:58:43 mpi Exp $ */
+/* $OpenBSD: if_ether.h,v 1.56 2015/04/10 13:58:20 dlg Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
@@ -188,7 +188,7 @@ struct sockaddr_inarp {
extern u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN];
extern u_int8_t ether_ipmulticast_min[ETHER_ADDR_LEN];
extern u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
-extern struct ifqueue arpintrq;
+extern struct niqueue arpintrq;
void arpwhohas(struct arpcom *, struct in_addr *);
void arpintr(void);
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 1319d89fa49..b7b55eb154d 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.112 2015/02/09 12:18:19 claudio Exp $ */
+/* $OpenBSD: in.h,v 1.113 2015/04/10 13:58:20 dlg Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -785,7 +785,7 @@ __END_DECLS
#ifdef _KERNEL
extern int inetctlerrmap[];
-extern struct ifqueue ipintrq; /* ip packet input queue */
+extern struct niqueue ipintrq; /* ip packet input queue */
extern struct in_addr zeroin_addr;
struct mbuf;
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index a1f85cfe60e..1b36f12dcd6 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.c,v 1.32 2015/01/24 00:29:06 deraadt Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.33 2015/04/10 13:58:20 dlg Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -82,11 +82,10 @@ int
divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
struct mbuf *control)
{
- struct ifqueue *inq;
struct sockaddr_in *sin;
struct socket *so;
struct ifaddr *ifa;
- int s, error = 0, min_hdrlen = 0, dir;
+ int error = 0, min_hdrlen = 0, dir;
struct ip *ip;
u_int16_t off;
@@ -149,8 +148,6 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
}
m->m_pkthdr.rcvif = ifa->ifa_ifp;
- inq = &ipintrq;
-
/*
* Recalculate IP and protocol checksums for the inbound packet
* since the userspace application may have modified the packet
@@ -160,10 +157,7 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
ip->ip_sum = in_cksum(m, off);
in_proto_cksum_out(m, NULL);
- s = splnet();
- IF_INPUT_ENQUEUE(inq, m);
- schednetisr(NETISR_IP);
- splx(s);
+ niq_enqueue(&ipintrq, m);
} else {
error = ip_output(m, NULL, &inp->inp_route,
IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, 0);
diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c
index 9c7def0c6a9..1633b5cd696 100644
--- a/sys/netinet/ip_ether.c
+++ b/sys/netinet/ip_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ether.c,v 1.70 2014/12/19 17:14:40 tedu Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.71 2015/04/10 13:58:20 dlg Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
@@ -280,8 +280,6 @@ void
mplsip_decap(struct mbuf *m, int iphlen)
{
struct gif_softc *sc;
- struct ifqueue *ifq;
- int s;
etheripstat.etherip_ipackets++;
@@ -330,22 +328,12 @@ mplsip_decap(struct mbuf *m, int iphlen)
pf_pkt_addr_changed(m);
#endif
- ifq = &mplsintrq;
- s = splnet();
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
+ if (niq_enqueue(&mplsintrq, m) != 0) {
etheripstat.etherip_qfull++;
- splx(s);
DPRINTF(("mplsip_input(): packet dropped because of full "
"queue\n"));
- return;
}
- IF_ENQUEUE(ifq, m);
- schednetisr(NETISR_MPLS);
- splx(s);
- return;
}
#endif
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c
index 10d4b6c90a0..c2038ccaa26 100644
--- a/sys/netinet/ip_gre.c
+++ b/sys/netinet/ip_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_gre.c,v 1.53 2015/03/18 01:12:16 mcbride Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.54 2015/04/10 13:58:20 dlg Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -93,8 +93,7 @@ int
gre_input2(struct mbuf *m, int hlen, u_char proto)
{
struct greip *gip;
- int s;
- struct ifqueue *ifq;
+ struct niqueue *ifq;
struct gre_softc *sc;
u_short flags;
u_int af;
@@ -168,7 +167,6 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
#ifdef INET6
case ETHERTYPE_IPV6:
ifq = &ip6intrq;
- schednetisr(NETISR_IPV6);
af = AF_INET6;
break;
#endif
@@ -181,7 +179,6 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MCAST:
ifq = &mplsintrq;
- schednetisr(NETISR_MPLS);
af = AF_MPLS;
break;
#endif
@@ -209,9 +206,7 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
pf_pkt_addr_changed(m);
#endif
- s = splnet(); /* possible */
- IF_INPUT_ENQUEUE(ifq, m);
- splx(s);
+ niq_enqueue(ifq, m);
return (1); /* packet is done, no further processing needed */
}
@@ -271,9 +266,8 @@ gre_mobile_input(struct mbuf *m, ...)
{
struct ip *ip;
struct mobip_h *mip;
- struct ifqueue *ifq;
struct gre_softc *sc;
- int hlen, s;
+ int hlen;
va_list ap;
u_char osrc = 0;
int msiz;
@@ -339,16 +333,12 @@ gre_mobile_input(struct mbuf *m, ...)
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m,(ip->ip_hl << 2));
- ifq = &ipintrq;
-
#if NBPFILTER > 0
if (sc->sc_if.if_bpf)
bpf_mtap_af(sc->sc_if.if_bpf, AF_INET, m, BPF_DIRECTION_IN);
#endif
- s = splnet(); /* possible */
- IF_INPUT_ENQUEUE(ifq, m);
- splx(s);
+ niq_enqueue(&ipintrq, m);
}
/*
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index d0525fb3e66..38b140395ab 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.247 2015/03/14 03:38:52 jsg Exp $ */
+/* $OpenBSD: ip_input.c,v 1.248 2015/04/10 13:58:20 dlg Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -49,6 +49,7 @@
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/route.h>
+#include <net/netisr.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -113,7 +114,7 @@ int ip_frags = 0;
int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS;
-struct ifqueue ipintrq;
+struct niqueue ipintrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IP);
struct pool ipqent_pool;
struct pool ipq_pool;
@@ -169,7 +170,6 @@ ip_init(void)
pr->pr_protocol < IPPROTO_MAX)
ip_protox[pr->pr_protocol] = pr - inetsw;
LIST_INIT(&ipq);
- IFQ_SET_MAXLEN(&ipintrq, IFQ_MAXLEN);
if (ip_mtudisc != 0)
ip_mtudisc_timeout_q =
rt_timer_queue_create(ip_mtudisc_timeout);
@@ -192,18 +192,12 @@ void
ipintr(void)
{
struct mbuf *m;
- int s;
- for (;;) {
- /*
- * Get next datagram off input queue and get IP header
- * in first mbuf.
- */
- s = splnet();
- IF_DEQUEUE(&ipintrq, m);
- splx(s);
- if (m == NULL)
- return;
+ /*
+ * Get next datagram off input queue and get IP header
+ * in first mbuf.
+ */
+ while ((m = niq_dequeue(&ipintrq)) != NULL) {
#ifdef DIAGNOSTIC
if ((m->m_flags & M_PKTHDR) == 0)
panic("ipintr no HDR");
@@ -1616,7 +1610,7 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
ipsec_def_comp,
sizeof(ipsec_def_comp)));
case IPCTL_IFQUEUE:
- return (sysctl_ifq(name + 1, namelen - 1,
+ return (sysctl_niq(name + 1, namelen - 1,
oldp, oldlenp, newp, newlen, &ipintrq));
case IPCTL_STATS:
return (sysctl_rdstruct(oldp, oldlenp, newp,
diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c
index d427512beb5..4128e3d3990 100644
--- a/sys/netinet/ip_ipip.c
+++ b/sys/netinet/ip_ipip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.c,v 1.56 2014/12/19 17:14:40 tedu Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.57 2015/04/10 13:58:20 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -146,15 +146,14 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp, int proto)
struct sockaddr_in *sin;
struct ifnet *ifp;
struct ifaddr *ifa;
- struct ifqueue *ifq = NULL;
+ struct niqueue *ifq = NULL;
struct ip *ipo;
u_int rdomain;
#ifdef INET6
struct sockaddr_in6 *sin6;
struct ip6_hdr *ip6;
#endif
- int isr;
- int mode, hlen, s;
+ int mode, hlen;
u_int8_t itos, otos;
u_int8_t v;
sa_family_t af;
@@ -352,13 +351,11 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp, int proto)
switch (proto) {
case IPPROTO_IPV4:
ifq = &ipintrq;
- isr = NETISR_IP;
af = AF_INET;
break;
#ifdef INET6
case IPPROTO_IPV6:
ifq = &ip6intrq;
- isr = NETISR_IPV6;
af = AF_INET6;
break;
#endif
@@ -374,23 +371,12 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp, int proto)
pf_pkt_addr_changed(m);
#endif
- s = splnet(); /* isn't it already? */
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
+ if (niq_enqueue(ifq, m) != 0) {
ipipstat.ipips_qfull++;
-
- splx(s);
-
DPRINTF(("ipip_input(): packet dropped because of full "
"queue\n"));
return;
}
-
- IF_ENQUEUE(ifq, m);
- schednetisr(isr);
- splx(s);
- return;
}
int
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 9973fcdc155..498c940bd33 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.127 2015/03/26 12:21:37 mikeb Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.128 2015/04/10 13:58:20 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -708,28 +708,18 @@ ah4_input(struct mbuf *m, ...)
int
ah4_input_cb(struct mbuf *m, ...)
{
- struct ifqueue *ifq = &ipintrq;
- int s = splnet();
-
/*
* Interface pointer is already in first mbuf; chop off the
* `outer' header and reschedule.
*/
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
+ if (niq_enqueue(&ipintrq, m) != 0) {
ahstat.ahs_qfull++;
- splx(s);
-
- m_freem(m);
DPRINTF(("ah4_input_cb(): dropped packet because of full "
"IP queue\n"));
return ENOBUFS;
}
- IF_ENQUEUE(ifq, m);
- schednetisr(NETISR_IP);
- splx(s);
return 0;
}
@@ -764,27 +754,17 @@ esp4_input(struct mbuf *m, ...)
int
esp4_input_cb(struct mbuf *m, ...)
{
- struct ifqueue *ifq = &ipintrq;
- int s = splnet();
-
/*
* Interface pointer is already in first mbuf; chop off the
* `outer' header and reschedule.
*/
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
+ if (niq_enqueue(&ipintrq, m) != 0) {
espstat.esps_qfull++;
- splx(s);
-
- m_freem(m);
DPRINTF(("esp4_input_cb(): dropped packet because of full "
"IP queue\n"));
return ENOBUFS;
}
- IF_ENQUEUE(ifq, m);
- schednetisr(NETISR_IP);
- splx(s);
return 0;
}
@@ -806,27 +786,16 @@ ipcomp4_input(struct mbuf *m, ...)
int
ipcomp4_input_cb(struct mbuf *m, ...)
{
- struct ifqueue *ifq = &ipintrq;
- int s = splnet();
-
/*
* Interface pointer is already in first mbuf; chop off the
* `outer' header and reschedule.
*/
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
+ if (niq_enqueue(&ipintrq, m) != 0) {
ipcompstat.ipcomps_qfull++;
- splx(s);
-
- m_freem(m);
DPRINTF(("ipcomp4_input_cb(): dropped packet because of full IP queue\n"));
return ENOBUFS;
}
- IF_ENQUEUE(ifq, m);
- schednetisr(NETISR_IP);
- splx(s);
-
return 0;
}