libn/d/overlay: rename the subnet setup functions
The driver creates one network sandbox for each overlay network, and initSubnetSandbox and setupSubnetSandbox add a subnet's bridge and VXLAN link to it. Their names, and the "subnet sandbox join failed" error, read as though each subnet had a sandbox of its own. Rename them to initSubnet and setupSubnet, rename the subnet's sboxInit flag to initDone, and report the error as a failure to join the network sandbox for the subnet. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
1 parent
06833726c4
commit
c24df862bd
5 files changed
+20
-20
No files matched your search
@@ -407,7 +407,7 @@ func (d *driver) restoreNetworkEncryptionFirewall(ctx context.Context, nid strin
|
||||
}
|
||||
|
||||
for _, s := range n.subnets {
|
||||
if !s.sboxInit {
|
||||
if !s.initDone {
|
||||
continue
|
||||
}
|
||||
// Unlike programOverlayEncryptionFirewall, do not roll back the
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestProgramMangleLifecycle(t *testing.T) {
|
||||
const vniA, vniB = 4096, 4097
|
||||
|
||||
// First encrypted network on the node: the marking rule is programmed
|
||||
// when the subnet sandbox is set up, ...
|
||||
// when the subnet is set up in the network sandbox, ...
|
||||
assert.NilError(t, d.programMangle(vniA, true))
|
||||
// ... and the mark-stripping rule when the first peer is discovered.
|
||||
assert.NilError(t, d.programMangleMarkSpoofProtection(true))
|
||||
@@ -201,15 +201,15 @@ func TestRestoreIptablesEncryptionRulesOnFirewalldReload(t *testing.T) {
|
||||
skip.If(t, nftables.Enabled(), "test is for the iptables backend")
|
||||
defer netnsutils.SetupTestOSContext(t)()
|
||||
|
||||
const encVNI, clearVNI, noSboxVNI = 4097, 4098, 4099
|
||||
const encVNI, clearVNI, notSetUpVNI = 4097, 4098, 4099
|
||||
d := newDriver(t.TempDir())
|
||||
d.advertiseAddress = netip.MustParseAddr("192.0.2.1")
|
||||
d.networks["enc"] = &network{id: "enc", driver: d, secure: true, subnets: []*subnet{
|
||||
{vni: encVNI, sboxInit: true},
|
||||
// A subnet whose sandbox has not been set up.
|
||||
{vni: noSboxVNI},
|
||||
{vni: encVNI, initDone: true},
|
||||
// A subnet which has not been set up.
|
||||
{vni: notSetUpVNI},
|
||||
}}
|
||||
d.networks["clear"] = &network{id: "clear", driver: d, subnets: []*subnet{{vni: clearVNI, sboxInit: true}}}
|
||||
d.networks["clear"] = &network{id: "clear", driver: d, subnets: []*subnet{{vni: clearVNI, initDone: true}}}
|
||||
|
||||
ipt := iptables.GetIptable(iptables.IPv4)
|
||||
type ruleset struct{ MangleOutput, FilterInput []string }
|
||||
@@ -227,8 +227,8 @@ func TestRestoreIptablesEncryptionRulesOnFirewalldReload(t *testing.T) {
|
||||
}
|
||||
noRules := dump()
|
||||
|
||||
// Install the rules as initSubnetSandbox does for the subnet of the
|
||||
// secure network with a sandbox.
|
||||
// Install the rules as initSubnet does for the subnet of the
|
||||
// secure network which has been set up.
|
||||
// Install and remove the rules for the other network's VNI, as for a
|
||||
// deleted secure network whose VNI was reassigned.
|
||||
ctx := t.Context()
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
type networkTable map[string]*network
|
||||
|
||||
type subnet struct {
|
||||
sboxInit bool
|
||||
initDone bool
|
||||
vxlanName string
|
||||
brName string
|
||||
vni uint32
|
||||
@@ -254,16 +254,16 @@ func (n *network) joinSandbox(s *subnet, incJoinCount bool) error {
|
||||
}
|
||||
|
||||
subnetErr := s.initErr
|
||||
if !s.sboxInit {
|
||||
subnetErr = n.initSubnetSandbox(s)
|
||||
if !s.initDone {
|
||||
subnetErr = n.initSubnet(s)
|
||||
// We can recover from these errors
|
||||
if subnetErr == nil {
|
||||
s.initErr = subnetErr
|
||||
s.sboxInit = true
|
||||
s.initDone = true
|
||||
}
|
||||
}
|
||||
if subnetErr != nil {
|
||||
return fmt.Errorf("subnet sandbox join failed for %q: %v", s.subnetIP.String(), subnetErr)
|
||||
return fmt.Errorf("network sandbox join failed for subnet %q: %v", s.subnetIP.String(), subnetErr)
|
||||
}
|
||||
|
||||
if incJoinCount {
|
||||
@@ -293,7 +293,7 @@ func (n *network) leaveSandbox() {
|
||||
n.sboxInit = false
|
||||
n.initErr = nil
|
||||
for _, s := range n.subnets {
|
||||
s.sboxInit = false
|
||||
s.initDone = false
|
||||
s.initErr = nil
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (n *network) getBridgeNamePrefix(s *subnet) string {
|
||||
return fmt.Sprintf("ov-%06x", s.vni)
|
||||
}
|
||||
|
||||
func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error {
|
||||
func (n *network) setupSubnet(s *subnet, brName, vxlanName string) error {
|
||||
// create a bridge and vxlan device for this subnet and move it to the sandbox
|
||||
sbox := n.sbox
|
||||
|
||||
@@ -472,7 +472,7 @@ func setDefaultVLAN(ns *osl.Namespace) error {
|
||||
}
|
||||
|
||||
// Must be called with the network lock
|
||||
func (n *network) initSubnetSandbox(s *subnet) error {
|
||||
func (n *network) initSubnet(s *subnet) error {
|
||||
brName := n.generateBridgeName(s)
|
||||
vxlanName := n.generateVxlanName(s)
|
||||
|
||||
@@ -483,7 +483,7 @@ func (n *network) initSubnetSandbox(s *subnet) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := n.setupSubnetSandbox(s, brName, vxlanName); err != nil {
|
||||
if err := n.setupSubnet(s, brName, vxlanName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func withSandbox(t *testing.T, n *network, key string) {
|
||||
n.sbox = sbox
|
||||
n.sboxInit = true
|
||||
n.subnets = []*subnet{{
|
||||
sboxInit: true,
|
||||
initDone: true,
|
||||
vxlanName: "vx-absent",
|
||||
subnetIP: netip.MustParsePrefix("10.0.0.0/24"),
|
||||
}}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (n *network) addNeighbor(peerIP netip.Prefix, peerMac hashable.MACAddr, vte
|
||||
}
|
||||
|
||||
if err := n.joinSandbox(s, false); err != nil {
|
||||
return fmt.Errorf("subnet sandbox join failed for %q: %v", s.subnetIP.String(), err)
|
||||
return fmt.Errorf("network sandbox join failed for subnet %q: %v", s.subnetIP.String(), err)
|
||||
}
|
||||
|
||||
if n.secure {
|
||||
|
||||
Reference in new issue
Block a user