-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pbr: fix nexthop-group json output #16949
base: master
Are you sure you want to change the base?
Conversation
- JSON format is changed. currently json output returns as array format, in which we cannot add extra attributes under it. so, we modified the JSON format into dict. - Added nhgCount into vtysh "show pbr nexthop-groups json". - Addressed interface-name & vrf-id issues. currently, "vrfId" is mapped with interface name. supported commands: ``` show pbr nexthop-groups json show pbr nexthop-groups <nh-grp> json ``` Ticket:#3963583 Issue: 3963583 Testing: Before fix: leaf12# show pbr nexthop-groups json [ { "id":10001, "name":"nh-grp-2", "valid":true, "installed":false, "nexthops":[ { "nexthop":"12.10.10.1", "vrfId":"swp1", ====> wrongly mapped "valid":true } ] }, { "id":10000, "name":"nh-grp-1", "valid":false, "installed":false, "nexthops":[ { "nexthop":"11.10.10.1", "vrfId":"lo", ====> wrongly mapped "valid":false } ] } ] After fix: leaf11# show pbr nexthop-groups nh-grp-1 json { "10000":{ "id":10000, "name":"nh-grp-1", "valid":false, "installed":false, "nexthops":[ { "nexthop":"11.10.10.1", "valid":false }, { "nexthop":"2.2.2.1", "interfaceName":"swp1", "vrfId":0, "valid":false } ] }, "nhgCount":1 } Signed-off-by: Sindhu Parvathi Gopinathan's <[email protected]>
@@ -1080,24 +1080,27 @@ void nexthop_group_json_nexthop(json_object *j, const struct nexthop *nh) | |||
|
|||
switch (nh->type) { | |||
case NEXTHOP_TYPE_IFINDEX: | |||
json_object_string_add(j, "nexthop", | |||
json_object_string_add(j, "interfaceName", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty clearly a fix - it should be a separate commit (and maybe even a separate PR, given the release freeze?)
pbr_nht_json_nexthop_group(j, word); | ||
|
||
pbr_nht_json_nexthop_group(j, word, &pbr_nhg_count); | ||
json_object_int_add(j, "nhgCount", pbr_nhg_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit confusing: first, it seems like the count of objects in the collection (whether an array or a dict) should be pretty easy to find? and second, it's confusing to have a dict where some keys are the string form of nhg ids, and their objects are nhg objects, but some other keys are ... entirely different, and key entirely different objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change of JSON, correct? Before/After is absolutely broken in terms of parsing JSON fundamentally. Should we take care of this?
supported commands:
Testing:
Before fix:
After fix:
Signed-off-by: Sindhu Parvathi Gopinathan's [email protected]