Convert MPLS from a legacy netisr to pktqueue.
This commit is contained in:
parent
ca257ba439
commit
dd8687cce0
|
@ -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 mbuf *m)
|
|||
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 mbuf *m)
|
|||
|
||||
#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 mbuf *m)
|
|||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
if (__predict_false(!inq)) {
|
||||
/* Should not happen. */
|
||||
goto error;
|
||||
}
|
||||
|
||||
IFQ_ENQUEUE_ISR(inq, m, isr);
|
||||
return;
|
||||
|
||||
drop:
|
||||
|
|
|
@ -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 mbuf *m, const struct gre_h *gh)
|
|||
#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 mbuf *m, const struct gre_h *gh)
|
|||
|
||||
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 */
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *m, const struct sockaddr *dst,
|
|||
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 *m, const struct sockaddr *dst,
|
|||
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 *m, const struct sockaddr *dst,
|
|||
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();
|
||||
|
|
|
@ -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 mbuf *m)
|
|||
}
|
||||
|
||||
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");
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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,v 1.32 2019/01/28 12:53:01 martin Exp $
|
|||
#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 ifnet *ifp)
|
|||
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 **clog)
|
|||
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),
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue