host-local: detect missing subnet and error out
authorStefan Junker <mail@stefanjunker.de>
Thu, 12 Nov 2015 19:00:48 +0000 (20:00 +0100)
committerStefan Junker <mail@stefanjunker.de>
Wed, 25 Nov 2015 20:18:48 +0000 (21:18 +0100)
plugins/ipam/host-local/allocator.go

index c333952..159e2cb 100644 (file)
@@ -142,6 +142,9 @@ func (a *IPAllocator) Release(id string) error {
 }
 
 func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) {
+       if ipnet.IP == nil {
+               return nil, nil, fmt.Errorf("missing field %q in IPAM configuration", "subnet")
+       }
        ip := ipnet.IP.To4()
        if ip == nil {
                ip = ipnet.IP.To16()