From dee7411f05468b4092264ff460180b7e77ece363 Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Wed, 12 Nov 2025 09:39:08 +0800 Subject: [PATCH] fix(libnetwork): nil pointer will cause panic make panic info more useful Signed-off-by: jokemanfire Signed-off-by: Sebastiaan van Stijn --- daemon/libnetwork/ns/init_linux.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/libnetwork/ns/init_linux.go b/daemon/libnetwork/ns/init_linux.go index 2ecb616b59..a59812ec07 100644 --- a/daemon/libnetwork/ns/init_linux.go +++ b/daemon/libnetwork/ns/init_linux.go @@ -2,6 +2,7 @@ package ns import ( "context" + "fmt" "sync" "syscall" "testing" @@ -30,7 +31,8 @@ func initHandles() { } initNl, err = nlwrap.NewHandle(getSupportedNlFamilies()...) if err != nil { - log.G(context.TODO()).Errorf("could not create netlink handle on initial namespace: %v", err) + // Fail fast to keep the invariant: NlHandle must be a valid handle + panic(fmt.Errorf("could not create netlink handle on initial (host) namespace: %w", err)) } err = initNl.SetSocketTimeout(NetlinkSocketsTimeout) if err != nil {