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 docs/module/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The module is supported on these platforms:
| --------------------- | :-: | :-: | :-: |
| Arista EOS | ✅ | ✅ | ✅ |
| Aruba AOS-CX | ✅ | ✅ | ✅ |
| BIRD | ✅ | ❌ | ❌ |
| Cisco IOS XE[^18v] | ❌ | ✅ | ✅ |
| Cisco IOS XR[^XR] | ❌ | ✅ | ✅ |
| Cisco Nexus OS | ❌ | ✅ | ✅ |
Expand Down
1 change: 1 addition & 0 deletions docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ These devices support additional control-plane protocols or BGP address families
| --------------------- | :-: | :-: | :-: | :-: |
| Arista EOS | ✅ | ✅ | ✅ | ✅ |
| Aruba AOS-CX | ✅ | ✅ | ✅ | ✅ |
| BIRD | ❌ | ❌ | ❌ | ✅ |
| Cisco IOS XE[^XE] | ✅ | ✅ | ✅ | ✅ |
| Cisco IOSv/IOSvL2 | ✅ | ❌ | ✅ | ✅ |
| Cisco IOS XR[^XR] | ❌ | ✅ | ✅ | ✅ |
Expand Down
5 changes: 5 additions & 0 deletions netsim/ansible/templates/gateway/bird.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
#
set -e
#
{% include 'frr/anycast-dp.j2' +%}
56 changes: 3 additions & 53 deletions netsim/ansible/templates/gateway/frr.j2
Original file line number Diff line number Diff line change
@@ -1,56 +1,6 @@
#!/bin/bash
#
set -e # Exit immediately when any command fails
set -e
#
sysctl -w net.ipv6.conf.all.enhanced_dad=0
sysctl -w net.ipv6.conf.default.enhanced_dad=0
{% for intf in interfaces if intf.gateway.protocol|default('none') == 'vrrp' %}
{% for afm in ['ipv4','ipv6'] if afm in intf.gateway %}
{% set v_if = 'vrrp%s-%s-%s'|format('6' if afm == 'ipv6' else '',intf.ifindex,intf.gateway.vrrp.group) %}
{% set v_mac = intf.gateway.vrrp.mac[afm] %}
if [ ! -e /sys/class/net/{{ v_if }} ]; then
ip link add {{ v_if }} link {{ intf.ifname }} type macvlan mode bridge
ip link set dev {{ v_if }} address {{ v_mac }} addrgenmode {{ 'none' if afm == 'ipv4' else 'random' }}
ip addr add {{ intf.gateway[afm] }} dev {{ v_if }}
{% if afm=='ipv4' %}
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_announce=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_ignore=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_accept=1
{% endif %}
{% if 'vrf' in intf %}
ip link set dev {{ v_if }} master {{ intf.vrf }}
{% endif %}
ip link set dev {{ v_if }} up
fi
{% endfor %}
{% endfor %}
{% for intf in interfaces if intf.gateway.protocol|default('none') == 'anycast' %}
{% set v_if = 'varp-%s'|format(intf.ifindex) %}
if [ ! -e /sys/class/net/{{ v_if }} ]; then
ip link add {{ v_if }} link {{ intf.ifname }} type macvlan mode private
ip link set dev {{ v_if }} address {{ intf.gateway.anycast.mac|ansible.utils.hwaddr('linux') }}
{% if intf.type == 'svi' %}
bridge fdb replace {{ intf.gateway.anycast.mac|ansible.utils.hwaddr('linux') }} dev {{ intf.ifname }} self
{% endif %}
{% for afm in ['ipv4','ipv6'] if afm in intf.gateway %}
ip addr add {{ intf.gateway[afm] }} dev {{ v_if }} metric 1024
{% endfor %}
{% if 'ipv4' in intf.gateway %}
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_announce=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_ignore=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_accept=1
{% endif %}
{% if 'ipv6' in intf.gateway %}
sysctl -w net.ipv6.conf.{{ v_if }}.enhanced_dad=0
sysctl -w net.ipv6.conf.{{ v_if }}.accept_dad=0
sysctl -w net.ipv6.conf.{{ v_if }}.dad_transmits=0
{% else %}
sysctl -w net.ipv6.conf.{{ v_if }}.disable_ipv6=1
{% endif %}
{% if 'vrf' in intf %}
ip link set dev {{ v_if }} master {{ intf.vrf }}
{% endif %}
ip link set dev {{ v_if }} up
fi
{% endfor %}
{% include 'frr.vrrp-config.j2' %}
{% include 'frr/data-plane.j2' +%}
{% include 'frr/vrrp-cp.j2' +%}
29 changes: 29 additions & 0 deletions netsim/ansible/templates/gateway/frr/anycast-dp.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% for intf in interfaces if intf.gateway.protocol|default('none') == 'anycast' %}
{% set v_if = 'varp-%s'|format(intf.ifindex) %}
if [ ! -e /sys/class/net/{{ v_if }} ]; then
ip link add {{ v_if }} link {{ intf.ifname }} type macvlan mode private
ip link set dev {{ v_if }} address {{ intf.gateway.anycast.mac|ansible.utils.hwaddr('linux') }}
{% if intf.type == 'svi' %}
bridge fdb replace {{ intf.gateway.anycast.mac|ansible.utils.hwaddr('linux') }} dev {{ intf.ifname }} self
{% endif %}
{% for afm in ['ipv4','ipv6'] if afm in intf.gateway %}
ip addr add {{ intf.gateway[afm] }} dev {{ v_if }} metric 1024
{% endfor %}
{% if 'ipv4' in intf.gateway %}
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_announce=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_ignore=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_accept=1
{% endif %}
{% if 'ipv6' in intf.gateway %}
sysctl -w net.ipv6.conf.{{ v_if }}.enhanced_dad=0
sysctl -w net.ipv6.conf.{{ v_if }}.accept_dad=0
sysctl -w net.ipv6.conf.{{ v_if }}.dad_transmits=0
{% else %}
sysctl -w net.ipv6.conf.{{ v_if }}.disable_ipv6=1
{% endif %}
{% if 'vrf' in intf %}
ip link set dev {{ v_if }} master {{ intf.vrf }}
{% endif %}
ip link set dev {{ v_if }} up
fi
{% endfor %}
5 changes: 5 additions & 0 deletions netsim/ansible/templates/gateway/frr/data-plane.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sysctl -w net.ipv6.conf.all.enhanced_dad=0
sysctl -w net.ipv6.conf.default.enhanced_dad=0
#
{% include 'frr/anycast-dp.j2' +%}
{% include 'frr/vrrp-dp.j2' %}
20 changes: 20 additions & 0 deletions netsim/ansible/templates/gateway/frr/vrrp-dp.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% for intf in interfaces if intf.gateway.protocol|default('none') == 'vrrp' %}
{% for afm in ['ipv4','ipv6'] if afm in intf.gateway %}
{% set v_if = 'vrrp%s-%s-%s'|format('6' if afm == 'ipv6' else '',intf.ifindex,intf.gateway.vrrp.group) %}
{% set v_mac = intf.gateway.vrrp.mac[afm] %}
if [ ! -e /sys/class/net/{{ v_if }} ]; then
ip link add {{ v_if }} link {{ intf.ifname }} type macvlan mode bridge
ip link set dev {{ v_if }} address {{ v_mac }} addrgenmode {{ 'none' if afm == 'ipv4' else 'random' }}
ip addr add {{ intf.gateway[afm] }} dev {{ v_if }}
{% if afm=='ipv4' %}
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_announce=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_ignore=2
sysctl -w net.ipv4.conf.{{ intf.ifname }}.arp_accept=1
{% endif %}
{% if 'vrf' in intf %}
ip link set dev {{ v_if }} master {{ intf.vrf }}
{% endif %}
ip link set dev {{ v_if }} up
fi
{% endfor %}
{% endfor %}
2 changes: 2 additions & 0 deletions netsim/daemons/bird.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ features:
routing:
static.discard: true
dhcp: false
gateway:
protocol: [ anycast ]
Comment thread
ipspace marked this conversation as resolved.
initial:
ipv4:
unnumbered: peer
Expand Down