github.com/cilium/cilium@v1.16.2/pkg/testutils/netns/netns.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package netns 5 6 import ( 7 "testing" 8 9 "github.com/cilium/cilium/pkg/netns" 10 ) 11 12 // NewNetNS returns a new network namespace. 13 func NewNetNS(tb testing.TB) *netns.NetNS { 14 tb.Helper() 15 16 ns, err := netns.New() 17 if err != nil { 18 tb.Fatal(err) 19 } 20 21 tb.Cleanup(func() { 22 ns.Close() 23 }) 24 25 return ns 26 }