From 484456b2d8b8c0f99fb280f0d7477f328a0c9c04 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Mon, 28 Oct 2019 19:00:27 +0000 Subject: [PATCH] netmap: enter NET_EPOCH on generic txsync After r353292, netmap generic adapter on if_vlan interfaces panics on asserting the NET_EPOCH. In more detail, this happens when nm_os_generic_xmit_frame() is called, that is in the generic txsync routine. Fix the issue by entering the NET_EPOCH during the generic txsync. We amortize the cost of entering/exiting over a whole batch of transmissions. PR: 241489 Reported by: Aleksandr Fedorov --- sys/dev/netmap/netmap_generic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c index 45b5d3bde35f..09ba550cae92 100644 --- a/sys/dev/netmap/netmap_generic.c +++ b/sys/dev/netmap/netmap_generic.c @@ -669,6 +669,11 @@ generic_netmap_txsync(struct netmap_kring *kring, int flags) if (nm_i != head) { /* we have new packets to send */ struct nm_os_gen_arg a; u_int event = -1; +#ifdef __FreeBSD__ + struct epoch_tracker et; + + NET_EPOCH_ENTER(et); +#endif if (gna->txqdisc && nm_kr_txempty(kring)) { /* In txqdisc mode, we ask for a delayed notification, @@ -776,6 +781,10 @@ generic_netmap_txsync(struct netmap_kring *kring, int flags) /* Update hwcur to the next slot to transmit. Here nm_i * is not necessarily head, we could break early. */ kring->nr_hwcur = nm_i; + +#ifdef __FreeBSD__ + NET_EPOCH_EXIT(et); +#endif } /*