Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frrcfgd] Support configuring source IPv6 for routes #20333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions dockers/docker-fpm-frr/frr/zebra/zebra.interfaces.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ exit
{% endfor %}
{% endif %}
{% endblock vrf %}
{% block setsrc %}
{% if BGP_GLOBALS is defined and BGP_GLOBALS|length > 0 %}
{% for vrf, bgp_sess in BGP_GLOBALS.items() %}
{% if 'route_map' in bgp_sess %}
!
vrf {{ vrf }}
ip protocol bgp route-map {{ bgp_sess['route_map'] }}
{% endif %}
{% if 'route_map_ipv6' in bgp_sess %}
!
vrf {{ vrf }}
ipv6 protocol bgp route-map {{ bgp_sess['route_map_ipv6'] }}
{% endif %}
{% endfor %}
{% endif %}
{% if ROUTE_MAP is defined and ROUTE_MAP|length > 0 %}
{% for rm_key, rm_val in ROUTE_MAP.items() %}
{% if 'route_operation' in rm_val and 'set_src' in rm_val %}
!
route-map {{rm_key[0]}} {{rm_val['route_operation']}} {{rm_key[1]}}
set src {{rm_val['set_src']}}
{% endif %}
{% endfor %}
{% endif %}
{% endblock setsrc %}
!
{% block interfaces %}
! Enable nht through default route
Expand Down
12 changes: 11 additions & 1 deletion src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,9 @@ class BGPConfigDaemon:
('confed_id', '{no:no-prefix}bgp confederation identifier {}'),
('confed_peers', '{no:no-prefix}bgp confederation peers {}', hdl_confed_peers),
(['keepalive', 'holdtime'], '{no:no-prefix}timers bgp {} {}'),
(['max_med_admin', '+max_med_admin_val'], '{no:no-prefix}bgp max-med administrative {}', ['true', 'false'])
(['max_med_admin', '+max_med_admin_val'], '{no:no-prefix}bgp max-med administrative {}', ['true', 'false']),
('route_map', '[zebra]{no:no-prefix}ip protocol bgp route-map {}'),
('route_map_ipv6', '[zebra]{no:no-prefix}ipv6 protocol bgp route-map {}'),
]

global_af_key_map = [(['ebgp_route_distance',
Expand Down Expand Up @@ -1877,6 +1879,7 @@ class BGPConfigDaemon:
('call_route_map', '{no:no-prefix}call {:enable-only}'),
('set_origin', '[bgpd]{no:no-prefix}set origin {:tolower}'),
('set_local_pref', '[bgpd]{no:no-prefix}set local-preference {}'),
('set_src', '[zebra]{no:no-prefix}set src {}'),
('set_next_hop', '{no:no-prefix}set ip next-hop {}'),
('set_ipv6_next_hop_global', '[bgpd]{no:no-prefix}set ipv6 next-hop global {}'),
('set_ipv6_next_hop_prefer_global', '[bgpd]{no:no-prefix}set ipv6 next-hop prefer-global', ['true', 'false']),
Expand Down Expand Up @@ -2642,6 +2645,13 @@ def __update_bgp(self, data_list):
if local_asn is None:
syslog.syslog(syslog.LOG_ERR, 'local ASN for VRF %s was not configured' % vrf)
continue
for route_map_key in ['route_map', 'route_map_ipv6']:
if route_map_key in data:
# Route maps are configured in a different context, so they need a different cmd_prefix
cmd_prefix = ['configure terminal', 'vrf {}'.format(vrf)]
if not key_map.run_command(self, table, {route_map_key: data[route_map_key]}, cmd_prefix):
syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command')
del data[route_map_key]
cmd_prefix = ['configure terminal', 'router bgp {} vrf {}'.format(local_asn, vrf)]
if not key_map.run_command(self, table, data, cmd_prefix):
syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command')
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-frr/frr
Submodule frr updated 6107 files
3 changes: 3 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"BGP_GLOBAL_VALID": {
"desc": "Configure BGP global table."
},
"BGP_GLOBAL_ROUTE_MAP_VALID": {
"desc": "Configure BGP global table with route map."
},
"BGP_NEIGHBOR_ALL_VALID": {
"desc": "Configure BGP neighbor table."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,36 @@
}
},

"BGP_GLOBAL_ROUTE_MAP_VALID": {
"sonic-vrf:sonic-vrf":{
"sonic-vrf:VRF": {
"VRF_LIST": [
{
"name":"Vrf1"
}
]
}
},
"sonic-bgp-global:sonic-bgp-global": {
"sonic-bgp-global:BGP_GLOBALS": {
"BGP_GLOBALS_LIST": [
{
"vrf_name":"default",
"local_asn": 65001,
"route_map": "RM_SET_SRC",
"route_map_ipv6": "RM_SET_SRC6"
},
{
"vrf_name":"Vrf1",
"local_asn": 65001,
"route_map": "RM_SET_SRC",
"route_map_ipv6": "RM_SET_SRC6"
}
]
}
}
},

"BGP_NEIGHBOR_ALL_VALID": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"set_metric_action": "METRIC_SET_VALUE",
"set_metric": 50,
"set_next_hop": "10.10.10.10",
"set_src": "10.10.10.10",
"set_ipv6_next_hop_global": "1000::1",
"set_ipv6_next_hop_prefer_global": true,
"set_repeat_asn": 5,
Expand Down
10 changes: 10 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-bgp-global.yang
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ module sonic-bgp-global {
type uint16;
description "Hold time";
}

leaf route_map {
type string;
description "IPv4 route map to apply to BGP-learned routes in Zebra";
}

leaf route_map_ipv6 {
type string;
description "IPv6 route map to apply to BGP-learned routes in Zebra";
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-route-map.yang
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ module sonic-route-map {
description "Set metric value";
}

leaf set_src{
type string;
description "Set route source address";
}

leaf set_next_hop{
type string;
description "Set IP nexthop";
Expand Down
Loading