git: e8348e2b35f3 - main - enc: create an interface at SI_SUB_PROTO_IF stage

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 13 Jan 2026 21:31:45 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=e8348e2b35f3f644c391b8e0585090c451896684

commit e8348e2b35f3f644c391b8e0585090c451896684
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-01-09 23:31:11 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-01-13 21:30:22 +0000

    enc: create an interface at SI_SUB_PROTO_IF stage
    
    Creation of enc0 before SI_SUB_PROTO_MC mangles the MLD list as well as
    encounters IGMP mutex not initialized yet.
    
    Reported & tested by:   mjg
    
    NB: the enc(4) is not a true interface indeed.  In a perfect world the
    module shall not create a cloner, shall not enter if_attach(), shall not
    trigger ifnet_arrival_event, neither shall have any protocol attached to
    it. The enc0 exists for two purposes: 1) create a bpf(9) tap; 2) to allow
    injection packets in the middle of ipsec(4) processing temporarily
    rewriting m_pkthdr.rcvif to point at enc0.  While the problem 1 is already
    solved with a recent divorce between bpf(9) and ifnet(9), the problem 2 is
    harder to solve without breaking packet filter rules that use "via enc0".
---
 sys/net/if_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index 3c3f19661063..159fb3ca34c9 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -387,7 +387,7 @@ vnet_enc_init(const void *unused __unused)
 	ifc_create_ifp(encname, &ifd, &ifp);
 	V_enc_sc = ifp->if_softc;
 }
-VNET_SYSINIT(vnet_enc_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
+VNET_SYSINIT(vnet_enc_init, SI_SUB_PROTO_IF, SI_ORDER_ANY,
     vnet_enc_init, NULL);
 
 static void