summaryrefslogtreecommitdiff
path: root/sys/net/if_loop.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2020-07-22 02:16:03 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2020-07-22 02:16:03 +0000
commite7539b190c92e728ca85bde26d2ba6e8599ec22c (patch)
tree855bd097524f5c275d95140541bec54bcee6faae /sys/net/if_loop.c
parent2a91cae0189e06d8a9ef9b033ff30a43f9c53bb4 (diff)
deprecate interface input handler lists, just use one input function.
the interface input handler lists were originally set up to help us during the intial mpsafe network stack work. at the time not all the virtual ethernet interfaces (vlan, svlan, bridge, trunk, etc) were mpsafe, so we wanted a way to avoid them by default, and only take the kernel lock hit when they were specifically enabled on the interface. since then, they have been fixed up to be mpsafe. i could leave the list in place, but it has some semantic problems. because virtual interfaces filter packets based on the order they were attached to the parent interface, you can get packets taken away in surprising ways, especially when you reboot and netstart does something different to what you did by hand. by hardcoding the order that things like vlan and bridge get to look at packets, we can document the behaviour and get consistency. it also means we can get rid of a use of SRPs which were difficult to replace with SMRs. the interface input handler list is an SRPL, which we would like to deprecate. it turns out that you can sleep during stack processing, which you're not supposed to do with SRPs or SMRs, but SRPs are a lot more forgiving and it worked. lastly, it turns out that this code is faster than the input list handling, so lots of winning all around. special thanks to hrvoje popovski and aaron bieber for testing. this has been in snaps as part of a larger diff for over a week.
Diffstat (limited to 'sys/net/if_loop.c')
-rw-r--r--sys/net/if_loop.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 1d3a8095b0e..2ba5b85570c 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_loop.c,v 1.90 2020/01/08 09:09:10 claudio Exp $ */
+/* $OpenBSD: if_loop.c,v 1.91 2020/07/22 02:16:01 dlg Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
@@ -143,7 +143,7 @@
int loioctl(struct ifnet *, u_long, caddr_t);
void loopattach(int);
void lortrequest(struct ifnet *, int, struct rtentry *);
-int loinput(struct ifnet *, struct mbuf *, void *);
+void loinput(struct ifnet *, struct mbuf *);
int looutput(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
@@ -175,6 +175,7 @@ loop_clone_create(struct if_clone *ifc, int unit)
ifp->if_xflags = IFXF_CLONED;
ifp->if_rtrequest = lortrequest;
ifp->if_ioctl = loioctl;
+ ifp->if_input = loinput;
ifp->if_output = looutput;
ifp->if_type = IFT_LOOP;
ifp->if_hdrlen = sizeof(u_int32_t);
@@ -188,7 +189,6 @@ loop_clone_create(struct if_clone *ifc, int unit)
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(u_int32_t));
#endif
- if_ih_insert(ifp, loinput, NULL);
return (0);
}
@@ -218,7 +218,6 @@ loop_clone_destroy(struct ifnet *ifp)
rdomain = ifp->if_rdomain;
}
- if_ih_remove(ifp, loinput, NULL);
if_detach(ifp);
free(ifp, M_DEVBUF, sizeof(*ifp));
@@ -228,8 +227,8 @@ loop_clone_destroy(struct ifnet *ifp)
return (0);
}
-int
-loinput(struct ifnet *ifp, struct mbuf *m, void *cookie)
+void
+loinput(struct ifnet *ifp, struct mbuf *m)
{
int error;
@@ -239,8 +238,6 @@ loinput(struct ifnet *ifp, struct mbuf *m, void *cookie)
error = if_input_local(ifp, m, m->m_pkthdr.ph_family);
if (error)
ifp->if_ierrors++;
-
- return (1);
}
int