diff --git a/libnetwork/drivers/overlay/peerdb.go b/libnetwork/drivers/overlay/peerdb.go index f5792f96e8..e0cad2c1a2 100644 --- a/libnetwork/drivers/overlay/peerdb.go +++ b/libnetwork/drivers/overlay/peerdb.go @@ -322,7 +322,7 @@ func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask } // Add neighbor entry for the peer IP - if err := sbox.AddNeighbor(peerIP, peerMac, l3Miss, sbox.NeighborOptions().LinkName(s.vxlanName)); err != nil { + if err := sbox.AddNeighbor(peerIP, peerMac, l3Miss, osl.WithLinkName(s.vxlanName)); err != nil { if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 1 { // We are in the transient case so only the first configuration is programmed into the kernel // Upon deletion if the active configuration is deleted the next one from the database will be restored @@ -333,8 +333,7 @@ func (d *driver) peerAddOp(nid, eid string, peerIP net.IP, peerIPMask net.IPMask } // Add fdb entry to the bridge for the peer mac - if err := sbox.AddNeighbor(vtep, peerMac, l2Miss, sbox.NeighborOptions().LinkName(s.vxlanName), - sbox.NeighborOptions().Family(syscall.AF_BRIDGE)); err != nil { + if err := sbox.AddNeighbor(vtep, peerMac, l2Miss, osl.WithLinkName(s.vxlanName), osl.WithFamily(syscall.AF_BRIDGE)); err != nil { return fmt.Errorf("could not add fdb entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err) } diff --git a/libnetwork/osl/namespace_linux.go b/libnetwork/osl/namespace_linux.go index 5c3714a62d..372e8fe35d 100644 --- a/libnetwork/osl/namespace_linux.go +++ b/libnetwork/osl/namespace_linux.go @@ -348,11 +348,6 @@ func (n *networkNamespace) InterfaceOptions() IfaceOptionSetter { return n } -// NeighborOptions returns an interface with methods to set neighbor options. -func (n *networkNamespace) NeighborOptions() NeighborOptionSetter { - return n -} - func (n *networkNamespace) loopbackUp() error { iface, err := n.nlHandle.LinkByName("lo") if err != nil { diff --git a/libnetwork/osl/options_linux.go b/libnetwork/osl/options_linux.go index 2250be1c09..db0f35f370 100644 --- a/libnetwork/osl/options_linux.go +++ b/libnetwork/osl/options_linux.go @@ -10,17 +10,15 @@ func (nh *neigh) processNeighOptions(options ...NeighOption) { } } -// LinkName returns an option setter to set the srcName of the link that should -// be used in the neighbor entry -func (n *networkNamespace) LinkName(name string) NeighOption { +// WithLinkName sets the srcName of the link to use in the neighbor entry. +func WithLinkName(name string) NeighOption { return func(nh *neigh) { nh.linkName = name } } -// Family returns an option setter to set the address family for the neighbor -// entry. eg. AF_BRIDGE -func (n *networkNamespace) Family(family int) NeighOption { +// WithFamily sets the address-family for the neighbor entry. e.g. [syscall.AF_BRIDGE]. +func WithFamily(family int) NeighOption { return func(nh *neigh) { nh.family = family } diff --git a/libnetwork/osl/sandbox.go b/libnetwork/osl/sandbox.go index cbba2db4b6..b29acef668 100644 --- a/libnetwork/osl/sandbox.go +++ b/libnetwork/osl/sandbox.go @@ -77,9 +77,6 @@ type Sandbox interface { // DeleteNeighbor deletes neighbor entry from the sandbox. DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDelete bool) error - // NeighborOptions returns an interface with methods to set neighbor options. - NeighborOptions() NeighborOptionSetter - // InterfaceOptions an interface with methods to set interface options. InterfaceOptions() IfaceOptionSetter @@ -98,17 +95,6 @@ type Sandbox interface { Info } -// NeighborOptionSetter interface defines the option setter methods for interface options -type NeighborOptionSetter interface { - // LinkName returns an option setter to set the srcName of the link that should - // be used in the neighbor entry - LinkName(string) NeighOption - - // Family returns an option setter to set the address family for the neighbor - // entry. eg. AF_BRIDGE - Family(int) NeighOption -} - // IfaceOptionSetter interface defines the option setter methods for interface options. type IfaceOptionSetter interface { // Bridge returns an option setter to set if the interface is a bridge.