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
This commit is contained in:
Zhenlei Huang 2025-08-30 23:23:51 +08:00
parent bb5135d0f2
commit ae7f8da8bf

View file

@ -5360,7 +5360,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;
@ -5714,6 +5713,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,