Module Name: src
Committed By: thorpej
Date: Sat Sep 3 02:25:00 UTC 2022
Modified Files:
src/sys/net: if_ethersubr.c if_gre.c if_loop.c if_mpls.c
netisr_dispatch.h
src/sys/netmpls: mpls_proto.c mpls_var.h
src/sys/rump/net/lib/libnetmpls: netmpls_component.c
Log Message:
Convert MPLS from a legacy netisr to pktqueue.
To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.182 -r1.183 src/sys/net/if_gre.c
cvs rdiff -u -r1.115 -r1.116 src/sys/net/if_loop.c
cvs rdiff -u -r1.38 -r1.39 src/sys/net/if_mpls.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net/netisr_dispatch.h
cvs rdiff -u -r1.32 -r1.33 src/sys/netmpls/mpls_proto.c
cvs rdiff -u -r1.2 -r1.3 src/sys/netmpls/mpls_var.h
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/net/lib/libnetmpls/netmpls_component.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.318 src/sys/net/if_ethersubr.c:1.319
--- src/sys/net/if_ethersubr.c:1.318 Sat Sep 3 01:48:22 2022
+++ src/sys/net/if_ethersubr.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.318 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.319 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.318 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.319 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -648,12 +648,10 @@ ether_input(struct ifnet *ifp, struct mb
struct ethercom *ec = (struct ethercom *) ifp;
#endif
pktqueue_t *pktq = NULL;
- struct ifqueue *inq = NULL;
uint16_t etype;
struct ether_header *eh;
size_t ehlen;
static int earlypkts;
- int isr = 0;
/* No RPS for not-IP. */
pktq_rps_hash_func_t rps_hash = NULL;
@@ -937,8 +935,7 @@ ether_input(struct ifnet *ifp, struct mb
#ifdef MPLS
case ETHERTYPE_MPLS:
- isr = NETISR_MPLS;
- inq = &mplsintrq;
+ pktq = mpls_pktq;
break;
#endif
@@ -946,20 +943,11 @@ ether_input(struct ifnet *ifp, struct mb
goto noproto;
}
- if (__predict_true(pktq)) {
- const uint32_t h = rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
- if (__predict_false(!pktq_enqueue(pktq, m, h))) {
- m_freem(m);
- }
- return;
- }
-
- if (__predict_false(!inq)) {
- /* Should not happen. */
- goto error;
+ KASSERT(pktq != NULL);
+ const uint32_t h = rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
+ if (__predict_false(!pktq_enqueue(pktq, m, h))) {
+ m_freem(m);
}
-
- IFQ_ENQUEUE_ISR(inq, m, isr);
return;
drop:
Index: src/sys/net/if_gre.c
diff -u src/sys/net/if_gre.c:1.182 src/sys/net/if_gre.c:1.183
--- src/sys/net/if_gre.c:1.182 Sat Sep 3 01:48:22 2022
+++ src/sys/net/if_gre.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gre.c,v 1.182 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_gre.c,v 1.183 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.182 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.183 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_atalk.h"
@@ -790,10 +790,8 @@ static int
gre_input(struct gre_softc *sc, struct mbuf *m, const struct gre_h *gh)
{
pktqueue_t *pktq = NULL;
- struct ifqueue *ifq = NULL;
uint16_t flags;
uint32_t af; /* af passed to BPF tap */
- int isr = 0, s;
int hlen;
if_statadd2(&sc->sc_if, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
@@ -837,8 +835,7 @@ gre_input(struct gre_softc *sc, struct m
#endif
#ifdef MPLS
case ETHERTYPE_MPLS:
- ifq = &mplsintrq;
- isr = NETISR_MPLS;
+ pktq = mpls_pktq;
af = AF_MPLS;
break;
#endif
@@ -860,24 +857,10 @@ gre_input(struct gre_softc *sc, struct m
m_set_rcvif(m, &sc->sc_if);
- if (__predict_true(pktq)) {
- if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
- m_freem(m);
- }
- return 1;
- }
-
- s = splnet();
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
+ KASSERT(pktq != NULL);
+ if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
m_freem(m);
- } else {
- IF_ENQUEUE(ifq, m);
}
- /* we need schednetisr since the address family may change */
- schednetisr(isr);
- splx(s);
-
return 1; /* packet is done, no further processing needed */
}
Index: src/sys/net/if_loop.c
diff -u src/sys/net/if_loop.c:1.115 src/sys/net/if_loop.c:1.116
--- src/sys/net/if_loop.c:1.115 Sat Sep 3 01:48:22 2022
+++ src/sys/net/if_loop.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_loop.c,v 1.115 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_loop.c,v 1.116 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.115 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.116 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -242,8 +242,7 @@ looutput(struct ifnet *ifp, struct mbuf
const struct rtentry *rt)
{
pktqueue_t *pktq = NULL;
- struct ifqueue *ifq = NULL;
- int s, isr = -1;
+ int s;
int csum_flags;
int error = 0;
size_t pktlen;
@@ -304,11 +303,10 @@ looutput(struct ifnet *ifp, struct mbuf
union mpls_shim msh;
msh.s_addr = MPLS_GETSADDR(rt);
if (msh.shim.label != MPLS_LABEL_IMPLNULL) {
- ifq = &mplsintrq;
- isr = NETISR_MPLS;
+ pktq = mpls_pktq;
}
}
- if (isr != NETISR_MPLS)
+ if (pktq != mpls_pktq)
#endif
switch (dst->sa_family) {
@@ -359,31 +357,17 @@ looutput(struct ifnet *ifp, struct mbuf
goto out;
}
- s = splnet();
- if (__predict_true(pktq)) {
- error = 0;
+ KASSERT(pktq != NULL);
- if (__predict_true(pktq_enqueue(pktq, m, 0))) {
- if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
- } else {
- m_freem(m);
- if_statinc(ifp, if_oerrors);
- error = ENOBUFS;
- }
- splx(s);
- goto out;
- }
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
+ error = 0;
+ s = splnet();
+ if (__predict_true(pktq_enqueue(pktq, m, 0))) {
+ if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
+ } else {
m_freem(m);
- splx(s);
- error = ENOBUFS;
if_statinc(ifp, if_oerrors);
- goto out;
+ error = ENOBUFS;
}
- if_statadd2(ifp, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
- IF_ENQUEUE(ifq, m);
- schednetisr(isr);
splx(s);
out:
KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
Index: src/sys/net/if_mpls.c
diff -u src/sys/net/if_mpls.c:1.38 src/sys/net/if_mpls.c:1.39
--- src/sys/net/if_mpls.c:1.38 Fri Jul 29 15:25:51 2022
+++ src/sys/net/if_mpls.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mpls.c,v 1.38 2022/07/29 15:25:51 skrll Exp $ */
+/* $NetBSD: if_mpls.c,v 1.39 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.38 2022/07/29 15:25:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.39 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -189,18 +189,11 @@ mpls_input(struct ifnet *ifp, struct mbu
}
void
-mplsintr(void)
+mplsintr(void *arg __unused)
{
struct mbuf *m;
- for (;;) {
- IFQ_LOCK(&mplsintrq);
- IF_DEQUEUE(&mplsintrq, m);
- IFQ_UNLOCK(&mplsintrq);
-
- if (!m)
- return;
-
+ while ((m = pktq_dequeue(mpls_pktq)) != NULL) {
if (((m->m_flags & M_PKTHDR) == 0) ||
(m->m_pkthdr.rcvif_index == 0))
panic("mplsintr(): no pkthdr or rcvif");
Index: src/sys/net/netisr_dispatch.h
diff -u src/sys/net/netisr_dispatch.h:1.23 src/sys/net/netisr_dispatch.h:1.24
--- src/sys/net/netisr_dispatch.h:1.23 Sat Sep 3 02:07:32 2022
+++ src/sys/net/netisr_dispatch.h Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: netisr_dispatch.h,v 1.23 2022/09/03 02:07:32 thorpej Exp $ */
+/* $NetBSD: netisr_dispatch.h,v 1.24 2022/09/03 02:24:59 thorpej Exp $ */
#ifndef _NET_NETISR_DISPATCH_H_
#define _NET_NETISR_DISPATCH_H_
@@ -27,8 +27,4 @@
* their prototypes in <net/netisr.h> (if necessary).
*/
-#ifdef MPLS
- DONETISR(NETISR_MPLS,mplsintr);
-#endif
-
#endif /* !_NET_NETISR_DISPATCH_H_ */
Index: src/sys/netmpls/mpls_proto.c
diff -u src/sys/netmpls/mpls_proto.c:1.32 src/sys/netmpls/mpls_proto.c:1.33
--- src/sys/netmpls/mpls_proto.c:1.32 Mon Jan 28 12:53:01 2019
+++ src/sys/netmpls/mpls_proto.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $ */
+/* $NetBSD: mpls_proto.c,v 1.33 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.33 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -49,7 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: mpls_proto.c
#include <netmpls/mpls.h>
#include <netmpls/mpls_var.h>
-struct ifqueue mplsintrq;
+#define MPLS_MAXQLEN 256
+pktqueue_t * mpls_pktq __read_mostly;
static int mpls_attach(struct socket *, int);
static void sysctl_net_mpls_setup(struct sysctllog **);
@@ -73,9 +74,8 @@ void mpls_init(void)
#ifdef MBUFTRACE
MOWNER_ATTACH(&mpls_owner);
#endif
- memset(&mplsintrq, 0, sizeof(mplsintrq));
- mplsintrq.ifq_maxlen = 256;
- IFQ_LOCK_INIT(&mplsintrq);
+ mpls_pktq = pktq_create(MPLS_MAXQLEN, mplsintr, NULL);
+ KASSERT(mpls_pktq != NULL);
sysctl_net_mpls_setup(NULL);
}
@@ -240,8 +240,9 @@ mpls_purgeif(struct socket *so, struct i
static void
sysctl_net_mpls_setup(struct sysctllog **clog)
{
+ const struct sysctlnode *mpls_node;
- sysctl_createv(clog, 0, NULL, NULL,
+ sysctl_createv(clog, 0, NULL, &mpls_node,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "mpls", NULL,
NULL, 0, NULL, 0,
@@ -265,12 +266,9 @@ sysctl_net_mpls_setup(struct sysctllog *
SYSCTL_DESCR("Accept MPLS Frames"),
NULL, 0, &mpls_frame_accept, 0,
CTL_NET, PF_MPLS, CTL_CREATE, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
- CTLTYPE_INT, "ifq_len",
- SYSCTL_DESCR("MPLS queue length"),
- NULL, 0, &mplsintrq.ifq_maxlen, 0,
- CTL_NET, PF_MPLS, CTL_CREATE, CTL_EOL);
+
+ pktq_sysctl_setup(mpls_pktq, clog, mpls_node, CTL_CREATE);
+
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "rfc4182",
@@ -389,7 +387,6 @@ struct domain mplsdomain = {
.dom_maxrtkey = sizeof(union mpls_shim),
.dom_ifattach = NULL,
.dom_ifdetach = NULL,
- .dom_ifqueues = { &mplsintrq, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("MPLS", ""),
.dom_sa_cmpofs = offsetof(struct sockaddr_mpls, smpls_addr),
Index: src/sys/netmpls/mpls_var.h
diff -u src/sys/netmpls/mpls_var.h:1.2 src/sys/netmpls/mpls_var.h:1.3
--- src/sys/netmpls/mpls_var.h:1.2 Mon Aug 24 22:21:27 2015
+++ src/sys/netmpls/mpls_var.h Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_var.h,v 1.2 2015/08/24 22:21:27 pooka Exp $ */
+/* $NetBSD: mpls_var.h,v 1.3 2022/09/03 02:24:59 thorpej Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -40,6 +40,8 @@
#include "opt_mbuftrace.h"
#endif
+#include <net/pktqueue.h>
+
#include "netmpls/mpls.h"
#define MPLS_GETSADDR(rt) ntohl(((struct sockaddr_mpls*)rt_gettag(rt))->smpls_addr.s_addr)
@@ -51,14 +53,14 @@ extern int mpls_mapprec_inet;
extern int mpls_mapclass_inet6;
extern int mpls_icmp_respond;
-extern struct ifqueue mplsintrq;
+extern pktqueue_t *mpls_pktq;
#ifdef MBUFTRACE
extern struct mowner mpls_owner;
#endif
void mpls_init(void);
-void mplsintr(void);
+void mplsintr(void *);
struct mbuf *mpls_ttl_dec(struct mbuf *);
Index: src/sys/rump/net/lib/libnetmpls/netmpls_component.c
diff -u src/sys/rump/net/lib/libnetmpls/netmpls_component.c:1.5 src/sys/rump/net/lib/libnetmpls/netmpls_component.c:1.6
--- src/sys/rump/net/lib/libnetmpls/netmpls_component.c:1.5 Sun Aug 7 17:42:18 2016
+++ src/sys/rump/net/lib/libnetmpls/netmpls_component.c Sat Sep 3 02:24:59 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: netmpls_component.c,v 1.5 2016/08/07 17:42:18 christos Exp $ */
+/* $NetBSD: netmpls_component.c,v 1.6 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netmpls_component.c,v 1.5 2016/08/07 17:42:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netmpls_component.c,v 1.6 2022/09/03 02:24:59 thorpej Exp $");
#include <sys/param.h>
#include <sys/domain.h>
@@ -53,8 +53,6 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET)
extern struct domain mplsdomain;
domain_attach(&mplsdomain);
-
- rump_netisr_register(NETISR_MPLS, mplsintr);
}
RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)