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

ospf6d: rework ospf6 neighbor state display #14912

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fdumontet6WIND
Copy link
Contributor

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'

  • nbrPriority : integer
  • Role: DR, BDR, DROther, or PointToPoint
  • nbrState : / 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.
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 : / 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.

and update related tests

@@ -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));
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taken into account

static void ospf6_neighbor_nstate_message(struct ospf6_neighbor *on,
char *nstate, size_t nstate_len)
{
char state[16];
Copy link
Member

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercased please role

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

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"}]},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

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"}]},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

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"}]},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -846,6 +846,39 @@ DEFPY(ipv6_ospf6_p2xp_neigh_poll_interval,

p2xp_unicast_hello_sched(p2xp_cfg);
return CMD_SUCCESS;

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

/* build state value */
static void ospf6_neighbor_state_message(struct ospf6_neighbor *on,
Copy link
Member

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";
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taken into account

@github-actions github-actions bot added size/L and removed size/M labels Dec 1, 2023
@fdumontet6WIND fdumontet6WIND force-pushed the rework_display branch 2 times, most recently from fb54a87 to 6cc8244 Compare December 1, 2023 11:47
@github-actions github-actions bot added size/M and removed size/L labels Dec 1, 2023

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));
Copy link
Member

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?

Copy link
Contributor Author

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

}

/* build nbrState value */
static void ospf6_neighbor_nstate_message(struct ospf6_neighbor *on,
Copy link
Member

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()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taken into account

@@ -848,16 +848,40 @@ DEFPY(ipv6_ospf6_p2xp_neigh_poll_interval,
return CMD_SUCCESS;
}

/* build state value */
Copy link
Member

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? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@fdumontet6WIND
Copy link
Contributor Author

ci:rerun

@github-actions github-actions bot added the rebase PR needs rebase label Dec 6, 2023
if (on->router_id == on->bdrouter)
return "BR";
return "DROther";

Copy link
Member

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.

Copy link
Contributor Author

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 Show resolved Hide resolved
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);
Copy link
Member

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().

Copy link
Contributor Author

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 Show resolved Hide resolved
Copy link
Member

@ton31337 ton31337 left a 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).

@@ -63,6 +63,7 @@ const char *const ospf6_neighbor_event_str[] = {
};

int ospf6_neighbor_cmp(void *va, void *vb)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this change.

Copy link
Contributor Author

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 Show resolved Hide resolved
@github-actions github-actions bot added size/L and removed size/M labels Dec 13, 2023
@fdumontet6WIND fdumontet6WIND force-pushed the rework_display branch 3 times, most recently from 97ab54c to 3f3986b Compare December 14, 2023 20:10
@fdumontet6WIND
Copy link
Contributor Author

ci:rerun

@fdumontet6WIND fdumontet6WIND force-pushed the rework_display branch 3 times, most recently from 700cddd to f6056ab Compare December 29, 2023 14:19
@fdumontet6WIND
Copy link
Contributor Author

ci:rerun

@fdumontet6WIND
Copy link
Contributor Author

ci:
rerun

@@ -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",
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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()

Copy link
Contributor Author

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

@mwinter-osr
Copy link
Member

CI:rerun Retest for new ASAN Memory Leaks

@fdumontet6WIND
Copy link
Contributor Author

ci:rerun

Copy link

github-actions bot commented Mar 8, 2024

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]>
Copy link

This PR is stale because it has been open 180 days with no activity. Comment or remove the autoclose label in order to avoid having this PR closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants