Skip to content

Commit

Permalink
Use reserved OVS controller ports for default Antrea ports
Browse files Browse the repository at this point in the history
Tunnel port, gateway port and uplink port.
These reserved port numbers (starting from 32,768) will never be
auto-assigned by OVS. By using them, we can avoid surprising ofport
changes in some edge cases.

Note that if these ports already exist when the Agent starts, we will
not re-create them or mutate their ofport. The new ofport values will
only be used when creating the OVS ports for the first time (e.g., on a
new K8s Node, or after a Node restart). That is the simplest solution
and is consistent with existing behavior. It should also be sufficient
for avoiding #6192, which was typically triggered by creating a new
tunnel port when updating the Antrea configuration in an existing
cluster.

After this change, we will also assume that br-int ports stored in OVSDB
always have the "antrea-type" external ID. This external ID became
required in Antrea v1.5, so this should be an acceptable change,
especially considering that this change is destined for the Antrea v2
release, which is a major version bump. Users will not be able to
upgrade from Antrea v1.5 to Antrea v2.0, but that this is not a
supported upgrade path anyway (for other reasons).
We also add some logic to prevent creating a port on the OVS bridge if a
required external ID is missing.

Fixes #6192

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas committed Apr 15, 2024
1 parent 6793694 commit 0733d0c
Show file tree
Hide file tree
Showing 31 changed files with 343 additions and 351 deletions.
5 changes: 4 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ func run(o *Options) error {
// Bridging mode will connect the uplink interface to the OVS bridge.
connectUplinkToBridge := enableBridgingMode
ovsDatapathType := ovsconfig.OVSDatapathType(o.config.OVSDatapathType)
ovsBridgeClient := ovsconfig.NewOVSBridge(o.config.OVSBridge, ovsDatapathType, ovsdbConnection)
// WithRequiredPortExternalIDs will ensure that whenever we create a port, the required
// external ID (interface type) is provided. This is a sanity check to ensure code
// correctness.
ovsBridgeClient := ovsconfig.NewOVSBridge(o.config.OVSBridge, ovsDatapathType, ovsdbConnection, ovsconfig.WithRequiredPortExternalIDs(interfacestore.AntreaInterfaceTypeKey))
ovsCtlClient := ovsctl.NewClient(o.config.OVSBridge)
ovsBridgeMgmtAddr := ofconfig.GetMgmtAddress(o.config.OVSRunDir, o.config.OVSBridge)
multicastEnabled := features.DefaultFeatureGate.Enabled(features.Multicast) && o.config.Multicast.Enable
Expand Down
16 changes: 8 additions & 8 deletions docs/antctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ local (coredns) Pod:
```bash
$ antctl trace-packet -S default/web-client -D kube-system/coredns-6955765f44-zcbwj -f udp,udp_dst=53
result: |
Flow: udp,in_port=1,vlan_tci=0x0000,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=53
Flow: udp,in_port=32768,vlan_tci=0x0000,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=53
bridge("br-int")
----------------
0. in_port=1, priority 200, cookie 0x5e000000000000
0. in_port=32768, priority 200, cookie 0x5e000000000000
load:0->NXM_NX_REG0[0..15]
resubmit(,30)
30. ip, priority 200, cookie 0x5e000000000000
Expand All @@ -387,14 +387,14 @@ result: |
-> Sets the packet to an untracked state, and clears all the conntrack fields.
Final flow: unchanged
Megaflow: recirc_id=0,eth,udp,in_port=1,nw_frag=no,tp_src=0x0/0xfc00
Megaflow: recirc_id=0,eth,udp,in_port=32768,nw_frag=no,tp_src=0x0/0xfc00
Datapath actions: ct(zone=65520),recirc(0x53)
===============================================================================
recirc(0x53) - resume conntrack with default ct_state=trk|new (use --ct-next to customize)
===============================================================================
Flow: recirc_id=0x53,ct_state=new|trk,ct_zone=65520,eth,udp,in_port=1,vlan_tci=0x0000,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=53
Flow: recirc_id=0x53,ct_state=new|trk,ct_zone=65520,eth,udp,in_port=32768,vlan_tci=0x0000,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=53
bridge("br-int")
----------------
Expand Down Expand Up @@ -425,15 +425,15 @@ result: |
-> A clone of the packet is forked to recirculate. The forked pipeline will be resumed at table 110.
-> Sets the packet to an untracked state, and clears all the conntrack fields.
Final flow: recirc_id=0x53,eth,udp,reg0=0x10000,reg1=0x5,in_port=1,vlan_tci=0x0000,dl_src=62:39:b4:e8:05:76,dl_dst=52:bd:c6:e0:eb:c1,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=63,tp_src=0,tp_dst=53
Megaflow: recirc_id=0x53,ct_state=+new-est-inv+trk,ct_mark=0,eth,udp,in_port=1,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=192.0.0.0/2,nw_dst=172.100.1.7,nw_ttl=64,nw_frag=no,tp_dst=53
Final flow: recirc_id=0x53,eth,udp,reg0=0x10000,reg1=0x5,in_port=32768,vlan_tci=0x0000,dl_src=62:39:b4:e8:05:76,dl_dst=52:bd:c6:e0:eb:c1,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=63,tp_src=0,tp_dst=53
Megaflow: recirc_id=0x53,ct_state=+new-est-inv+trk,ct_mark=0,eth,udp,in_port=32768,dl_src=aa:bb:cc:dd:ee:ff,dl_dst=aa:bb:cc:dd:ee:ff,nw_src=192.0.0.0/2,nw_dst=172.100.1.7,nw_ttl=64,nw_frag=no,tp_dst=53
Datapath actions: set(eth(src=62:39:b4:e8:05:76,dst=52:bd:c6:e0:eb:c1)),set(ipv4(ttl=63)),ct(commit,zone=65520),recirc(0x54)
===============================================================================
recirc(0x54) - resume conntrack with default ct_state=trk|new (use --ct-next to customize)
===============================================================================
Flow: recirc_id=0x54,ct_state=new|trk,ct_zone=65520,eth,udp,reg0=0x10000,reg1=0x5,in_port=1,vlan_tci=0x0000,dl_src=62:39:b4:e8:05:76,dl_dst=52:bd:c6:e0:eb:c1,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=63,tp_src=0,tp_dst=53
Flow: recirc_id=0x54,ct_state=new|trk,ct_zone=65520,eth,udp,reg0=0x10000,reg1=0x5,in_port=32768,vlan_tci=0x0000,dl_src=62:39:b4:e8:05:76,dl_dst=52:bd:c6:e0:eb:c1,nw_src=172.100.2.11,nw_dst=172.100.1.7,nw_tos=0,nw_ecn=0,nw_ttl=63,tp_src=0,tp_dst=53
bridge("br-int")
----------------
Expand All @@ -444,7 +444,7 @@ result: |
-> output port is 5
Final flow: unchanged
Megaflow: recirc_id=0x54,eth,ip,in_port=1,nw_frag=no
Megaflow: recirc_id=0x54,eth,ip,in_port=32768,nw_frag=no
Datapath actions: 3
```

Expand Down
26 changes: 13 additions & 13 deletions docs/design/ovs-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ should be performed for the packet in [L3ForwardingTable].
If you dump the flows for this table, you may see the following:

```text
1. table=0, priority=200,in_port=2 actions=set_field:0x1/0xf->reg0,resubmit(,10)
2. table=0, priority=200,in_port=1 actions=set_field:0/0xf->reg0,load:0x1->NXM_NX_REG0[19],resubmit(,30)
1. table=0, priority=200,in_port=32769 actions=set_field:0x1/0xf->reg0,resubmit(,10)
2. table=0, priority=200,in_port=32768 actions=set_field:0/0xf->reg0,load:0x1->NXM_NX_REG0[19],resubmit(,30)
3. table=0, priority=190,in_port=4 actions=set_field:0x2/0xf->reg0,resubmit(,10)
4. table=0, priority=190,in_port=3 actions=set_field:0x2/0xf->reg0,resubmit(,10)
4. table=0, priority=190,in_port=32770 actions=set_field:0x2/0xf->reg0,resubmit(,10)
5. table=0, priority=0 actions=drop
```

Expand Down Expand Up @@ -275,12 +275,12 @@ the host to advertise a different MAC address on antrea-gw0.
If you dump the flows for this table, you may see the following:

```text
1. table=10, priority=200,ip,in_port=2 actions=resubmit(,23)
2. table=10, priority=200,arp,in_port=2,arp_spa=10.10.0.1,arp_sha=3a:dd:79:0f:55:4c actions=resubmit(,20)
1. table=10, priority=200,ip,in_port=32769 actions=resubmit(,23)
2. table=10, priority=200,arp,in_port=32769,arp_spa=10.10.0.1,arp_sha=3a:dd:79:0f:55:4c actions=resubmit(,20)
3. table=10, priority=200,arp,in_port=4,arp_spa=10.10.0.2,arp_sha=ce:99:ca:bd:62:c5 actions=resubmit(,20)
4. table=10, priority=200,arp,in_port=3,arp_spa=10.10.0.3,arp_sha=3a:41:49:42:98:69 actions=resubmit(,20)
4. table=10, priority=200,arp,in_port=32770,arp_spa=10.10.0.3,arp_sha=3a:41:49:42:98:69 actions=resubmit(,20)
5. table=10, priority=200,ip,in_port=4,dl_src=ce:99:ca:bd:62:c5,nw_src=10.10.0.2 actions=resubmit(,23)
6. table=10, priority=200,ip,in_port=3,dl_src=3a:41:49:42:98:69,nw_src=10.10.0.3 actions=resubmit(,23)
6. table=10, priority=200,ip,in_port=32770,dl_src=3a:41:49:42:98:69,nw_src=10.10.0.3 actions=resubmit(,23)
7. table=10, priority=0 actions=drop
```

Expand Down Expand Up @@ -891,10 +891,10 @@ port (tunnel port, gateway port, and local Pod ports), as you can see if you
dump the flows:

```text
1. table=80, priority=200,dl_dst=aa:bb:cc:dd:ee:ff actions=set_field:0x1->reg1,set_field:0x10000/0x10000->reg0,goto_table:105
2. table=80, priority=200,dl_dst=e2:e5:a4:9b:1c:b1 actions=set_field:0x2->reg1,set_field:0x10000/0x10000->reg0,goto_table:105
1. table=80, priority=200,dl_dst=aa:bb:cc:dd:ee:ff actions=set_field:0x8000->reg1,set_field:0x10000/0x10000->reg0,goto_table:105
2. table=80, priority=200,dl_dst=e2:e5:a4:9b:1c:b1 actions=set_field:0x8001->reg1,set_field:0x10000/0x10000->reg0,goto_table:105
3. table=80, priority=200,dl_dst=12:9e:a6:47:d0:70 actions=set_field:0x3->reg1,set_field:0x10000/0x10000->reg0,goto_table:90
4. table=80, priority=200,dl_dst=ba:a8:13:ca:ed:cf actions=set_field:0x4->reg1,set_field:0x10000/0x10000->reg0,goto_table:90
4. table=80, priority=200,dl_dst=ba:a8:13:ca:ed:cf actions=set_field:0x8002->reg1,set_field:0x10000/0x10000->reg0,goto_table:90
5. table=80, priority=0 actions=goto_table:105
```

Expand Down Expand Up @@ -990,7 +990,7 @@ If you dump the flows for this table, you should see something like this:
3. table=90, priority=200,ip,nw_src=10.10.1.2 actions=conjunction(3,1/3)
4. table=90, priority=200,ip,nw_src=10.10.1.3 actions=conjunction(3,1/3)
5. table=90, priority=200,ip,reg1=0x3 actions=conjunction(3,2/3)
6. table=90, priority=200,ip,reg1=0x4 actions=conjunction(3,2/3)
6. table=90, priority=200,ip,reg1=0x8002 actions=conjunction(3,2/3)
7. table=90, priority=200,tcp,tp_dst=80 actions=conjunction(3,3/3)
8. table=90, priority=190,conj_id=3,ip actions=load:0x3->NXM_NX_REG6[],ct(commit,table=101,zone=65520,exec(load:0x3->NXM_NX_CT_LABEL[0..31]))
9. table=90, priority=0 actions=goto_table:100
Expand Down Expand Up @@ -1045,7 +1045,7 @@ the flows:

```text
1. table=100, priority=200,ip,reg1=0x3 actions=drop
2. table=100, priority=200,ip,reg1=0x4 actions=drop
2. table=100, priority=200,ip,reg1=0x8002 actions=drop
3. table=100, priority=0 actions=goto_table:105
```

Expand Down Expand Up @@ -1149,7 +1149,7 @@ across the different backends for each Service.
If you dump the flows for this table, you should see something like this:

```text
1. table=40, priority=200,ip,nw_dst=10.96.0.0/12 actions=set_field:0x2->reg1,load:0x1->NXM_NX_REG0[16],goto_table:105
1. table=40, priority=200,ip,nw_dst=10.96.0.0/12 actions=set_field:0x8001->reg1,load:0x1->NXM_NX_REG0[16],goto_table:105
2. table=40, priority=0 actions=goto_table:45
```

Expand Down
117 changes: 37 additions & 80 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (i *Initializer) validateSupportedDPFeatures() error {
func (i *Initializer) initInterfaceStore() error {
ovsPorts, err := i.ovsBridgeClient.GetPortList()
if err != nil {
klog.Errorf("Failed to list OVS ports: %v", err)
klog.ErrorS(err, "Failed to list OVS ports")
return err
}

Expand All @@ -278,8 +278,7 @@ func (i *Initializer) initInterfaceStore() error {
MAC: port.MAC,
OVSPortConfig: ovsPort}
if intf.InterfaceName != i.hostGateway {
klog.Warningf("The discovered gateway interface name %s is different from the configured value: %s",
intf.InterfaceName, i.hostGateway)
klog.InfoS("The discovered gateway interface name is different from the configured value", "discovered", intf.InterfaceName, "configured", i.hostGateway)
// Set the gateway interface name to the discovered name.
i.hostGateway = intf.InterfaceName
}
Expand All @@ -294,10 +293,10 @@ func (i *Initializer) initInterfaceStore() error {
}
parseTunnelInterfaceFunc := func(port *ovsconfig.OVSPortData, ovsPort *interfacestore.OVSPortConfig) *interfacestore.InterfaceConfig {
intf := noderoute.ParseTunnelInterfaceConfig(port, ovsPort)
if intf != nil && port.OFPort == config.DefaultTunOFPort &&
intf.InterfaceName != i.nodeConfig.DefaultTunName {
klog.Infof("The discovered default tunnel interface name %s is different from the default value: %s",
intf.InterfaceName, i.nodeConfig.DefaultTunName)
// This function can be called for both the "regular" tunnel port or an IPsec tunnel
// port, but the rest of the function only applies to the "regular" tunnel port.
if intf != nil && intf.Type == interfacestore.TunnelInterface && intf.InterfaceName != i.nodeConfig.DefaultTunName {
klog.InfoS("The discovered default tunnel interface name is different from the default value", "discovered", intf.InterfaceName, "default", i.nodeConfig.DefaultTunName)
// Set the default tunnel interface name to the discovered name.
i.nodeConfig.DefaultTunName = intf.InterfaceName
}
Expand All @@ -312,78 +311,36 @@ func (i *Initializer) initInterfaceStore() error {
var intf *interfacestore.InterfaceConfig
interfaceType, ok := port.ExternalIDs[interfacestore.AntreaInterfaceTypeKey]
if !ok {
interfaceType = interfacestore.AntreaUnset
}
if interfaceType != interfacestore.AntreaUnset {
switch interfaceType {
case interfacestore.AntreaGateway:
intf = parseGatewayInterfaceFunc(port, ovsPort)
case interfacestore.AntreaUplink:
intf = parseUplinkInterfaceFunc(port, ovsPort)
case interfacestore.AntreaTunnel:
fallthrough
case interfacestore.AntreaIPsecTunnel:
intf = parseTunnelInterfaceFunc(port, ovsPort)
case interfacestore.AntreaHost:
if port.Name == i.ovsBridge {
// Need not to load the OVS bridge port to the interfaceStore
intf = nil
} else {
var err error
intf, err = externalnode.ParseHostInterfaceConfig(i.ovsBridgeClient, port, ovsPort)
if err != nil {
return fmt.Errorf("failed to get interfaceConfig by port %s: %v", port.Name, err)
}
}
case interfacestore.AntreaContainer:
// The port should be for a container interface.
intf = cniserver.ParseOVSPortInterfaceConfig(port, ovsPort)
case interfacestore.AntreaTrafficControl:
intf = trafficcontrol.ParseTrafficControlInterfaceConfig(port, ovsPort)
default:
klog.InfoS("Unknown Antrea interface type", "type", interfaceType)
}
} else {
// Antrea Interface type is not saved in OVS port external_ids in earlier Antrea versions, so we use
// the old way to decide the interface type for the upgrade case.
uplinkIfName := i.nodeConfig.UplinkNetConfig.Name
var antreaIFType string
switch {
case port.OFPort == config.HostGatewayOFPort:
intf = parseGatewayInterfaceFunc(port, ovsPort)
antreaIFType = interfacestore.AntreaGateway
case port.Name == uplinkIfName:
intf = parseUplinkInterfaceFunc(port, ovsPort)
antreaIFType = interfacestore.AntreaUplink
case port.IFType == ovsconfig.GeneveTunnel:
fallthrough
case port.IFType == ovsconfig.VXLANTunnel:
fallthrough
case port.IFType == ovsconfig.GRETunnel:
fallthrough
case port.IFType == ovsconfig.STTTunnel:
intf = parseTunnelInterfaceFunc(port, ovsPort)
if intf.Type == interfacestore.IPSecTunnelInterface {
antreaIFType = interfacestore.AntreaIPsecTunnel
} else {
antreaIFType = interfacestore.AntreaTunnel
}
case port.Name == i.ovsBridge:
klog.ErrorS(nil, "Interface type is not set, you may be trying to upgrade from an Antrea version which is too old", "interfaceName", intf.InterfaceName)
continue
}
switch interfaceType {
case interfacestore.AntreaGateway:
intf = parseGatewayInterfaceFunc(port, ovsPort)
case interfacestore.AntreaUplink:
intf = parseUplinkInterfaceFunc(port, ovsPort)
case interfacestore.AntreaTunnel:
fallthrough
case interfacestore.AntreaIPsecTunnel:
intf = parseTunnelInterfaceFunc(port, ovsPort)
case interfacestore.AntreaHost:
if port.Name == i.ovsBridge {
// Need not to load the OVS bridge port to the interfaceStore
intf = nil
antreaIFType = interfacestore.AntreaHost
default:
// The port should be for a container interface.
intf = cniserver.ParseOVSPortInterfaceConfig(port, ovsPort)
antreaIFType = interfacestore.AntreaContainer
}
updatedExtIDs := make(map[string]interface{})
for k, v := range port.ExternalIDs {
updatedExtIDs[k] = v
}
updatedExtIDs[interfacestore.AntreaInterfaceTypeKey] = antreaIFType
if err := i.ovsBridgeClient.SetPortExternalIDs(port.Name, updatedExtIDs); err != nil {
klog.ErrorS(err, "Failed to set Antrea interface type on OVS port", "port", port.Name)
} else {
var err error
intf, err = externalnode.ParseHostInterfaceConfig(i.ovsBridgeClient, port, ovsPort)
if err != nil {
return fmt.Errorf("failed to get interfaceConfig by port %s: %v", port.Name, err)
}
}
case interfacestore.AntreaContainer:
// The port should be for a container interface.
intf = cniserver.ParseOVSPortInterfaceConfig(port, ovsPort)
case interfacestore.AntreaTrafficControl:
intf = trafficcontrol.ParseTrafficControlInterfaceConfig(port, ovsPort)
default:
klog.InfoS("Unknown Antrea interface type", "type", interfaceType)
}
if intf != nil {
klog.V(2).InfoS("Adding interface to cache", "interfaceName", intf.InterfaceName)
Expand Down Expand Up @@ -699,7 +656,7 @@ func (i *Initializer) setupGatewayInterface() error {
interfacestore.AntreaInterfaceTypeKey: interfacestore.AntreaGateway,
}
mac := util.GenerateRandomMAC()
gwPortUUID, err := i.ovsBridgeClient.CreateInternalPort(i.hostGateway, config.HostGatewayOFPort, mac.String(), externalIDs)
gwPortUUID, err := i.ovsBridgeClient.CreateInternalPort(i.hostGateway, config.DefaultHostGatewayOFPort, mac.String(), externalIDs)
if err != nil {
klog.ErrorS(err, "Failed to create gateway port on OVS bridge", "port", i.hostGateway)
return err
Expand All @@ -714,7 +671,7 @@ func (i *Initializer) setupGatewayInterface() error {
gatewayIface.OVSPortConfig = &interfacestore.OVSPortConfig{PortUUID: gwPortUUID, OFPort: gwPort}
i.ifaceStore.AddInterface(gatewayIface)
} else {
klog.V(2).Infof("Gateway port %s already exists on OVS bridge", i.hostGateway)
klog.V(2).InfoS("Gateway port already exists on OVS bridge", "name", i.hostGateway, "ofPort", gatewayIface.OFPort)
}

// Idempotent operation to set the gateway's MTU: we perform this operation regardless of
Expand Down Expand Up @@ -839,7 +796,7 @@ func (i *Initializer) setupDefaultTunnelInterface() error {
tunnelIface.TunnelInterfaceConfig.Type == i.networkConfig.TunnelType &&
tunnelIface.TunnelInterfaceConfig.DestinationPort == i.networkConfig.TunnelPort &&
tunnelIface.TunnelInterfaceConfig.LocalIP.Equal(localIP) {
klog.V(2).Infof("Tunnel port %s already exists on OVS bridge", tunnelPortName)
klog.V(2).InfoS("Tunnel port already exists on OVS bridge", "name", tunnelPortName, "ofPort", tunnelIface.OFPort)
if shouldEnableCsum != tunnelIface.TunnelInterfaceConfig.Csum {
klog.InfoS("Updating csum for tunnel port", "port", tunnelPortName, "csum", shouldEnableCsum)
if err := i.setTunnelCsum(tunnelPortName, shouldEnableCsum); err != nil {
Expand Down
23 changes: 8 additions & 15 deletions pkg/agent/agent_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"antrea.io/antrea/pkg/agent/interfacestore"
"antrea.io/antrea/pkg/agent/util"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
"antrea.io/antrea/pkg/ovs/ovsconfig"
utilip "antrea.io/antrea/pkg/util/ip"
)

Expand Down Expand Up @@ -97,7 +98,7 @@ func (i *Initializer) prepareOVSBridgeForK8sNode() error {
}

if hostOFPort, err := i.ovsBridgeClient.GetOFPort(uplinkNetConfig.Name, false); err == nil {
klog.Infof("OVS bridge local port %s already exists", uplinkNetConfig.Name)
klog.InfoS("OVS bridge local port already exists", "name", uplinkNetConfig.Name)
i.nodeConfig.HostInterfaceOFPort = uint32(hostOFPort)
// If local port exists, get the real uplink interface.
// This branch is used when antrea-agent had a hard restart (e.g. SIGKILL)
Expand All @@ -112,20 +113,12 @@ func (i *Initializer) prepareOVSBridgeForK8sNode() error {
} else {
uplinkNetConfig.Index = adapter.Index
}
klog.InfoS("Found uplink", "Name", adapter.Name, "Index", uplinkNetConfig.Index, "OFPort", uplinkNetConfig.OFPort)
klog.InfoS("Found uplink", "Name", adapter.Name, "Index", uplinkNetConfig.Index, "ofPort", uplinkNetConfig.OFPort)
} else {
freePort, err := i.ovsBridgeClient.AllocateOFPort(config.UplinkOFPort)
if err != nil {
return err
}
uplinkNetConfig.OFPort = uint32(freePort)
klog.InfoS("Set OpenFlow port in UplinkNetConfig", "ofport", uplinkNetConfig.OFPort)
freePort, err = i.ovsBridgeClient.AllocateOFPort(config.UplinkOFPort)
if err != nil {
return err
}
i.nodeConfig.HostInterfaceOFPort = uint32(freePort)
klog.InfoS("Set host interface", "ofport", i.nodeConfig.HostInterfaceOFPort)
klog.InfoS("Using default OpenFlow port for uplink", "ofPort", config.DefaultUplinkOFPort)
uplinkNetConfig.OFPort = config.DefaultUplinkOFPort
klog.InfoS("Using default OpenFlow port for host interface", "ofPort", config.DefaultHostInterfaceOFPort)
i.nodeConfig.HostInterfaceOFPort = config.DefaultHostInterfaceOFPort
}
return nil
}
Expand Down Expand Up @@ -357,7 +350,7 @@ func (i *Initializer) prepareL7EngineInterfaces() error {
if exists {
continue
}
portUUID, err := i.ovsBridgeClient.CreateInternalPort(portName, 0, "", trafficControlPortExternalIDs)
portUUID, err := i.ovsBridgeClient.CreateInternalPort(portName, ovsconfig.AutoAssignedOFPort, "", trafficControlPortExternalIDs)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 0733d0c

Please sign in to comment.