Skip to content

Commit 58b376c

Browse files
mavenugoabhi
authored andcommitted
Overlay Driver fixes required for CNI providers
* Support HostAccess overlay option * Make HostMode configurable via overlay driver label * Disble SD and start in host-mode by default for CNI dnet * Moving the default dnet port from 2385 to 2389 * Fix hostAccess iptables rules * Implement JoinInfo and LeaveInfo interfaces on all builtin drivers * Enhance JoinInfo and LeaveInfo to allow ip allocation for gateway-ip * Make use of the RequestAddress feature for hostAccess overlay network * HostAccess network must also handle traffic from bridge to ! bridge. This is required for the ingress cases Signed-off-by: Madhu Venugopal <madhu@docker.com>
1 parent 0404c65 commit 58b376c

37 files changed

Lines changed: 274 additions & 95 deletions

api/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ func procPublishService(c libnetwork.NetworkController, vars map[string]string,
646646
setFctList = append(setFctList, libnetwork.CreateOptionMyAlias(str))
647647
}
648648

649+
if sp.DisableResolution {
650+
setFctList = append(setFctList, libnetwork.CreateOptionDisableResolution())
651+
}
652+
649653
ep, err := n.CreateEndpoint(sp.Name, setFctList...)
650654
if err != nil {
651655
return "", endpointToService(convertNetworkError(err))

api/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ type endpointJoin struct {
8484

8585
// servicePublish represents the body of the "publish service" http request message
8686
type servicePublish struct {
87-
Name string `json:"name"`
88-
MyAliases []string `json:"my_aliases"`
89-
Network string `json:"network_name"`
87+
Name string `json:"name"`
88+
MyAliases []string `json:"my_aliases"`
89+
Network string `json:"network_name"`
90+
DisableResolution bool `json:"disable_resolution"`
9091
}
9192

9293
// serviceDelete represents the body of the "unpublish service" http request message

client/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ type networkCreate struct {
5454

5555
// ServiceCreate represents the body of the "publish service" http request message
5656
type ServiceCreate struct {
57-
Name string `json:"name"`
58-
MyAliases []string `json:"my_aliases"`
59-
Network string `json:"network_name"`
57+
Name string `json:"name"`
58+
MyAliases []string `json:"my_aliases"`
59+
Network string `json:"network_name"`
60+
DisableResolution bool `json:"disable_resolution"`
6061
}
6162

6263
// ServiceDelete represents the body of the "unpublish service" http request message

cmd/dnet/dnet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const (
4343
// DefaultHTTPHost is used if only port is provided to -H flag e.g. docker -d -H tcp://:8080
4444
DefaultHTTPHost = "0.0.0.0"
4545
// DefaultHTTPPort is the default http port used by dnet
46-
DefaultHTTPPort = 2385
46+
DefaultHTTPPort = 2389
4747
// DefaultUnixSocket exported
4848
DefaultUnixSocket = "/var/run/dnet.sock"
4949
cfgFileEnv = "LIBNETWORK_CFG"
@@ -447,7 +447,7 @@ func (d *dnetConnection) httpCall(method, path string, data interface{}, headers
447447

448448
req.URL.Host = d.addr
449449
req.URL.Scheme = "http"
450-
fmt.Printf("Requesting http: %+v",req)
450+
fmt.Printf("Requesting http: %+v", req)
451451
httpClient := &http.Client{}
452452
resp, err := httpClient.Do(req)
453453
statusCode := -1

config/libnetwork.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
title = "LibNetwork Configuration file"
22

33
[daemon]
4-
debug = false
4+
debug = true
5+
labels = ["com.docker.network.driver.overlay.hostmode=true"]
56
[cluster]
6-
discovery = "token://swarm-discovery-token"
7-
Address = "Cluster-wide reachable Host IP"
7+
discovery = "etcd://localhost:2379"
8+
Address = "192.168.56.101"
89
[datastore]
910
embedded = false
1011
[datastore.client]
11-
provider = "consul"
12-
Address = "localhost:8500"
12+
provider = "etcd"
13+
Address = "localhost:2379"
14+
[scopes]
15+
[scopes.global]
16+
[scopes.global.client]
17+
provider = "etcd"
18+
address = "localhost:2379"

default_gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (sb *sandbox) setupDefaultGW() error {
4747
}
4848
}
4949

50-
createOptions := []EndpointOption{CreateOptionAnonymous()}
50+
createOptions := []EndpointOption{CreateOptionAnonymous(), CreateOptionDisableResolution()}
5151

5252
eplen := gwEPlen
5353
if len(sb.containerID) < gwEPlen {

driverapi/driverapi.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Driver interface {
5656
Join(nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error
5757

5858
// Leave method is invoked when a Sandbox detaches from an endpoint.
59-
Leave(nid, eid string) error
59+
Leave(nid, eid string, linfo LeaveInfo) error
6060

6161
// ProgramExternalConnectivity invokes the driver method which does the necessary
6262
// programming to allow the external connectivity dictated by the passed options
@@ -136,6 +136,9 @@ type JoinInfo interface {
136136
// SetGateway sets the default IPv4 gateway when a container joins the endpoint.
137137
SetGateway(net.IP) error
138138

139+
// RequestAddress allocates an IP address as required by the driver
140+
RequestAddress(*net.IPNet) (*net.IPNet, error)
141+
139142
// SetGatewayIPv6 sets the default IPv6 gateway when a container joins the endpoint.
140143
SetGatewayIPv6(net.IP) error
141144

@@ -151,6 +154,11 @@ type JoinInfo interface {
151154
AddTableEntry(tableName string, key string, value []byte) error
152155
}
153156

157+
type LeaveInfo interface {
158+
// ReleaseAddress frees up allocated IP
159+
ReleaseAddress(net.IP) error
160+
}
161+
154162
// DriverCallback provides a Callback interface for Drivers into LibNetwork
155163
type DriverCallback interface {
156164
// GetPluginGetter returns the pluginv2 getter.

drivers/bridge/bridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
12441244
}
12451245

12461246
// Leave method is invoked when a Sandbox detaches from an endpoint.
1247-
func (d *driver) Leave(nid, eid string) error {
1247+
func (d *driver) Leave(nid, eid string, linfo driverapi.LeaveInfo) error {
12481248
defer osl.InitOSContext()()
12491249

12501250
network, err := d.getNetwork(nid)

drivers/bridge/bridge_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
686686
}
687687

688688
// release host mapped ports
689-
err = d.Leave("net1", "ep1")
689+
err = d.Leave("net1", "ep1", nil)
690690
if err != nil {
691691
t.Fatal(err)
692692
}
@@ -810,7 +810,7 @@ func TestLinkContainers(t *testing.T) {
810810
t.Fatalf("Failed to revoke external connectivity: %v", err)
811811
}
812812

813-
err = d.Leave("net1", "ep2")
813+
err = d.Leave("net1", "ep2", nil)
814814
if err != nil {
815815
t.Fatal("Failed to unlink ep1 and ep2")
816816
}

drivers/bridge/brmanager/brmanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
5959
return types.NotImplementedErrorf("not implemented")
6060
}
6161

62-
func (d *driver) Leave(nid, eid string) error {
62+
func (d *driver) Leave(nid, eid string, linfo driverapi.LeaveInfo) error {
6363
return types.NotImplementedErrorf("not implemented")
6464
}
6565

0 commit comments

Comments
 (0)