-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
srlinux refactor templates and add vxlan l3 vrf support (#406)
* Update doc to show current interface naming * Check transit_vni value range * Add vni values from the topology to the list, such that duplicate check works * Use vrf.vrfidx for transit evi value * Move VLAN handling to vlan module, use macro for ip addressing The data model makes it hard to associate an svi interface with the corresponding original vlan; this patch uses a vlan<nnnn> interface naming convention for the lookup * Support L3 VXLAN interfaces; add them to their VRF * Refactor vxlan interface configuration, for both l2 and l3 VNIs * Add srlinux vxlan vrf support (l3) and vrf loopbacks * Update docs Co-authored-by: Jeroen van Bemmel <[email protected]>
- Loading branch information
Showing
9 changed files
with
138 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,61 @@ | ||
{% from "templates/initial/srlinux.j2" import ip_addresses with context %} | ||
|
||
updates: | ||
{# Create mac-vrfs for L2 VLANs, add IRB interface if any #} | ||
{% if vlans is defined %} | ||
{% for vname,vdata in vlans.items() if vdata.mode|default('irb') != 'route' %} | ||
{% set irb_ifname = "irb0." + vdata.id | string() %} | ||
- path: network-instance[name=vlan_{{ vname }}] | ||
{# Use only vlan.id in name, such that svi interfaces can be associated #} | ||
- path: network-instance[name=vlan{{ vdata.id }}] | ||
val: | ||
type: mac-vrf | ||
description: "VLAN {{ vname }}" | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% macro add_interface(macvrf,ifname,vlan,i) %} | ||
- path: interface[name={{ifname}}] | ||
val: | ||
{% if i.type in ["vlan_member"] %} | ||
vlan-tagging: True | ||
{% endif %} | ||
subinterface: | ||
- index: {{ vlan }} | ||
{% if ifname!="irb0" %} | ||
type: bridged | ||
{% if i.type in ["vlan_member"] %} | ||
vlan: | ||
encap: | ||
{% if i.vlan.access_id is defined %} | ||
single-tagged: | ||
vlan-id: "{{ i.vlan.access_id }}" | ||
{% else %} | ||
untagged: { } | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{{ ip_addresses(ifname,vlan,i) }} | ||
|
||
- path: network-instance[name={{ macvrf }}] | ||
val: | ||
interface: | ||
{% for l in interfaces|default([]) %} | ||
{% if l.type in ['lan'] and l.vlan is defined and l.vlan.access == vname %} | ||
- name: {{ l.ifname }}.{{ l.vlan.access_id }} | ||
{% elif l.type in ['vlan_member'] and l.vlan is defined and l.vlan.access|default('?') == vname %} | ||
- name: {{ l.ifname }} | ||
{% elif l.type=='svi' and l.ifname == irb_ifname and (l.vlan is not defined or l.vlan.mode|default('irb') == 'irb') %} | ||
- name: {{ l.ifname }} | ||
- name: {{ ifname }}.{{ vlan }} | ||
|
||
{% if ifname=="irb0" %} | ||
- path: network-instance[name={{ i.vrf|default('default') }}] | ||
val: | ||
interface: | ||
- name: {{ ifname }}.{{ vlan }} | ||
{% endif %} | ||
|
||
{% endmacro %} | ||
|
||
{% for l in interfaces|default([]) if l.vlan is defined %} | ||
{% if l.type in ['svi'] and l.vlan.mode|default('irb') == 'irb' %} | ||
{% set vlan = l.ifname[4:]|int %} | ||
{{ add_interface( l.ifname, "irb0", vlan, l ) }} | ||
{% elif l.type in ['lan','vlan_member'] %} | ||
{% set vlan = l.vlan.access_id %} | ||
{{ add_interface( "vlan" + vlan|string, l.parent_ifname|default(l.ifname), vlan, l ) }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
updates: | ||
{% if vxlan.vlans is defined %} | ||
{% for vname in vxlan.vlans if vlans[vname].vni is defined %} | ||
{% set vlan = vlans[vname] %} | ||
- path: tunnel-interface[name=vxlan0]/vxlan-interface[index={{vlan.id}}] | ||
{% macro vxlan_interface(vrf,index,type,vni,evi) %} | ||
- path: tunnel-interface[name=vxlan0]/vxlan-interface[index={{index}}] | ||
val: | ||
type: bridged | ||
type: {{ type }} | ||
ingress: | ||
vni: {{ vlan.vni }} | ||
vni: {{ vni }} | ||
egress: | ||
source-ip: use-system-ipv4-address | ||
|
||
- path: network-instance[name=vlan_{{vname}}] | ||
- path: network-instance[name={{vrf}}] | ||
val: | ||
type: mac-vrf | ||
type: {{ 'mac-vrf' if type=='bridged' else 'ip-vrf' }} | ||
vxlan-interface: | ||
- name: vxlan0.{{ vlan.id }} | ||
- name: vxlan0.{{ index }} | ||
protocols: | ||
bgp-vpn: | ||
bgp-instance: | ||
- id: 1 | ||
route-target: | ||
_annotate: "For compatibility with frr, override auto-derived RT based on EVI {{evi}} with VNI {{vni}}" | ||
import-rt: "target:{{ bgp.as }}:{{ vni }}" | ||
export-rt: "target:{{ bgp.as }}:{{ vni }}" | ||
bgp-evpn: | ||
bgp-instance: | ||
- id: 1 | ||
evi: {{ vlan.evpn.evi }} | ||
evi: {{ evi }} | ||
ecmp: 8 | ||
vxlan-interface: vxlan0.{{ vlan.id }} | ||
vxlan-interface: vxlan0.{{ index }} | ||
{% endmacro %} | ||
|
||
updates: | ||
{% if vlans is defined and vxlan.vlans is defined %} | ||
{% for vname in vxlan.vlans if vlans[vname].vni is defined %} | ||
{% set vlan = vlans[vname] %} | ||
{{ vxlan_interface('vlan'+vlan.id|string,vlan.id,'bridged',vlan.vni,vlan.evpn.evi) }} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{# Symmetric IRB interfaces, note using VRF ID as transit EVI value #} | ||
{% if vrfs is defined %} | ||
{% for vname,vdata in vrfs.items() if 'evpn' in vdata and 'transit_vni' in vdata.evpn %} | ||
{{ vxlan_interface(vname,vdata.vrfidx,'routed',vdata.evpn.transit_vni,vdata.vrfidx) }} | ||
{% endfor %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters