Explorar el Código

Merge pull request #1019 from nerdalert/v4_null_check

Reject a null v4 IPAM slice in exp vlan drivers
Madhu Venugopal hace 9 años
padre
commit
0946e1444f

+ 4 - 0
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",
 		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)
 			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
 	// parse and validate the config and bind to networkConfiguration
 	config, err := parseNetworkOptions(nid, option)
 	config, err := parseNetworkOptions(nid, option)
 	if err != nil {
 	if err != nil {

+ 4 - 0
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",
 		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)
 			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
 	// parse and validate the config and bind to networkConfiguration
 	config, err := parseNetworkOptions(nid, option)
 	config, err := parseNetworkOptions(nid, option)
 	if err != nil {
 	if err != nil {