|
@@ -163,6 +163,7 @@ type network struct {
|
|
|
persist bool
|
|
|
stopWatchCh chan struct{}
|
|
|
drvOnce *sync.Once
|
|
|
+ internal bool
|
|
|
sync.Mutex
|
|
|
}
|
|
|
|
|
@@ -305,6 +306,7 @@ func (n *network) CopyTo(o datastore.KVObject) error {
|
|
|
dstN.dbIndex = n.dbIndex
|
|
|
dstN.dbExists = n.dbExists
|
|
|
dstN.drvOnce = n.drvOnce
|
|
|
+ dstN.internal = n.internal
|
|
|
|
|
|
for _, v4conf := range n.ipamV4Config {
|
|
|
dstV4Conf := &IpamConf{}
|
|
@@ -391,6 +393,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
|
|
|
}
|
|
|
netMap["ipamV6Info"] = string(iis)
|
|
|
}
|
|
|
+ netMap["internal"] = n.internal
|
|
|
return json.Marshal(netMap)
|
|
|
}
|
|
|
|
|
@@ -454,6 +457,9 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
+ if v, ok := netMap["internal"]; ok {
|
|
|
+ n.internal = v.(bool)
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -480,6 +486,18 @@ func NetworkOptionPersist(persist bool) NetworkOption {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// NetworkOptionInternalNetwork returns an option setter to config the network
|
|
|
+// to be internal which disables default gateway service
|
|
|
+func NetworkOptionInternalNetwork() NetworkOption {
|
|
|
+ return func(n *network) {
|
|
|
+ n.internal = true
|
|
|
+ if n.generic == nil {
|
|
|
+ n.generic = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ n.generic[netlabel.Internal] = true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// NetworkOptionIpam function returns an option setter for the ipam configuration for this network
|
|
|
func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ipV6 []*IpamConf) NetworkOption {
|
|
|
return func(n *network) {
|
|
@@ -1187,3 +1205,10 @@ func (n *network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
|
|
|
|
|
|
return v4Info, v6Info
|
|
|
}
|
|
|
+
|
|
|
+func (n *network) Internal() bool {
|
|
|
+ n.Lock()
|
|
|
+ defer n.Unlock()
|
|
|
+
|
|
|
+ return n.internal
|
|
|
+}
|