Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Changelog
* `suppress_inactive`
* `table_map`
* Extend interface with attributes:
* `fabric_forwarding_anycast_gateway`
* `ipv4_acl_in`, `ipv4_acl_out`, `ipv6_acl_in`, `ipv6_acl_out`
* `ipv4_address_secondary`, `ipv4_arp_timeout`
* `vlan_mapping`
Expand Down
6 changes: 6 additions & 0 deletions lib/cisco_node_utils/cmd_ref/interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ encapsulation_dot1q:
config_set_append: "%s encapsulation dot1q %s"
default_value: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the CHANGELOG to include this property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


fabric_forwarding_anycast_gateway:
kind: boolean
config_get_token_append: '/^fabric forwarding mode anycast-gateway$/'
config_set_append: "%s fabric forwarding mode anycast-gateway"
default_value: false

feature_lacp:
kind: boolean
config_get: "show running | i ^feature"
Expand Down
23 changes: 23 additions & 0 deletions lib/cisco_node_utils/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require_relative 'pim'
require_relative 'vrf'
require_relative 'vni'
require_relative 'overlay_global'

# Add some interface-specific constants to the Cisco namespace
module Cisco
Expand Down Expand Up @@ -205,6 +206,28 @@ def fabricpath_feature_set(fabricpath_set)
FabricpathGlobal.fabricpath_feature_set(fabricpath_set)
end

def fabric_forwarding_anycast_gateway
config_get('interface', 'fabric_forwarding_anycast_gateway', @name)
end

def fabric_forwarding_anycast_gateway=(state)
no_cmd = (state ? '' : 'no')
config_set('interface',
'fabric_forwarding_anycast_gateway', @name, no_cmd)
fail if fabric_forwarding_anycast_gateway.to_s != state.to_s
rescue Cisco::CliError => e
anycast_gateway_mac = OverlayGlobal.new.anycast_gateway_mac
if anycast_gateway_mac.nil? || anycast_gateway_mac.empty?
raise "[#{@name}] '#{e.command}' : #{e.clierror}
Anycast gateway mac needs to be configured
before configuring forwarding mode under interface"
end
end

def default_fabric_forwarding_anycast_gateway
config_get_default('interface', 'fabric_forwarding_anycast_gateway')
end

def fex_feature
fex = config_get('fex', 'feature')
fail 'fex_feature not found' if fex.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/overlay_global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def anycast_gateway_mac
def anycast_gateway_mac=(mac_addr)
fail TypeError unless mac_addr.is_a?(String)

Feature.nv_overlay_evpn_enable unless Feature.nv_overlay_evpn_enabled?
Feature.nv_overlay_evpn_enable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

if mac_addr == default_anycast_gateway_mac
state = 'no'
mac_addr = ''
Expand Down
37 changes: 37 additions & 0 deletions tests/test_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
require_relative 'ciscotest'
require_relative '../lib/cisco_node_utils/acl'
require_relative '../lib/cisco_node_utils/interface'
require_relative '../lib/cisco_node_utils/overlay_global'

include Cisco

Expand Down Expand Up @@ -958,6 +959,42 @@ def test_interface_ipv4_arp_timeout
assert_raises(RuntimeError) { nonvlanint.ipv4_arp_timeout = 300 }
end

def test_interface_fabric_forwarding_anycast_gateway
# Setup
config('no interface vlan11')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the config api, please use the Interface and VxlanGlobal providers to accomplish the same task.

Update: Thinking more... using the config api to remove the vlan is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored

int = Interface.new('vlan11')
foo = OverlayGlobal.new
foo.anycast_gateway_mac = '1223.3445.5668'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly configuring 'feature fabric forwarding' isn't needed for VxlanGlobal/OverlayGlobal - unless it's needed for the interface property, please remove it. These three lines should just become:

OverlayGlobal.new.anycast_gateway_mac = '1223.3445.5668'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennmatthews It is needed in I2 images.

agent-lab10-nx(config)# sh run | i 'feature fabric'
agent-lab10-nx(config)# conf t
agent-lab10-nx(config)# int vlan 11
agent-lab10-nx(config-if)# fabric fo?
                           ^
% Invalid command at '^' marker.
agent-lab10-nx(config-if)# 
agent-lab10-nx(config-if)# feature fabric forwarding
agent-lab10-nx(config)# int vlan 11
agent-lab10-nx(config-if)# fabric forwarding mode anycast-gateway 

vs. the behavior on I3 images...

dt-n9k5-1(config)# feature interface-vlan 
dt-n9k5-1(config)# 
dt-n9k5-1(config)# sh run | i 'feature fabric'
dt-n9k5-1(config)# 
dt-n9k5-1(config)# int vlan 11
dt-n9k5-1(config-if)# fabric forwarding mode anycast-gateway 
dt-n9k5-1(config-if)# 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smigopal I spoke with @glennmatthews and he clarified that his point is that OverlayGlobal.new.anycast_gateway_mac will handle turning feature fabric forwarding on I2 images and ignore cli failures on I3 images.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikewiebe : Awesome. Just to verify, this means I wouldn't need to enable the feature using "config('feature fabric forwarding')". Just the setter should suffice = "OverlayGlobal.new.anycast_gateway_mac = '1223.3445.5668'"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored.


# 1. Testing default
int.fabric_forwarding_anycast_gateway =
int.default_fabric_forwarding_anycast_gateway
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer removing these two lines - have the test below be for verifying that the default state of a newly created Vlan matches the expected default value, rather than explicitly setting it to default.

assert_equal(int.default_fabric_forwarding_anycast_gateway,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh? assert_equal is the correct thing to use here since you're comparing against the default value.

However, the line above should be:

int.fabric_forwarding_anycast_gateway = int.default_fabric_forwarding_anycast_gateway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, my mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int.fabric_forwarding_anycast_gateway)

# 2. Testing non-default:true
int.fabric_forwarding_anycast_gateway = true
assert(int.fabric_forwarding_anycast_gateway)

# 3. Setting back to false
int.fabric_forwarding_anycast_gateway = false
refute(int.fabric_forwarding_anycast_gateway)

# 4. Removing fabric forwarding anycast gateway mac
foo.anycast_gateway_mac = foo.default_anycast_gateway_mac
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably we already have similar tests for VxlanGlobal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but this is testing the specific error case in the interface code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just making sure we don't have any unnecessary overlap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored


# 5. Removing feature fabric forwarding
config('no feature fabric forwarding')
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }

# 6. Attempting to configure on a non-vlan interface
nonvlanint = create_interface
assert_raises(RuntimeError) do
nonvlanint.fabric_forwarding_anycast_gateway = true
end
end

def test_interface_ipv4_proxy_arp
interface = create_interface
interface.switchport_mode = :disabled
Expand Down