iflib: Set the get counter routine prior to attaching the interface

This ensures other threads, e.g. ioctl threads, see the correct counter
routine once after the interface has been attached.

This change partially reverts commit 23ac9029f9, which for unclear
reason moved setting the get counter routine after ether_ifattach().

Reviewed by:	kbowling, kgalazka, #iflib
Fixes:		23ac9029f9 Update iflib to support more NIC designs
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50712

(cherry picked from commit ae7f8da8bf6ed0c4f0e9f0e95ae2b08abce54378)
This commit is contained in:
Zhenlei Huang 2025-08-30 23:23:51 +08:00 committed by Franco Fichtner
parent dbec722413
commit 57d006208f

View file

@ -5431,7 +5431,6 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
DEBUGNET_SET(ctx->ifc_ifp, iflib);
if_setgetcounterfn(ctx->ifc_ifp, iflib_if_get_counter);
iflib_add_device_sysctl_post(ctx);
iflib_add_pfil(ctx);
ctx->ifc_flags |= IFC_INIT_DONE;
@ -5785,6 +5784,7 @@ iflib_register(if_ctx_t ctx)
if_settransmitfn(ifp, iflib_if_transmit);
#endif
if_setqflushfn(ifp, iflib_if_qflush);
if_setgetcounterfn(ifp, iflib_if_get_counter);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
ctx->ifc_vlan_attach_event =
EVENTHANDLER_REGISTER(vlan_config, iflib_vlan_register, ctx,