Browse code

Make macvlan and ipvlan drivers as experimental

Signed-off-by: Madhu Venugopal <madhu@docker.com>

Madhu Venugopal authored on 2016/03/03 10:13:15
Showing 20 changed files
... ...
@@ -23,7 +23,7 @@ build: ${build_image}.created
23 23
 
24 24
 build-local:
25 25
 	@mkdir -p "bin"
26
-	$(shell which godep) go build -o "bin/dnet" ./cmd/dnet
26
+	$(shell which godep) go build -tags experimental -o "bin/dnet" ./cmd/dnet
27 27
 
28 28
 clean:
29 29
 	@if [ -d bin ]; then \
... ...
@@ -4,7 +4,6 @@ import (
4 4
 	"net"
5 5
 	"sync"
6 6
 
7
-	"github.com/Sirupsen/logrus"
8 7
 	"github.com/docker/libnetwork/datastore"
9 8
 	"github.com/docker/libnetwork/discoverapi"
10 9
 	"github.com/docker/libnetwork/driverapi"
... ...
@@ -15,14 +14,14 @@ const (
15 15
 	vethLen             = 7
16 16
 	containerVethPrefix = "eth"
17 17
 	vethPrefix          = "veth"
18
-	ipvlanType          = "ipvlan"     // driver type name
19
-	modeL2              = "l2"         // ipvlan mode l2 is the default
20
-	modeL3              = "l3"         // ipvlan L3 mode
21
-	hostIfaceOpt        = "host_iface" // host interface -o host_iface
22
-	modeOpt             = "_mode"      // ipvlan mode ux opt suffix
18
+	ipvlanType          = "ipvlan" // driver type name
19
+	modeL2              = "l2"     // ipvlan mode l2 is the default
20
+	modeL3              = "l3"     // ipvlan L3 mode
21
+	parentOpt           = "parent" // parent interface -o parent
22
+	modeOpt             = "_mode"  // ipvlan mode ux opt suffix
23 23
 )
24 24
 
25
-var driverModeOpt = ipvlanType + modeOpt // mode --option ipvlan_mode
25
+var driverModeOpt = ipvlanType + modeOpt // mode -o ipvlan_mode
26 26
 
27 27
 type endpointTable map[string]*endpoint
28 28
 
... ...
@@ -54,9 +53,6 @@ type network struct {
54 54
 
55 55
 // Init initializes and registers the libnetwork ipvlan driver
56 56
 func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
57
-	if err := kernelSupport(ipvlanType); err != nil {
58
-		logrus.Warnf("encountered issues loading the ipvlan kernel module: %v", err)
59
-	}
60 57
 	c := driverapi.Capability{
61 58
 		DataScope: datastore.LocalScope,
62 59
 	}
... ...
@@ -64,6 +60,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
64 64
 		networks: networkTable{},
65 65
 	}
66 66
 	d.initStore(config)
67
+
67 68
 	return dc.RegisterDriver(ipvlanType, d, c)
68 69
 }
69 70
 
... ...
@@ -3,6 +3,7 @@ package ipvlan
3 3
 import (
4 4
 	"fmt"
5 5
 
6
+	"github.com/Sirupsen/logrus"
6 7
 	"github.com/docker/libnetwork/driverapi"
7 8
 	"github.com/docker/libnetwork/netlabel"
8 9
 	"github.com/docker/libnetwork/netutils"
... ...
@@ -43,7 +44,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
43 43
 	if opt, ok := epOptions[netlabel.PortMap]; ok {
44 44
 		if _, ok := opt.([]types.PortBinding); ok {
45 45
 			if len(opt.([]types.PortBinding)) > 0 {
46
-				return fmt.Errorf("%s driver does not support port mappings", ipvlanType)
46
+				logrus.Warnf("%s driver does not support port mappings", ipvlanType)
47 47
 			}
48 48
 		}
49 49
 	}
... ...
@@ -51,7 +52,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
51 51
 	if opt, ok := epOptions[netlabel.ExposedPorts]; ok {
52 52
 		if _, ok := opt.([]types.TransportPort); ok {
53 53
 			if len(opt.([]types.TransportPort)) > 0 {
54
-				return fmt.Errorf("%s driver does not support port exposures", ipvlanType)
54
+				logrus.Warnf("%s driver does not support port exposures", ipvlanType)
55 55
 			}
56 56
 		}
57 57
 	}
... ...
@@ -76,5 +77,6 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
76 76
 	if link, err := netlink.LinkByName(ep.srcName); err == nil {
77 77
 		netlink.LinkDel(link)
78 78
 	}
79
+
79 80
 	return nil
80 81
 }
... ...
@@ -39,7 +39,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
39 39
 		return fmt.Errorf("error generating an interface name: %v", err)
40 40
 	}
41 41
 	// create the netlink ipvlan interface
42
-	vethName, err := createIPVlan(containerIfName, n.config.HostIface, n.config.IpvlanMode)
42
+	vethName, err := createIPVlan(containerIfName, n.config.Parent, n.config.IpvlanMode)
43 43
 	if err != nil {
44 44
 		return err
45 45
 	}
... ...
@@ -59,8 +59,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
59 59
 		if err := jinfo.AddStaticRoute(defaultRoute.Destination, defaultRoute.RouteType, defaultRoute.NextHop); err != nil {
60 60
 			return fmt.Errorf("failed to set an ipvlan l3 mode ipv4 default gateway: %v", err)
61 61
 		}
62
-		logrus.Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Ipvlan_Mode: %s, Host_Iface: %s",
63
-			ep.addr.IP.String(), n.config.IpvlanMode, n.config.HostIface)
62
+		logrus.Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
63
+			ep.addr.IP.String(), n.config.IpvlanMode, n.config.Parent)
64 64
 		// If the endpoint has a v6 address, set a v6 default route
65 65
 		if ep.addrv6 != nil {
66 66
 			default6Route, err := ifaceGateway(defaultV6RouteCidr)
... ...
@@ -70,8 +70,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
70 70
 			if err = jinfo.AddStaticRoute(default6Route.Destination, default6Route.RouteType, default6Route.NextHop); err != nil {
71 71
 				return fmt.Errorf("failed to set an ipvlan l3 mode ipv6 default gateway: %v", err)
72 72
 			}
73
-			logrus.Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Ipvlan_Mode: %s, Host_Iface: %s",
74
-				ep.addrv6.IP.String(), n.config.IpvlanMode, n.config.HostIface)
73
+			logrus.Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
74
+				ep.addrv6.IP.String(), n.config.IpvlanMode, n.config.Parent)
75 75
 		}
76 76
 	}
77 77
 	if n.config.IpvlanMode == modeL2 {
... ...
@@ -89,8 +89,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
89 89
 			if err != nil {
90 90
 				return err
91 91
 			}
92
-			logrus.Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Host_Iface: %s",
93
-				ep.addr.IP.String(), v4gw.String(), n.config.IpvlanMode, n.config.HostIface)
92
+			logrus.Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
93
+				ep.addr.IP.String(), v4gw.String(), n.config.IpvlanMode, n.config.Parent)
94 94
 		}
95 95
 		// parse and correlate the endpoint v6 address with the available v6 subnets
96 96
 		if len(n.config.Ipv6Subnets) > 0 {
... ...
@@ -106,8 +106,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
106 106
 			if err != nil {
107 107
 				return err
108 108
 			}
109
-			logrus.Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Host_Iface: %s",
110
-				ep.addrv6.IP.String(), v6gw.String(), n.config.IpvlanMode, n.config.HostIface)
109
+			logrus.Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
110
+				ep.addrv6.IP.String(), v6gw.String(), n.config.IpvlanMode, n.config.Parent)
111 111
 		}
112 112
 	}
113 113
 	iNames := jinfo.InterfaceName()
... ...
@@ -115,6 +115,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
115 115
 	if err != nil {
116 116
 		return err
117 117
 	}
118
+
118 119
 	return nil
119 120
 }
120 121
 
... ...
@@ -131,6 +132,7 @@ func (d *driver) Leave(nid, eid string) error {
131 131
 	if endpoint == nil {
132 132
 		return fmt.Errorf("could not find endpoint with id %s", eid)
133 133
 	}
134
+
134 135
 	return nil
135 136
 }
136 137
 
... ...
@@ -145,6 +147,7 @@ func ifaceGateway(dfNet string) (*staticRoute, error) {
145 145
 		RouteType:   types.CONNECTED,
146 146
 		NextHop:     nh,
147 147
 	}
148
+
148 149
 	return defaultRoute, nil
149 150
 }
150 151
 
... ...
@@ -165,6 +168,7 @@ func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet {
165 165
 			return s
166 166
 		}
167 167
 	}
168
+
168 169
 	return nil
169 170
 }
170 171
 
... ...
@@ -185,5 +189,6 @@ func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet {
185 185
 			return s
186 186
 		}
187 187
 	}
188
+
188 189
 	return nil
189 190
 }
... ...
@@ -12,14 +12,14 @@ import (
12 12
 )
13 13
 
14 14
 // CreateNetwork the network for the specified driver type
15
-func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
15
+func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
16 16
 	// parse and validate the config and bind to networkConfiguration
17
-	config, err := parseNetworkOptions(id, option)
17
+	config, err := parseNetworkOptions(nid, option)
18 18
 	if err != nil {
19 19
 		return err
20 20
 	}
21
-	config.ID = id
22
-	err = config.processIPAM(id, ipV4Data, ipV6Data)
21
+	config.ID = nid
22
+	err = config.processIPAM(nid, ipV4Data, ipV6Data)
23 23
 	if err != nil {
24 24
 		return err
25 25
 	}
... ...
@@ -33,14 +33,16 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
33 33
 	default:
34 34
 		return fmt.Errorf("requested ipvlan mode '%s' is not valid, 'l2' mode is the ipvlan driver default", config.IpvlanMode)
35 35
 	}
36
-	// user must specify a parent interface on the host to attach the container vif -o host_iface=eth0
37
-	if config.HostIface == "" {
38
-		return fmt.Errorf("%s requires an interface from the docker host to be specified (usage: -o host_iface=eth)", ipvlanType)
39
-	}
40 36
 	// loopback is not a valid parent link
41
-	if config.HostIface == "lo" {
37
+	if config.Parent == "lo" {
42 38
 		return fmt.Errorf("loopback interface is not a valid %s parent link", ipvlanType)
43 39
 	}
40
+	// if parent interface not specified, create a dummy type link to use named dummy+net_id
41
+	if config.Parent == "" {
42
+		config.Parent = getDummyName(stringid.TruncateID(config.ID))
43
+		// empty parent and --internal are handled the same. Set here to update k/v
44
+		config.Internal = true
45
+	}
44 46
 	err = d.createNetwork(config)
45 47
 	if err != nil {
46 48
 		return err
... ...
@@ -49,6 +51,7 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
49 49
 	err = d.storeUpdate(config)
50 50
 	if err != nil {
51 51
 		d.deleteNetwork(config.ID)
52
+		logrus.Debugf("encoutered an error rolling back a network create for %s : %v", config.ID, err)
52 53
 		return err
53 54
 	}
54 55
 
... ...
@@ -57,23 +60,40 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
57 57
 
58 58
 // createNetwork is used by new network callbacks and persistent network cache
59 59
 func (d *driver) createNetwork(config *configuration) error {
60
+	// fail the network create if the ipvlan kernel module is unavailable
61
+	if err := kernelSupport(ipvlanType); err != nil {
62
+		return err
63
+	}
60 64
 	networkList := d.getNetworks()
61 65
 	for _, nw := range networkList {
62
-		if config.HostIface == nw.config.HostIface {
63
-			return fmt.Errorf("network %s is already using host interface %s",
64
-				stringid.TruncateID(nw.config.ID), config.HostIface)
66
+		if config.Parent == nw.config.Parent {
67
+			return fmt.Errorf("network %s is already using parent interface %s",
68
+				getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent)
65 69
 		}
66 70
 	}
67
-	// if the -o host_iface does not exist, attempt to parse a parent_iface.vlan_id
68
-	if ok := hostIfaceExists(config.HostIface); !ok {
69
-		// if the subinterface parent_iface.vlan_id checks do not pass, return err.
70
-		//  a valid example is eth0.10 for a parent iface: eth0 with a vlan id: 10
71
-		err := createVlanLink(config.HostIface)
72
-		if err != nil {
73
-			return err
71
+	if !parentExists(config.Parent) {
72
+		// if the --internal flag is set, create a dummy link
73
+		if config.Internal {
74
+			err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID)))
75
+			if err != nil {
76
+				return err
77
+			}
78
+			config.CreatedSlaveLink = true
79
+			// notify the user in logs they have limited comunicatins
80
+			if config.Parent == getDummyName(stringid.TruncateID(config.ID)) {
81
+				logrus.Debugf("Empty -o parent= and --internal flags limit communications to other containers inside of network: %s",
82
+					config.Parent)
83
+			}
84
+		} else {
85
+			// if the subinterface parent_iface.vlan_id checks do not pass, return err.
86
+			//  a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10'
87
+			err := createVlanLink(config.Parent)
88
+			if err != nil {
89
+				return err
90
+			}
91
+			// if driver created the networks slave link, record it for future deletion
92
+			config.CreatedSlaveLink = true
74 93
 		}
75
-		// if driver created the networks slave link, record it for future deletion
76
-		config.CreatedSlaveLink = true
77 94
 	}
78 95
 	n := &network{
79 96
 		id:        config.ID,
... ...
@@ -90,20 +110,38 @@ func (d *driver) createNetwork(config *configuration) error {
90 90
 // DeleteNetwork the network for the specified driver type
91 91
 func (d *driver) DeleteNetwork(nid string) error {
92 92
 	n := d.network(nid)
93
+	if n == nil {
94
+		return fmt.Errorf("network id %s not found", nid)
95
+	}
93 96
 	// if the driver created the slave interface, delete it, otherwise leave it
94 97
 	if ok := n.config.CreatedSlaveLink; ok {
95
-		// if the interface exists, only delete if it matches iface.vlan naming
96
-		if ok := hostIfaceExists(n.config.HostIface); ok {
97
-			err := delVlanLink(n.config.HostIface)
98
-			if err != nil {
99
-				logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v", n.config.HostIface, err)
98
+		// if the interface exists, only delete if it matches iface.vlan or dummy.net_id naming
99
+		if ok := parentExists(n.config.Parent); ok {
100
+			// only delete the link if it is named the net_id
101
+			if n.config.Parent == getDummyName(stringid.TruncateID(nid)) {
102
+				err := delDummyLink(n.config.Parent)
103
+				if err != nil {
104
+					logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v",
105
+						n.config.Parent, err)
106
+				}
107
+			} else {
108
+				// only delete the link if it matches iface.vlan naming
109
+				err := delVlanLink(n.config.Parent)
110
+				if err != nil {
111
+					logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v",
112
+						n.config.Parent, err)
113
+				}
100 114
 			}
101 115
 		}
102 116
 	}
103 117
 	// delete the *network
104 118
 	d.deleteNetwork(nid)
105 119
 	// delete the network record from persistent cache
106
-	return d.storeDelete(n.config)
120
+	err := d.storeDelete(n.config)
121
+	if err != nil {
122
+		return fmt.Errorf("error deleting deleting id %s from datastore: %v", nid, err)
123
+	}
124
+	return nil
107 125
 }
108 126
 
109 127
 // parseNetworkOptions parse docker network options
... ...
@@ -118,9 +156,11 @@ func parseNetworkOptions(id string, option options.Generic) (*configuration, err
118 118
 			return nil, err
119 119
 		}
120 120
 	}
121
-	// return an error if the unsupported --internal is passed
121
+	// setting the parent to "" will trigger an isolated network dummy parent link
122 122
 	if _, ok := option[netlabel.Internal]; ok {
123
-		return nil, fmt.Errorf("--internal option is not supported with the ipvlan driver")
123
+		config.Internal = true
124
+		// empty --parent= and --internal are handled the same.
125
+		config.Parent = ""
124 126
 	}
125 127
 	return config, nil
126 128
 }
... ...
@@ -152,9 +192,9 @@ func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
152 152
 func (config *configuration) fromOptions(labels map[string]string) error {
153 153
 	for label, value := range labels {
154 154
 		switch label {
155
-		case hostIfaceOpt:
156
-			// parse driver option '-o host_iface'
157
-			config.HostIface = value
155
+		case parentOpt:
156
+			// parse driver option '-o parent'
157
+			config.Parent = value
158 158
 		case driverModeOpt:
159 159
 			// parse driver option '-o ipvlan_mode'
160 160
 			config.IpvlanMode = value
... ...
@@ -13,32 +13,42 @@ import (
13 13
 	"github.com/vishvananda/netlink"
14 14
 )
15 15
 
16
-// Create the ipvlan netlink interface specifying the source name
17
-func createIPVlan(containerIfName, hostIface, ipVlanMode string) (string, error) {
16
+const (
17
+	dummyPrefix     = "di-"  // ipvlan prefix for dummy parent interface
18
+	ipvlanKernelVer = "3.19" // minimum ipvlan kernel version support
19
+)
20
+
21
+// createIPVlan Create the ipvlan slave specifying the source name
22
+func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) {
18 23
 	defer osl.InitOSContext()()
19
-	// Set the ipvlan mode. Default is L2 mode
20
-	mode, err := setIPVlanMode(ipVlanMode)
24
+
25
+	// Set the ipvlan mode. Default is bridge mode
26
+	mode, err := setIPVlanMode(ipvlanMode)
21 27
 	if err != nil {
22
-		return "", fmt.Errorf("unsupported %s ipvlan mode: %v", ipVlanMode, err)
28
+		return "", fmt.Errorf("Unsupported %s ipvlan mode: %v", ipvlanMode, err)
29
+	}
30
+	// verify the Docker host interface acting as the macvlan parent iface exists
31
+	if !parentExists(parent) {
32
+		return "", fmt.Errorf("the requested parent interface %s was not found on the Docker host", parent)
23 33
 	}
24 34
 	// Get the link for the master index (Example: the docker host eth iface)
25
-	hostEth, err := netlink.LinkByName(hostIface)
35
+	parentLink, err := netlink.LinkByName(parent)
26 36
 	if err != nil {
27
-		return "", fmt.Errorf("the requested host interface %s was not found on the Docker host", hostIface)
37
+		return "", fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", ipvlanType, parent, err)
28 38
 	}
29 39
 	// Create a ipvlan link
30 40
 	ipvlan := &netlink.IPVlan{
31 41
 		LinkAttrs: netlink.LinkAttrs{
32 42
 			Name:        containerIfName,
33
-			ParentIndex: hostEth.Attrs().Index,
43
+			ParentIndex: parentLink.Attrs().Index,
34 44
 		},
35 45
 		Mode: mode,
36 46
 	}
37 47
 	if err := netlink.LinkAdd(ipvlan); err != nil {
38
-		// verbose but will be an issue if you create a macvlan and ipvlan using the same parent iface
39
-		logrus.Warn("Ensure there are no macvlan networks using the same `-o host_iface` as the ipvlan network.")
40
-		return "", fmt.Errorf("Failed to create ipvlan link: %s with the error: %v", ipvlan.Name, err)
48
+		// If a user creates a macvlan and ipvlan on same parent, only one slave iface can be active at a time.
49
+		return "", fmt.Errorf("failed to create the %s port: %v", ipvlanType, err)
41 50
 	}
51
+
42 52
 	return ipvlan.Attrs().Name, nil
43 53
 }
44 54
 
... ...
@@ -54,12 +64,13 @@ func setIPVlanMode(mode string) (netlink.IPVlanMode, error) {
54 54
 	}
55 55
 }
56 56
 
57
-// validateHostIface check if the specified interface exists in the default namespace
58
-func hostIfaceExists(ifaceStr string) bool {
57
+// parentExists check if the specified interface exists in the default namespace
58
+func parentExists(ifaceStr string) bool {
59 59
 	_, err := netlink.LinkByName(ifaceStr)
60 60
 	if err != nil {
61 61
 		return false
62 62
 	}
63
+
63 64
 	return true
64 65
 }
65 66
 
... ...
@@ -78,13 +89,14 @@ func kernelSupport(networkTpe string) error {
78 78
 			return nil
79 79
 		}
80 80
 	}
81
-	return fmt.Errorf("required kernel module '%s' was not found in /proc/modules, ipvlan requires kernel version >= 3.19", ipvlanType)
81
+
82
+	return fmt.Errorf("unable to load the Linux kernel module %s", ipvlanType)
82 83
 }
83 84
 
84 85
 // createVlanLink parses sub-interfaces and vlan id for creation
85
-func createVlanLink(ifaceName string) error {
86
-	if strings.Contains(ifaceName, ".") {
87
-		parentIface, vidInt, err := parseVlan(ifaceName)
86
+func createVlanLink(parentName string) error {
87
+	if strings.Contains(parentName, ".") {
88
+		parent, vidInt, err := parseVlan(parentName)
88 89
 		if err != nil {
89 90
 			return err
90 91
 		}
... ...
@@ -93,74 +105,124 @@ func createVlanLink(ifaceName string) error {
93 93
 			return fmt.Errorf("vlan id must be between 1-4094, received: %d", vidInt)
94 94
 		}
95 95
 		// get the parent link to attach a vlan subinterface
96
-		hostIface, err := netlink.LinkByName(parentIface)
96
+		parentLink, err := netlink.LinkByName(parent)
97 97
 		if err != nil {
98
-			return fmt.Errorf("failed to find master interface %s on the Docker host: %v", parentIface, err)
98
+			return fmt.Errorf("failed to find master interface %s on the Docker host: %v", parent, err)
99 99
 		}
100
-		vlanIface := &netlink.Vlan{
100
+		vlanLink := &netlink.Vlan{
101 101
 			LinkAttrs: netlink.LinkAttrs{
102
-				Name:        ifaceName,
103
-				ParentIndex: hostIface.Attrs().Index,
102
+				Name:        parentName,
103
+				ParentIndex: parentLink.Attrs().Index,
104 104
 			},
105 105
 			VlanId: vidInt,
106 106
 		}
107 107
 		// create the subinterface
108
-		if err := netlink.LinkAdd(vlanIface); err != nil {
109
-			return fmt.Errorf("failed to create %s vlan link: %v", vlanIface.Name, err)
108
+		if err := netlink.LinkAdd(vlanLink); err != nil {
109
+			return fmt.Errorf("failed to create %s vlan link: %v", vlanLink.Name, err)
110 110
 		}
111 111
 		// Bring the new netlink iface up
112
-		if err := netlink.LinkSetUp(vlanIface); err != nil {
113
-			return fmt.Errorf("failed to enable %s the ipvlan netlink link: %v", vlanIface.Name, err)
112
+		if err := netlink.LinkSetUp(vlanLink); err != nil {
113
+			return fmt.Errorf("failed to enable %s the ipvlan parent link %v", vlanLink.Name, err)
114 114
 		}
115
-		logrus.Debugf("Added a vlan tagged netlink subinterface: %s with a vlan id: %d", ifaceName, vidInt)
115
+		logrus.Debugf("Added a vlan tagged netlink subinterface: %s with a vlan id: %d", parentName, vidInt)
116 116
 		return nil
117 117
 	}
118
-	return fmt.Errorf("invalid subinterface vlan name %s, example formatting is eth0.10", ifaceName)
118
+
119
+	return fmt.Errorf("invalid subinterface vlan name %s, example formatting is eth0.10", parentName)
119 120
 }
120 121
 
121
-// verifyVlanDel verifies only sub-interfaces with a vlan id get deleted
122
-func delVlanLink(ifaceName string) error {
123
-	if strings.Contains(ifaceName, ".") {
124
-		_, _, err := parseVlan(ifaceName)
122
+// delVlanLink verifies only sub-interfaces with a vlan id get deleted
123
+func delVlanLink(linkName string) error {
124
+	if strings.Contains(linkName, ".") {
125
+		_, _, err := parseVlan(linkName)
125 126
 		if err != nil {
126 127
 			return err
127 128
 		}
128 129
 		// delete the vlan subinterface
129
-		vlanIface, err := netlink.LinkByName(ifaceName)
130
+		vlanLink, err := netlink.LinkByName(linkName)
130 131
 		if err != nil {
131
-			return fmt.Errorf("failed to find interface %s on the Docker host : %v", ifaceName, err)
132
+			return fmt.Errorf("failed to find interface %s on the Docker host : %v", linkName, err)
132 133
 		}
133 134
 		// verify a parent interface isn't being deleted
134
-		if vlanIface.Attrs().ParentIndex == 0 {
135
-			return fmt.Errorf("interface %s does not appear to be a slave device: %v", ifaceName, err)
135
+		if vlanLink.Attrs().ParentIndex == 0 {
136
+			return fmt.Errorf("interface %s does not appear to be a slave device: %v", linkName, err)
136 137
 		}
137 138
 		// delete the ipvlan slave device
138
-		if err := netlink.LinkDel(vlanIface); err != nil {
139
-			return fmt.Errorf("failed to delete  %s link: %v", ifaceName, err)
139
+		if err := netlink.LinkDel(vlanLink); err != nil {
140
+			return fmt.Errorf("failed to delete  %s link: %v", linkName, err)
140 141
 		}
141
-		logrus.Debugf("Deleted a vlan tagged netlink subinterface: %s", ifaceName)
142
+		logrus.Debugf("Deleted a vlan tagged netlink subinterface: %s", linkName)
142 143
 	}
143 144
 	// if the subinterface doesn't parse to iface.vlan_id leave the interface in
144 145
 	// place since it could be a user specified name not created by the driver.
145 146
 	return nil
146 147
 }
147 148
 
148
-// parseVlan parses and verifies a slave interface name: -o host_iface=eth0.10
149
-func parseVlan(ifaceName string) (string, int, error) {
150
-	// parse -o host_iface=eth0.10
151
-	splitIface := strings.Split(ifaceName, ".")
152
-	if len(splitIface) != 2 {
153
-		return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", ifaceName)
149
+// parseVlan parses and verifies a slave interface name: -o parent=eth0.10
150
+func parseVlan(linkName string) (string, int, error) {
151
+	// parse -o parent=eth0.10
152
+	splitName := strings.Split(linkName, ".")
153
+	if len(splitName) != 2 {
154
+		return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", linkName)
154 155
 	}
155
-	parentIface, vidStr := splitIface[0], splitIface[1]
156
+	parent, vidStr := splitName[0], splitName[1]
156 157
 	// validate type and convert vlan id to int
157 158
 	vidInt, err := strconv.Atoi(vidStr)
158 159
 	if err != nil {
159 160
 		return "", 0, fmt.Errorf("unable to parse a valid vlan id from: %s (ex. eth0.10 for vlan 10)", vidStr)
160 161
 	}
161 162
 	// Check if the interface exists
162
-	if ok := hostIfaceExists(parentIface); !ok {
163
-		return "", 0, fmt.Errorf("-o host_iface parent interface does was not found on the host: %s", parentIface)
163
+	if !parentExists(parent) {
164
+		return "", 0, fmt.Errorf("-o parent interface does was not found on the host: %s", parent)
165
+	}
166
+
167
+	return parent, vidInt, nil
168
+}
169
+
170
+// createDummyLink creates a dummy0 parent link
171
+func createDummyLink(dummyName, truncNetID string) error {
172
+	// create a parent interface since one was not specified
173
+	parent := &netlink.Dummy{
174
+		LinkAttrs: netlink.LinkAttrs{
175
+			Name: dummyName,
176
+		},
177
+	}
178
+	if err := netlink.LinkAdd(parent); err != nil {
179
+		return err
164 180
 	}
165
-	return parentIface, vidInt, nil
181
+	parentDummyLink, err := netlink.LinkByName(dummyName)
182
+	if err != nil {
183
+		return fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", ipvlanType, dummyName, err)
184
+	}
185
+	// bring the new netlink iface up
186
+	if err := netlink.LinkSetUp(parentDummyLink); err != nil {
187
+		return fmt.Errorf("failed to enable %s the ipvlan parent link: %v", dummyName, err)
188
+	}
189
+
190
+	return nil
191
+}
192
+
193
+// delDummyLink deletes the link type dummy used when -o parent is not passed
194
+func delDummyLink(linkName string) error {
195
+	// delete the vlan subinterface
196
+	dummyLink, err := netlink.LinkByName(linkName)
197
+	if err != nil {
198
+		return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err)
199
+	}
200
+	// verify a parent interface is being deleted
201
+	if dummyLink.Attrs().ParentIndex != 0 {
202
+		return fmt.Errorf("link %s is not a parent dummy interface", linkName)
203
+	}
204
+	// delete the ipvlan dummy device
205
+	if err := netlink.LinkDel(dummyLink); err != nil {
206
+		return fmt.Errorf("failed to delete the dummy %s link: %v", linkName, err)
207
+	}
208
+	logrus.Debugf("Deleted a dummy parent link: %s", linkName)
209
+
210
+	return nil
211
+}
212
+
213
+// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
214
+func getDummyName(netID string) string {
215
+	return fmt.Sprintf("%s%s", dummyPrefix, netID)
166 216
 }
... ...
@@ -6,17 +6,17 @@ import (
6 6
 	"github.com/vishvananda/netlink"
7 7
 )
8 8
 
9
-// TestValidateLink tests the validateHostIface function
9
+// TestValidateLink tests the parentExists function
10 10
 func TestValidateLink(t *testing.T) {
11 11
 	validIface := "lo"
12 12
 	invalidIface := "foo12345"
13 13
 
14 14
 	// test a valid parent interface validation
15
-	if ok := hostIfaceExists(validIface); !ok {
15
+	if ok := parentExists(validIface); !ok {
16 16
 		t.Fatalf("failed validating loopback %s", validIface)
17 17
 	}
18 18
 	// test a invalid parent interface validation
19
-	if ok := hostIfaceExists(invalidIface); ok {
19
+	if ok := parentExists(invalidIface); ok {
20 20
 		t.Fatalf("failed to invalidate interface %s", invalidIface)
21 21
 	}
22 22
 }
... ...
@@ -15,6 +15,7 @@ func (d *driver) network(nid string) *network {
15 15
 	if !ok {
16 16
 		logrus.Errorf("network id %s not found", nid)
17 17
 	}
18
+
18 19
 	return n
19 20
 }
20 21
 
... ...
@@ -39,6 +40,7 @@ func (d *driver) getNetworks() []*network {
39 39
 	for _, nw := range d.networks {
40 40
 		ls = append(ls, nw)
41 41
 	}
42
+
42 43
 	return ls
43 44
 }
44 45
 
... ...
@@ -70,6 +72,7 @@ func (n *network) getEndpoint(eid string) (*endpoint, error) {
70 70
 	if ep, ok := n.endpoints[eid]; ok {
71 71
 		return ep, nil
72 72
 	}
73
+
73 74
 	return nil, nil
74 75
 }
75 76
 
... ...
@@ -80,12 +83,14 @@ func validateID(nid, eid string) error {
80 80
 	if eid == "" {
81 81
 		return fmt.Errorf("invalid endpoint id")
82 82
 	}
83
+
83 84
 	return nil
84 85
 }
85 86
 
86 87
 func (n *network) sandbox() osl.Sandbox {
87 88
 	n.Lock()
88 89
 	defer n.Unlock()
90
+
89 91
 	return n.sbox
90 92
 }
91 93
 
... ...
@@ -105,5 +110,6 @@ func (d *driver) getNetwork(id string) (*network, error) {
105 105
 	if nw, ok := d.networks[id]; ok {
106 106
 		return nw, nil
107 107
 	}
108
+
108 109
 	return nil, types.NotFoundErrorf("network not found: %s", id)
109 110
 }
... ...
@@ -21,7 +21,7 @@ type configuration struct {
21 21
 	dbIndex          uint64
22 22
 	dbExists         bool
23 23
 	Internal         bool
24
-	HostIface        string
24
+	Parent           string
25 25
 	IpvlanMode       string
26 26
 	CreatedSlaveLink bool
27 27
 	Ipv4Subnets      []*ipv4Subnet
... ...
@@ -114,8 +114,9 @@ func (config *configuration) MarshalJSON() ([]byte, error) {
114 114
 	nMap := make(map[string]interface{})
115 115
 	nMap["ID"] = config.ID
116 116
 	nMap["Mtu"] = config.Mtu
117
-	nMap["HostIface"] = config.HostIface
117
+	nMap["Parent"] = config.Parent
118 118
 	nMap["IpvlanMode"] = config.IpvlanMode
119
+	nMap["Internal"] = config.Internal
119 120
 	nMap["CreatedSubIface"] = config.CreatedSlaveLink
120 121
 	if len(config.Ipv4Subnets) > 0 {
121 122
 		iis, err := json.Marshal(config.Ipv4Subnets)
... ...
@@ -131,6 +132,7 @@ func (config *configuration) MarshalJSON() ([]byte, error) {
131 131
 		}
132 132
 		nMap["Ipv6Subnets"] = string(iis)
133 133
 	}
134
+
134 135
 	return json.Marshal(nMap)
135 136
 }
136 137
 
... ...
@@ -145,8 +147,9 @@ func (config *configuration) UnmarshalJSON(b []byte) error {
145 145
 	}
146 146
 	config.ID = nMap["ID"].(string)
147 147
 	config.Mtu = int(nMap["Mtu"].(float64))
148
-	config.HostIface = nMap["HostIface"].(string)
148
+	config.Parent = nMap["Parent"].(string)
149 149
 	config.IpvlanMode = nMap["IpvlanMode"].(string)
150
+	config.Internal = nMap["Internal"].(bool)
150 151
 	config.CreatedSlaveLink = nMap["CreatedSubIface"].(bool)
151 152
 	if v, ok := nMap["Ipv4Subnets"]; ok {
152 153
 		if err := json.Unmarshal([]byte(v.(string)), &config.Ipv4Subnets); err != nil {
... ...
@@ -158,6 +161,7 @@ func (config *configuration) UnmarshalJSON(b []byte) error {
158 158
 			return err
159 159
 		}
160 160
 	}
161
+
161 162
 	return nil
162 163
 }
163 164
 
... ...
@@ -4,7 +4,6 @@ import (
4 4
 	"net"
5 5
 	"sync"
6 6
 
7
-	"github.com/Sirupsen/logrus"
8 7
 	"github.com/docker/libnetwork/datastore"
9 8
 	"github.com/docker/libnetwork/discoverapi"
10 9
 	"github.com/docker/libnetwork/driverapi"
... ...
@@ -15,13 +14,13 @@ const (
15 15
 	vethLen             = 7
16 16
 	containerVethPrefix = "eth"
17 17
 	vethPrefix          = "veth"
18
-	macvlanType         = "macvlan"    // driver type name
19
-	modePrivate         = "private"    // macvlan mode private
20
-	modeVepa            = "vepa"       // macvlan mode vepa
21
-	modeBridge          = "bridge"     // macvlan mode bridge
22
-	modePassthru        = "passthru"   // macvlan mode passthrough
23
-	hostIfaceOpt        = "host_iface" // host interface -o host_iface
24
-	modeOpt             = "_mode"      // macvlan mode ux opt suffix
18
+	macvlanType         = "macvlan"  // driver type name
19
+	modePrivate         = "private"  // macvlan mode private
20
+	modeVepa            = "vepa"     // macvlan mode vepa
21
+	modeBridge          = "bridge"   // macvlan mode bridge
22
+	modePassthru        = "passthru" // macvlan mode passthrough
23
+	parentOpt           = "parent"   // parent interface -o parent
24
+	modeOpt             = "_mode"    // macvlan mode ux opt suffix
25 25
 )
26 26
 
27 27
 var driverModeOpt = macvlanType + modeOpt // mode --option macvlan_mode
... ...
@@ -56,9 +55,6 @@ type network struct {
56 56
 
57 57
 // Init initializes and registers the libnetwork macvlan driver
58 58
 func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
59
-	if err := kernelSupport(macvlanType); err != nil {
60
-		logrus.Warnf("encountered errors loading the macvlan kernel module: %v", err)
61
-	}
62 59
 	c := driverapi.Capability{
63 60
 		DataScope: datastore.LocalScope,
64 61
 	}
... ...
@@ -66,6 +62,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
66 66
 		networks: networkTable{},
67 67
 	}
68 68
 	d.initStore(config)
69
+
69 70
 	return dc.RegisterDriver(macvlanType, d, c)
70 71
 }
71 72
 
... ...
@@ -3,6 +3,7 @@ package macvlan
3 3
 import (
4 4
 	"fmt"
5 5
 
6
+	"github.com/Sirupsen/logrus"
6 7
 	"github.com/docker/libnetwork/driverapi"
7 8
 	"github.com/docker/libnetwork/netlabel"
8 9
 	"github.com/docker/libnetwork/netutils"
... ...
@@ -21,9 +22,6 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
21 21
 	if err != nil {
22 22
 		return fmt.Errorf("network id %q not found", nid)
23 23
 	}
24
-	if ifInfo.MacAddress() != nil {
25
-		return fmt.Errorf("%s interfaces do not support custom mac address assigment", macvlanType)
26
-	}
27 24
 	ep := &endpoint{
28 25
 		id:     eid,
29 26
 		addr:   ifInfo.Address(),
... ...
@@ -43,7 +41,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
43 43
 	if opt, ok := epOptions[netlabel.PortMap]; ok {
44 44
 		if _, ok := opt.([]types.PortBinding); ok {
45 45
 			if len(opt.([]types.PortBinding)) > 0 {
46
-				return fmt.Errorf("%s driver does not support port mappings", macvlanType)
46
+				logrus.Warnf("%s driver does not support port mappings", macvlanType)
47 47
 			}
48 48
 		}
49 49
 	}
... ...
@@ -51,7 +49,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
51 51
 	if opt, ok := epOptions[netlabel.ExposedPorts]; ok {
52 52
 		if _, ok := opt.([]types.TransportPort); ok {
53 53
 			if len(opt.([]types.TransportPort)) > 0 {
54
-				return fmt.Errorf("%s driver does not support port exposures", macvlanType)
54
+				logrus.Warnf("%s driver does not support port exposures", macvlanType)
55 55
 			}
56 56
 		}
57 57
 	}
... ...
@@ -76,5 +74,6 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
76 76
 	if link, err := netlink.LinkByName(ep.srcName); err == nil {
77 77
 		netlink.LinkDel(link)
78 78
 	}
79
+
79 80
 	return nil
80 81
 }
... ...
@@ -27,7 +27,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
27 27
 		return fmt.Errorf("error generating an interface name: %s", err)
28 28
 	}
29 29
 	// create the netlink macvlan interface
30
-	vethName, err := createMacVlan(containerIfName, n.config.HostIface, n.config.MacvlanMode)
30
+	vethName, err := createMacVlan(containerIfName, n.config.Parent, n.config.MacvlanMode)
31 31
 	if err != nil {
32 32
 		return err
33 33
 	}
... ...
@@ -51,8 +51,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
51 51
 		if err != nil {
52 52
 			return err
53 53
 		}
54
-		logrus.Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, MacVlan_Mode: %s, Host_Iface: %s",
55
-			ep.addr.IP.String(), v4gw.String(), n.config.MacvlanMode, n.config.HostIface)
54
+		logrus.Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, MacVlan_Mode: %s, Parent: %s",
55
+			ep.addr.IP.String(), v4gw.String(), n.config.MacvlanMode, n.config.Parent)
56 56
 	}
57 57
 	// parse and match the endpoint address with the available v6 subnets
58 58
 	if len(n.config.Ipv6Subnets) > 0 {
... ...
@@ -68,14 +68,15 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
68 68
 		if err != nil {
69 69
 			return err
70 70
 		}
71
-		logrus.Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s Gateway: %s MacVlan_Mode: %s, Host_Iface: %s",
72
-			ep.addrv6.IP.String(), v6gw.String(), n.config.MacvlanMode, n.config.HostIface)
71
+		logrus.Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s Gateway: %s MacVlan_Mode: %s, Parent: %s",
72
+			ep.addrv6.IP.String(), v6gw.String(), n.config.MacvlanMode, n.config.Parent)
73 73
 	}
74 74
 	iNames := jinfo.InterfaceName()
75 75
 	err = iNames.SetNames(vethName, containerVethPrefix)
76 76
 	if err != nil {
77 77
 		return err
78 78
 	}
79
+
79 80
 	return nil
80 81
 }
81 82
 
... ...
@@ -92,6 +93,7 @@ func (d *driver) Leave(nid, eid string) error {
92 92
 	if endpoint == nil {
93 93
 		return fmt.Errorf("could not find endpoint with id %s", eid)
94 94
 	}
95
+
95 96
 	return nil
96 97
 }
97 98
 
... ...
@@ -112,6 +114,7 @@ func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet {
112 112
 			return s
113 113
 		}
114 114
 	}
115
+
115 116
 	return nil
116 117
 }
117 118
 
... ...
@@ -132,5 +135,6 @@ func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet {
132 132
 			return s
133 133
 		}
134 134
 	}
135
+
135 136
 	return nil
136 137
 }
... ...
@@ -12,25 +12,17 @@ import (
12 12
 )
13 13
 
14 14
 // CreateNetwork the network for the specified driver type
15
-func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
15
+func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
16 16
 	// parse and validate the config and bind to networkConfiguration
17
-	config, err := parseNetworkOptions(id, option)
17
+	config, err := parseNetworkOptions(nid, option)
18 18
 	if err != nil {
19 19
 		return err
20 20
 	}
21
-	config.ID = id
22
-	err = config.processIPAM(id, ipV4Data, ipV6Data)
21
+	config.ID = nid
22
+	err = config.processIPAM(nid, ipV4Data, ipV6Data)
23 23
 	if err != nil {
24 24
 		return err
25 25
 	}
26
-	// user must specify a parent interface on the host to attach the container vif -o host_iface=eth0
27
-	if config.HostIface == "" {
28
-		return fmt.Errorf("%s requires an interface from the docker host to be specified (usage: -o host_iface=eth)", macvlanType)
29
-	}
30
-	// loopback is not a valid parent link
31
-	if config.HostIface == "lo" {
32
-		return fmt.Errorf("loopback interface is not a valid %s parent link", macvlanType)
33
-	}
34 26
 	// verify the macvlan mode from -o macvlan_mode option
35 27
 	switch config.MacvlanMode {
36 28
 	case "", modeBridge:
... ...
@@ -45,6 +37,16 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
45 45
 	default:
46 46
 		return fmt.Errorf("requested macvlan mode '%s' is not valid, 'bridge' mode is the macvlan driver default", config.MacvlanMode)
47 47
 	}
48
+	// loopback is not a valid parent link
49
+	if config.Parent == "lo" {
50
+		return fmt.Errorf("loopback interface is not a valid %s parent link", macvlanType)
51
+	}
52
+	// if parent interface not specified, create a dummy type link to use named dummy+net_id
53
+	if config.Parent == "" {
54
+		config.Parent = getDummyName(stringid.TruncateID(config.ID))
55
+		// empty parent and --internal are handled the same. Set here to update k/v
56
+		config.Internal = true
57
+	}
48 58
 	err = d.createNetwork(config)
49 59
 	if err != nil {
50 60
 		return err
... ...
@@ -53,6 +55,7 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
53 53
 	err = d.storeUpdate(config)
54 54
 	if err != nil {
55 55
 		d.deleteNetwork(config.ID)
56
+		logrus.Debugf("encoutered an error rolling back a network create for %s : %v", config.ID, err)
56 57
 		return err
57 58
 	}
58 59
 
... ...
@@ -61,24 +64,40 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
61 61
 
62 62
 // createNetwork is used by new network callbacks and persistent network cache
63 63
 func (d *driver) createNetwork(config *configuration) error {
64
-	// if the -o host_iface does not exist, attempt to parse a parent_iface.vlan_id
64
+	// fail the network create if the macvlan kernel module is unavailable
65
+	if err := kernelSupport(macvlanType); err != nil {
66
+		return err
67
+	}
65 68
 	networkList := d.getNetworks()
66 69
 	for _, nw := range networkList {
67
-		if config.HostIface == nw.config.HostIface {
68
-			return fmt.Errorf("network %s is already using host interface %s",
69
-				stringid.TruncateID(nw.config.ID), config.HostIface)
70
+		if config.Parent == nw.config.Parent {
71
+			return fmt.Errorf("network %s is already using parent interface %s",
72
+				getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent)
70 73
 		}
71 74
 	}
72
-	// if the -o host_iface does not exist, attempt to parse a parent_iface.vlan_id
73
-	if ok := hostIfaceExists(config.HostIface); !ok {
74
-		// if the subinterface parent_iface.vlan_id checks do not pass, return err.
75
-		//  a valid example is eth0.10 for a parent iface: eth0 with a vlan id: 10
76
-		err := createVlanLink(config.HostIface)
77
-		if err != nil {
78
-			return err
75
+	if !parentExists(config.Parent) {
76
+		// if the --internal flag is set, create a dummy link
77
+		if config.Internal {
78
+			err := createDummyLink(config.Parent, getDummyName(stringid.TruncateID(config.ID)))
79
+			if err != nil {
80
+				return err
81
+			}
82
+			config.CreatedSlaveLink = true
83
+			// notify the user in logs they have limited comunicatins
84
+			if config.Parent == getDummyName(stringid.TruncateID(config.ID)) {
85
+				logrus.Debugf("Empty -o parent= and --internal flags limit communications to other containers inside of network: %s",
86
+					config.Parent)
87
+			}
88
+		} else {
89
+			// if the subinterface parent_iface.vlan_id checks do not pass, return err.
90
+			//  a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10'
91
+			err := createVlanLink(config.Parent)
92
+			if err != nil {
93
+				return err
94
+			}
95
+			// if driver created the networks slave link, record it for future deletion
96
+			config.CreatedSlaveLink = true
79 97
 		}
80
-		// if driver created the networks slave link, record it for future deletion
81
-		config.CreatedSlaveLink = true
82 98
 	}
83 99
 	n := &network{
84 100
 		id:        config.ID,
... ...
@@ -95,20 +114,38 @@ func (d *driver) createNetwork(config *configuration) error {
95 95
 // DeleteNetwork the network for the specified driver type
96 96
 func (d *driver) DeleteNetwork(nid string) error {
97 97
 	n := d.network(nid)
98
+	if n == nil {
99
+		return fmt.Errorf("network id %s not found", nid)
100
+	}
98 101
 	// if the driver created the slave interface, delete it, otherwise leave it
99 102
 	if ok := n.config.CreatedSlaveLink; ok {
100
-		// if the interface exists, only delete if it matches iface.vlan naming
101
-		if ok := hostIfaceExists(n.config.HostIface); ok {
102
-			err := delVlanLink(n.config.HostIface)
103
-			if err != nil {
104
-				logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v", n.config.HostIface, err)
103
+		// if the interface exists, only delete if it matches iface.vlan or dummy.net_id naming
104
+		if ok := parentExists(n.config.Parent); ok {
105
+			// only delete the link if it is named the net_id
106
+			if n.config.Parent == getDummyName(stringid.TruncateID(nid)) {
107
+				err := delDummyLink(n.config.Parent)
108
+				if err != nil {
109
+					logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v",
110
+						n.config.Parent, err)
111
+				}
112
+			} else {
113
+				// only delete the link if it matches iface.vlan naming
114
+				err := delVlanLink(n.config.Parent)
115
+				if err != nil {
116
+					logrus.Debugf("link %s was not deleted, continuing the delete network operation: %v",
117
+						n.config.Parent, err)
118
+				}
105 119
 			}
106 120
 		}
107 121
 	}
108 122
 	// delete the *network
109 123
 	d.deleteNetwork(nid)
110 124
 	// delete the network record from persistent cache
111
-	return d.storeDelete(n.config)
125
+	err := d.storeDelete(n.config)
126
+	if err != nil {
127
+		return fmt.Errorf("error deleting deleting id %s from datastore: %v", nid, err)
128
+	}
129
+	return nil
112 130
 }
113 131
 
114 132
 // parseNetworkOptions parse docker network options
... ...
@@ -123,10 +160,13 @@ func parseNetworkOptions(id string, option options.Generic) (*configuration, err
123 123
 			return nil, err
124 124
 		}
125 125
 	}
126
-	// return an error if the unsupported --internal is passed
126
+	// setting the parent to "" will trigger an isolated network dummy parent link
127 127
 	if _, ok := option[netlabel.Internal]; ok {
128
-		return nil, fmt.Errorf("--internal option is not supported with the macvlan driver")
128
+		config.Internal = true
129
+		// empty --parent= and --internal are handled the same.
130
+		config.Parent = ""
129 131
 	}
132
+
130 133
 	return config, nil
131 134
 }
132 135
 
... ...
@@ -150,6 +190,7 @@ func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
150 150
 	default:
151 151
 		err = types.BadRequestErrorf("unrecognized network configuration format: %v", opt)
152 152
 	}
153
+
153 154
 	return config, err
154 155
 }
155 156
 
... ...
@@ -157,14 +198,15 @@ func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
157 157
 func (config *configuration) fromOptions(labels map[string]string) error {
158 158
 	for label, value := range labels {
159 159
 		switch label {
160
-		case hostIfaceOpt:
161
-			// parse driver option '-o host_iface'
162
-			config.HostIface = value
160
+		case parentOpt:
161
+			// parse driver option '-o parent'
162
+			config.Parent = value
163 163
 		case driverModeOpt:
164 164
 			// parse driver option '-o macvlan_mode'
165 165
 			config.MacvlanMode = value
166 166
 		}
167 167
 	}
168
+
168 169
 	return nil
169 170
 }
170 171
 
... ...
@@ -188,5 +230,6 @@ func (config *configuration) processIPAM(id string, ipamV4Data, ipamV6Data []dri
188 188
 			config.Ipv6Subnets = append(config.Ipv6Subnets, s)
189 189
 		}
190 190
 	}
191
+
191 192
 	return nil
192 193
 }
... ...
@@ -13,8 +13,13 @@ import (
13 13
 	"github.com/vishvananda/netlink"
14 14
 )
15 15
 
16
-// Create the netlink interface specifying the source name
17
-func createMacVlan(containerIfName, hostIface, macvlanMode string) (string, error) {
16
+const (
17
+	dummyPrefix      = "dm-" // macvlan prefix for dummy parent interface
18
+	macvlanKernelVer = "3.9" // minimum ipvlan kernel version support
19
+)
20
+
21
+// Create the macvlan slave specifying the source name
22
+func createMacVlan(containerIfName, parent, macvlanMode string) (string, error) {
18 23
 	defer osl.InitOSContext()()
19 24
 
20 25
 	// Set the macvlan mode. Default is bridge mode
... ...
@@ -23,27 +28,27 @@ func createMacVlan(containerIfName, hostIface, macvlanMode string) (string, erro
23 23
 		return "", fmt.Errorf("Unsupported %s macvlan mode: %v", macvlanMode, err)
24 24
 	}
25 25
 	// verify the Docker host interface acting as the macvlan parent iface exists
26
-	if ok := hostIfaceExists(hostIface); !ok {
27
-		return "", fmt.Errorf("the requested host interface %s was not found on the Docker host", hostIface)
26
+	if !parentExists(parent) {
27
+		return "", fmt.Errorf("the requested parent interface %s was not found on the Docker host", parent)
28 28
 	}
29 29
 	// Get the link for the master index (Example: the docker host eth iface)
30
-	hostEth, err := netlink.LinkByName(hostIface)
30
+	parentLink, err := netlink.LinkByName(parent)
31 31
 	if err != nil {
32
-		logrus.Errorf("error occoured looking up the parent iface %s mode: %s error: %s", hostIface, macvlanMode, err)
32
+		return "", fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", macvlanType, parent, err)
33 33
 	}
34 34
 	// Create a macvlan link
35 35
 	macvlan := &netlink.Macvlan{
36 36
 		LinkAttrs: netlink.LinkAttrs{
37 37
 			Name:        containerIfName,
38
-			ParentIndex: hostEth.Attrs().Index,
38
+			ParentIndex: parentLink.Attrs().Index,
39 39
 		},
40 40
 		Mode: mode,
41 41
 	}
42 42
 	if err := netlink.LinkAdd(macvlan); err != nil {
43
-		// verbose but will be an issue if user creates a macvlan and ipvlan on same parent.Netlink msg is uninformative
44
-		logrus.Warn("Ensure there are no ipvlan networks using the same `-o host_iface` as the macvlan network.")
45
-		return "", fmt.Errorf("Failed to create macvlan link: %s with the error: %v", macvlan.Name, err)
43
+		// If a user creates a macvlan and ipvlan on same parent, only one slave iface can be active at a time.
44
+		return "", fmt.Errorf("failed to create the %s port: %v", macvlanType, err)
46 45
 	}
46
+
47 47
 	return macvlan.Attrs().Name, nil
48 48
 }
49 49
 
... ...
@@ -63,12 +68,13 @@ func setMacVlanMode(mode string) (netlink.MacvlanMode, error) {
63 63
 	}
64 64
 }
65 65
 
66
-// validateHostIface check if the specified interface exists in the default namespace
67
-func hostIfaceExists(ifaceStr string) bool {
66
+// parentExists check if the specified interface exists in the default namespace
67
+func parentExists(ifaceStr string) bool {
68 68
 	_, err := netlink.LinkByName(ifaceStr)
69 69
 	if err != nil {
70 70
 		return false
71 71
 	}
72
+
72 73
 	return true
73 74
 }
74 75
 
... ...
@@ -87,13 +93,14 @@ func kernelSupport(networkTpe string) error {
87 87
 			return nil
88 88
 		}
89 89
 	}
90
-	return fmt.Errorf("required kernel module '%s' was not found in /proc/modules, kernel version >= 3.19 is recommended", macvlanType)
90
+
91
+	return fmt.Errorf("unable to load the Linux kernel module %s", macvlanType)
91 92
 }
92 93
 
93 94
 // createVlanLink parses sub-interfaces and vlan id for creation
94
-func createVlanLink(ifaceName string) error {
95
-	if strings.Contains(ifaceName, ".") {
96
-		parentIface, vidInt, err := parseVlan(ifaceName)
95
+func createVlanLink(parentName string) error {
96
+	if strings.Contains(parentName, ".") {
97
+		parent, vidInt, err := parseVlan(parentName)
97 98
 		if err != nil {
98 99
 			return err
99 100
 		}
... ...
@@ -102,74 +109,124 @@ func createVlanLink(ifaceName string) error {
102 102
 			return fmt.Errorf("vlan id must be between 1-4094, received: %d", vidInt)
103 103
 		}
104 104
 		// get the parent link to attach a vlan subinterface
105
-		hostIface, err := netlink.LinkByName(parentIface)
105
+		parentLink, err := netlink.LinkByName(parent)
106 106
 		if err != nil {
107
-			return fmt.Errorf("failed to find master interface %s on the Docker host: %v", parentIface, err)
107
+			return fmt.Errorf("failed to find master interface %s on the Docker host: %v", parent, err)
108 108
 		}
109
-		vlanIface := &netlink.Vlan{
109
+		vlanLink := &netlink.Vlan{
110 110
 			LinkAttrs: netlink.LinkAttrs{
111
-				Name:        ifaceName,
112
-				ParentIndex: hostIface.Attrs().Index,
111
+				Name:        parentName,
112
+				ParentIndex: parentLink.Attrs().Index,
113 113
 			},
114 114
 			VlanId: vidInt,
115 115
 		}
116 116
 		// create the subinterface
117
-		if err := netlink.LinkAdd(vlanIface); err != nil {
118
-			return fmt.Errorf("failed to create %s vlan link: %v", vlanIface.Name, err)
117
+		if err := netlink.LinkAdd(vlanLink); err != nil {
118
+			return fmt.Errorf("failed to create %s vlan link: %v", vlanLink.Name, err)
119 119
 		}
120 120
 		// Bring the new netlink iface up
121
-		if err := netlink.LinkSetUp(vlanIface); err != nil {
122
-			return fmt.Errorf("failed to enable %s the macvlan netlink link: %v", vlanIface.Name, err)
121
+		if err := netlink.LinkSetUp(vlanLink); err != nil {
122
+			return fmt.Errorf("failed to enable %s the macvlan parent link %v", vlanLink.Name, err)
123 123
 		}
124
-		logrus.Debugf("Added a vlan tagged netlink subinterface: %s with a vlan id: %d", ifaceName, vidInt)
124
+		logrus.Debugf("Added a vlan tagged netlink subinterface: %s with a vlan id: %d", parentName, vidInt)
125 125
 		return nil
126 126
 	}
127
-	return fmt.Errorf("invalid subinterface vlan name %s, example formatting is eth0.10", ifaceName)
127
+
128
+	return fmt.Errorf("invalid subinterface vlan name %s, example formatting is eth0.10", parentName)
128 129
 }
129 130
 
130
-// verifyVlanDel verifies only sub-interfaces with a vlan id get deleted
131
-func delVlanLink(ifaceName string) error {
132
-	if strings.Contains(ifaceName, ".") {
133
-		_, _, err := parseVlan(ifaceName)
131
+// delVlanLink verifies only sub-interfaces with a vlan id get deleted
132
+func delVlanLink(linkName string) error {
133
+	if strings.Contains(linkName, ".") {
134
+		_, _, err := parseVlan(linkName)
134 135
 		if err != nil {
135 136
 			return err
136 137
 		}
137 138
 		// delete the vlan subinterface
138
-		vlanIface, err := netlink.LinkByName(ifaceName)
139
+		vlanLink, err := netlink.LinkByName(linkName)
139 140
 		if err != nil {
140
-			return fmt.Errorf("failed to find interface %s on the Docker host : %v", ifaceName, err)
141
+			return fmt.Errorf("failed to find interface %s on the Docker host : %v", linkName, err)
141 142
 		}
142 143
 		// verify a parent interface isn't being deleted
143
-		if vlanIface.Attrs().ParentIndex == 0 {
144
-			return fmt.Errorf("interface %s does not appear to be a slave device: %v", ifaceName, err)
144
+		if vlanLink.Attrs().ParentIndex == 0 {
145
+			return fmt.Errorf("interface %s does not appear to be a slave device: %v", linkName, err)
145 146
 		}
146 147
 		// delete the macvlan slave device
147
-		if err := netlink.LinkDel(vlanIface); err != nil {
148
-			return fmt.Errorf("failed to delete  %s link: %v", ifaceName, err)
148
+		if err := netlink.LinkDel(vlanLink); err != nil {
149
+			return fmt.Errorf("failed to delete  %s link: %v", linkName, err)
149 150
 		}
150
-		logrus.Debugf("Deleted a vlan tagged netlink subinterface: %s", ifaceName)
151
+		logrus.Debugf("Deleted a vlan tagged netlink subinterface: %s", linkName)
151 152
 	}
152 153
 	// if the subinterface doesn't parse to iface.vlan_id leave the interface in
153 154
 	// place since it could be a user specified name not created by the driver.
154 155
 	return nil
155 156
 }
156 157
 
157
-// parseVlan parses and verifies a slave interface name: -o host_iface=eth0.10
158
-func parseVlan(ifaceName string) (string, int, error) {
159
-	// parse -o host_iface=eth0.10
160
-	splitIface := strings.Split(ifaceName, ".")
161
-	if len(splitIface) != 2 {
162
-		return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", ifaceName)
158
+// parseVlan parses and verifies a slave interface name: -o parent=eth0.10
159
+func parseVlan(linkName string) (string, int, error) {
160
+	// parse -o parent=eth0.10
161
+	splitName := strings.Split(linkName, ".")
162
+	if len(splitName) != 2 {
163
+		return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", linkName)
163 164
 	}
164
-	parentIface, vidStr := splitIface[0], splitIface[1]
165
+	parent, vidStr := splitName[0], splitName[1]
165 166
 	// validate type and convert vlan id to int
166 167
 	vidInt, err := strconv.Atoi(vidStr)
167 168
 	if err != nil {
168 169
 		return "", 0, fmt.Errorf("unable to parse a valid vlan id from: %s (ex. eth0.10 for vlan 10)", vidStr)
169 170
 	}
170 171
 	// Check if the interface exists
171
-	if ok := hostIfaceExists(parentIface); !ok {
172
-		return "", 0, fmt.Errorf("-o host_iface parent interface does was not found on the host: %s", parentIface)
172
+	if !parentExists(parent) {
173
+		return "", 0, fmt.Errorf("-o parent interface does was not found on the host: %s", parent)
173 174
 	}
174
-	return parentIface, vidInt, nil
175
+
176
+	return parent, vidInt, nil
177
+}
178
+
179
+// createDummyLink creates a dummy0 parent link
180
+func createDummyLink(dummyName, truncNetID string) error {
181
+	// create a parent interface since one was not specified
182
+	parent := &netlink.Dummy{
183
+		LinkAttrs: netlink.LinkAttrs{
184
+			Name: dummyName,
185
+		},
186
+	}
187
+	if err := netlink.LinkAdd(parent); err != nil {
188
+		return err
189
+	}
190
+	parentDummyLink, err := netlink.LinkByName(dummyName)
191
+	if err != nil {
192
+		return fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", macvlanType, dummyName, err)
193
+	}
194
+	// bring the new netlink iface up
195
+	if err := netlink.LinkSetUp(parentDummyLink); err != nil {
196
+		return fmt.Errorf("failed to enable %s the macvlan parent link: %v", dummyName, err)
197
+	}
198
+
199
+	return nil
200
+}
201
+
202
+// delDummyLink deletes the link type dummy used when -o parent is not passed
203
+func delDummyLink(linkName string) error {
204
+	// delete the vlan subinterface
205
+	dummyLink, err := netlink.LinkByName(linkName)
206
+	if err != nil {
207
+		return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err)
208
+	}
209
+	// verify a parent interface is being deleted
210
+	if dummyLink.Attrs().ParentIndex != 0 {
211
+		return fmt.Errorf("link %s is not a parent dummy interface", linkName)
212
+	}
213
+	// delete the macvlan dummy device
214
+	if err := netlink.LinkDel(dummyLink); err != nil {
215
+		return fmt.Errorf("failed to delete the dummy %s link: %v", linkName, err)
216
+	}
217
+	logrus.Debugf("Deleted a dummy parent link: %s", linkName)
218
+
219
+	return nil
220
+}
221
+
222
+// getDummyName returns the name of a dummy parent with truncated net ID and driver prefix
223
+func getDummyName(netID string) string {
224
+	return fmt.Sprintf("%s%s", dummyPrefix, netID)
175 225
 }
... ...
@@ -6,17 +6,17 @@ import (
6 6
 	"github.com/vishvananda/netlink"
7 7
 )
8 8
 
9
-// TestValidateLink tests the validateHostIface function
9
+// TestValidateLink tests the parentExists function
10 10
 func TestValidateLink(t *testing.T) {
11 11
 	validIface := "lo"
12 12
 	invalidIface := "foo12345"
13 13
 
14 14
 	// test a valid parent interface validation
15
-	if ok := hostIfaceExists(validIface); !ok {
15
+	if ok := parentExists(validIface); !ok {
16 16
 		t.Fatalf("failed validating loopback %s", validIface)
17 17
 	}
18 18
 	// test a invalid parent interface validation
19
-	if ok := hostIfaceExists(invalidIface); ok {
19
+	if ok := parentExists(invalidIface); ok {
20 20
 		t.Fatalf("failed to invalidate interface %s", invalidIface)
21 21
 	}
22 22
 }
... ...
@@ -15,6 +15,7 @@ func (d *driver) network(nid string) *network {
15 15
 	if !ok {
16 16
 		logrus.Errorf("network id %s not found", nid)
17 17
 	}
18
+
18 19
 	return n
19 20
 }
20 21
 
... ...
@@ -39,6 +40,7 @@ func (d *driver) getNetworks() []*network {
39 39
 	for _, nw := range d.networks {
40 40
 		ls = append(ls, nw)
41 41
 	}
42
+
42 43
 	return ls
43 44
 }
44 45
 
... ...
@@ -70,6 +72,7 @@ func (n *network) getEndpoint(eid string) (*endpoint, error) {
70 70
 	if ep, ok := n.endpoints[eid]; ok {
71 71
 		return ep, nil
72 72
 	}
73
+
73 74
 	return nil, nil
74 75
 }
75 76
 
... ...
@@ -86,6 +89,7 @@ func validateID(nid, eid string) error {
86 86
 func (n *network) sandbox() osl.Sandbox {
87 87
 	n.Lock()
88 88
 	defer n.Unlock()
89
+
89 90
 	return n.sbox
90 91
 }
91 92
 
... ...
@@ -104,5 +108,6 @@ func (d *driver) getNetwork(id string) (*network, error) {
104 104
 	if nw, ok := d.networks[id]; ok {
105 105
 		return nw, nil
106 106
 	}
107
+
107 108
 	return nil, types.NotFoundErrorf("network not found: %s", id)
108 109
 }
... ...
@@ -21,7 +21,7 @@ type configuration struct {
21 21
 	dbIndex          uint64
22 22
 	dbExists         bool
23 23
 	Internal         bool
24
-	HostIface        string
24
+	Parent           string
25 25
 	MacvlanMode      string
26 26
 	CreatedSlaveLink bool
27 27
 	Ipv4Subnets      []*ipv4Subnet
... ...
@@ -114,8 +114,9 @@ func (config *configuration) MarshalJSON() ([]byte, error) {
114 114
 	nMap := make(map[string]interface{})
115 115
 	nMap["ID"] = config.ID
116 116
 	nMap["Mtu"] = config.Mtu
117
-	nMap["HostIface"] = config.HostIface
117
+	nMap["Parent"] = config.Parent
118 118
 	nMap["MacvlanMode"] = config.MacvlanMode
119
+	nMap["Internal"] = config.Internal
119 120
 	nMap["CreatedSubIface"] = config.CreatedSlaveLink
120 121
 	if len(config.Ipv4Subnets) > 0 {
121 122
 		iis, err := json.Marshal(config.Ipv4Subnets)
... ...
@@ -131,6 +132,7 @@ func (config *configuration) MarshalJSON() ([]byte, error) {
131 131
 		}
132 132
 		nMap["Ipv6Subnets"] = string(iis)
133 133
 	}
134
+
134 135
 	return json.Marshal(nMap)
135 136
 }
136 137
 
... ...
@@ -145,8 +147,9 @@ func (config *configuration) UnmarshalJSON(b []byte) error {
145 145
 	}
146 146
 	config.ID = nMap["ID"].(string)
147 147
 	config.Mtu = int(nMap["Mtu"].(float64))
148
-	config.HostIface = nMap["HostIface"].(string)
148
+	config.Parent = nMap["Parent"].(string)
149 149
 	config.MacvlanMode = nMap["MacvlanMode"].(string)
150
+	config.Internal = nMap["Internal"].(bool)
150 151
 	config.CreatedSlaveLink = nMap["CreatedSubIface"].(bool)
151 152
 	if v, ok := nMap["Ipv4Subnets"]; ok {
152 153
 		if err := json.Unmarshal([]byte(v.(string)), &config.Ipv4Subnets); err != nil {
... ...
@@ -158,6 +161,7 @@ func (config *configuration) UnmarshalJSON(b []byte) error {
158 158
 			return err
159 159
 		}
160 160
 	}
161
+
161 162
 	return nil
162 163
 }
163 164
 
... ...
@@ -174,6 +178,7 @@ func (config *configuration) Value() []byte {
174 174
 	if err != nil {
175 175
 		return nil
176 176
 	}
177
+
177 178
 	return b
178 179
 }
179 180
 
... ...
@@ -205,6 +210,7 @@ func (config *configuration) New() datastore.KVObject {
205 205
 func (config *configuration) CopyTo(o datastore.KVObject) error {
206 206
 	dstNcfg := o.(*configuration)
207 207
 	*dstNcfg = *config
208
+
208 209
 	return nil
209 210
 }
210 211
 
211 212
new file mode 100644
... ...
@@ -0,0 +1,15 @@
0
+// +build experimental
1
+
2
+package libnetwork
3
+
4
+import (
5
+	"github.com/docker/libnetwork/drivers/ipvlan"
6
+	"github.com/docker/libnetwork/drivers/macvlan"
7
+)
8
+
9
+func additionalDrivers() []initializer {
10
+	return []initializer{
11
+		{macvlan.Init, "macvlan"},
12
+		{ipvlan.Init, "ipvlan"},
13
+	}
14
+}
... ...
@@ -3,21 +3,20 @@ package libnetwork
3 3
 import (
4 4
 	"github.com/docker/libnetwork/drivers/bridge"
5 5
 	"github.com/docker/libnetwork/drivers/host"
6
-	"github.com/docker/libnetwork/drivers/ipvlan"
7
-	"github.com/docker/libnetwork/drivers/macvlan"
8 6
 	"github.com/docker/libnetwork/drivers/null"
9 7
 	"github.com/docker/libnetwork/drivers/overlay"
10 8
 	"github.com/docker/libnetwork/drivers/remote"
11 9
 )
12 10
 
13 11
 func getInitializers() []initializer {
14
-	return []initializer{
12
+	in := []initializer{
15 13
 		{bridge.Init, "bridge"},
16 14
 		{host.Init, "host"},
17 15
 		{null.Init, "null"},
18 16
 		{remote.Init, "remote"},
19 17
 		{overlay.Init, "overlay"},
20
-		{macvlan.Init, "macvlan"},
21
-		{ipvlan.Init, "ipvlan"},
22 18
 	}
19
+
20
+	in = append(in, additionalDrivers()...)
21
+	return in
23 22
 }
24 23
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+// +build !experimental
1
+
2
+package libnetwork
3
+
4
+func additionalDrivers() []initializer {
5
+	return nil
6
+}