From 2b2d011899457437909e5ff5f0f8b77a65443a0b Mon Sep 17 00:00:00 2001 From: Brent Salisbury Date: Sun, 13 Mar 2016 00:42:00 -0500 Subject: [PATCH] Reject a null v4 IPAM slice in exp vlan drivers Issue #1018 Signed-off-by: Brent Salisbury --- libnetwork/drivers/ipvlan/ipvlan_network.go | 4 ++++ libnetwork/drivers/macvlan/macvlan_network.go | 4 ++++ 2 files changed, 8 insertions(+) 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 {