Skip to content

Commit

Permalink
IOSv/XE: VRF-aware RIPv2/RIPng
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Sep 12, 2024
1 parent ac0e9bc commit 7a2bb2d
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 39 deletions.
4 changes: 2 additions & 2 deletions docs/module/ripv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The following table describes per-platform support of individual RIPv2/RIPng fea
| Operating system | IPv4<br>(RIPv2) | IPv6<br>(RIPng) | Passive<br>interfaces | Route<br>import | VRF<br>instances |
| ------------------ | :-: | :-: | :-: | :-: | :-: |
| Arista EOS |||||
| Cisco IOSv/IOSvL2 |||[](caveats-iosv) |[](caveats-iosv) |
| Cisco IOS XE[^18v] |||[](caveats-iosv) |[](caveats-iosv) |
| Cisco IOSv/IOSvL2 |||[](caveats-iosv) |[](caveats-iosv) ||
| Cisco IOS XE[^18v] |||[](caveats-iosv) |[](caveats-iosv) ||
| Cumulus Linux ||||||
| FRR ||||||
| VyOS |||||
Expand Down
4 changes: 2 additions & 2 deletions docs/module/vrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ These platforms support routing protocols in VRFs:
| --------------------- | :-: | :-: | :-: | :-: | :-: |
| Arista EOS ||||
| Aruba AOS-CX ||||
| Cisco IOS/IOSvL2 |[](caveats-iosv) |||
| Cisco IOS XE[^18v] |[](caveats-csr) |||
| Cisco IOS/IOSvL2 |[](caveats-iosv) |||||
| Cisco IOS XE[^18v] |[](caveats-csr) |||||
| Cisco Nexus OS ||||
| Cumulus Linux ||||||
| Dell OS10 ||||
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/ospf/ios.ospfv2.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ router ospf {{ ospf_pid }}
passive-interface {{ l.ifname }}
{% endfor %}
{{ ospf_default.config(ospf_data,'ipv4') }}
{{ redistribute.config(ospf_data,af='ipv4',t_proto='ospf') }}
{{ redistribute.config(ospf_data,af='ipv4',t_proto='ospf',vrf=ospf_vrf) }}
!
{% for l in intf_data if 'ospf' in l and ('ipv4' in l or 'ipv4' in l.dhcp.client|default({})) %}
interface {{ l.ifname }}
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/ospf/ios.ospfv3.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ router ospfv3 {{ ospf_pid }}
passive-interface {{ l.ifname }}
{% endfor %}
{{ ospf_default.config(ospf_data,'ipv6')|indent(1,first=True) }}
{{ redistribute.config(ospf_data,af='ipv6')|indent(1,first=True) }}
{{ redistribute.config(ospf_data,af='ipv6',vrf=ospf_vrf)|indent(1,first=True) }}
!
{% for l in intf_data if 'ospf' in l and ('ipv6' in l or 'ipv6' in l.dhcp.client|default({})) %}
interface {{ l.ifname }}
Expand Down
29 changes: 2 additions & 27 deletions netsim/ansible/templates/ripv2/ios.j2
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
{% import "templates/routing/_redistribute.ios.j2" as redistribute with context %}
{% import "ios.macro.j2" as rip with context %}
!
{% if ripv2.af.ipv4|default(False) %}
router rip
version 2
no auto-summary
{% if 'import' in ripv2 %}
default-metric {{ netlab_ripv2_default_metric|default(5) }}
{% endif %}
{{ redistribute.config(ripv2,af='ipv4',ospf_pid=ospf.process|default(1)) }}
{% for intf in netlab_interfaces if 'ipv4' in intf and not 'vrf' in intf %}
network {{ intf.ipv4|ipaddr('address') }}
{% if intf.ripv2.passive|default(False) or not 'ripv2' in intf %}
passive-interface {{ intf.ifname }}
{% endif %}
{% endfor %}
{% endif %}
!
{% if ripv2.af.ipv6|default(False) %}
ipv6 router rip Gandalf
{{ redistribute.config(ripv2,af='ipv6',ospf_pid=ospf.process|default(1)) }}
!
{% for intf in netlab_interfaces if 'ripv2' in intf and 'ipv6' in intf %}
!
interface {{ intf.ifname }}
ipv6 rip Gandalf enable
{% endfor %}
{% endif %}
{{ rip.config(ripv2,vrf='',ospf_pid=ospf.process|default(1)) }}
41 changes: 41 additions & 0 deletions netsim/ansible/templates/ripv2/ios.macro.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% import "templates/routing/_redistribute.ios.j2" as redistribute with context %}
!
{% macro config(ripv2,vrf='',ospf_pid=1) -%}
{% if vrf %}
ipv6 rip vrf-mode enable
{% endif %}
{% if ripv2.af.ipv4|default(False) %}
router rip
version 2
no auto-summary
address-family ipv4 {{ 'vrf '+vrf if vrf else 'unicast' }}
{% if 'import' in ripv2 %}
default-metric {{ netlab_ripv2_default_metric|default(5) }}
{% endif %}
{{ redistribute.config(ripv2,af='ipv4',ospf_pid=ospf_pid)|indent(1,first=True) }}
{% for intf in ripv2.interfaces|default(netlab_interfaces) %}
{% if 'ripv2' in intf and intf.ipv4|default(False) is string %}
network {{ intf.ipv4|ipaddr('address') }}
{% endif %}
{% set in_vrf = (vrf == '' and 'vrf' not in intf) or (intf.vrf == vrf) %}
{% if in_vrf and (intf.ripv2.passive|default(False) or not 'ripv2' in intf) %}
passive-interface {{ intf.ifname }}
{% endif %}
{% endfor %}
{% endif %}
!
{% if ripv2.af.ipv6|default(False) %}
{% set r_instance = vrf or 'default' %}
ipv6 router rip default
{% if vrf %}
address-family ipv6 vrf {{ vrf }}
{% endif %}
{{ redistribute.config(ripv2,af='ipv6',ospf_pid=ospf_pid)|indent(1,first=True) }}
!
{% for intf in ripv2.interfaces|default(netlab_interfaces) if 'ripv2' in intf and 'ipv6' in intf %}
!
interface {{ intf.ifname }}
ipv6 rip default enable
{% endfor %}
{% endif %}
{%- endmacro %}
4 changes: 2 additions & 2 deletions netsim/ansible/templates/routing/_redistribute.ios.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% macro policy(sp_data,af) -%}
{% if 'policy' in sp_data %} route-map {{ sp_data.policy }}-{{ af }}{% endif +%}
{%- endmacro %}
{% macro config(pdata,af='ipv4',t_proto='',ospf_pid=1) -%}
{% macro config(pdata,af='ipv4',t_proto='',ospf_pid=1,vrf='default') -%}
{% if pdata.import is defined %}
{% set r_append = ' subnets' if t_proto == 'ospf' else '' %}
{% for s_proto,s_data in pdata.import.items() %}
Expand All @@ -13,7 +13,7 @@
{% elif s_proto == 'ospf' %}
{% set sp_config = sp_config + ' ' + ospf_pid|string + ' match internal external' %}
{% elif s_proto == 'rip' and af == 'ipv6' %}
{% set sp_config = sp_config + ' Gandalf' %}
{% set sp_config = sp_config + ' default' %}
{% endif %}
redistribute {{ sp_config }}{{ policy(s_data,af) }}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/vrf/ios.bgp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ router bgp {{ bgp.as }}
{% for af in ('ipv4','ipv6') if af in vdata.af|default({}) %}
address-family {{ af }} vrf {{ vname }}
bgp router-id {{ vdata.bgp.router_id|default(bgp.router_id) }}
{{ redistribute.config(vdata.bgp,af=af,ospf_pid=vdata.vrfidx) }}
{{ redistribute.config(vdata.bgp,af=af,ospf_pid=vdata.vrfidx,vrf=vname)|indent(1,first=True) }}
!
{% for n in vdata.networks|default([]) if af in n %}
{{ bgpcfg.bgp_network(af,n[af]) }}
Expand Down
4 changes: 4 additions & 0 deletions netsim/ansible/templates/vrf/ios.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% import "templates/ospf/ios.ospfv2.j2" as ospfv2 with context %}
{% import "templates/ospf/ios.ospfv3.j2" as ospfv3 with context %}
{% import "templates/ripv2/ios.macro.j2" as rip with context %}
{% if bgp.as is defined %}
{% include 'ios.bgp.j2' %}
{% endif %}
Expand All @@ -11,3 +12,6 @@
{{ ospfv3.config(vdata.vrfidx,vname,vdata.ospf,vdata.ospf.interfaces|default([]),bgp|default({})) }}
{% endif %}
{% endfor %}
{% for vname,vdata in vrfs.items() if 'ripv2' in vdata %}
{{ rip.config(ripv2=vdata.ripv2,vrf=vname,ospf_pid=vdata.vrfidx) }}
{% endfor %}
4 changes: 3 additions & 1 deletion netsim/devices/iosv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ features:
ipv4: true
ipv6: true
passive: true
import: [ bgp, isis, ospf, connected ]
import: [ bgp, isis, ospf, connected, vrf ]
routing:
policy:
set:
Expand All @@ -95,6 +95,8 @@ features:
ospfv2: True
ospfv3: True
bgp: True
ripv2: True
ripng: True
gateway:
protocol: [ vrrp ]
external:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ripv2/21-import-ds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ validate:
plugin: ospf_prefix(pfx=nodes.r3.loopback.ipv4)
ospf_v6:
description: Check whether R3 RIP IPv6 prefix is redistributed into OSPF
wait: 10
wait: 15
wait_msg: Waiting for the loopback prefix to be originated and redistributed
nodes: [ r2 ]
plugin: ospf6_prefix(pfx=nodes.r3.interfaces[0].ipv6)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ripv2/32-vrf-ipv6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ validate:
description: Check for RIPng prefix in BGP
wait_msg: Waiting for RIPng and BGP convergence
fail: RIPng is not redistributed into BGP
wait: 3
wait: 40
nodes: [ r2 ]
plugin: bgp_prefix(nodes.r1.interfaces[0].ipv6,af='ipv6')
red_lb_ping:
Expand Down

0 comments on commit 7a2bb2d

Please sign in to comment.