[config]Static routes to config_db#1534
Conversation
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
|
Here, the user is expected to run |
|
@prsunny |
ok, so how is it expected to be restored from config_db after reboot? |
I'm not sure, but maybe the update can be triggered using crontab or along with running the bgp container. |
|
Can you add unit-tests as well? |
|
Why is the schema showing nexthop in key? |
|
And also why do we need prefix in the value field? It's already part of the key... |
|
we already have frrcfgd monitoring config db, so the part of programming frr cfg is not necessary as long as config_db is updated, isn't it? |
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
|
@prsunny @caizhenghui-juniper |
|
Hi, Dmytro,
Here it is: https://github.com/Azure/sonic-buildimage/tree/master/src/sonic-frr-mgmt-framework/frrcfgd
One more issue: in swss, we do require VRF name conforms with prefix Vrf, so please correct that in VRF test case accordingly. Small problem 😊
And the schema defined in frrcfgd for vrf is using vrf_name instead of vrf.
Plus, are you still setting prefix as field? At line 3248?
Thanks
Zhenghui
From: Dmytro ***@***.***>
Reply-To: Azure/sonic-utilities ***@***.***>
Date: Wednesday, March 31, 2021 at 1:52 PM
To: Azure/sonic-utilities ***@***.***>
Cc: Zhenghui Cai ***@***.***>, Mention ***@***.***>
Subject: Re: [Azure/sonic-utilities] [config]Static routes to config_db (#1534)
[External Email. Be cautious of content]
@prsunny<https://github.com/prsunny> @caizhenghui-juniper<https://github.com/caizhenghui-juniper>
I updated the record name with a prefix as the key and nexthop as the value, and also added base UT. But I cannot find frrcfgd in the repositories, can you tell me where it is?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1534 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKDUQJVEG3JZD3HB5MP773DTGNOOTANCNFSM42CKDI4Q>.
Juniper Business Use Only
|
|
and can you put support for ECMP too? With more than 1 next hops for the static routes? |
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
tests/static_routes_test.py
Outdated
| ["prefix", "3.2.3.4/32", "nexthop", "vrf", "Vrfred", "30.0.0.6"], obj=obj) | ||
| print(result.exit_code, result.output) | ||
| assert ('3.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') | ||
| assert db.cfgdb.get_entry('STATIC_ROUTE', '3.2.3.4/32') == {"nexthop": "30.0.0.6", "nexthop_vrf": "Vrfred"} |
There was a problem hiding this comment.
I think we need to follow a certain schema design for the STATIC_ROUTE table. In sonic-net/SONiC#585, there is a schema for the table but it seems different here.
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
|
I'm not sure if this is a bug or not, but after reboot, the frr daemon does not start with the system, and also after manual start, the daemon sees a static route, but does not add it to frr cfg Before reboot After reboot Syslog And if I try to change the nexthop on this entry, staticd crashes because it has no previous entry |
prsunny
left a comment
There was a problem hiding this comment.
I see that this PR is missing ecmp handling. In the existing code, by calling vtysh, it does handle ECMP. My suggestion is, when user configure the same route prefix with a different nexthop, it should modify the STATIC_ROUTE DB entry instead of overwriting thus supporting ECMP (similar to vtysh). @shi-su, this should be handled by bgpcfgd.
tests/static_routes_test.py
Outdated
| runner = CliRunner() | ||
| obj = {'config_db':db.cfgdb} | ||
|
|
||
| # config route add prefix 2.2.3.4/32 nexthop 30.0.0.6 |
There was a problem hiding this comment.
please update the comment to include vrf
tests/static_routes_test.py
Outdated
| runner = CliRunner() | ||
| obj = {'config_db':db.cfgdb} | ||
|
|
||
| # config route add prefix 3.2.3.4/32 nexthop 30.0.0.6 |
There was a problem hiding this comment.
same here, please update the correct command with vrf
config/main.py
Outdated
| clicommon.run_command(cmd) | ||
| key, route = cli_sroute_to_config(ctx, command_str) | ||
| config_db = ctx.obj['config_db'] | ||
| config_db.set_entry("STATIC_ROUTE", key, route) |
There was a problem hiding this comment.
If user update the route, this would overwrite the entry, correct?
|
Please update CLI command reference document |
Yes, the STATIC_ROUTE DB entry needs to be updated when nexthop changes. The bgpcfgd should be able to know the changes and only apply the differences for the same route prefix. |
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
| if vrf_name == "": | ||
| cmd += ' {} nexthop-vrf {}'.format(ip, vrf_name_dst) | ||
| config_db = ctx.obj['config_db'] | ||
| key, route = cli_sroute_to_config(ctx, command_str) |
There was a problem hiding this comment.
Now that we are writing to DB, lets check the correctness of key (like a valid ip prefix)
| if 'ifname' in current_entry: | ||
| ifname = current_entry['ifname'].split(',') | ||
|
|
||
| nh_zip = list(itertools.zip_longest(nh, nh_vrf, ifname, fillvalue='')) |
There was a problem hiding this comment.
can you add some comments to understand the logic in this section?
| ctx.fail('Not found {} in {}'.format(cmd_tuple, key)) | ||
|
|
||
| if len(nh) == 0 or (len(nh) == 1 and nh[0] == ''): | ||
| config_db.set_entry("STATIC_ROUTE", key, None) |
There was a problem hiding this comment.
if user just deletes the route without mentioning any nexthops, then the route is expected to be fully deleted.
There was a problem hiding this comment.
If the user tries to delete a route without nexthop (for example, 'сonfig del config route del prefix 1.2.3.4/32'), he will receive an error: 'argument is not in pattern'. So if the user has previously added ECMP routes, he must remove them one by one.
This condition checks if the record still has any nexthop, if so, it just updates this record, if it doesn't have the nexthop, it removes the key. Is this the correct behavior or should user be able to delete the entire entry at once?
There was a problem hiding this comment.
IMO, user should be able to delete the entire route at once.
tests/static_routes_test.py
Outdated
| print(result.exit_code, result.output) | ||
| assert not ('3.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') | ||
|
|
||
| def test_several_nexthops_static_route(self): |
There was a problem hiding this comment.
please rename it to test_multiple_nexthops_static_route
tests/static_routes_test.py
Outdated
| print(result.exit_code, result.output) | ||
| assert not ('11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') | ||
|
|
||
| def test_static_route_ECMP_nextfop_vrf(self): |
| assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') | ||
| assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {"nexthop": "30.0.0.6,30.0.0.7"} | ||
|
|
||
| # config route del prefix 6.2.3.4/32 nexthop 30.0.0.7 |
There was a problem hiding this comment.
please have a test to del prefix without any nexthops and ensure its removed from DB.
| key, route = cli_sroute_to_config(ctx, command_str) | ||
|
|
||
| # If defined intf name, check if it exists | ||
| if 'ifname' in route: |
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
| config_db = ConfigDBConnector() | ||
| config_db.connect() | ||
| ctx.obj = {} | ||
| ctx.obj['config_db'] = config_db |
There was a problem hiding this comment.
can you add the support for multi asic ?
Similar to how it is done for interface command https://github.com/Azure/sonic-utilities/blob/08337aa7637b290bb8407c38b2a5dbe3e8383b3e/config/main.py#L2359
There was a problem hiding this comment.
@arlakshm, can we add multiasic as another enhancement PR?
There was a problem hiding this comment.
@prsunny, Sure. Can we create an issue or task to track this?
shi-su
left a comment
There was a problem hiding this comment.
I do not have any other comments. Please check with other reviewers.
| else: | ||
| route['distance'] = '0' | ||
|
|
||
| if 'blackhole' in route: |
There was a problem hiding this comment.
We would need to handle one scenario for blackhole routes. If the user configure with "ifname" as "null", could you please add the attribute 'blackhole' as true.
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
| else: | ||
| route['blackhole'] = 'false' | ||
| # If the user configure with "ifname" as "null", set 'blackhole' attribute as true. | ||
| if 'ifname' in route and route['ifname'] == 'null': |
There was a problem hiding this comment.
Just want to confirm. Does this mean that it is necessary to confirm the route is completely removed before setting it to blackhole? If a route already exists in Config_DB and then we configure it to blackhole, the command would simply get ignored? If this is the case, could you please add logic to notify the caller that the command is getting ignored (e.g., fail the command with an error message)?
|
@prsunny - Can you please add the tag "Required to 202012" ? |
* Write static routes to config_db * Update configuration with "ifname" as "null" Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
* Write static routes to config_db * Update configuration with "ifname" as "null" Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
|
Is this already available in the prebuilt sonic-aboot-broadcom.swi ? If not, then how to configure (and persist across reboots) static routes? |
7f50b9815e14d90c02d9dce63fd08d90e25cee3f (HEAD -> 201911, origin/201911) handled update() function of fdb orchagent for FDB FLUSH event (sonic-net#1534) 17adc13b6ca21846fe27c94d6a16f9909c712d77 Add a check for warm-restart, and do a clear only when warm-restart is enable. (sonic-net#1498) d097260a5aa7bd611babd5062e220056374e23d8 Fixed compilation failure with debug option (sonic-net#1518) Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
What I did
fixes sonic-net/sonic-buildimage#6997
Added process for writing static routes to config_db.
fixes sonic-net/sonic-buildimage#7261
Added interface validation before creating route.
How I did it
Refactored add/del route functions. Wrote generic function that returns a vtysh command and an entry for config_db with name.
Instead of running the vtysh command, it creates config_db entries that will be loaded by the ffr daemon: