From 4a44abe0a9405bedc73a309cd53b99d20e37a3ad Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 8 Mar 2020 12:39:58 +0100 Subject: vrf: T31: enable vrf support for pseudo-ethernet/macvlan interface --- .../interfaces-pseudo-ethernet.xml.in | 1 + src/conf_mode/interfaces-pseudo-ethernet.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/interface-definitions/interfaces-pseudo-ethernet.xml.in b/interface-definitions/interfaces-pseudo-ethernet.xml.in index c2dea438a..e6e8fd20c 100644 --- a/interface-definitions/interfaces-pseudo-ethernet.xml.in +++ b/interface-definitions/interfaces-pseudo-ethernet.xml.in @@ -21,6 +21,7 @@ #include #include #include + #include #include diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index e775b0fcd..989b1432b 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -53,7 +53,8 @@ default_config_data = { 'vif_s': [], 'vif_s_remove': [], 'vif': [], - 'vif_remove': [] + 'vif_remove': [], + 'vrf': '' } def get_config(): @@ -159,6 +160,10 @@ def get_config(): if conf.exists(['mode']): peth['mode'] = conf.return_value(['mode']) + # retrieve VRF instance + if conf.exists('vrf'): + peth['vrf'] = conf.return_value('vrf') + # re-set configuration level to parse new nodes conf.set_level(cfg_base) # get vif-s interfaces (currently effective) - to determine which vif-s @@ -200,9 +205,12 @@ def verify(peth): if not peth['link'] in interfaces(): raise ConfigError('Pseudo-ethernet source interface does not exist') + vrf_name = peth['vrf'] + if vrf_name and vrf_name not in interfaces(): + raise ConfigError(f'VRF "{vrf_name}" does not exist') + # use common function to verify VLAN configuration verify_vlan_config(peth) - return None def generate(peth): @@ -289,6 +297,12 @@ def apply(peth): # Enable private VLAN proxy ARP on this interface p.set_proxy_arp_pvlan(peth['ip_proxy_arp_pvlan']) + # assign to VRF + if peth['vrf']: + p.add_vrf(peth['vrf']) + else: + p.del_vrf(peth['vrf']) + # Change interface MAC address if peth['mac']: p.set_mac(peth['mac']) -- cgit v1.2.3