Skip to content

Commit

Permalink
VRRP on FRRouting
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Sep 18, 2024
1 parent be9caba commit 8f84a9e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/module/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The module is supported on these platforms:
| Cisco Nexus OS ||||
| Cumulus Linux ||||
| Dell OS10 |[](caveats-os10) |[](caveats-os10) |[](caveats-os10) |
| FRRouting ||||
| Nokia SR OS ||||
| Nokia SR Linux ||||
| VyOS ||||
Expand Down
17 changes: 17 additions & 0 deletions netsim/ansible/templates/gateway/frr.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#
set -e # Exit immediately when any command fails
#
{% 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 = '00:00:5e:00:%02x:%02x'|format(2 if afm == 'ipv6' else 1,intf.gateway.vrrp.group) %}
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 }}
ip addr add {{ intf.gateway[afm] }} dev {{ v_if }}
ip link set dev {{ v_if }} up
fi
{% endfor %}
{% endfor %}
{% include 'frr.vrrp-config.j2' %}
19 changes: 19 additions & 0 deletions netsim/ansible/templates/gateway/frr.vrrp-config.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
cat >/tmp/vrrp_config <<CONFIG
{% for intf in interfaces if intf.gateway.protocol|default('') == 'vrrp' %}
interface {{ intf.ifname }}
vrrp {{ intf.gateway.vrrp.group }} shutdown
{% if 'priority' in intf.gateway.vrrp %}
vrrp {{ intf.gateway.vrrp.group }} priority {{ intf.gateway.vrrp.priority }}
{% endif %}
{% if intf.gateway.vrrp.preempt|default(False) %}
vrrp {{ intf.gateway.vrrp.group }} preempt
{% endif %}
{% for af in 'ipv4','ipv6' if af in intf.gateway %}
vrrp {{ intf.gateway.vrrp.group }} {{ af|replace('ipv4','ip') }} {{ intf.gateway[af]|ipaddr('address') }}
{% endfor %}
no vrrp {{ intf.gateway.vrrp.group }} shutdown
{% endfor %}
do write
CONFIG
vtysh -f /tmp/vrrp_config
1 change: 1 addition & 0 deletions netsim/ansible/templates/initial/frr/daemons.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'ripv2':['ripd','ripngd'],
'isis':['isisd'],
'vrf':['bgpd'],
'gateway':['vrrpd'],
'mpls':['ldpd'] } %}
{% for m in module|default([]) if modlist[m] is defined %}
{% for frr_m in [modlist[m]]|flatten %}
Expand Down
2 changes: 2 additions & 0 deletions netsim/devices/frr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ features:
evpn:
irb: true
asymmetrical_irb: True
gateway:
protocol: [ vrrp ]
isis:
import: [ bgp, ripv2, ospf, connected ]
unnumbered:
Expand Down
1 change: 1 addition & 0 deletions netsim/templates/provider/clab/frr/daemons.j2
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ frr_profile="datacenter"
'ripv2':['ripd','ripngd'],
'isis':['isisd'],
'vrf':['bgpd'],
'gateway':['vrrpd'],
'mpls':['ldpd'] } %}
{% for m in module|default([]) if modlist[m] is defined %}
{% for frr_m in modlist[m] %}
Expand Down

0 comments on commit 8f84a9e

Please sign in to comment.