summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiaan van Stijn <thaJeztah@users.noreply.github.com>2023-05-04 17:48:15 +0200
committerGitHub <noreply@github.com>2023-05-04 17:48:15 +0200
commit7d7749ee472d3884f73cdd9be4547d5134ba2d7b (patch)
treee59138da02224c70ee0d06f2b3ed3f2c5e78fcc6
parent5c052e6c04a5440abd0cde450b831cb93cf2a89c (diff)
parent8142051a3b244f514ba05bc6b9a93efe45c0087f (diff)
downloaddocker-7d7749ee472d3884f73cdd9be4547d5134ba2d7b.tar.gz
Merge pull request #45429 from thaJeztah/libnetwork_cleanup_buildtags_and_stubs
libnetwork: remove redundant init(), remove dead code, and fix stubs / build-tags
-rw-r--r--libnetwork/drivers/overlay/overlayutils/utils.go8
-rw-r--r--libnetwork/drivers_unsupported.go8
-rw-r--r--libnetwork/osl/interface_freebsd.go4
-rw-r--r--libnetwork/osl/interface_linux.go3
-rw-r--r--libnetwork/osl/interface_unsupported.go6
-rw-r--r--libnetwork/osl/interface_windows.go4
-rw-r--r--libnetwork/osl/namespace_linux.go12
-rw-r--r--libnetwork/osl/neigh_freebsd.go4
-rw-r--r--libnetwork/osl/neigh_linux.go3
-rw-r--r--libnetwork/osl/neigh_unsupported.go6
-rw-r--r--libnetwork/osl/neigh_windows.go4
-rw-r--r--libnetwork/osl/sandbox.go6
-rw-r--r--libnetwork/service_unsupported.go17
13 files changed, 42 insertions, 43 deletions
diff --git a/libnetwork/drivers/overlay/overlayutils/utils.go b/libnetwork/drivers/overlay/overlayutils/utils.go
index 73136e8e2a..2d7674a535 100644
--- a/libnetwork/drivers/overlay/overlayutils/utils.go
+++ b/libnetwork/drivers/overlay/overlayutils/utils.go
@@ -8,14 +8,10 @@ import (
var (
mutex sync.RWMutex
- vxlanUDPPort uint32
+ vxlanUDPPort = defaultVXLANUDPPort
)
-const defaultVXLANUDPPort = 4789
-
-func init() {
- vxlanUDPPort = defaultVXLANUDPPort
-}
+const defaultVXLANUDPPort uint32 = 4789
// ConfigVXLANUDPPort configures the VXLAN UDP port (data path port) number.
// If no port is set, the default (4789) is returned. Valid port numbers are
diff --git a/libnetwork/drivers_unsupported.go b/libnetwork/drivers_unsupported.go
new file mode 100644
index 0000000000..fd71a1bbca
--- /dev/null
+++ b/libnetwork/drivers_unsupported.go
@@ -0,0 +1,8 @@
+//go:build !freebsd && !linux && !windows
+// +build !freebsd,!linux,!windows
+
+package libnetwork
+
+func getInitializers() []initializer {
+ return nil
+}
diff --git a/libnetwork/osl/interface_freebsd.go b/libnetwork/osl/interface_freebsd.go
deleted file mode 100644
index 9c0141fd9b..0000000000
--- a/libnetwork/osl/interface_freebsd.go
+++ /dev/null
@@ -1,4 +0,0 @@
-package osl
-
-// IfaceOption is a function option type to set interface options
-type IfaceOption func()
diff --git a/libnetwork/osl/interface_linux.go b/libnetwork/osl/interface_linux.go
index 561e7fc7e0..ee1b4ab842 100644
--- a/libnetwork/osl/interface_linux.go
+++ b/libnetwork/osl/interface_linux.go
@@ -14,9 +14,6 @@ import (
"github.com/vishvananda/netns"
)
-// IfaceOption is a function option type to set interface options
-type IfaceOption func(i *nwIface)
-
type nwIface struct {
srcName string
dstName string
diff --git a/libnetwork/osl/interface_unsupported.go b/libnetwork/osl/interface_unsupported.go
new file mode 100644
index 0000000000..55a6ae73f1
--- /dev/null
+++ b/libnetwork/osl/interface_unsupported.go
@@ -0,0 +1,6 @@
+//go:build !linux
+// +build !linux
+
+package osl
+
+type nwIface struct{}
diff --git a/libnetwork/osl/interface_windows.go b/libnetwork/osl/interface_windows.go
deleted file mode 100644
index 9c0141fd9b..0000000000
--- a/libnetwork/osl/interface_windows.go
+++ /dev/null
@@ -1,4 +0,0 @@
-package osl
-
-// IfaceOption is a function option type to set interface options
-type IfaceOption func()
diff --git a/libnetwork/osl/namespace_linux.go b/libnetwork/osl/namespace_linux.go
index 3ad9bb9d26..6da6f95b01 100644
--- a/libnetwork/osl/namespace_linux.go
+++ b/libnetwork/osl/namespace_linux.go
@@ -600,29 +600,29 @@ func (n *networkNamespace) checkLoV6() {
}
func setIPv6(nspath, iface string, enable bool) error {
- origns, err := netns.Get()
+ origNS, err := netns.Get()
if err != nil {
return fmt.Errorf("failed to get current network namespace: %w", err)
}
- defer origns.Close()
+ defer origNS.Close()
- ns, err := netns.GetFromPath(nspath)
+ namespace, err := netns.GetFromPath(nspath)
if err != nil {
return fmt.Errorf("failed get network namespace %q: %w", nspath, err)
}
- defer ns.Close()
+ defer namespace.Close()
errCh := make(chan error, 1)
go func() {
defer close(errCh)
runtime.LockOSThread()
- if err = netns.Set(ns); err != nil {
+ if err = netns.Set(namespace); err != nil {
errCh <- fmt.Errorf("setting into container netns %q failed: %w", nspath, err)
return
}
defer func() {
- if err := netns.Set(origns); err != nil {
+ if err := netns.Set(origNS); err != nil {
logrus.WithError(err).Error("libnetwork: restoring thread network namespace failed")
// The error is only fatal for the current thread. Keep this
// goroutine locked to the thread to make the runtime replace it
diff --git a/libnetwork/osl/neigh_freebsd.go b/libnetwork/osl/neigh_freebsd.go
deleted file mode 100644
index 280f006396..0000000000
--- a/libnetwork/osl/neigh_freebsd.go
+++ /dev/null
@@ -1,4 +0,0 @@
-package osl
-
-// NeighOption is a function option type to set neighbor options
-type NeighOption func()
diff --git a/libnetwork/osl/neigh_linux.go b/libnetwork/osl/neigh_linux.go
index 7105bf6dde..e46b12a89f 100644
--- a/libnetwork/osl/neigh_linux.go
+++ b/libnetwork/osl/neigh_linux.go
@@ -20,9 +20,6 @@ func (n NeighborSearchError) Error() string {
return fmt.Sprintf("Search neighbor failed for IP %v, mac %v, present in db:%t", n.ip, n.mac, n.present)
}
-// NeighOption is a function option type to set interface options
-type NeighOption func(nh *neigh)
-
type neigh struct {
dstIP net.IP
dstMac net.HardwareAddr
diff --git a/libnetwork/osl/neigh_unsupported.go b/libnetwork/osl/neigh_unsupported.go
new file mode 100644
index 0000000000..6d2f285698
--- /dev/null
+++ b/libnetwork/osl/neigh_unsupported.go
@@ -0,0 +1,6 @@
+//go:build !linux
+// +build !linux
+
+package osl
+
+type neigh struct{}
diff --git a/libnetwork/osl/neigh_windows.go b/libnetwork/osl/neigh_windows.go
deleted file mode 100644
index 280f006396..0000000000
--- a/libnetwork/osl/neigh_windows.go
+++ /dev/null
@@ -1,4 +0,0 @@
-package osl
-
-// NeighOption is a function option type to set neighbor options
-type NeighOption func()
diff --git a/libnetwork/osl/sandbox.go b/libnetwork/osl/sandbox.go
index 52117a4c05..84833167e6 100644
--- a/libnetwork/osl/sandbox.go
+++ b/libnetwork/osl/sandbox.go
@@ -17,6 +17,12 @@ const (
SandboxTypeLoadBalancer = iota
)
+// IfaceOption is a function option type to set interface options.
+type IfaceOption func(i *nwIface)
+
+// NeighOption is a function option type to set neighbor options.
+type NeighOption func(nh *neigh)
+
// Sandbox represents a network sandbox, identified by a specific key. It
// holds a list of Interfaces, routes etc, and more can be added dynamically.
type Sandbox interface {
diff --git a/libnetwork/service_unsupported.go b/libnetwork/service_unsupported.go
index 104b6ea91c..2fcfa99a90 100644
--- a/libnetwork/service_unsupported.go
+++ b/libnetwork/service_unsupported.go
@@ -4,23 +4,22 @@
package libnetwork
import (
- "fmt"
+ "errors"
"net"
)
-func (c *Controller) cleanupServiceBindings(nid string) {
-}
+func (c *Controller) cleanupServiceDiscovery(cleanupNID string) {}
+
+func (c *Controller) cleanupServiceBindings(nid string) {}
func (c *Controller) addServiceBinding(name, sid, nid, eid string, vip net.IP, ingressPorts []*PortConfig, aliases []string, ip net.IP) error {
- return fmt.Errorf("not supported")
+ return errors.New("not supported")
}
func (c *Controller) rmServiceBinding(name, sid, nid, eid string, vip net.IP, ingressPorts []*PortConfig, aliases []string, ip net.IP) error {
- return fmt.Errorf("not supported")
+ return errors.New("not supported")
}
-func (sb *sandbox) populateLoadBalancers(ep *endpoint) {
-}
+func (sb *Sandbox) populateLoadBalancers(*Endpoint) {}
-func arrangeIngressFilterRule() {
-}
+func arrangeIngressFilterRule() {}