MCPcopy Create free account
hub / github.com/containerd/nerdctl / GetLiveNetworkSubnets

Function GetLiveNetworkSubnets

pkg/netutil/subnet/subnet.go:26–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24)
25
26func GetLiveNetworkSubnets() ([]*net.IPNet, error) {
27 var addrs []net.Addr
28 if err := rootlessutil.WithDetachedNetNSIfAny(func() error {
29 var err2 error
30 addrs, err2 = net.InterfaceAddrs()
31 return err2
32 }); err != nil {
33 return nil, err
34 }
35 nets := make([]*net.IPNet, 0, len(addrs))
36 for _, address := range addrs {
37 _, n, err := net.ParseCIDR(address.String())
38 if err != nil {
39 return nil, err
40 }
41 nets = append(nets, n)
42 }
43 return nets, nil
44}
45
46// GetFreeSubnet try to find a free subnet in the given network
47func GetFreeSubnet(n *net.IPNet, usedNetworks []*net.IPNet) (*net.IPNet, error) {

Callers

nothing calls this directly

Calls 2

WithDetachedNetNSIfAnyFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…