This extra serialization is not required. In packet processing path we
have shared netlock held, but we do read-only access on per session
`flags' and `ifindex'. We always modify them from ioctl(2) path with
exclusive netlock held. The rest of pipex(4) session is immutable or
uses per-session locks.
It's not related to this diff, but the per-session `ifindex' could be
declared as immutable. We only set int to non null value when we link
pipex(4) session to the stack, and we never change it while session is
linked. We only use `ifindex' to set `ph_ifidx' of the mbuf(9) which
will be enqueued. It's absolutely normal to have the mbufs with invalid
`ph_ifidx'.
Index: sys/net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.280
diff -u -p -r1.280 if_ethersubr.c
--- sys/net/if_ethersubr.c 26 Jun 2022 15:50:21 -0000 1.280
+++ sys/net/if_ethersubr.c 26 Jun 2022 16:27:40 -0000
@@ -540,7 +540,6 @@ ether_input(struct ifnet *ifp, struct mb
case ETHERTYPE_PPPOE:
if (m->m_flags & (M_MCAST | M_BCAST))
goto dropanyway;
- KERNEL_LOCK();
#ifdef PIPEX
if (pipex_enable) {
struct pipex_session *session;
@@ -548,12 +547,12 @@ ether_input(struct ifnet *ifp, struct mb
if ((session = pipex_pppoe_lookup_session(m)) != NULL) {
pipex_pppoe_input(m, session);
pipex_rele_session(session);
- KERNEL_UNLOCK();
return;
}
pipex_rele_session(session);
}
#endif
+ KERNEL_LOCK();
if (etype == ETHERTYPE_PPPOEDISC)
pppoe_disc_input(m);
else