diff --git a/libnetwork/drivers/ipvlan/ipvlan_network.go b/libnetwork/drivers/ipvlan/ipvlan_network.go index b39cb5a25f..f2f307daa3 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_network.go +++ b/libnetwork/drivers/ipvlan/ipvlan_network.go @@ -25,6 +25,10 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Da return fmt.Errorf("kernel version failed to meet the minimum ipvlan kernel requirement of %d.%d, found %d.%d.%d", ipvlanKernelVer, ipvlanMajorVer, kv.Kernel, kv.Major, kv.Minor) } + // reject a null v4 network + if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" { + return fmt.Errorf("ipv4 pool is empty") + } // parse and validate the config and bind to networkConfiguration config, err := parseNetworkOptions(nid, option) if err != nil { diff --git a/libnetwork/drivers/macvlan/macvlan_network.go b/libnetwork/drivers/macvlan/macvlan_network.go index 2fb616a1ff..78f906fbf5 100644 --- a/libnetwork/drivers/macvlan/macvlan_network.go +++ b/libnetwork/drivers/macvlan/macvlan_network.go @@ -25,6 +25,10 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Da return fmt.Errorf("kernel version failed to meet the minimum macvlan kernel requirement of %d.%d, found %d.%d.%d", macvlanKernelVer, macvlanMajorVer, kv.Kernel, kv.Major, kv.Minor) } + // reject a null v4 network + if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" { + return fmt.Errorf("ipv4 pool is empty") + } // parse and validate the config and bind to networkConfiguration config, err := parseNetworkOptions(nid, option) if err != nil {