summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-04-22 03:26:17 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-04-22 03:26:17 +0000
commit782e69f62d32ccd5d86bd087b5f0c760a122b8db (patch)
tree1bba597db88b6fd452df6595a53ce0add0f9f6ed
parent499144806daac2a213e9f2cc21e62806af60c154 (diff)
add if_vinput so pseudo (ethernet) interfaces can bypass ifiqs
if_vinput assumes that the interface that its called against uses per cpu counters so it can count input packets, but basically does all the things that if_input and ifiq_input do. the main difference is it assumes the network stack is already running and runs the interface input handlers directly. this is instead of queuing the packets for a nettq to run. ifiqs arent free, especially when they only run per packet like they do on psuedo interfaces. this allows that overhead to be bypassed.
-rw-r--r--sys/net/if.c28
-rw-r--r--sys/net/if_var.h3
2 files changed, 29 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index fd4992d57c6..9285372af00 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.579 2019/04/22 02:53:40 dlg Exp $ */
+/* $OpenBSD: if.c,v 1.580 2019/04/22 03:26:16 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -948,6 +948,32 @@ if_input_process(struct ifnet *ifp, struct mbuf_list *ml)
}
void
+if_vinput(struct ifnet *ifp, struct mbuf *m)
+{
+#if NBPFILTER > 0
+ caddr_t if_bpf;
+#endif
+
+ m->m_pkthdr.ph_ifidx = ifp->if_index;
+ m->m_pkthdr.ph_rtableid = ifp->if_rdomain;
+
+ counters_pkt(ifp->if_counters,
+ ifc_ipackets, ifc_ibytes, m->m_pkthdr.len);
+
+#if NBPFILTER > 0
+ if_bpf = ifp->if_bpf;
+ if (if_bpf) {
+ if (bpf_mtap_ether(if_bpf, m, BPF_DIRECTION_OUT)) {
+ m_freem(m);
+ return;
+ }
+ }
+#endif
+
+ if_ih_input(ifp, m);
+}
+
+void
if_netisr(void *unused)
{
int n, t = 0;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 9547f66462f..fa61488f71d 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.97 2019/04/19 07:38:02 dlg Exp $ */
+/* $OpenBSD: if_var.h,v 1.98 2019/04/22 03:26:16 dlg Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -341,6 +341,7 @@ void if_start(struct ifnet *);
int if_enqueue(struct ifnet *, struct mbuf *);
int if_enqueue_ifq(struct ifnet *, struct mbuf *);
void if_input(struct ifnet *, struct mbuf_list *);
+void if_vinput(struct ifnet *, struct mbuf *);
void if_input_process(struct ifnet *, struct mbuf_list *);
int if_input_local(struct ifnet *, struct mbuf *, sa_family_t);
int if_output_local(struct ifnet *, struct mbuf *, sa_family_t);