-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ospf6d: rework ospf6 neighbor state display #14912
base: master
Are you sure you want to change the base?
Conversation
2886f64
to
3cec1ba
Compare
ospf6d/ospf6_neighbor.c
Outdated
@@ -892,6 +910,7 @@ static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on, | |||
else | |||
snprintf(nstate, sizeof(nstate), "DROther"); | |||
} | |||
ospf6_neighbor_state_message(on, nstate, sizeof(nstate)); |
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.
I'm not sure I really understand this change at all. This just completely blows away the nstate changes starting on line 900 and go to line 912. what's the goal here at all?
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.
align the output state between ospfv2 and ospfv3.
we want to achieve it step by step.
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.
taken into account
ospf6d/ospf6_neighbor.c
Outdated
static void ospf6_neighbor_nstate_message(struct ospf6_neighbor *on, | ||
char *nstate, size_t nstate_len) | ||
{ | ||
char state[16]; |
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.
nit: char state[16] = {};
. This way we don't need memset()
.
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.
done
ospf6d/ospf6_neighbor.c
Outdated
json_object_int_add(json_route, "priority", on->priority); | ||
json_object_string_add(json_route, "deadTime", deadtime); | ||
json_object_string_add(json_route, "state", | ||
ospf6_neighbor_state_str[on->state]); | ||
json_object_int_add(json_route, "nbrPriority", on->priority); | ||
json_object_string_add(json_route, "nbrState", nstate); | ||
json_object_string_add(json_route, "Role", |
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.
lowercased please role
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.
done
ospf6d/ospf6_neighbor.c
Outdated
json_object_string_add(json_neighbor, "neighborState", | ||
ospf6_neighbor_state_str[on->state]); | ||
json_object_int_add(json_neighbor, "nbrPriority", on->priority); | ||
json_object_string_add(json_neighbor, "nbrState", nstate); | ||
json_object_string_add(json_neighbor, "Role", |
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.
Ditto.
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.
done
@@ -174,7 +174,7 @@ def expect_neighbor_full(router, neighbor): | |||
topotest.router_json_cmp, | |||
tgen.gears[router], | |||
"show ipv6 ospf6 neighbor json", | |||
{"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, | |||
{"neighbors": [{"neighborId": neighbor, "Role": "Full"}]}, |
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.
Ditto.
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.
done
@@ -157,7 +157,7 @@ def expect_neighbor_full(router, neighbor): | |||
topotest.router_json_cmp, | |||
tgen.gears[router], | |||
"show ipv6 ospf6 neighbor json", | |||
{"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, | |||
{"neighbors": [{"neighborId": neighbor, "Role": "Full"}]}, |
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.
Ditto.
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.
done
@@ -154,7 +154,7 @@ def expect_ospfv3_neighbor_full(router, neighbor): | |||
topotest.router_json_cmp, | |||
tgen.gears[router], | |||
"show ipv6 ospf6 neighbor json", | |||
{"neighbors": [{"neighborId": neighbor, "state": "Full"}]}, | |||
{"neighbors": [{"neighborId": neighbor, "Role": "Full"}]}, |
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.
Ditto.
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.
done
ospf6d/ospf6_neighbor.c
Outdated
@@ -846,6 +846,39 @@ DEFPY(ipv6_ospf6_p2xp_neigh_poll_interval, | |||
|
|||
p2xp_unicast_hello_sched(p2xp_cfg); | |||
return CMD_SUCCESS; | |||
|
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.
Can you remove this empty line?
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.
done
ospf6d/ospf6_neighbor.c
Outdated
} | ||
|
||
/* build state value */ | ||
static void ospf6_neighbor_state_message(struct ospf6_neighbor *on, |
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.
Can't we use static strings for this goal at all? Like:
static const char *ospf6_neighbor_state_message(...) {
if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT)
return "PointToPoint";
...
}
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.
taken into account
3cec1ba
to
36f564c
Compare
fb54a87
to
6cc8244
Compare
ospf6d/ospf6_neighbor.c
Outdated
|
||
inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr, | ||
sizeof(linklocal_addr)); | ||
inet_ntop(AF_INET, &on->drouter, drouter, sizeof(drouter)); | ||
inet_ntop(AF_INET, &on->bdrouter, bdrouter, sizeof(bdrouter)); | ||
|
||
ospf6_neighbor_nstate_message(on, nstate, sizeof(nstate)); |
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.
I'm not sure why we need to return the values via arguments here?
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.
function remove following next comment
ospf6d/ospf6_neighbor.c
Outdated
} | ||
|
||
/* build nbrState value */ | ||
static void ospf6_neighbor_nstate_message(struct ospf6_neighbor *on, |
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.
Why can't we print this information directly using json_object_string_addf()
?
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.
taken into account
ospf6d/ospf6_neighbor.c
Outdated
@@ -848,16 +848,40 @@ DEFPY(ipv6_ospf6_p2xp_neigh_poll_interval, | |||
return CMD_SUCCESS; | |||
} | |||
|
|||
/* build state value */ |
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.
What does it mean build state
? :)
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.
removed
6cc8244
to
b277924
Compare
b277924
to
e54d248
Compare
ci:rerun |
e54d248
to
7e45a7b
Compare
ospf6d/ospf6_neighbor.c
Outdated
if (on->router_id == on->bdrouter) | ||
return "BR"; | ||
return "DROther"; | ||
|
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.
nit: Drop this empty line, please.
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.
done
ospf6d/ospf6_neighbor.c
Outdated
json_object_int_add(json_route, "priority", on->priority); | ||
json_object_string_add(json_route, "deadTime", deadtime); | ||
json_object_string_add(json_route, "state", | ||
ospf6_neighbor_state_str[on->state]); | ||
json_object_int_add(json_route, "nbrPriority", on->priority); | ||
json_object_string_add(json_route, "nbrState", nstate); |
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.
Same here: let's use json_object_string_addf()
.
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.
done
7e45a7b
to
2746555
Compare
2746555
to
fab79cb
Compare
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.
Still some nits. Another question is: can we make identical changes for ospfv2? Just looks ridiculous when that differs (despite they are separate protocols).
ospf6d/ospf6_neighbor.c
Outdated
@@ -63,6 +63,7 @@ const char *const ospf6_neighbor_event_str[] = { | |||
}; | |||
|
|||
int ospf6_neighbor_cmp(void *va, void *vb) | |||
|
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.
Please drop this change.
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.
done
97ab54c
to
3f3986b
Compare
ci:rerun |
3f3986b
to
bd6fea6
Compare
700cddd
to
f6056ab
Compare
ci:rerun |
f6056ab
to
6b53a6f
Compare
ci: |
@@ -922,7 +949,8 @@ static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on, | |||
} else | |||
vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n", |
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.
Is this enough/aligned with the new output?
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.
in fact only json part is modified
if (uj) | ||
if (uj) | ||
vty_json(vty, json); | ||
} else if (uj) | ||
json_object_free(json); |
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.
I think we should call and print an empty JSON in such a case, right? vty_json_empty()
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.
i use vty_json since it manage "/" caracter
6b53a6f
to
92f6973
Compare
CI:rerun Retest for new ASAN Memory Leaks |
ci:rerun |
92f6973
to
2028898
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
A separate function ospf6_neighbor_state_message() is created to return a string that stands for the neighbor kind: DR, BDR, DROther, or PointToPoint. Signed-off-by: Philippe Guibert <[email protected]>
With a 16 byte nstate value, the "PointToPoint" string is missing one extra-character to handle the full string and the termination character. Fix this by enlarging the nstate buffer size to 17 instead of 16. Fixes: 508e53e ("Ospf6d merge from Zebra repository with added privs stuff and merged zclient changes.") Signed-off-by: Philippe Guibert <[email protected]>
Add the following attributes in each neighbor of the vty command: 'show ipv6 ospf6 neighbor detail json' - nbrPriority : integer - Role: DR, BDR, DROther, or PointToPoint - nbrState : <state>/<Role> where: o Role is the above attribute o state is "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange", "Loading", "Full" - routerDeadIntervalTimerDueMsec: integer value otherwise "inactive" Enter in a deprecation workflow for neighborState value, which is replaced by nbrState. Signed-off-by: Philippe Guibert <[email protected]>
Add the following attributes in each neighbor of the vty command: 'show ipv6 ospf6 neighbor json': - nbrPriority : integer - Role: DR, BDR, DROther, or PointToPoint - nbrState : <state>/<Role> where: o Role is the above attribute o state is "None", "Down", "Attempt", "Init", "Twoway", "ExStart", "ExChange", "Loading", "Full" - routerDeadIntervalTimerDueMsec: integer value otherwise "inactive" Enter in a deprecation workflow for state and priority values, which are replaced by nbrState. Signed-off-by: Philippe Guibert <[email protected]>
To handle the future change of naming in the ospf6 state, align the ospf6 tests with the new 'Role' nickname instead of the old 'state' value. Signed-off-by: Philippe Guibert <[email protected]>
2028898
to
bee2291
Compare
This PR is stale because it has been open 180 days with no activity. Comment or remove the |
A separate function ospf6_neighbor_state_message() is created
to return a string that stands for the neighbor kind: DR, BDR,
DROther, or PointToPoint.
Add the following attributes in each neighbor of the vty command:
'show ipv6 ospf6 neighbor detail json'
o Role is the above attribute
o state is "None", "Down", "Attempt", "Init", "Twoway",
"ExStart", "ExChange", "Loading", "Full"
Enter in a deprecation workflow for neighborState value, which is
replaced by nbrState.
Add the following attributes in each neighbor of the vty command:
'show ipv6 ospf6 neighbor json':
o Role is the above attribute
o state is "None", "Down", "Attempt", "Init", "Twoway",
"ExStart", "ExChange", "Loading", "Full"
Enter in a deprecation workflow for state and priority values, which
are replaced by nbrState.
and update related tests