Browse code

libnetwork: remove Network interface

There's only one implementation; drop the interface and use the
concrete type instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/22 07:38:57
Showing 31 changed files
... ...
@@ -12,7 +12,7 @@ import (
12 12
 // Backend is all the methods that need to be implemented
13 13
 // to provide network specific functionality.
14 14
 type Backend interface {
15
-	FindNetwork(idName string) (libnetwork.Network, error)
15
+	FindNetwork(idName string) (*libnetwork.Network, error)
16 16
 	GetNetworks(filters.Args, types.NetworkListConfig) ([]types.NetworkResource, error)
17 17
 	CreateNetwork(nc types.NetworkCreateRequest) (*types.NetworkCreateResponse, error)
18 18
 	ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
... ...
@@ -95,7 +95,7 @@ type lnInterface struct {
95 95
 	provider *bridgeProvider
96 96
 }
97 97
 
98
-func (iface *lnInterface) init(c *libnetwork.Controller, n libnetwork.Network) {
98
+func (iface *lnInterface) init(c *libnetwork.Controller, n *libnetwork.Network) {
99 99
 	defer close(iface.ready)
100 100
 	id := identity.NewID()
101 101
 
... ...
@@ -35,7 +35,7 @@ import (
35 35
 type Backend interface {
36 36
 	CreateManagedNetwork(clustertypes.NetworkCreateRequest) error
37 37
 	DeleteManagedNetwork(networkID string) error
38
-	FindNetwork(idName string) (libnetwork.Network, error)
38
+	FindNetwork(idName string) (*libnetwork.Network, error)
39 39
 	SetupIngress(clustertypes.NetworkCreateRequest, string) (<-chan struct{}, error)
40 40
 	ReleaseIngress() (<-chan struct{}, error)
41 41
 	CreateManagedContainer(ctx context.Context, config types.ContainerCreateConfig) (container.CreateResponse, error)
... ...
@@ -247,7 +247,7 @@ func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *contain
247 247
 	return sboxOptions, nil
248 248
 }
249 249
 
250
-func (daemon *Daemon) updateNetworkSettings(container *container.Container, n libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
250
+func (daemon *Daemon) updateNetworkSettings(container *container.Container, n *libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
251 251
 	if container.NetworkSettings == nil {
252 252
 		container.NetworkSettings = &network.Settings{}
253 253
 	}
... ...
@@ -293,7 +293,7 @@ func (daemon *Daemon) updateNetworkSettings(container *container.Container, n li
293 293
 	return nil
294 294
 }
295 295
 
296
-func (daemon *Daemon) updateEndpointNetworkSettings(cfg *config.Config, container *container.Container, n libnetwork.Network, ep *libnetwork.Endpoint) error {
296
+func (daemon *Daemon) updateEndpointNetworkSettings(cfg *config.Config, container *container.Container, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
297 297
 	if err := buildEndpointInfo(container.NetworkSettings, n, ep); err != nil {
298 298
 		return err
299 299
 	}
... ...
@@ -320,7 +320,7 @@ func (daemon *Daemon) updateNetwork(cfg *config.Config, container *container.Con
320 320
 	}
321 321
 
322 322
 	// Find if container is connected to the default bridge network
323
-	var n libnetwork.Network
323
+	var n *libnetwork.Network
324 324
 	for name, v := range container.NetworkSettings.Networks {
325 325
 		sn, err := daemon.FindNetwork(getNetworkID(name, v.EndpointSettings))
326 326
 		if err != nil {
... ...
@@ -351,7 +351,7 @@ func (daemon *Daemon) updateNetwork(cfg *config.Config, container *container.Con
351 351
 	return nil
352 352
 }
353 353
 
354
-func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (libnetwork.Network, *networktypes.NetworkingConfig, error) {
354
+func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrName string, epConfig *networktypes.EndpointSettings) (*libnetwork.Network, *networktypes.NetworkingConfig, error) {
355 355
 	id := getNetworkID(idOrName, epConfig)
356 356
 
357 357
 	n, err := daemon.FindNetwork(id)
... ...
@@ -451,7 +451,7 @@ func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrN
451 451
 
452 452
 // updateContainerNetworkSettings updates the network settings
453 453
 func (daemon *Daemon) updateContainerNetworkSettings(container *container.Container, endpointsConfig map[string]*networktypes.EndpointSettings) {
454
-	var n libnetwork.Network
454
+	var n *libnetwork.Network
455 455
 
456 456
 	mode := container.HostConfig.NetworkMode
457 457
 	if container.Config.NetworkDisabled || mode.IsContainer() {
... ...
@@ -622,7 +622,7 @@ func hasUserDefinedIPAddress(ipamConfig *networktypes.EndpointIPAMConfig) bool {
622 622
 }
623 623
 
624 624
 // User specified ip address is acceptable only for networks with user specified subnets.
625
-func validateNetworkingConfig(n libnetwork.Network, epConfig *networktypes.EndpointSettings) error {
625
+func validateNetworkingConfig(n *libnetwork.Network, epConfig *networktypes.EndpointSettings) error {
626 626
 	if n == nil || epConfig == nil {
627 627
 		return nil
628 628
 	}
... ...
@@ -684,7 +684,7 @@ func cleanOperationalData(es *network.EndpointSettings) {
684 684
 	}
685 685
 }
686 686
 
687
-func (daemon *Daemon) updateNetworkConfig(container *container.Container, n libnetwork.Network, endpointConfig *networktypes.EndpointSettings, updateSettings bool) error {
687
+func (daemon *Daemon) updateNetworkConfig(container *container.Container, n *libnetwork.Network, endpointConfig *networktypes.EndpointSettings, updateSettings bool) error {
688 688
 	if containertypes.NetworkMode(n.Name()).IsUserDefined() {
689 689
 		addShortID := true
690 690
 		shortID := stringid.TruncateID(container.ID)
... ...
@@ -835,7 +835,7 @@ func (daemon *Daemon) connectToNetwork(cfg *config.Config, container *container.
835 835
 	return nil
836 836
 }
837 837
 
838
-func updateJoinInfo(networkSettings *network.Settings, n libnetwork.Network, ep *libnetwork.Endpoint) error {
838
+func updateJoinInfo(networkSettings *network.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
839 839
 	if ep == nil {
840 840
 		return errors.New("invalid enppoint whhile building portmap info")
841 841
 	}
... ...
@@ -880,7 +880,7 @@ func (daemon *Daemon) ForceEndpointDelete(name string, networkName string) error
880 880
 	return ep.Delete(true)
881 881
 }
882 882
 
883
-func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n libnetwork.Network, force bool) error {
883
+func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n *libnetwork.Network, force bool) error {
884 884
 	var (
885 885
 		ep   *libnetwork.Endpoint
886 886
 		sbox *libnetwork.Sandbox
... ...
@@ -932,7 +932,7 @@ func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n li
932 932
 	return nil
933 933
 }
934 934
 
935
-func (daemon *Daemon) tryDetachContainerFromClusterNetwork(network libnetwork.Network, container *container.Container) {
935
+func (daemon *Daemon) tryDetachContainerFromClusterNetwork(network *libnetwork.Network, container *container.Container) {
936 936
 	if daemon.clusterProvider != nil && network.Info().Dynamic() && !container.Managed {
937 937
 		if err := daemon.clusterProvider.DetachNetwork(network.Name(), container.ID); err != nil {
938 938
 			log.G(context.TODO()).Warnf("error detaching from network %s: %v", network.Name(), err)
... ...
@@ -1018,7 +1018,7 @@ func (daemon *Daemon) releaseNetwork(container *container.Container) {
1018 1018
 		return
1019 1019
 	}
1020 1020
 
1021
-	var networks []libnetwork.Network
1021
+	var networks []*libnetwork.Network
1022 1022
 	for n, epSettings := range settings {
1023 1023
 		if nw, err := daemon.FindNetwork(getNetworkID(n, epSettings.EndpointSettings)); err == nil {
1024 1024
 			networks = append(networks, nw)
... ...
@@ -323,8 +323,8 @@ func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSand
323 323
 		if networkTypeNorm == "private" || networkTypeNorm == "internal" {
324 324
 			continue // workaround for HNS reporting unsupported networks
325 325
 		}
326
-		var n libnetwork.Network
327
-		s := func(current libnetwork.Network) bool {
326
+		var n *libnetwork.Network
327
+		s := func(current *libnetwork.Network) bool {
328 328
 			hnsid := current.Info().DriverOptions()[winlibnetwork.HNSID]
329 329
 			if hnsid == v.Id {
330 330
 				n = current
... ...
@@ -67,12 +67,12 @@ func (daemon *Daemon) LogVolumeEvent(volumeID, action string, attributes map[str
67 67
 }
68 68
 
69 69
 // LogNetworkEvent generates an event related to a network with only the default attributes.
70
-func (daemon *Daemon) LogNetworkEvent(nw libnetwork.Network, action string) {
70
+func (daemon *Daemon) LogNetworkEvent(nw *libnetwork.Network, action string) {
71 71
 	daemon.LogNetworkEventWithAttributes(nw, action, map[string]string{})
72 72
 }
73 73
 
74 74
 // LogNetworkEventWithAttributes generates an event related to a network with specific given attributes.
75
-func (daemon *Daemon) LogNetworkEventWithAttributes(nw libnetwork.Network, action string, attributes map[string]string) {
75
+func (daemon *Daemon) LogNetworkEventWithAttributes(nw *libnetwork.Network, action string, attributes map[string]string) {
76 76
 	attributes["name"] = nw.Name()
77 77
 	attributes["type"] = nw.Type()
78 78
 	actor := events.Actor{
... ...
@@ -61,9 +61,9 @@ func (daemon *Daemon) NetworkController() *libnetwork.Controller {
61 61
 // 2. Full Name
62 62
 // 3. Partial ID
63 63
 // as long as there is no ambiguity
64
-func (daemon *Daemon) FindNetwork(term string) (libnetwork.Network, error) {
65
-	listByFullName := []libnetwork.Network{}
66
-	listByPartialID := []libnetwork.Network{}
64
+func (daemon *Daemon) FindNetwork(term string) (*libnetwork.Network, error) {
65
+	listByFullName := []*libnetwork.Network{}
66
+	listByPartialID := []*libnetwork.Network{}
67 67
 	for _, nw := range daemon.getAllNetworks() {
68 68
 		if nw.ID() == term {
69 69
 			return nw, nil
... ...
@@ -94,7 +94,7 @@ func (daemon *Daemon) FindNetwork(term string) (libnetwork.Network, error) {
94 94
 
95 95
 // GetNetworkByID function returns a network whose ID matches the given ID.
96 96
 // It fails with an error if no matching network is found.
97
-func (daemon *Daemon) GetNetworkByID(id string) (libnetwork.Network, error) {
97
+func (daemon *Daemon) GetNetworkByID(id string) (*libnetwork.Network, error) {
98 98
 	c := daemon.netController
99 99
 	if c == nil {
100 100
 		return nil, errors.Wrap(libnetwork.ErrNoSuchNetwork(id), "netcontroller is nil")
... ...
@@ -104,7 +104,7 @@ func (daemon *Daemon) GetNetworkByID(id string) (libnetwork.Network, error) {
104 104
 
105 105
 // GetNetworkByName function returns a network for a given network name.
106 106
 // If no network name is given, the default network is returned.
107
-func (daemon *Daemon) GetNetworkByName(name string) (libnetwork.Network, error) {
107
+func (daemon *Daemon) GetNetworkByName(name string) (*libnetwork.Network, error) {
108 108
 	c := daemon.netController
109 109
 	if c == nil {
110 110
 		return nil, libnetwork.ErrNoSuchNetwork(name)
... ...
@@ -116,13 +116,13 @@ func (daemon *Daemon) GetNetworkByName(name string) (libnetwork.Network, error)
116 116
 }
117 117
 
118 118
 // GetNetworksByIDPrefix returns a list of networks whose ID partially matches zero or more networks
119
-func (daemon *Daemon) GetNetworksByIDPrefix(partialID string) []libnetwork.Network {
119
+func (daemon *Daemon) GetNetworksByIDPrefix(partialID string) []*libnetwork.Network {
120 120
 	c := daemon.netController
121 121
 	if c == nil {
122 122
 		return nil
123 123
 	}
124
-	list := []libnetwork.Network{}
125
-	l := func(nw libnetwork.Network) bool {
124
+	list := []*libnetwork.Network{}
125
+	l := func(nw *libnetwork.Network) bool {
126 126
 		if strings.HasPrefix(nw.ID(), partialID) {
127 127
 			list = append(list, nw)
128 128
 		}
... ...
@@ -134,7 +134,7 @@ func (daemon *Daemon) GetNetworksByIDPrefix(partialID string) []libnetwork.Netwo
134 134
 }
135 135
 
136 136
 // getAllNetworks returns a list containing all networks
137
-func (daemon *Daemon) getAllNetworks() []libnetwork.Network {
137
+func (daemon *Daemon) getAllNetworks() []*libnetwork.Network {
138 138
 	c := daemon.netController
139 139
 	if c == nil {
140 140
 		return nil
... ...
@@ -527,7 +527,7 @@ func (daemon *Daemon) DeleteNetwork(networkID string) error {
527 527
 	return daemon.deleteNetwork(n, false)
528 528
 }
529 529
 
530
-func (daemon *Daemon) deleteNetwork(nw libnetwork.Network, dynamic bool) error {
530
+func (daemon *Daemon) deleteNetwork(nw *libnetwork.Network, dynamic bool) error {
531 531
 	if runconfig.IsPreDefinedNetwork(nw.Name()) && !dynamic {
532 532
 		err := fmt.Errorf("%s is a pre-defined network and cannot be removed", nw.Name())
533 533
 		return errdefs.Forbidden(err)
... ...
@@ -564,9 +564,9 @@ func (daemon *Daemon) GetNetworks(filter filters.Args, config types.NetworkListC
564 564
 	networks := daemon.getAllNetworks()
565 565
 
566 566
 	list := make([]types.NetworkResource, 0, len(networks))
567
-	var idx map[string]libnetwork.Network
567
+	var idx map[string]*libnetwork.Network
568 568
 	if config.Detailed {
569
-		idx = make(map[string]libnetwork.Network)
569
+		idx = make(map[string]*libnetwork.Network)
570 570
 	}
571 571
 
572 572
 	for _, n := range networks {
... ...
@@ -594,7 +594,7 @@ func (daemon *Daemon) GetNetworks(filter filters.Args, config types.NetworkListC
594 594
 	return list, nil
595 595
 }
596 596
 
597
-func buildNetworkResource(nw libnetwork.Network) types.NetworkResource {
597
+func buildNetworkResource(nw *libnetwork.Network) types.NetworkResource {
598 598
 	r := types.NetworkResource{}
599 599
 	if nw == nil {
600 600
 		return r
... ...
@@ -628,7 +628,7 @@ func buildNetworkResource(nw libnetwork.Network) types.NetworkResource {
628 628
 	return r
629 629
 }
630 630
 
631
-func buildDetailedNetworkResources(r *types.NetworkResource, nw libnetwork.Network, verbose bool) {
631
+func buildDetailedNetworkResources(r *types.NetworkResource, nw *libnetwork.Network, verbose bool) {
632 632
 	if nw == nil {
633 633
 		return
634 634
 	}
... ...
@@ -797,7 +797,7 @@ func (daemon *Daemon) clearAttachableNetworks() {
797 797
 }
798 798
 
799 799
 // buildCreateEndpointOptions builds endpoint options from a given network.
800
-func buildCreateEndpointOptions(c *container.Container, n libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
800
+func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
801 801
 	var (
802 802
 		bindings      = make(nat.PortMap)
803 803
 		pbList        []networktypes.PortBinding
... ...
@@ -1028,7 +1028,7 @@ func getEndpointPortMapInfo(ep *libnetwork.Endpoint) (nat.PortMap, error) {
1028 1028
 }
1029 1029
 
1030 1030
 // buildEndpointInfo sets endpoint-related fields on container.NetworkSettings based on the provided network and endpoint.
1031
-func buildEndpointInfo(networkSettings *internalnetwork.Settings, n libnetwork.Network, ep *libnetwork.Endpoint) error {
1031
+func buildEndpointInfo(networkSettings *internalnetwork.Settings, n *libnetwork.Network, ep *libnetwork.Endpoint) error {
1032 1032
 	if ep == nil {
1033 1033
 		return errors.New("endpoint cannot be nil")
1034 1034
 	}
... ...
@@ -7,7 +7,7 @@ import (
7 7
 )
8 8
 
9 9
 // getEndpointInNetwork returns the container's endpoint to the provided network.
10
-func getEndpointInNetwork(name string, n libnetwork.Network) (*libnetwork.Endpoint, error) {
10
+func getEndpointInNetwork(name string, n *libnetwork.Network) (*libnetwork.Endpoint, error) {
11 11
 	endpointName := strings.TrimPrefix(name, "/")
12 12
 	return n.EndpointByName(endpointName)
13 13
 }
... ...
@@ -102,7 +102,7 @@ func (daemon *Daemon) localNetworksPrune(ctx context.Context, pruneFilters filte
102 102
 	until, _ := getUntilFromPruneFilters(pruneFilters)
103 103
 
104 104
 	// When the function returns true, the walk will stop.
105
-	l := func(nw libnetwork.Network) bool {
105
+	daemon.netController.WalkNetworks(func(nw *libnetwork.Network) bool {
106 106
 		select {
107 107
 		case <-ctx.Done():
108 108
 			// context cancelled
... ...
@@ -131,8 +131,7 @@ func (daemon *Daemon) localNetworksPrune(ctx context.Context, pruneFilters filte
131 131
 		}
132 132
 		rep.NetworksDeleted = append(rep.NetworksDeleted, nwName)
133 133
 		return false
134
-	}
135
-	daemon.netController.WalkNetworks(l)
134
+	})
136 135
 	return rep
137 136
 }
138 137
 
... ...
@@ -436,7 +436,7 @@ type epRecord struct {
436 436
 	lbIndex int
437 437
 }
438 438
 
439
-func (n *network) Services() map[string]ServiceInfo {
439
+func (n *Network) Services() map[string]ServiceInfo {
440 440
 	eps := make(map[string]epRecord)
441 441
 
442 442
 	if !n.isClusterEligible() {
... ...
@@ -519,14 +519,14 @@ func (n *network) Services() map[string]ServiceInfo {
519 519
 	return sinfo
520 520
 }
521 521
 
522
-func (n *network) isClusterEligible() bool {
522
+func (n *Network) isClusterEligible() bool {
523 523
 	if n.scope != datastore.SwarmScope || !n.driverIsMultihost() {
524 524
 		return false
525 525
 	}
526 526
 	return n.getController().getAgent() != nil
527 527
 }
528 528
 
529
-func (n *network) joinCluster() error {
529
+func (n *Network) joinCluster() error {
530 530
 	if !n.isClusterEligible() {
531 531
 		return nil
532 532
 	}
... ...
@@ -539,7 +539,7 @@ func (n *network) joinCluster() error {
539 539
 	return agent.networkDB.JoinNetwork(n.ID())
540 540
 }
541 541
 
542
-func (n *network) leaveCluster() error {
542
+func (n *Network) leaveCluster() error {
543 543
 	if !n.isClusterEligible() {
544 544
 		return nil
545 545
 	}
... ...
@@ -743,7 +743,7 @@ func (ep *Endpoint) deleteServiceInfoFromCluster(sb *Sandbox, fullRemove bool, m
743 743
 	return nil
744 744
 }
745 745
 
746
-func disableServiceInNetworkDB(a *agent, n *network, ep *Endpoint) {
746
+func disableServiceInNetworkDB(a *agent, n *Network, ep *Endpoint) {
747 747
 	var epRec EndpointRecord
748 748
 
749 749
 	log.G(context.TODO()).Debugf("disableServiceInNetworkDB for %s %s", ep.svcName, ep.ID())
... ...
@@ -772,7 +772,7 @@ func disableServiceInNetworkDB(a *agent, n *network, ep *Endpoint) {
772 772
 	}
773 773
 }
774 774
 
775
-func (n *network) addDriverWatches() {
775
+func (n *Network) addDriverWatches() {
776 776
 	if !n.isClusterEligible() {
777 777
 		return
778 778
 	}
... ...
@@ -808,7 +808,7 @@ func (n *network) addDriverWatches() {
808 808
 	}
809 809
 }
810 810
 
811
-func (n *network) cancelDriverWatches() {
811
+func (n *Network) cancelDriverWatches() {
812 812
 	if !n.isClusterEligible() {
813 813
 		return
814 814
 	}
... ...
@@ -839,7 +839,7 @@ func (c *Controller) handleTableEvents(ch *events.Channel, fn func(events.Event)
839 839
 	}
840 840
 }
841 841
 
842
-func (n *network) handleDriverTableEvent(ev events.Event) {
842
+func (n *Network) handleDriverTableEvent(ev events.Event) {
843 843
 	d, err := n.driver(false)
844 844
 	if err != nil {
845 845
 		log.G(context.TODO()).Errorf("Could not resolve driver %s while handling driver table event: %v", n.networkType, err)
... ...
@@ -76,7 +76,7 @@ import (
76 76
 
77 77
 // NetworkWalker is a client provided function which will be used to walk the Networks.
78 78
 // When the function returns true, the walk will stop.
79
-type NetworkWalker func(nw Network) bool
79
+type NetworkWalker func(nw *Network) bool
80 80
 
81 81
 // SandboxWalker is a client provided function which will be used to walk the Sandboxes.
82 82
 // When the function returns true, the walk will stop.
... ...
@@ -461,11 +461,11 @@ const overlayDSROptionString = "dsr"
461 461
 
462 462
 // NewNetwork creates a new network of the specified network type. The options
463 463
 // are network specific and modeled in a generic way.
464
-func (c *Controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (Network, error) {
464
+func (c *Controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (*Network, error) {
465 465
 	var (
466 466
 		caps           driverapi.Capability
467 467
 		err            error
468
-		t              *network
468
+		t              *Network
469 469
 		skipCfgEpCount bool
470 470
 	)
471 471
 
... ...
@@ -488,7 +488,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ...
488 488
 
489 489
 	defaultIpam := defaultIpamForNetworkType(networkType)
490 490
 	// Construct the network object
491
-	nw := &network{
491
+	nw := &Network{
492 492
 		name:             name,
493 493
 		networkType:      networkType,
494 494
 		generic:          map[string]interface{}{netlabel.GenericData: make(map[string]string)},
... ...
@@ -603,7 +603,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ...
603 603
 	// time pressure to get this in without adding changes to moby,
604 604
 	// swarm and CLI, it is being implemented as a driver-specific
605 605
 	// option.  Unfortunately, drivers can't influence the core
606
-	// "libnetwork.network" data type.  Hence we need this hack code
606
+	// "libnetwork.Network" data type.  Hence we need this hack code
607 607
 	// to implement in this manner.
608 608
 	if gval, ok := nw.generic[netlabel.GenericData]; ok && nw.networkType == "overlay" {
609 609
 		optMap := gval.(map[string]string)
... ...
@@ -670,15 +670,14 @@ addToStore:
670 670
 	return nw, nil
671 671
 }
672 672
 
673
-var joinCluster NetworkWalker = func(nw Network) bool {
674
-	n := nw.(*network)
675
-	if n.configOnly {
673
+var joinCluster NetworkWalker = func(nw *Network) bool {
674
+	if nw.configOnly {
676 675
 		return false
677 676
 	}
678
-	if err := n.joinCluster(); err != nil {
679
-		log.G(context.TODO()).Errorf("Failed to join network %s (%s) into agent cluster: %v", n.Name(), n.ID(), err)
677
+	if err := nw.joinCluster(); err != nil {
678
+		log.G(context.TODO()).Errorf("Failed to join network %s (%s) into agent cluster: %v", nw.Name(), nw.ID(), err)
680 679
 	}
681
-	n.addDriverWatches()
680
+	nw.addDriverWatches()
682 681
 	return false
683 682
 }
684 683
 
... ...
@@ -746,7 +745,7 @@ func (c *Controller) reservePools() {
746 746
 	}
747 747
 }
748 748
 
749
-func doReplayPoolReserve(n *network) bool {
749
+func doReplayPoolReserve(n *Network) bool {
750 750
 	_, caps, err := n.getController().getIPAMDriver(n.ipamType)
751 751
 	if err != nil {
752 752
 		log.G(context.TODO()).Warnf("Failed to retrieve ipam driver for network %q (%s): %v", n.Name(), n.ID(), err)
... ...
@@ -755,7 +754,7 @@ func doReplayPoolReserve(n *network) bool {
755 755
 	return caps.RequiresRequestReplay
756 756
 }
757 757
 
758
-func (c *Controller) addNetwork(n *network) error {
758
+func (c *Controller) addNetwork(n *Network) error {
759 759
 	d, err := n.driver(true)
760 760
 	if err != nil {
761 761
 		return err
... ...
@@ -772,8 +771,8 @@ func (c *Controller) addNetwork(n *network) error {
772 772
 }
773 773
 
774 774
 // Networks returns the list of Network(s) managed by this controller.
775
-func (c *Controller) Networks() []Network {
776
-	var list []Network
775
+func (c *Controller) Networks() []*Network {
776
+	var list []*Network
777 777
 
778 778
 	for _, n := range c.getNetworksFromStore() {
779 779
 		if n.inDelete {
... ...
@@ -796,21 +795,19 @@ func (c *Controller) WalkNetworks(walker NetworkWalker) {
796 796
 
797 797
 // NetworkByName returns the Network which has the passed name.
798 798
 // If not found, the error [ErrNoSuchNetwork] is returned.
799
-func (c *Controller) NetworkByName(name string) (Network, error) {
799
+func (c *Controller) NetworkByName(name string) (*Network, error) {
800 800
 	if name == "" {
801 801
 		return nil, ErrInvalidName(name)
802 802
 	}
803
-	var n Network
803
+	var n *Network
804 804
 
805
-	s := func(current Network) bool {
805
+	c.WalkNetworks(func(current *Network) bool {
806 806
 		if current.Name() == name {
807 807
 			n = current
808 808
 			return true
809 809
 		}
810 810
 		return false
811
-	}
812
-
813
-	c.WalkNetworks(s)
811
+	})
814 812
 
815 813
 	if n == nil {
816 814
 		return nil, ErrNoSuchNetwork(name)
... ...
@@ -821,7 +818,7 @@ func (c *Controller) NetworkByName(name string) (Network, error) {
821 821
 
822 822
 // NetworkByID returns the Network which has the passed id.
823 823
 // If not found, the error [ErrNoSuchNetwork] is returned.
824
-func (c *Controller) NetworkByID(id string) (Network, error) {
824
+func (c *Controller) NetworkByID(id string) (*Network, error) {
825 825
 	if id == "" {
826 826
 		return nil, ErrInvalidID(id)
827 827
 	}
... ...
@@ -162,7 +162,7 @@ func (ep *Endpoint) endpointInGWNetwork() bool {
162 162
 
163 163
 // Looks for the default gw network and creates it if not there.
164 164
 // Parallel executions are serialized.
165
-func (c *Controller) defaultGwNetwork() (Network, error) {
165
+func (c *Controller) defaultGwNetwork() (*Network, error) {
166 166
 	procGwNetwork <- true
167 167
 	defer func() { <-procGwNetwork }()
168 168
 
... ...
@@ -8,6 +8,6 @@ func getPlatformOption() EndpointOption {
8 8
 	return nil
9 9
 }
10 10
 
11
-func (c *Controller) createGWNetwork() (Network, error) {
11
+func (c *Controller) createGWNetwork() (*Network, error) {
12 12
 	return nil, types.NotImplementedErrorf("default gateway functionality is not implemented in freebsd")
13 13
 }
... ...
@@ -13,15 +13,13 @@ func getPlatformOption() EndpointOption {
13 13
 	return nil
14 14
 }
15 15
 
16
-func (c *Controller) createGWNetwork() (Network, error) {
17
-	netOption := map[string]string{
18
-		bridge.BridgeName:         libnGWNetwork,
19
-		bridge.EnableICC:          strconv.FormatBool(false),
20
-		bridge.EnableIPMasquerade: strconv.FormatBool(true),
21
-	}
22
-
16
+func (c *Controller) createGWNetwork() (*Network, error) {
23 17
 	n, err := c.NewNetwork("bridge", libnGWNetwork, "",
24
-		NetworkOptionDriverOpts(netOption),
18
+		NetworkOptionDriverOpts(map[string]string{
19
+			bridge.BridgeName:         libnGWNetwork,
20
+			bridge.EnableICC:          strconv.FormatBool(false),
21
+			bridge.EnableIPMasquerade: strconv.FormatBool(true),
22
+		}),
25 23
 		NetworkOptionEnableIPv6(false),
26 24
 	)
27 25
 	if err != nil {
... ...
@@ -16,6 +16,6 @@ func getPlatformOption() EndpointOption {
16 16
 	return EndpointOptionGeneric(epOption)
17 17
 }
18 18
 
19
-func (c *Controller) createGWNetwork() (Network, error) {
19
+func (c *Controller) createGWNetwork() (*Network, error) {
20 20
 	return nil, types.NotImplementedErrorf("default gateway functionality is not implemented in windows")
21 21
 }
... ...
@@ -24,7 +24,7 @@ type EndpointOption func(ep *Endpoint)
24 24
 type Endpoint struct {
25 25
 	name              string
26 26
 	id                string
27
-	network           *network
27
+	network           *Network
28 28
 	iface             *endpointInterface
29 29
 	joinInfo          *endpointJoinInfo
30 30
 	sandboxID         string
... ...
@@ -378,14 +378,14 @@ func (ep *Endpoint) processOptions(options ...EndpointOption) {
378 378
 	}
379 379
 }
380 380
 
381
-func (ep *Endpoint) getNetwork() *network {
381
+func (ep *Endpoint) getNetwork() *Network {
382 382
 	ep.mu.Lock()
383 383
 	defer ep.mu.Unlock()
384 384
 
385 385
 	return ep.network
386 386
 }
387 387
 
388
-func (ep *Endpoint) getNetworkFromStore() (*network, error) {
388
+func (ep *Endpoint) getNetworkFromStore() (*Network, error) {
389 389
 	if ep.network == nil {
390 390
 		return nil, fmt.Errorf("invalid network object in endpoint %s", ep.Name())
391 391
 	}
... ...
@@ -932,7 +932,7 @@ func CreateOptionIpam(ipV4, ipV6 net.IP, llIPs []net.IP, ipamOptions map[string]
932 932
 }
933 933
 
934 934
 // CreateOptionExposedPorts function returns an option setter for the container exposed
935
-// ports option to be passed to network.CreateEndpoint() method.
935
+// ports option to be passed to [Network.CreateEndpoint] method.
936 936
 func CreateOptionExposedPorts(exposedPorts []types.TransportPort) EndpointOption {
937 937
 	return func(ep *Endpoint) {
938 938
 		// Defensive copy
... ...
@@ -945,7 +945,7 @@ func CreateOptionExposedPorts(exposedPorts []types.TransportPort) EndpointOption
945 945
 }
946 946
 
947 947
 // CreateOptionPortMapping function returns an option setter for the mapping
948
-// ports option to be passed to network.CreateEndpoint() method.
948
+// ports option to be passed to [Network.CreateEndpoint] method.
949 949
 func CreateOptionPortMapping(portBindings []types.PortBinding) EndpointOption {
950 950
 	return func(ep *Endpoint) {
951 951
 		// Store a copy of the bindings as generic data to pass to the driver
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 type endpointCnt struct {
12
-	n        *network
12
+	n        *Network
13 13
 	Count    uint64
14 14
 	dbIndex  uint64
15 15
 	dbExists bool
... ...
@@ -20,7 +20,7 @@ import (
20 20
 )
21 21
 
22 22
 func TestNetworkMarshalling(t *testing.T) {
23
-	n := &network{
23
+	n := &Network{
24 24
 		name:        "Miao",
25 25
 		id:          "abccba",
26 26
 		ipamType:    "default",
... ...
@@ -128,7 +128,7 @@ func TestNetworkMarshalling(t *testing.T) {
128 128
 		t.Fatal(err)
129 129
 	}
130 130
 
131
-	nn := &network{}
131
+	nn := &Network{}
132 132
 	err = json.Unmarshal(b, nn)
133 133
 	if err != nil {
134 134
 		t.Fatal(err)
... ...
@@ -319,7 +319,7 @@ func TestAuxAddresses(t *testing.T) {
319 319
 	}
320 320
 	defer c.Stop()
321 321
 
322
-	n := &network{ipamType: ipamapi.DefaultIPAM, networkType: "bridge", ctrlr: c}
322
+	n := &Network{ipamType: ipamapi.DefaultIPAM, networkType: "bridge", ctrlr: c}
323 323
 
324 324
 	input := []struct {
325 325
 		masterPool   string
... ...
@@ -486,12 +486,12 @@ func TestServiceVIPReuse(t *testing.T) {
486 486
 	}
487 487
 
488 488
 	// Add 2 services with same name but different service ID to share the same VIP
489
-	n.(*network).addSvcRecords("ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
490
-	n.(*network).addSvcRecords("ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
489
+	n.addSvcRecords("ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
490
+	n.addSvcRecords("ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
491 491
 
492 492
 	ipToResolve := netutils.ReverseIP("192.168.0.1")
493 493
 
494
-	ipList, _ := n.(*network).ResolveName("service_test", types.IPv4)
494
+	ipList, _ := n.ResolveName("service_test", types.IPv4)
495 495
 	if len(ipList) == 0 {
496 496
 		t.Fatal("There must be the VIP")
497 497
 	}
... ...
@@ -501,7 +501,7 @@ func TestServiceVIPReuse(t *testing.T) {
501 501
 	if ipList[0].String() != "192.168.0.1" {
502 502
 		t.Fatal("The service VIP is 192.168.0.1")
503 503
 	}
504
-	name := n.(*network).ResolveIP(ipToResolve)
504
+	name := n.ResolveIP(ipToResolve)
505 505
 	if name == "" {
506 506
 		t.Fatal("It must return a name")
507 507
 	}
... ...
@@ -510,8 +510,8 @@ func TestServiceVIPReuse(t *testing.T) {
510 510
 	}
511 511
 
512 512
 	// Delete service record for one of the services, the IP should remain because one service is still associated with it
513
-	n.(*network).deleteSvcRecords("ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
514
-	ipList, _ = n.(*network).ResolveName("service_test", types.IPv4)
513
+	n.deleteSvcRecords("ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
514
+	ipList, _ = n.ResolveName("service_test", types.IPv4)
515 515
 	if len(ipList) == 0 {
516 516
 		t.Fatal("There must be the VIP")
517 517
 	}
... ...
@@ -521,7 +521,7 @@ func TestServiceVIPReuse(t *testing.T) {
521 521
 	if ipList[0].String() != "192.168.0.1" {
522 522
 		t.Fatal("The service VIP is 192.168.0.1")
523 523
 	}
524
-	name = n.(*network).ResolveIP(ipToResolve)
524
+	name = n.ResolveIP(ipToResolve)
525 525
 	if name == "" {
526 526
 		t.Fatal("It must return a name")
527 527
 	}
... ...
@@ -530,8 +530,8 @@ func TestServiceVIPReuse(t *testing.T) {
530 530
 	}
531 531
 
532 532
 	// Delete again the service using the previous service ID, nothing should happen
533
-	n.(*network).deleteSvcRecords("ep2", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
534
-	ipList, _ = n.(*network).ResolveName("service_test", types.IPv4)
533
+	n.deleteSvcRecords("ep2", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
534
+	ipList, _ = n.ResolveName("service_test", types.IPv4)
535 535
 	if len(ipList) == 0 {
536 536
 		t.Fatal("There must be the VIP")
537 537
 	}
... ...
@@ -541,7 +541,7 @@ func TestServiceVIPReuse(t *testing.T) {
541 541
 	if ipList[0].String() != "192.168.0.1" {
542 542
 		t.Fatal("The service VIP is 192.168.0.1")
543 543
 	}
544
-	name = n.(*network).ResolveIP(ipToResolve)
544
+	name = n.ResolveIP(ipToResolve)
545 545
 	if name == "" {
546 546
 		t.Fatal("It must return a name")
547 547
 	}
... ...
@@ -550,12 +550,12 @@ func TestServiceVIPReuse(t *testing.T) {
550 550
 	}
551 551
 
552 552
 	// Delete now using the second service ID, now all the entries should be gone
553
-	n.(*network).deleteSvcRecords("ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
554
-	ipList, _ = n.(*network).ResolveName("service_test", types.IPv4)
553
+	n.deleteSvcRecords("ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
554
+	ipList, _ = n.ResolveName("service_test", types.IPv4)
555 555
 	if len(ipList) != 0 {
556 556
 		t.Fatal("All the VIPs should be gone now")
557 557
 	}
558
-	name = n.(*network).ResolveIP(ipToResolve)
558
+	name = n.ResolveIP(ipToResolve)
559 559
 	if name != "" {
560 560
 		t.Fatalf("It must return empty no more services associated, instead:%s", name)
561 561
 	}
... ...
@@ -31,7 +31,7 @@ const (
31 31
 	bridgeNetType = "bridge"
32 32
 )
33 33
 
34
-func makeTesthostNetwork(t *testing.T, c *libnetwork.Controller) libnetwork.Network {
34
+func makeTesthostNetwork(t *testing.T, c *libnetwork.Controller) *libnetwork.Network {
35 35
 	t.Helper()
36 36
 	n, err := createTestNetwork(c, "host", "testhost", options.Generic{}, nil, nil)
37 37
 	if err != nil {
... ...
@@ -847,7 +847,7 @@ func TestResolvConf(t *testing.T) {
847 847
 type parallelTester struct {
848 848
 	osctx      *testutils.OSContext
849 849
 	controller *libnetwork.Controller
850
-	net1, net2 libnetwork.Network
850
+	net1, net2 *libnetwork.Network
851 851
 	iterCnt    int
852 852
 }
853 853
 
... ...
@@ -47,7 +47,7 @@ func newController(t *testing.T) *libnetwork.Controller {
47 47
 	return c
48 48
 }
49 49
 
50
-func createTestNetwork(c *libnetwork.Controller, networkType, networkName string, netOption options.Generic, ipamV4Configs, ipamV6Configs []*libnetwork.IpamConf) (libnetwork.Network, error) {
50
+func createTestNetwork(c *libnetwork.Controller, networkType, networkName string, netOption options.Generic, ipamV4Configs, ipamV6Configs []*libnetwork.IpamConf) (*libnetwork.Network, error) {
51 51
 	return c.NewNetwork(networkType, networkName, "",
52 52
 		libnetwork.NetworkOptionGeneric(netOption),
53 53
 		libnetwork.NetworkOptionIpam(ipamapi.DefaultIPAM, "", ipamV4Configs, ipamV6Configs, nil))
... ...
@@ -549,8 +549,8 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
549 549
 
550 550
 	// Test Network Walk method
551 551
 	var netName string
552
-	var netWanted libnetwork.Network
553
-	nwWlk := func(nw libnetwork.Network) bool {
552
+	var netWanted *libnetwork.Network
553
+	nwWlk := func(nw *libnetwork.Network) bool {
554 554
 		if nw.Name() == netName {
555 555
 			netWanted = nw
556 556
 			return true
... ...
@@ -24,41 +24,6 @@ import (
24 24
 	"github.com/docker/docker/pkg/stringid"
25 25
 )
26 26
 
27
-// A Network represents a logical connectivity zone that containers may
28
-// join using the Link method. A Network is managed by a specific driver.
29
-type Network interface {
30
-	// Name returns a user chosen name for this network.
31
-	Name() string
32
-
33
-	// ID returns a system generated id for this network.
34
-	ID() string
35
-
36
-	// Type returns the type of network, which corresponds to its managing driver.
37
-	Type() string
38
-
39
-	// CreateEndpoint creates a new endpoint to this network symbolically identified by the
40
-	// specified unique name. The options parameter carries driver specific options.
41
-	CreateEndpoint(name string, options ...EndpointOption) (*Endpoint, error)
42
-
43
-	// Delete the network.
44
-	Delete(options ...NetworkDeleteOption) error
45
-
46
-	// Endpoints returns the list of Endpoint(s) in this network.
47
-	Endpoints() []*Endpoint
48
-
49
-	// WalkEndpoints uses the provided function to walk the Endpoints.
50
-	WalkEndpoints(walker EndpointWalker)
51
-
52
-	// EndpointByName returns the Endpoint which has the passed name. If not found, the error ErrNoSuchEndpoint is returned.
53
-	EndpointByName(name string) (*Endpoint, error)
54
-
55
-	// EndpointByID returns the Endpoint which has the passed id. If not found, the error ErrNoSuchEndpoint is returned.
56
-	EndpointByID(id string) (*Endpoint, error)
57
-
58
-	// Info returns certain operational data belonging to this network.
59
-	Info() NetworkInfo
60
-}
61
-
62 27
 // NetworkInfo returns some configuration and operational information about the network
63 28
 type NetworkInfo interface {
64 29
 	IpamConfig() (string, map[string]string, []*IpamConf, []*IpamConf)
... ...
@@ -199,7 +164,9 @@ func (i *IpamInfo) UnmarshalJSON(data []byte) error {
199 199
 	return nil
200 200
 }
201 201
 
202
-type network struct {
202
+// Network represents a logical connectivity zone that containers may
203
+// join using the Link method. A network is managed by a specific driver.
204
+type Network struct {
203 205
 	ctrlr            *Controller
204 206
 	name             string
205 207
 	networkType      string
... ...
@@ -243,45 +210,48 @@ const (
243 243
 	loadBalancerModeDefault = loadBalancerModeNAT
244 244
 )
245 245
 
246
-func (n *network) Name() string {
246
+// Name returns a user chosen name for this network.
247
+func (n *Network) Name() string {
247 248
 	n.mu.Lock()
248 249
 	defer n.mu.Unlock()
249 250
 
250 251
 	return n.name
251 252
 }
252 253
 
253
-func (n *network) ID() string {
254
+// ID returns a system generated id for this network.
255
+func (n *Network) ID() string {
254 256
 	n.mu.Lock()
255 257
 	defer n.mu.Unlock()
256 258
 
257 259
 	return n.id
258 260
 }
259 261
 
260
-func (n *network) Created() time.Time {
262
+func (n *Network) Created() time.Time {
261 263
 	n.mu.Lock()
262 264
 	defer n.mu.Unlock()
263 265
 
264 266
 	return n.created
265 267
 }
266 268
 
267
-func (n *network) Type() string {
269
+// Type returns the type of network, which corresponds to its managing driver.
270
+func (n *Network) Type() string {
268 271
 	n.mu.Lock()
269 272
 	defer n.mu.Unlock()
270 273
 
271 274
 	return n.networkType
272 275
 }
273 276
 
274
-func (n *network) Key() []string {
277
+func (n *Network) Key() []string {
275 278
 	n.mu.Lock()
276 279
 	defer n.mu.Unlock()
277 280
 	return []string{datastore.NetworkKeyPrefix, n.id}
278 281
 }
279 282
 
280
-func (n *network) KeyPrefix() []string {
283
+func (n *Network) KeyPrefix() []string {
281 284
 	return []string{datastore.NetworkKeyPrefix}
282 285
 }
283 286
 
284
-func (n *network) Value() []byte {
287
+func (n *Network) Value() []byte {
285 288
 	n.mu.Lock()
286 289
 	defer n.mu.Unlock()
287 290
 	b, err := json.Marshal(n)
... ...
@@ -291,40 +261,40 @@ func (n *network) Value() []byte {
291 291
 	return b
292 292
 }
293 293
 
294
-func (n *network) SetValue(value []byte) error {
294
+func (n *Network) SetValue(value []byte) error {
295 295
 	return json.Unmarshal(value, n)
296 296
 }
297 297
 
298
-func (n *network) Index() uint64 {
298
+func (n *Network) Index() uint64 {
299 299
 	n.mu.Lock()
300 300
 	defer n.mu.Unlock()
301 301
 	return n.dbIndex
302 302
 }
303 303
 
304
-func (n *network) SetIndex(index uint64) {
304
+func (n *Network) SetIndex(index uint64) {
305 305
 	n.mu.Lock()
306 306
 	n.dbIndex = index
307 307
 	n.dbExists = true
308 308
 	n.mu.Unlock()
309 309
 }
310 310
 
311
-func (n *network) Exists() bool {
311
+func (n *Network) Exists() bool {
312 312
 	n.mu.Lock()
313 313
 	defer n.mu.Unlock()
314 314
 	return n.dbExists
315 315
 }
316 316
 
317
-func (n *network) Skip() bool {
317
+func (n *Network) Skip() bool {
318 318
 	n.mu.Lock()
319 319
 	defer n.mu.Unlock()
320 320
 	return !n.persist
321 321
 }
322 322
 
323
-func (n *network) New() datastore.KVObject {
323
+func (n *Network) New() datastore.KVObject {
324 324
 	n.mu.Lock()
325 325
 	defer n.mu.Unlock()
326 326
 
327
-	return &network{
327
+	return &Network{
328 328
 		ctrlr:   n.ctrlr,
329 329
 		drvOnce: &sync.Once{},
330 330
 		scope:   n.scope,
... ...
@@ -369,7 +339,7 @@ func (i *IpamInfo) CopyTo(dstI *IpamInfo) error {
369 369
 	return nil
370 370
 }
371 371
 
372
-func (n *network) validateConfiguration() error {
372
+func (n *Network) validateConfiguration() error {
373 373
 	if n.configOnly {
374 374
 		// Only supports network specific configurations.
375 375
 		// Network operator configurations are not supported.
... ...
@@ -417,7 +387,7 @@ func (n *network) validateConfiguration() error {
417 417
 }
418 418
 
419 419
 // applyConfigurationTo applies network specific configurations.
420
-func (n *network) applyConfigurationTo(to *network) error {
420
+func (n *Network) applyConfigurationTo(to *Network) error {
421 421
 	to.enableIPv6 = n.enableIPv6
422 422
 	if len(n.labels) > 0 {
423 423
 		to.labels = make(map[string]string, len(n.labels))
... ...
@@ -455,11 +425,11 @@ func (n *network) applyConfigurationTo(to *network) error {
455 455
 	return nil
456 456
 }
457 457
 
458
-func (n *network) CopyTo(o datastore.KVObject) error {
458
+func (n *Network) CopyTo(o datastore.KVObject) error {
459 459
 	n.mu.Lock()
460 460
 	defer n.mu.Unlock()
461 461
 
462
-	dstN := o.(*network)
462
+	dstN := o.(*Network)
463 463
 	dstN.name = n.name
464 464
 	dstN.id = n.id
465 465
 	dstN.created = n.created
... ...
@@ -537,7 +507,7 @@ func (n *network) CopyTo(o datastore.KVObject) error {
537 537
 	return nil
538 538
 }
539 539
 
540
-func (n *network) DataScope() string {
540
+func (n *Network) DataScope() string {
541 541
 	s := n.Scope()
542 542
 	// All swarm scope networks have local datascope
543 543
 	if s == datastore.SwarmScope {
... ...
@@ -546,7 +516,7 @@ func (n *network) DataScope() string {
546 546
 	return s
547 547
 }
548 548
 
549
-func (n *network) getEpCnt() *endpointCnt {
549
+func (n *Network) getEpCnt() *endpointCnt {
550 550
 	n.mu.Lock()
551 551
 	defer n.mu.Unlock()
552 552
 
... ...
@@ -554,7 +524,7 @@ func (n *network) getEpCnt() *endpointCnt {
554 554
 }
555 555
 
556 556
 // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
557
-func (n *network) MarshalJSON() ([]byte, error) {
557
+func (n *Network) MarshalJSON() ([]byte, error) {
558 558
 	netMap := make(map[string]interface{})
559 559
 	netMap["name"] = n.name
560 560
 	netMap["id"] = n.id
... ...
@@ -611,7 +581,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
611 611
 }
612 612
 
613 613
 // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
614
-func (n *network) UnmarshalJSON(b []byte) (err error) {
614
+func (n *Network) UnmarshalJSON(b []byte) (err error) {
615 615
 	var netMap map[string]interface{}
616 616
 	if err := json.Unmarshal(b, &netMap); err != nil {
617 617
 		return err
... ...
@@ -734,12 +704,12 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
734 734
 // NetworkOption is an option setter function type used to pass various options to
735 735
 // NewNetwork method. The various setter functions of type NetworkOption are
736 736
 // provided by libnetwork, they look like NetworkOptionXXXX(...)
737
-type NetworkOption func(n *network)
737
+type NetworkOption func(n *Network)
738 738
 
739 739
 // NetworkOptionGeneric function returns an option setter for a Generic option defined
740 740
 // in a Dictionary of Key-Value pair
741 741
 func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption {
742
-	return func(n *network) {
742
+	return func(n *Network) {
743 743
 		if n.generic == nil {
744 744
 			n.generic = make(map[string]interface{})
745 745
 		}
... ...
@@ -758,21 +728,21 @@ func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption {
758 758
 // NetworkOptionIngress returns an option setter to indicate if a network is
759 759
 // an ingress network.
760 760
 func NetworkOptionIngress(ingress bool) NetworkOption {
761
-	return func(n *network) {
761
+	return func(n *Network) {
762 762
 		n.ingress = ingress
763 763
 	}
764 764
 }
765 765
 
766 766
 // NetworkOptionPersist returns an option setter to set persistence policy for a network
767 767
 func NetworkOptionPersist(persist bool) NetworkOption {
768
-	return func(n *network) {
768
+	return func(n *Network) {
769 769
 		n.persist = persist
770 770
 	}
771 771
 }
772 772
 
773 773
 // NetworkOptionEnableIPv6 returns an option setter to explicitly configure IPv6
774 774
 func NetworkOptionEnableIPv6(enableIPv6 bool) NetworkOption {
775
-	return func(n *network) {
775
+	return func(n *Network) {
776 776
 		if n.generic == nil {
777 777
 			n.generic = make(map[string]interface{})
778 778
 		}
... ...
@@ -784,7 +754,7 @@ func NetworkOptionEnableIPv6(enableIPv6 bool) NetworkOption {
784 784
 // NetworkOptionInternalNetwork returns an option setter to config the network
785 785
 // to be internal which disables default gateway service
786 786
 func NetworkOptionInternalNetwork() NetworkOption {
787
-	return func(n *network) {
787
+	return func(n *Network) {
788 788
 		if n.generic == nil {
789 789
 			n.generic = make(map[string]interface{})
790 790
 		}
... ...
@@ -795,7 +765,7 @@ func NetworkOptionInternalNetwork() NetworkOption {
795 795
 
796 796
 // NetworkOptionAttachable returns an option setter to set attachable for a network
797 797
 func NetworkOptionAttachable(attachable bool) NetworkOption {
798
-	return func(n *network) {
798
+	return func(n *Network) {
799 799
 		n.attachable = attachable
800 800
 	}
801 801
 }
... ...
@@ -803,14 +773,14 @@ func NetworkOptionAttachable(attachable bool) NetworkOption {
803 803
 // NetworkOptionScope returns an option setter to overwrite the network's scope.
804 804
 // By default the network's scope is set to the network driver's datascope.
805 805
 func NetworkOptionScope(scope string) NetworkOption {
806
-	return func(n *network) {
806
+	return func(n *Network) {
807 807
 		n.scope = scope
808 808
 	}
809 809
 }
810 810
 
811 811
 // NetworkOptionIpam function returns an option setter for the ipam configuration for this network
812 812
 func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ipV6 []*IpamConf, opts map[string]string) NetworkOption {
813
-	return func(n *network) {
813
+	return func(n *Network) {
814 814
 		if ipamDriver != "" {
815 815
 			n.ipamType = ipamDriver
816 816
 			if ipamDriver == ipamapi.DefaultIPAM {
... ...
@@ -826,14 +796,14 @@ func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ip
826 826
 
827 827
 // NetworkOptionLBEndpoint function returns an option setter for the configuration of the load balancer endpoint for this network
828 828
 func NetworkOptionLBEndpoint(ip net.IP) NetworkOption {
829
-	return func(n *network) {
829
+	return func(n *Network) {
830 830
 		n.loadBalancerIP = ip
831 831
 	}
832 832
 }
833 833
 
834 834
 // NetworkOptionDriverOpts function returns an option setter for any driver parameter described by a map
835 835
 func NetworkOptionDriverOpts(opts map[string]string) NetworkOption {
836
-	return func(n *network) {
836
+	return func(n *Network) {
837 837
 		if n.generic == nil {
838 838
 			n.generic = make(map[string]interface{})
839 839
 		}
... ...
@@ -847,14 +817,14 @@ func NetworkOptionDriverOpts(opts map[string]string) NetworkOption {
847 847
 
848 848
 // NetworkOptionLabels function returns an option setter for labels specific to a network
849 849
 func NetworkOptionLabels(labels map[string]string) NetworkOption {
850
-	return func(n *network) {
850
+	return func(n *Network) {
851 851
 		n.labels = labels
852 852
 	}
853 853
 }
854 854
 
855 855
 // NetworkOptionDynamic function returns an option setter for dynamic option for a network
856 856
 func NetworkOptionDynamic() NetworkOption {
857
-	return func(n *network) {
857
+	return func(n *Network) {
858 858
 		n.dynamic = true
859 859
 	}
860 860
 }
... ...
@@ -864,7 +834,7 @@ func NetworkOptionDynamic() NetworkOption {
864 864
 // to a container as combination of fixed-cidr-v6 + mac-address
865 865
 // TODO: Remove this option setter once we support endpoint ipam options
866 866
 func NetworkOptionDeferIPv6Alloc(enable bool) NetworkOption {
867
-	return func(n *network) {
867
+	return func(n *Network) {
868 868
 		n.postIPv6 = enable
869 869
 	}
870 870
 }
... ...
@@ -873,7 +843,7 @@ func NetworkOptionDeferIPv6Alloc(enable bool) NetworkOption {
873 873
 // a configuration only network. It serves as a configuration
874 874
 // for other networks.
875 875
 func NetworkOptionConfigOnly() NetworkOption {
876
-	return func(n *network) {
876
+	return func(n *Network) {
877 877
 		n.configOnly = true
878 878
 	}
879 879
 }
... ...
@@ -881,12 +851,12 @@ func NetworkOptionConfigOnly() NetworkOption {
881 881
 // NetworkOptionConfigFrom tells controller to pick the
882 882
 // network configuration from a configuration only network
883 883
 func NetworkOptionConfigFrom(name string) NetworkOption {
884
-	return func(n *network) {
884
+	return func(n *Network) {
885 885
 		n.configFrom = name
886 886
 	}
887 887
 }
888 888
 
889
-func (n *network) processOptions(options ...NetworkOption) {
889
+func (n *Network) processOptions(options ...NetworkOption) {
890 890
 	for _, opt := range options {
891 891
 		if opt != nil {
892 892
 			opt(n)
... ...
@@ -899,10 +869,10 @@ type networkDeleteParams struct {
899 899
 }
900 900
 
901 901
 // NetworkDeleteOption is a type for optional parameters to pass to the
902
-// network.Delete() function.
902
+// Network.Delete() function.
903 903
 type NetworkDeleteOption func(p *networkDeleteParams)
904 904
 
905
-// NetworkDeleteOptionRemoveLB informs a network.Delete() operation that should
905
+// NetworkDeleteOptionRemoveLB informs a Network.Delete() operation that should
906 906
 // remove the load balancer endpoint for this network.  Note that the Delete()
907 907
 // method will automatically remove a load balancing endpoint for most networks
908 908
 // when the network is otherwise empty.  However, this does not occur for some
... ...
@@ -916,7 +886,7 @@ func NetworkDeleteOptionRemoveLB(p *networkDeleteParams) {
916 916
 	p.rmLBEndpoint = true
917 917
 }
918 918
 
919
-func (n *network) resolveDriver(name string, load bool) (driverapi.Driver, driverapi.Capability, error) {
919
+func (n *Network) resolveDriver(name string, load bool) (driverapi.Driver, driverapi.Capability, error) {
920 920
 	c := n.getController()
921 921
 
922 922
 	// Check if a driver for the specified network type is available
... ...
@@ -941,7 +911,7 @@ func (n *network) resolveDriver(name string, load bool) (driverapi.Driver, drive
941 941
 	return d, cap, nil
942 942
 }
943 943
 
944
-func (n *network) driverIsMultihost() bool {
944
+func (n *Network) driverIsMultihost() bool {
945 945
 	_, cap, err := n.resolveDriver(n.networkType, true)
946 946
 	if err != nil {
947 947
 		return false
... ...
@@ -949,7 +919,7 @@ func (n *network) driverIsMultihost() bool {
949 949
 	return cap.ConnectivityScope == datastore.GlobalScope
950 950
 }
951 951
 
952
-func (n *network) driver(load bool) (driverapi.Driver, error) {
952
+func (n *Network) driver(load bool) (driverapi.Driver, error) {
953 953
 	d, cap, err := n.resolveDriver(n.networkType, load)
954 954
 	if err != nil {
955 955
 		return nil, err
... ...
@@ -969,7 +939,8 @@ func (n *network) driver(load bool) (driverapi.Driver, error) {
969 969
 	return d, nil
970 970
 }
971 971
 
972
-func (n *network) Delete(options ...NetworkDeleteOption) error {
972
+// Delete the network.
973
+func (n *Network) Delete(options ...NetworkDeleteOption) error {
973 974
 	var params networkDeleteParams
974 975
 	for _, opt := range options {
975 976
 		opt(&params)
... ...
@@ -985,7 +956,7 @@ func (n *network) Delete(options ...NetworkDeleteOption) error {
985 985
 //     remove load balancer and network if endpoint count == 1
986 986
 //   - controller.networkCleanup() -- (true, true)
987 987
 //     remove the network no matter what
988
-func (n *network) delete(force bool, rmLBEndpoint bool) error {
988
+func (n *Network) delete(force bool, rmLBEndpoint bool) error {
989 989
 	n.mu.Lock()
990 990
 	c := n.ctrlr
991 991
 	name := n.name
... ...
@@ -1093,7 +1064,7 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error {
1093 1093
 
1094 1094
 removeFromStore:
1095 1095
 	// deleteFromStore performs an atomic delete operation and the
1096
-	// network.epCnt will help prevent any possible
1096
+	// Network.epCnt will help prevent any possible
1097 1097
 	// race between endpoint join and network delete
1098 1098
 	if err = c.deleteFromStore(n.getEpCnt()); err != nil {
1099 1099
 		if !force {
... ...
@@ -1109,10 +1080,10 @@ removeFromStore:
1109 1109
 	return nil
1110 1110
 }
1111 1111
 
1112
-func (n *network) deleteNetwork() error {
1112
+func (n *Network) deleteNetwork() error {
1113 1113
 	d, err := n.driver(true)
1114 1114
 	if err != nil {
1115
-		return fmt.Errorf("failed deleting network: %v", err)
1115
+		return fmt.Errorf("failed deleting Network: %v", err)
1116 1116
 	}
1117 1117
 
1118 1118
 	if err := d.DeleteNetwork(n.ID()); err != nil {
... ...
@@ -1132,7 +1103,7 @@ func (n *network) deleteNetwork() error {
1132 1132
 	return nil
1133 1133
 }
1134 1134
 
1135
-func (n *network) addEndpoint(ep *Endpoint) error {
1135
+func (n *Network) addEndpoint(ep *Endpoint) error {
1136 1136
 	d, err := n.driver(true)
1137 1137
 	if err != nil {
1138 1138
 		return fmt.Errorf("failed to add endpoint: %v", err)
... ...
@@ -1147,7 +1118,9 @@ func (n *network) addEndpoint(ep *Endpoint) error {
1147 1147
 	return nil
1148 1148
 }
1149 1149
 
1150
-func (n *network) CreateEndpoint(name string, options ...EndpointOption) (*Endpoint, error) {
1150
+// CreateEndpoint creates a new endpoint to this network symbolically identified by the
1151
+// specified unique name. The options parameter carries driver specific options.
1152
+func (n *Network) CreateEndpoint(name string, options ...EndpointOption) (*Endpoint, error) {
1151 1153
 	var err error
1152 1154
 	if strings.TrimSpace(name) == "" {
1153 1155
 		return nil, ErrInvalidName(name)
... ...
@@ -1167,7 +1140,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (*Endpo
1167 1167
 	return n.createEndpoint(name, options...)
1168 1168
 }
1169 1169
 
1170
-func (n *network) createEndpoint(name string, options ...EndpointOption) (*Endpoint, error) {
1170
+func (n *Network) createEndpoint(name string, options ...EndpointOption) (*Endpoint, error) {
1171 1171
 	var err error
1172 1172
 
1173 1173
 	ep := &Endpoint{name: name, generic: make(map[string]interface{}), iface: &endpointInterface{}}
... ...
@@ -1265,7 +1238,8 @@ func (n *network) createEndpoint(name string, options ...EndpointOption) (*Endpo
1265 1265
 	return ep, nil
1266 1266
 }
1267 1267
 
1268
-func (n *network) Endpoints() []*Endpoint {
1268
+// Endpoints returns the list of Endpoint(s) in this network.
1269
+func (n *Network) Endpoints() []*Endpoint {
1269 1270
 	endpoints, err := n.getEndpointsFromStore()
1270 1271
 	if err != nil {
1271 1272
 		log.G(context.TODO()).Error(err)
... ...
@@ -1273,7 +1247,8 @@ func (n *network) Endpoints() []*Endpoint {
1273 1273
 	return endpoints
1274 1274
 }
1275 1275
 
1276
-func (n *network) WalkEndpoints(walker EndpointWalker) {
1276
+// WalkEndpoints uses the provided function to walk the Endpoints.
1277
+func (n *Network) WalkEndpoints(walker EndpointWalker) {
1277 1278
 	for _, e := range n.Endpoints() {
1278 1279
 		if walker(e) {
1279 1280
 			return
... ...
@@ -1281,7 +1256,9 @@ func (n *network) WalkEndpoints(walker EndpointWalker) {
1281 1281
 	}
1282 1282
 }
1283 1283
 
1284
-func (n *network) EndpointByName(name string) (*Endpoint, error) {
1284
+// EndpointByName returns the Endpoint which has the passed name. If not found,
1285
+// the error ErrNoSuchEndpoint is returned.
1286
+func (n *Network) EndpointByName(name string) (*Endpoint, error) {
1285 1287
 	if name == "" {
1286 1288
 		return nil, ErrInvalidName(name)
1287 1289
 	}
... ...
@@ -1304,7 +1281,9 @@ func (n *network) EndpointByName(name string) (*Endpoint, error) {
1304 1304
 	return e, nil
1305 1305
 }
1306 1306
 
1307
-func (n *network) EndpointByID(id string) (*Endpoint, error) {
1307
+// EndpointByID returns the Endpoint which has the passed id. If not found,
1308
+// the error ErrNoSuchEndpoint is returned.
1309
+func (n *Network) EndpointByID(id string) (*Endpoint, error) {
1308 1310
 	if id == "" {
1309 1311
 		return nil, ErrInvalidID(id)
1310 1312
 	}
... ...
@@ -1317,7 +1296,7 @@ func (n *network) EndpointByID(id string) (*Endpoint, error) {
1317 1317
 	return ep, nil
1318 1318
 }
1319 1319
 
1320
-func (n *network) updateSvcRecord(ep *Endpoint, localEps []*Endpoint, isAdd bool) {
1320
+func (n *Network) updateSvcRecord(ep *Endpoint, localEps []*Endpoint, isAdd bool) {
1321 1321
 	var ipv6 net.IP
1322 1322
 	epName := ep.Name()
1323 1323
 	if iface := ep.Iface(); iface != nil && iface.Address() != nil {
... ...
@@ -1393,7 +1372,7 @@ func delNameToIP(svcMap *setmatrix.SetMatrix[svcMapEntry], name, serviceID strin
1393 1393
 	})
1394 1394
 }
1395 1395
 
1396
-func (n *network) addSvcRecords(eID, name, serviceID string, epIP, epIPv6 net.IP, ipMapUpdate bool, method string) {
1396
+func (n *Network) addSvcRecords(eID, name, serviceID string, epIP, epIPv6 net.IP, ipMapUpdate bool, method string) {
1397 1397
 	// Do not add service names for ingress network as this is a
1398 1398
 	// routing only network
1399 1399
 	if n.ingress {
... ...
@@ -1425,7 +1404,7 @@ func (n *network) addSvcRecords(eID, name, serviceID string, epIP, epIPv6 net.IP
1425 1425
 	}
1426 1426
 }
1427 1427
 
1428
-func (n *network) deleteSvcRecords(eID, name, serviceID string, epIP net.IP, epIPv6 net.IP, ipMapUpdate bool, method string) {
1428
+func (n *Network) deleteSvcRecords(eID, name, serviceID string, epIP net.IP, epIPv6 net.IP, ipMapUpdate bool, method string) {
1429 1429
 	// Do not delete service names from ingress network as this is a
1430 1430
 	// routing only network
1431 1431
 	if n.ingress {
... ...
@@ -1458,7 +1437,7 @@ func (n *network) deleteSvcRecords(eID, name, serviceID string, epIP net.IP, epI
1458 1458
 	}
1459 1459
 }
1460 1460
 
1461
-func (n *network) getSvcRecords(ep *Endpoint) []etchosts.Record {
1461
+func (n *Network) getSvcRecords(ep *Endpoint) []etchosts.Record {
1462 1462
 	n.mu.Lock()
1463 1463
 	defer n.mu.Unlock()
1464 1464
 
... ...
@@ -1503,13 +1482,13 @@ func (n *network) getSvcRecords(ep *Endpoint) []etchosts.Record {
1503 1503
 	return recs
1504 1504
 }
1505 1505
 
1506
-func (n *network) getController() *Controller {
1506
+func (n *Network) getController() *Controller {
1507 1507
 	n.mu.Lock()
1508 1508
 	defer n.mu.Unlock()
1509 1509
 	return n.ctrlr
1510 1510
 }
1511 1511
 
1512
-func (n *network) ipamAllocate() error {
1512
+func (n *Network) ipamAllocate() error {
1513 1513
 	if n.hasSpecialDriver() {
1514 1514
 		return nil
1515 1515
 	}
... ...
@@ -1544,7 +1523,7 @@ func (n *network) ipamAllocate() error {
1544 1544
 	return err
1545 1545
 }
1546 1546
 
1547
-func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) {
1547
+func (n *Network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) {
1548 1548
 	for {
1549 1549
 		poolID, pool, meta, err := ipam.RequestPool(addressSpace, preferredPool, subPool, options, v6)
1550 1550
 		if err != nil {
... ...
@@ -1585,7 +1564,7 @@ func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPo
1585 1585
 	}
1586 1586
 }
1587 1587
 
1588
-func (n *network) ipamAllocateVersion(ipVer int, ipam ipamapi.Ipam) error {
1588
+func (n *Network) ipamAllocateVersion(ipVer int, ipam ipamapi.Ipam) error {
1589 1589
 	var (
1590 1590
 		cfgList  *[]*IpamConf
1591 1591
 		infoList *[]*IpamInfo
... ...
@@ -1673,7 +1652,7 @@ func (n *network) ipamAllocateVersion(ipVer int, ipam ipamapi.Ipam) error {
1673 1673
 	return nil
1674 1674
 }
1675 1675
 
1676
-func (n *network) ipamRelease() {
1676
+func (n *Network) ipamRelease() {
1677 1677
 	if n.hasSpecialDriver() {
1678 1678
 		return
1679 1679
 	}
... ...
@@ -1686,7 +1665,7 @@ func (n *network) ipamRelease() {
1686 1686
 	n.ipamReleaseVersion(6, ipam)
1687 1687
 }
1688 1688
 
1689
-func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
1689
+func (n *Network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
1690 1690
 	var infoList *[]*IpamInfo
1691 1691
 
1692 1692
 	switch ipVer {
... ...
@@ -1728,7 +1707,7 @@ func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
1728 1728
 	*infoList = nil
1729 1729
 }
1730 1730
 
1731
-func (n *network) getIPInfo(ipVer int) []*IpamInfo {
1731
+func (n *Network) getIPInfo(ipVer int) []*IpamInfo {
1732 1732
 	var info []*IpamInfo
1733 1733
 	switch ipVer {
1734 1734
 	case 4:
... ...
@@ -1745,7 +1724,7 @@ func (n *network) getIPInfo(ipVer int) []*IpamInfo {
1745 1745
 	return l
1746 1746
 }
1747 1747
 
1748
-func (n *network) getIPData(ipVer int) []driverapi.IPAMData {
1748
+func (n *Network) getIPData(ipVer int) []driverapi.IPAMData {
1749 1749
 	var info []*IpamInfo
1750 1750
 	switch ipVer {
1751 1751
 	case 4:
... ...
@@ -1764,7 +1743,7 @@ func (n *network) getIPData(ipVer int) []driverapi.IPAMData {
1764 1764
 	return l
1765 1765
 }
1766 1766
 
1767
-func (n *network) deriveAddressSpace() (string, error) {
1767
+func (n *Network) deriveAddressSpace() (string, error) {
1768 1768
 	ipam, _ := n.getController().ipamRegistry.IPAM(n.ipamType)
1769 1769
 	if ipam == nil {
1770 1770
 		return "", types.NotFoundErrorf("failed to get default address space: unknown ipam type %q", n.ipamType)
... ...
@@ -1779,11 +1758,12 @@ func (n *network) deriveAddressSpace() (string, error) {
1779 1779
 	return local, nil
1780 1780
 }
1781 1781
 
1782
-func (n *network) Info() NetworkInfo {
1782
+// Info returns certain operational data belonging to this network.
1783
+func (n *Network) Info() NetworkInfo {
1783 1784
 	return n
1784 1785
 }
1785 1786
 
1786
-func (n *network) Peers() []networkdb.PeerInfo {
1787
+func (n *Network) Peers() []networkdb.PeerInfo {
1787 1788
 	if !n.Dynamic() {
1788 1789
 		return []networkdb.PeerInfo{}
1789 1790
 	}
... ...
@@ -1796,7 +1776,7 @@ func (n *network) Peers() []networkdb.PeerInfo {
1796 1796
 	return agent.networkDB.Peers(n.ID())
1797 1797
 }
1798 1798
 
1799
-func (n *network) DriverOptions() map[string]string {
1799
+func (n *Network) DriverOptions() map[string]string {
1800 1800
 	n.mu.Lock()
1801 1801
 	defer n.mu.Unlock()
1802 1802
 	if n.generic != nil {
... ...
@@ -1807,13 +1787,13 @@ func (n *network) DriverOptions() map[string]string {
1807 1807
 	return map[string]string{}
1808 1808
 }
1809 1809
 
1810
-func (n *network) Scope() string {
1810
+func (n *Network) Scope() string {
1811 1811
 	n.mu.Lock()
1812 1812
 	defer n.mu.Unlock()
1813 1813
 	return n.scope
1814 1814
 }
1815 1815
 
1816
-func (n *network) IpamConfig() (string, map[string]string, []*IpamConf, []*IpamConf) {
1816
+func (n *Network) IpamConfig() (string, map[string]string, []*IpamConf, []*IpamConf) {
1817 1817
 	n.mu.Lock()
1818 1818
 	defer n.mu.Unlock()
1819 1819
 
... ...
@@ -1839,7 +1819,7 @@ func (n *network) IpamConfig() (string, map[string]string, []*IpamConf, []*IpamC
1839 1839
 	return n.ipamType, n.ipamOptions, v4L, v6L
1840 1840
 }
1841 1841
 
1842
-func (n *network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
1842
+func (n *Network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
1843 1843
 	n.mu.Lock()
1844 1844
 	defer n.mu.Unlock()
1845 1845
 
... ...
@@ -1865,56 +1845,56 @@ func (n *network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
1865 1865
 	return v4Info, v6Info
1866 1866
 }
1867 1867
 
1868
-func (n *network) Internal() bool {
1868
+func (n *Network) Internal() bool {
1869 1869
 	n.mu.Lock()
1870 1870
 	defer n.mu.Unlock()
1871 1871
 
1872 1872
 	return n.internal
1873 1873
 }
1874 1874
 
1875
-func (n *network) Attachable() bool {
1875
+func (n *Network) Attachable() bool {
1876 1876
 	n.mu.Lock()
1877 1877
 	defer n.mu.Unlock()
1878 1878
 
1879 1879
 	return n.attachable
1880 1880
 }
1881 1881
 
1882
-func (n *network) Ingress() bool {
1882
+func (n *Network) Ingress() bool {
1883 1883
 	n.mu.Lock()
1884 1884
 	defer n.mu.Unlock()
1885 1885
 
1886 1886
 	return n.ingress
1887 1887
 }
1888 1888
 
1889
-func (n *network) Dynamic() bool {
1889
+func (n *Network) Dynamic() bool {
1890 1890
 	n.mu.Lock()
1891 1891
 	defer n.mu.Unlock()
1892 1892
 
1893 1893
 	return n.dynamic
1894 1894
 }
1895 1895
 
1896
-func (n *network) IPv6Enabled() bool {
1896
+func (n *Network) IPv6Enabled() bool {
1897 1897
 	n.mu.Lock()
1898 1898
 	defer n.mu.Unlock()
1899 1899
 
1900 1900
 	return n.enableIPv6
1901 1901
 }
1902 1902
 
1903
-func (n *network) ConfigFrom() string {
1903
+func (n *Network) ConfigFrom() string {
1904 1904
 	n.mu.Lock()
1905 1905
 	defer n.mu.Unlock()
1906 1906
 
1907 1907
 	return n.configFrom
1908 1908
 }
1909 1909
 
1910
-func (n *network) ConfigOnly() bool {
1910
+func (n *Network) ConfigOnly() bool {
1911 1911
 	n.mu.Lock()
1912 1912
 	defer n.mu.Unlock()
1913 1913
 
1914 1914
 	return n.configOnly
1915 1915
 }
1916 1916
 
1917
-func (n *network) Labels() map[string]string {
1917
+func (n *Network) Labels() map[string]string {
1918 1918
 	n.mu.Lock()
1919 1919
 	defer n.mu.Unlock()
1920 1920
 
... ...
@@ -1926,7 +1906,7 @@ func (n *network) Labels() map[string]string {
1926 1926
 	return lbls
1927 1927
 }
1928 1928
 
1929
-func (n *network) TableEventRegister(tableName string, objType driverapi.ObjectType) error {
1929
+func (n *Network) TableEventRegister(tableName string, objType driverapi.ObjectType) error {
1930 1930
 	if !driverapi.IsValidType(objType) {
1931 1931
 		return fmt.Errorf("invalid object type %v in registering table, %s", objType, tableName)
1932 1932
 	}
... ...
@@ -1941,7 +1921,7 @@ func (n *network) TableEventRegister(tableName string, objType driverapi.ObjectT
1941 1941
 	return nil
1942 1942
 }
1943 1943
 
1944
-func (n *network) UpdateIpamConfig(ipV4Data []driverapi.IPAMData) {
1944
+func (n *Network) UpdateIpamConfig(ipV4Data []driverapi.IPAMData) {
1945 1945
 	ipamV4Config := make([]*IpamConf, len(ipV4Data))
1946 1946
 
1947 1947
 	for i, data := range ipV4Data {
... ...
@@ -1956,16 +1936,16 @@ func (n *network) UpdateIpamConfig(ipV4Data []driverapi.IPAMData) {
1956 1956
 	n.ipamV4Config = ipamV4Config
1957 1957
 }
1958 1958
 
1959
-// Special drivers are ones which do not need to perform any network plumbing
1960
-func (n *network) hasSpecialDriver() bool {
1959
+// Special drivers are ones which do not need to perform any Network plumbing
1960
+func (n *Network) hasSpecialDriver() bool {
1961 1961
 	return n.Type() == "host" || n.Type() == "null"
1962 1962
 }
1963 1963
 
1964
-func (n *network) hasLoadBalancerEndpoint() bool {
1964
+func (n *Network) hasLoadBalancerEndpoint() bool {
1965 1965
 	return len(n.loadBalancerIP) != 0
1966 1966
 }
1967 1967
 
1968
-func (n *network) ResolveName(req string, ipType int) ([]net.IP, bool) {
1968
+func (n *Network) ResolveName(req string, ipType int) ([]net.IP, bool) {
1969 1969
 	var ipv6Miss bool
1970 1970
 
1971 1971
 	c := n.getController()
... ...
@@ -2009,7 +1989,7 @@ func (n *network) ResolveName(req string, ipType int) ([]net.IP, bool) {
2009 2009
 	return nil, ipv6Miss
2010 2010
 }
2011 2011
 
2012
-func (n *network) HandleQueryResp(name string, ip net.IP) {
2012
+func (n *Network) HandleQueryResp(name string, ip net.IP) {
2013 2013
 	networkID := n.ID()
2014 2014
 	c := n.getController()
2015 2015
 	c.mu.Lock()
... ...
@@ -2029,7 +2009,7 @@ func (n *network) HandleQueryResp(name string, ip net.IP) {
2029 2029
 	}
2030 2030
 }
2031 2031
 
2032
-func (n *network) ResolveIP(ip string) string {
2032
+func (n *Network) ResolveIP(ip string) string {
2033 2033
 	networkID := n.ID()
2034 2034
 	c := n.getController()
2035 2035
 	c.mu.Lock()
... ...
@@ -2059,7 +2039,7 @@ func (n *network) ResolveIP(ip string) string {
2059 2059
 	return elem.name + "." + nwName
2060 2060
 }
2061 2061
 
2062
-func (n *network) ResolveService(name string) ([]*net.SRV, []net.IP) {
2062
+func (n *Network) ResolveService(name string) ([]*net.SRV, []net.IP) {
2063 2063
 	c := n.getController()
2064 2064
 
2065 2065
 	srv := []*net.SRV{}
... ...
@@ -2114,36 +2094,33 @@ func (n *network) ResolveService(name string) ([]*net.SRV, []net.IP) {
2114 2114
 	return srv, ip
2115 2115
 }
2116 2116
 
2117
-func (n *network) ExecFunc(f func()) error {
2117
+func (n *Network) ExecFunc(f func()) error {
2118 2118
 	return types.NotImplementedErrorf("ExecFunc not supported by network")
2119 2119
 }
2120 2120
 
2121
-func (n *network) NdotsSet() bool {
2121
+func (n *Network) NdotsSet() bool {
2122 2122
 	return false
2123 2123
 }
2124 2124
 
2125 2125
 // config-only network is looked up by name
2126
-func (c *Controller) getConfigNetwork(name string) (*network, error) {
2127
-	var n Network
2128
-
2129
-	s := func(current Network) bool {
2126
+func (c *Controller) getConfigNetwork(name string) (*Network, error) {
2127
+	var n *Network
2128
+	c.WalkNetworks(func(current *Network) bool {
2130 2129
 		if current.Info().ConfigOnly() && current.Name() == name {
2131 2130
 			n = current
2132 2131
 			return true
2133 2132
 		}
2134 2133
 		return false
2135
-	}
2136
-
2137
-	c.WalkNetworks(s)
2134
+	})
2138 2135
 
2139 2136
 	if n == nil {
2140 2137
 		return nil, types.NotFoundErrorf("configuration network %q not found", name)
2141 2138
 	}
2142 2139
 
2143
-	return n.(*network), nil
2140
+	return n, nil
2144 2141
 }
2145 2142
 
2146
-func (n *network) lbSandboxName() string {
2143
+func (n *Network) lbSandboxName() string {
2147 2144
 	name := "lb-" + n.name
2148 2145
 	if n.ingress {
2149 2146
 		name = n.name + "-sbox"
... ...
@@ -2151,11 +2128,11 @@ func (n *network) lbSandboxName() string {
2151 2151
 	return name
2152 2152
 }
2153 2153
 
2154
-func (n *network) lbEndpointName() string {
2154
+func (n *Network) lbEndpointName() string {
2155 2155
 	return n.name + "-endpoint"
2156 2156
 }
2157 2157
 
2158
-func (n *network) createLoadBalancerSandbox() (retErr error) {
2158
+func (n *Network) createLoadBalancerSandbox() (retErr error) {
2159 2159
 	sandboxName := n.lbSandboxName()
2160 2160
 	// Mark the sandbox to be a load balancer
2161 2161
 	sbOptions := []SandboxOption{OptionLoadBalancer(n.id)}
... ...
@@ -2202,7 +2179,7 @@ func (n *network) createLoadBalancerSandbox() (retErr error) {
2202 2202
 	return sb.EnableService()
2203 2203
 }
2204 2204
 
2205
-func (n *network) deleteLoadBalancerSandbox() error {
2205
+func (n *Network) deleteLoadBalancerSandbox() error {
2206 2206
 	n.mu.Lock()
2207 2207
 	c := n.ctrlr
2208 2208
 	name := n.name
... ...
@@ -6,7 +6,7 @@ import "github.com/docker/docker/libnetwork/ipamapi"
6 6
 
7 7
 // Stub implementations for DNS related functions
8 8
 
9
-func (n *network) startResolver() {
9
+func (n *Network) startResolver() {
10 10
 }
11 11
 
12 12
 func defaultIpamForNetworkType(networkType string) string {
... ...
@@ -28,7 +28,7 @@ func executeInCompartment(compartmentID uint32, x func()) {
28 28
 	x()
29 29
 }
30 30
 
31
-func (n *network) startResolver() {
31
+func (n *Network) startResolver() {
32 32
 	if n.networkType == "ics" {
33 33
 		return
34 34
 	}
... ...
@@ -139,7 +139,7 @@ func TestDNSIPQuery(t *testing.T) {
139 139
 	}
140 140
 
141 141
 	// add service records which are used to resolve names. These are the real targets for the DNS querries
142
-	n.(*network).addSvcRecords("ep1", "name1", "svc1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
142
+	n.addSvcRecords("ep1", "name1", "svc1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
143 143
 
144 144
 	w := new(tstwriter)
145 145
 	// the unit tests right now will focus on non-proxyed DNS requests
... ...
@@ -234,7 +234,7 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
234 234
 			var ep *Endpoint
235 235
 			if err != nil {
236 236
 				log.G(context.TODO()).Errorf("getNetworkFromStore for nid %s failed while trying to build sandbox for cleanup: %v", eps.Nid, err)
237
-				n = &network{id: eps.Nid, ctrlr: c, drvOnce: &sync.Once{}, persist: true}
237
+				n = &Network{id: eps.Nid, ctrlr: c, drvOnce: &sync.Once{}, persist: true}
238 238
 				ep = &Endpoint{id: eps.Eid, network: n, sandboxID: sbs.ID}
239 239
 			} else {
240 240
 				ep, err = n.getEndpointFromStore(eps.Eid)
... ...
@@ -14,7 +14,7 @@ import (
14 14
 	"gotest.tools/v3/skip"
15 15
 )
16 16
 
17
-func getTestEnv(t *testing.T, opts ...[]NetworkOption) (*Controller, []Network) {
17
+func getTestEnv(t *testing.T, opts ...[]NetworkOption) (*Controller, []*Network) {
18 18
 	skip.If(t, runtime.GOOS == "windows", "test only works on linux")
19 19
 
20 20
 	const netType = "bridge"
... ...
@@ -33,7 +33,7 @@ func getTestEnv(t *testing.T, opts ...[]NetworkOption) (*Controller, []Network)
33 33
 		return c, nil
34 34
 	}
35 35
 
36
-	nwList := make([]Network, 0, len(opts))
36
+	nwList := make([]*Network, 0, len(opts))
37 37
 	for i, opt := range opts {
38 38
 		name := "test_nw_" + strconv.Itoa(i)
39 39
 		newOptions := []NetworkOption{
... ...
@@ -31,23 +31,23 @@ func (c *Controller) addEndpointNameResolution(svcName, svcID, nID, eID, contain
31 31
 	}
32 32
 
33 33
 	// Add endpoint IP to special "tasks.svc_name" so that the applications have access to DNS RR.
34
-	n.(*network).addSvcRecords(eID, "tasks."+svcName, serviceID, ip, nil, false, method)
34
+	n.addSvcRecords(eID, "tasks."+svcName, serviceID, ip, nil, false, method)
35 35
 	for _, alias := range serviceAliases {
36
-		n.(*network).addSvcRecords(eID, "tasks."+alias, serviceID, ip, nil, false, method)
36
+		n.addSvcRecords(eID, "tasks."+alias, serviceID, ip, nil, false, method)
37 37
 	}
38 38
 
39 39
 	// Add service name to vip in DNS, if vip is valid. Otherwise resort to DNS RR
40 40
 	if len(vip) == 0 {
41
-		n.(*network).addSvcRecords(eID, svcName, serviceID, ip, nil, false, method)
41
+		n.addSvcRecords(eID, svcName, serviceID, ip, nil, false, method)
42 42
 		for _, alias := range serviceAliases {
43
-			n.(*network).addSvcRecords(eID, alias, serviceID, ip, nil, false, method)
43
+			n.addSvcRecords(eID, alias, serviceID, ip, nil, false, method)
44 44
 		}
45 45
 	}
46 46
 
47 47
 	if addService && len(vip) != 0 {
48
-		n.(*network).addSvcRecords(eID, svcName, serviceID, vip, nil, false, method)
48
+		n.addSvcRecords(eID, svcName, serviceID, vip, nil, false, method)
49 49
 		for _, alias := range serviceAliases {
50
-			n.(*network).addSvcRecords(eID, alias, serviceID, vip, nil, false, method)
50
+			n.addSvcRecords(eID, alias, serviceID, vip, nil, false, method)
51 51
 		}
52 52
 	}
53 53
 
... ...
@@ -62,11 +62,11 @@ func (c *Controller) addContainerNameResolution(nID, eID, containerName string,
62 62
 	log.G(context.TODO()).Debugf("addContainerNameResolution %s %s", eID, containerName)
63 63
 
64 64
 	// Add resolution for container name
65
-	n.(*network).addSvcRecords(eID, containerName, eID, ip, nil, true, method)
65
+	n.addSvcRecords(eID, containerName, eID, ip, nil, true, method)
66 66
 
67 67
 	// Add resolution for taskaliases
68 68
 	for _, alias := range taskAliases {
69
-		n.(*network).addSvcRecords(eID, alias, eID, ip, nil, false, method)
69
+		n.addSvcRecords(eID, alias, eID, ip, nil, false, method)
70 70
 	}
71 71
 
72 72
 	return nil
... ...
@@ -93,25 +93,25 @@ func (c *Controller) deleteEndpointNameResolution(svcName, svcID, nID, eID, cont
93 93
 
94 94
 	// Delete the special "tasks.svc_name" backend record.
95 95
 	if !multipleEntries {
96
-		n.(*network).deleteSvcRecords(eID, "tasks."+svcName, serviceID, ip, nil, false, method)
96
+		n.deleteSvcRecords(eID, "tasks."+svcName, serviceID, ip, nil, false, method)
97 97
 		for _, alias := range serviceAliases {
98
-			n.(*network).deleteSvcRecords(eID, "tasks."+alias, serviceID, ip, nil, false, method)
98
+			n.deleteSvcRecords(eID, "tasks."+alias, serviceID, ip, nil, false, method)
99 99
 		}
100 100
 	}
101 101
 
102 102
 	// If we are doing DNS RR delete the endpoint IP from DNS record right away.
103 103
 	if !multipleEntries && len(vip) == 0 {
104
-		n.(*network).deleteSvcRecords(eID, svcName, serviceID, ip, nil, false, method)
104
+		n.deleteSvcRecords(eID, svcName, serviceID, ip, nil, false, method)
105 105
 		for _, alias := range serviceAliases {
106
-			n.(*network).deleteSvcRecords(eID, alias, serviceID, ip, nil, false, method)
106
+			n.deleteSvcRecords(eID, alias, serviceID, ip, nil, false, method)
107 107
 		}
108 108
 	}
109 109
 
110 110
 	// Remove the DNS record for VIP only if we are removing the service
111 111
 	if rmService && len(vip) != 0 && !multipleEntries {
112
-		n.(*network).deleteSvcRecords(eID, svcName, serviceID, vip, nil, false, method)
112
+		n.deleteSvcRecords(eID, svcName, serviceID, vip, nil, false, method)
113 113
 		for _, alias := range serviceAliases {
114
-			n.(*network).deleteSvcRecords(eID, alias, serviceID, vip, nil, false, method)
114
+			n.deleteSvcRecords(eID, alias, serviceID, vip, nil, false, method)
115 115
 		}
116 116
 	}
117 117
 
... ...
@@ -126,11 +126,11 @@ func (c *Controller) delContainerNameResolution(nID, eID, containerName string,
126 126
 	log.G(context.TODO()).Debugf("delContainerNameResolution %s %s", eID, containerName)
127 127
 
128 128
 	// Delete resolution for container name
129
-	n.(*network).deleteSvcRecords(eID, containerName, eID, ip, nil, true, method)
129
+	n.deleteSvcRecords(eID, containerName, eID, ip, nil, true, method)
130 130
 
131 131
 	// Delete resolution for taskaliases
132 132
 	for _, alias := range taskAliases {
133
-		n.(*network).deleteSvcRecords(eID, alias, eID, ip, nil, true, method)
133
+		n.deleteSvcRecords(eID, alias, eID, ip, nil, true, method)
134 134
 	}
135 135
 
136 136
 	return nil
... ...
@@ -299,7 +299,7 @@ func (c *Controller) addServiceBinding(svcName, svcID, nID, eID, containerName s
299 299
 	}
300 300
 
301 301
 	// Add loadbalancer service and backend to the network
302
-	n.(*network).addLBBackend(ip, lb)
302
+	n.addLBBackend(ip, lb)
303 303
 
304 304
 	// Add the appropriate name resolutions
305 305
 	if err := c.addEndpointNameResolution(svcName, svcID, nID, eID, containerName, vip, serviceAliases, taskAliases, ip, addService, "addServiceBinding"); err != nil {
... ...
@@ -382,7 +382,7 @@ func (c *Controller) rmServiceBinding(svcName, svcID, nID, eID, containerName st
382 382
 		// removing the network from the store or dataplane.
383 383
 		n, err := c.NetworkByID(nID)
384 384
 		if err == nil {
385
-			n.(*network).rmLBBackend(ip, lb, rmService, fullRemove)
385
+			n.rmLBBackend(ip, lb, rmService, fullRemove)
386 386
 		}
387 387
 	}
388 388
 
... ...
@@ -20,7 +20,7 @@ func TestCleanupServiceDiscovery(t *testing.T) {
20 20
 	assert.NilError(t, err)
21 21
 	defer c.Stop()
22 22
 
23
-	cleanup := func(n Network) {
23
+	cleanup := func(n *Network) {
24 24
 		if err := n.Delete(); err != nil {
25 25
 			t.Error(err)
26 26
 		}
... ...
@@ -33,11 +33,11 @@ func TestCleanupServiceDiscovery(t *testing.T) {
33 33
 	assert.NilError(t, err)
34 34
 	defer cleanup(n2)
35 35
 
36
-	n1.(*network).addSvcRecords("N1ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
37
-	n1.(*network).addSvcRecords("N2ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.2"), net.IP{}, true, "test")
36
+	n1.addSvcRecords("N1ep1", "service_test", "serviceID1", net.ParseIP("192.168.0.1"), net.IP{}, true, "test")
37
+	n1.addSvcRecords("N2ep2", "service_test", "serviceID2", net.ParseIP("192.168.0.2"), net.IP{}, true, "test")
38 38
 
39
-	n2.(*network).addSvcRecords("N2ep1", "service_test", "serviceID1", net.ParseIP("192.168.1.1"), net.IP{}, true, "test")
40
-	n2.(*network).addSvcRecords("N2ep2", "service_test", "serviceID2", net.ParseIP("192.168.1.2"), net.IP{}, true, "test")
39
+	n2.addSvcRecords("N2ep1", "service_test", "serviceID1", net.ParseIP("192.168.1.1"), net.IP{}, true, "test")
40
+	n2.addSvcRecords("N2ep2", "service_test", "serviceID2", net.ParseIP("192.168.1.2"), net.IP{}, true, "test")
41 41
 
42 42
 	if len(c.svcRecords) != 2 {
43 43
 		t.Fatalf("Service record not added correctly:%v", c.svcRecords)
... ...
@@ -38,7 +38,7 @@ func (sb *Sandbox) populateLoadBalancers(ep *Endpoint) {
38 38
 	}
39 39
 }
40 40
 
41
-func (n *network) findLBEndpointSandbox() (*Endpoint, *Sandbox, error) {
41
+func (n *Network) findLBEndpointSandbox() (*Endpoint, *Sandbox, error) {
42 42
 	// TODO: get endpoint from store?  See EndpointInfo()
43 43
 	var ep *Endpoint
44 44
 	// Find this node's LB sandbox endpoint:  there should be exactly one
... ...
@@ -79,7 +79,7 @@ func findIfaceDstName(sb *Sandbox, ep *Endpoint) string {
79 79
 
80 80
 // Add loadbalancer backend to the loadbalncer sandbox for the network.
81 81
 // If needed add the service as well.
82
-func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
82
+func (n *Network) addLBBackend(ip net.IP, lb *loadBalancer) {
83 83
 	if len(lb.vip) == 0 {
84 84
 		return
85 85
 	}
... ...
@@ -168,7 +168,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
168 168
 // network. If 'rmService' is true, then remove the service entry as well.
169 169
 // If 'fullRemove' is true then completely remove the entry, otherwise
170 170
 // just deweight it for now.
171
-func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullRemove bool) {
171
+func (n *Network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullRemove bool) {
172 172
 	if len(lb.vip) == 0 {
173 173
 		return
174 174
 	}
... ...
@@ -15,7 +15,7 @@ type policyLists struct {
15 15
 
16 16
 var lbPolicylistMap = make(map[*loadBalancer]*policyLists)
17 17
 
18
-func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
18
+func (n *Network) addLBBackend(ip net.IP, lb *loadBalancer) {
19 19
 	if len(lb.vip) == 0 {
20 20
 		return
21 21
 	}
... ...
@@ -117,7 +117,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
117 117
 	}
118 118
 }
119 119
 
120
-func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullRemove bool) {
120
+func (n *Network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullRemove bool) {
121 121
 	if len(lb.vip) == 0 {
122 122
 		return
123 123
 	}
... ...
@@ -46,7 +46,7 @@ func (c *Controller) getStore() datastore.DataStore {
46 46
 	return c.store
47 47
 }
48 48
 
49
-func (c *Controller) getNetworkFromStore(nid string) (*network, error) {
49
+func (c *Controller) getNetworkFromStore(nid string) (*Network, error) {
50 50
 	for _, n := range c.getNetworksFromStore() {
51 51
 		if n.id == nid {
52 52
 			return n, nil
... ...
@@ -55,8 +55,8 @@ func (c *Controller) getNetworkFromStore(nid string) (*network, error) {
55 55
 	return nil, ErrNoSuchNetwork(nid)
56 56
 }
57 57
 
58
-func (c *Controller) getNetworks() ([]*network, error) {
59
-	var nl []*network
58
+func (c *Controller) getNetworks() ([]*Network, error) {
59
+	var nl []*Network
60 60
 
61 61
 	store := c.getStore()
62 62
 	if store == nil {
... ...
@@ -64,13 +64,13 @@ func (c *Controller) getNetworks() ([]*network, error) {
64 64
 	}
65 65
 
66 66
 	kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix),
67
-		&network{ctrlr: c})
67
+		&Network{ctrlr: c})
68 68
 	if err != nil && err != datastore.ErrKeyNotFound {
69 69
 		return nil, fmt.Errorf("failed to get networks: %w", err)
70 70
 	}
71 71
 
72 72
 	for _, kvo := range kvol {
73
-		n := kvo.(*network)
73
+		n := kvo.(*Network)
74 74
 		n.ctrlr = c
75 75
 
76 76
 		ec := &endpointCnt{n: n}
... ...
@@ -90,11 +90,11 @@ func (c *Controller) getNetworks() ([]*network, error) {
90 90
 	return nl, nil
91 91
 }
92 92
 
93
-func (c *Controller) getNetworksFromStore() []*network { // FIXME: unify with c.getNetworks()
94
-	var nl []*network
93
+func (c *Controller) getNetworksFromStore() []*Network { // FIXME: unify with c.getNetworks()
94
+	var nl []*Network
95 95
 
96 96
 	store := c.getStore()
97
-	kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix), &network{ctrlr: c})
97
+	kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix), &Network{ctrlr: c})
98 98
 	if err != nil {
99 99
 		if err != datastore.ErrKeyNotFound {
100 100
 			log.G(context.TODO()).Debugf("failed to get networks from store: %v", err)
... ...
@@ -108,7 +108,7 @@ func (c *Controller) getNetworksFromStore() []*network { // FIXME: unify with c.
108 108
 	}
109 109
 
110 110
 	for _, kvo := range kvol {
111
-		n := kvo.(*network)
111
+		n := kvo.(*Network)
112 112
 		n.mu.Lock()
113 113
 		n.ctrlr = c
114 114
 		ec := &endpointCnt{n: n}
... ...
@@ -128,7 +128,7 @@ func (c *Controller) getNetworksFromStore() []*network { // FIXME: unify with c.
128 128
 	return nl
129 129
 }
130 130
 
131
-func (n *network) getEndpointFromStore(eid string) (*Endpoint, error) {
131
+func (n *Network) getEndpointFromStore(eid string) (*Endpoint, error) {
132 132
 	store := n.ctrlr.getStore()
133 133
 	ep := &Endpoint{id: eid, network: n}
134 134
 	err := store.GetObject(datastore.Key(ep.Key()...), ep)
... ...
@@ -138,7 +138,7 @@ func (n *network) getEndpointFromStore(eid string) (*Endpoint, error) {
138 138
 	return ep, nil
139 139
 }
140 140
 
141
-func (n *network) getEndpointsFromStore() ([]*Endpoint, error) {
141
+func (n *Network) getEndpointsFromStore() ([]*Endpoint, error) {
142 142
 	var epl []*Endpoint
143 143
 
144 144
 	tmp := Endpoint{network: n}
... ...
@@ -332,8 +332,8 @@ func (c *Controller) networkCleanup() {
332 332
 	}
333 333
 }
334 334
 
335
-var populateSpecial NetworkWalker = func(nw Network) bool {
336
-	if n := nw.(*network); n.hasSpecialDriver() && !n.ConfigOnly() {
335
+var populateSpecial NetworkWalker = func(nw *Network) bool {
336
+	if n := nw; n.hasSpecialDriver() && !n.ConfigOnly() {
337 337
 		if err := n.getController().addNetwork(n); err != nil {
338 338
 			log.G(context.TODO()).Warnf("Failed to populate network %q with driver %q", nw.Name(), nw.Type())
339 339
 		}