summaryrefslogtreecommitdiff
path: root/libnetwork/cmd
diff options
context:
space:
mode:
authorAlbin Kerouanton <albinker@gmail.com>2023-02-10 10:07:33 +0100
committerAlbin Kerouanton <albinker@gmail.com>2023-04-06 19:33:04 +0200
commit00037cd44bdf4059736b6281781d1fe594dcb95e (patch)
tree9b2169813d87ac512e1946f04b39a19d3017c0a6 /libnetwork/cmd
parent58c027ac8ba19a3fa339c65274ea6704ccbec977 (diff)
downloaddocker-00037cd44bdf4059736b6281781d1fe594dcb95e.tar.gz
libnetwork: remove ovrouter cmd
This command was useful when overlay networks based on external KV store was developed but is unused nowadays. As the last reference to OverlayBindInterface and OverlayNeighborIP netlabels are in the ovrouter cmd, they're removed too. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Diffstat (limited to 'libnetwork/cmd')
-rw-r--r--libnetwork/cmd/ovrouter/ovrouter.go171
1 files changed, 0 insertions, 171 deletions
diff --git a/libnetwork/cmd/ovrouter/ovrouter.go b/libnetwork/cmd/ovrouter/ovrouter.go
deleted file mode 100644
index faad115a4b..0000000000
--- a/libnetwork/cmd/ovrouter/ovrouter.go
+++ /dev/null
@@ -1,171 +0,0 @@
-//go:build linux
-// +build linux
-
-package main
-
-import (
- "fmt"
- "net"
- "os"
- "os/signal"
-
- "github.com/docker/docker/libnetwork/driverapi"
- "github.com/docker/docker/libnetwork/drivers/overlay"
- "github.com/docker/docker/libnetwork/netlabel"
- "github.com/docker/docker/libnetwork/types"
- "github.com/docker/docker/pkg/reexec"
- "github.com/vishvananda/netlink"
-)
-
-type router struct {
- d driverapi.Driver
-}
-
-type endpoint struct {
- addr *net.IPNet
- mac net.HardwareAddr
- name string
-}
-
-func (r *router) RegisterDriver(name string, driver driverapi.Driver, c driverapi.Capability) error {
- r.d = driver
- return nil
-}
-
-func (ep *endpoint) Interface() driverapi.InterfaceInfo {
- return nil
-}
-
-func (ep *endpoint) SetMacAddress(mac net.HardwareAddr) error {
- if ep.mac != nil {
- return types.ForbiddenErrorf("endpoint interface MAC address present (%s). Cannot be modified with %s.", ep.mac, mac)
- }
- if mac == nil {
- return types.BadRequestErrorf("tried to set nil MAC address to endpoint interface")
- }
- ep.mac = types.GetMacCopy(mac)
- return nil
-}
-
-func (ep *endpoint) SetIPAddress(address *net.IPNet) error {
- if address.IP == nil {
- return types.BadRequestErrorf("tried to set nil IP address to endpoint interface")
- }
- if address.IP.To4() == nil {
- return types.NotImplementedErrorf("do not support ipv6 yet")
- }
- if ep.addr != nil {
- return types.ForbiddenErrorf("endpoint interface IP present (%s). Cannot be modified with %s.", ep.addr, address)
- }
- ep.addr = types.GetIPNetCopy(address)
- return nil
-}
-
-func (ep *endpoint) MacAddress() net.HardwareAddr {
- return types.GetMacCopy(ep.mac)
-}
-
-func (ep *endpoint) Address() *net.IPNet {
- return types.GetIPNetCopy(ep.addr)
-}
-
-func (ep *endpoint) AddressIPv6() *net.IPNet {
- return nil
-}
-
-func (ep *endpoint) InterfaceName() driverapi.InterfaceNameInfo {
- return ep
-}
-
-func (ep *endpoint) SetNames(srcName, dstPrefix string) error {
- ep.name = srcName
- return nil
-}
-
-func (ep *endpoint) SetGateway(net.IP) error {
- return nil
-}
-
-func (ep *endpoint) SetGatewayIPv6(net.IP) error {
- return nil
-}
-
-func (ep *endpoint) AddStaticRoute(destination *net.IPNet, routeType int,
- nextHop net.IP) error {
- return nil
-}
-
-func (ep *endpoint) AddTableEntry(tableName string, key string, value []byte) error {
- return nil
-}
-
-func (ep *endpoint) DisableGatewayService() {}
-
-func main() {
- if reexec.Init() {
- return
- }
-
- opt := make(map[string]interface{})
- if len(os.Args) > 1 {
- opt[netlabel.OverlayBindInterface] = os.Args[1]
- }
- if len(os.Args) > 2 {
- opt[netlabel.OverlayNeighborIP] = os.Args[2]
- }
- if len(os.Args) > 3 {
- opt[netlabel.GlobalKVProvider] = os.Args[3]
- }
- if len(os.Args) > 4 {
- opt[netlabel.GlobalKVProviderURL] = os.Args[4]
- }
-
- r := &router{}
- if err := overlay.Register(r, opt); err != nil {
- fmt.Printf("Failed to initialize overlay driver: %v\n", err)
- os.Exit(1)
- }
-
- if err := r.d.CreateNetwork("testnetwork",
- map[string]interface{}{}, nil, nil, nil); err != nil {
- fmt.Printf("Failed to create network in the driver: %v\n", err)
- os.Exit(1)
- }
-
- ep := &endpoint{}
- if err := r.d.CreateEndpoint("testnetwork", "testep",
- ep, map[string]interface{}{}); err != nil {
- fmt.Printf("Failed to create endpoint in the driver: %v\n", err)
- os.Exit(1)
- }
-
- if err := r.d.Join("testnetwork", "testep",
- "", ep, map[string]interface{}{}); err != nil {
- fmt.Printf("Failed to join an endpoint in the driver: %v\n", err)
- os.Exit(1)
- }
-
- link, err := netlink.LinkByName(ep.name)
- if err != nil {
- fmt.Printf("Failed to find the container interface with name %s: %v\n",
- ep.name, err)
- os.Exit(1)
- }
-
- ipAddr := &netlink.Addr{IPNet: ep.addr, Label: ""}
- if err := netlink.AddrAdd(link, ipAddr); err != nil {
- fmt.Printf("Failed to add address to the interface: %v\n", err)
- os.Exit(1)
- }
-
- sigCh := make(chan os.Signal, 1)
- signal.Notify(sigCh, os.Interrupt)
-
- for range sigCh {
- if err := r.d.Leave("testnetwork", "testep"); err != nil {
- fmt.Printf("Error leaving: %v", err)
- }
- overlay.Fini(r.d)
- os.Exit(0)
- }
-}