Skip to content

Commit dfde4ad

Browse files
committed
Support configuring source IPv6 for routes through FRR
Signed-off-by: Matej Feder <[email protected]>
1 parent 173561c commit dfde4ad

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

dockers/docker-fpm-frr/frr/zebra/zebra.interfaces.conf.j2

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ exit
1717
vrf {{ vrf }}
1818
ip protocol bgp route-map {{ bgp_sess['route_map'] }}
1919
{% endif %}
20+
{% if 'route_map_ipv6' in bgp_sess %}
21+
!
22+
vrf {{ vrf }}
23+
ipv6 protocol bgp route-map {{ bgp_sess['route_map_ipv6'] }}
24+
{% endif %}
2025
{% endfor %}
2126
{% endif %}
2227
{% if ROUTE_MAP is defined and ROUTE_MAP|length > 0 %}

src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,8 @@ class BGPConfigDaemon:
17551755
('confed_peers', '{no:no-prefix}bgp confederation peers {}', hdl_confed_peers),
17561756
(['keepalive', 'holdtime'], '{no:no-prefix}timers bgp {} {}'),
17571757
(['max_med_admin', '+max_med_admin_val'], '{no:no-prefix}bgp max-med administrative {}', ['true', 'false']),
1758-
('route_map', '{no:no-prefix}ip protocol bgp route-map {}'),
1758+
('route_map', '[zebra]{no:no-prefix}ip protocol bgp route-map {}'),
1759+
('route_map_ipv6', '[zebra]{no:no-prefix}ipv6 protocol bgp route-map {}'),
17591760
]
17601761

17611762
global_af_key_map = [(['ebgp_route_distance',
@@ -1878,7 +1879,7 @@ class BGPConfigDaemon:
18781879
('call_route_map', '{no:no-prefix}call {:enable-only}'),
18791880
('set_origin', '[bgpd]{no:no-prefix}set origin {:tolower}'),
18801881
('set_local_pref', '[bgpd]{no:no-prefix}set local-preference {}'),
1881-
('set_src', '{no:no-prefix}set src {}'),
1882+
('set_src', '[zebra]{no:no-prefix}set src {}'),
18821883
('set_next_hop', '{no:no-prefix}set ip next-hop {}'),
18831884
('set_ipv6_next_hop_global', '[bgpd]{no:no-prefix}set ipv6 next-hop global {}'),
18841885
('set_ipv6_next_hop_prefer_global', '[bgpd]{no:no-prefix}set ipv6 next-hop prefer-global', ['true', 'false']),
@@ -2644,12 +2645,13 @@ def __update_bgp(self, data_list):
26442645
if local_asn is None:
26452646
syslog.syslog(syslog.LOG_ERR, 'local ASN for VRF %s was not configured' % vrf)
26462647
continue
2647-
if 'route_map' in data:
2648-
# Route maps are configured in a different context, so they need a different cmd_prefix
2649-
cmd_prefix = ['configure terminal', 'vrf {}'.format(vrf)]
2650-
if not key_map.run_command(self, table, {'route_map': data['route_map']}, cmd_prefix):
2651-
syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command')
2652-
del data['route_map']
2648+
for route_map_key in ['route_map', 'route_map_ipv6']:
2649+
if route_map_key in data:
2650+
# Route maps are configured in a different context, so they need a different cmd_prefix
2651+
cmd_prefix = ['configure terminal', 'vrf {}'.format(vrf)]
2652+
if not key_map.run_command(self, table, {route_map_key: data[route_map_key]}, cmd_prefix):
2653+
syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command')
2654+
del data[route_map_key]
26532655
cmd_prefix = ['configure terminal', 'router bgp {} vrf {}'.format(local_asn, vrf)]
26542656
if not key_map.run_command(self, table, data, cmd_prefix):
26552657
syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command')

src/sonic-frr/frr

Submodule frr updated 6107 files

src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"BGP_GLOBAL_VALID": {
33
"desc": "Configure BGP global table."
44
},
5+
"BGP_GLOBAL_ROUTE_MAP_VALID": {
6+
"desc": "Configure BGP global table with route map."
7+
},
58
"BGP_NEIGHBOR_ALL_VALID": {
69
"desc": "Configure BGP neighbor table."
710
},

src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json

+30
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,36 @@
8282
}
8383
},
8484

85+
"BGP_GLOBAL_ROUTE_MAP_VALID": {
86+
"sonic-vrf:sonic-vrf":{
87+
"sonic-vrf:VRF": {
88+
"VRF_LIST": [
89+
{
90+
"name":"Vrf1"
91+
}
92+
]
93+
}
94+
},
95+
"sonic-bgp-global:sonic-bgp-global": {
96+
"sonic-bgp-global:BGP_GLOBALS": {
97+
"BGP_GLOBALS_LIST": [
98+
{
99+
"vrf_name":"default",
100+
"local_asn": 65001,
101+
"route_map": "RM_SET_SRC",
102+
"route_map_ipv6": "RM_SET_SRC6"
103+
},
104+
{
105+
"vrf_name":"Vrf1",
106+
"local_asn": 65001,
107+
"route_map": "RM_SET_SRC",
108+
"route_map_ipv6": "RM_SET_SRC6"
109+
}
110+
]
111+
}
112+
}
113+
},
114+
85115
"BGP_NEIGHBOR_ALL_VALID": {
86116
"sonic-port:sonic-port": {
87117
"sonic-port:PORT": {

src/sonic-yang-models/yang-models/sonic-bgp-global.yang

+6-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ module sonic-bgp-global {
320320

321321
leaf route_map {
322322
type string;
323-
description "Route map to apply to BGP-learned routes in Zebra";
323+
description "IPv4 route map to apply to BGP-learned routes in Zebra";
324+
}
325+
326+
leaf route_map_ipv6 {
327+
type string;
328+
description "IPv6 route map to apply to BGP-learned routes in Zebra";
324329
}
325330
}
326331
}

0 commit comments

Comments
 (0)