From 402e966cbe650d502550cfcc11a72f1a52de0e60 Mon Sep 17 00:00:00 2001 From: kp Date: Wed, 2 Sep 2020 11:49:22 +0000 Subject: [PATCH] ng_ether: Enter NET_EPOCH where required We must enter NET_EPOCH before calling ether_output_frame(). Several of the functions it calls (pfil_run_hooks, if_transmit) expect to be running in the NET_EPOCH. While here remove an unneeded EPOCH entry (which wasn't wide enough to cover BRIDGE_INPUT). PR: 248958 Reviewed by: glebius, bz (previous version), melifaro (previous version) Tested by: manu Differential Revision: https://reviews.freebsd.org/D26226 --- sys/netgraph/ng_ether.c | 3 --- sys/netgraph/ng_pppoe.c | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index c5ea9d102d5c..0d0d5f990f84 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -711,7 +711,6 @@ ng_ether_rcv_lower(hook_p hook, item_p item) static int ng_ether_rcv_upper(hook_p hook, item_p item) { - struct epoch_tracker et; struct mbuf *m; const node_p node = NG_HOOK_NODE(hook); const priv_p priv = NG_NODE_PRIVATE(node); @@ -739,9 +738,7 @@ ng_ether_rcv_upper(hook_p hook, item_p item) } /* Route packet back in */ - NET_EPOCH_ENTER(et); ether_demux(ifp, m); - NET_EPOCH_EXIT(et); return (0); } diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index 70f893498420..295a136cc554 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -761,6 +762,7 @@ ng_pppoe_connect(hook_p hook) static int ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook) { + struct epoch_tracker et; priv_p privp = NG_NODE_PRIVATE(node); struct ngpppoe_init_data *ourmsg = NULL; struct ng_mesg *resp = NULL; @@ -980,7 +982,9 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook) neg->service.hdr.tag_len = htons((uint16_t)srvlen); bcopy(ourmsg->data + srvpos, neg->service.data, srvlen); neg->service_len = srvlen; + NET_EPOCH_ENTER(et); pppoe_start(sp); + NET_EPOCH_EXIT(et); break; } case NGM_PPPOE_LISTEN: @@ -1166,8 +1170,10 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook) m->m_pkthdr.len = m->m_len = sizeof(*wh) + sizeof(*tag) + ourmsg->data_len; wh->ph.length = htons(sizeof(*tag) + ourmsg->data_len); + NET_EPOCH_ENTER(et); NG_SEND_DATA_ONLY(error, privp->ethernet_hook, m); + NET_EPOCH_EXIT(et); } break; } @@ -1209,8 +1215,10 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook) m->m_pkthdr.len = m->m_len = sizeof(*wh) + sizeof(*tag) + ourmsg->data_len; wh->ph.length = htons(sizeof(*tag) + ourmsg->data_len); + NET_EPOCH_ENTER(et); NG_SEND_DATA_ONLY(error, privp->ethernet_hook, m); + NET_EPOCH_EXIT(et); } break; }