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

[mclagdctl] added peer link state #9416

Open
wants to merge 6 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
12 changes: 8 additions & 4 deletions src/iccpd/src/iccp_cmd_show.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ int iccp_mclag_config_dump(char * *buf, int *num, int mclag_id)
memcpy(state_info.peer_ip, csm->peer_ip, ICCP_MAX_IP_STR_LEN);

if (peer_link_if)
{
memcpy(state_info.peer_link_if, peer_link_if->name, ICCP_MAX_PORT_NAME);
memcpy(state_info.peer_link_mac, peer_link_if->mac_addr, ETHER_ADDR_LEN);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this linbe trying to fix something that was not mentioned in your PR?? Did someone reviewed this change? The other changes looks straight forward but not this one...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. the magic number 6 was replaced by the appropriate constant instead.
  2. there was a confusing logic with duplicated check.
if (peer_link_if) 
    do_some_stuff()
else
    do_another_stuff()

if (peer_link_if)
    do_the_rest()

As those lines needed to be changed in this PR simplified it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh... I overlooked the original code that you changed from. Must have missed my coffee that day. My bad... It makes perfect sense for this change.

state_info.peer_link_state = peer_link_if->state;
}
else
{
memcpy(state_info.peer_link_if, unknown, strlen(unknown));

if (peer_link_if)
memcpy(state_info.peer_link_mac, peer_link_if->mac_addr, 6);
state_info.peer_link_state = PORT_STATE_DOWN;
}

state_info.keepalive_time = csm->keepalive_time;
state_info.session_timeout = csm->session_timeout;

logconfig = logger_get_configuration();
memcpy(state_info.loglevel, log_level_to_string(logconfig->log_level), strlen( log_level_to_string(logconfig->log_level)));

Expand Down
12 changes: 12 additions & 0 deletions src/iccpd/src/mclagdctl/mclagdctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ int mclagdctl_parse_dump_state(char *msg, int data_len)
fprintf(stdout, "%s: %s\n", "Local Ip", state_info->local_ip);
fprintf(stdout, "%s: %s\n", "Peer Ip", state_info->peer_ip);
fprintf(stdout, "%s: %s\n", "Peer Link Interface", state_info->peer_link_if);

char* peer_link_state = "";
if (state_info->peer_link_state == PORT_STATE_UP)
peer_link_state = "Up";
else if (state_info->peer_link_state == PORT_STATE_DOWN)
peer_link_state = "Down";
else if (state_info->peer_link_state == PORT_STATE_ADMIN_DOWN)
peer_link_state = "Admin-down";
else if (state_info->peer_link_state == PORT_STATE_TEST)
peer_link_state = "Test";
fprintf(stdout, "Peer Link state: %s\n", peer_link_state);

fprintf(stdout, "%s: %d\n", "Keepalive time", state_info->keepalive_time);
fprintf(stdout, "%s: %d\n", "sesssion Timeout ", state_info->session_timeout);

Expand Down
1 change: 1 addition & 0 deletions src/iccpd/src/mclagdctl/mclagdctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct mclagd_state
int session_timeout;
int keepalive_time;
char loglevel[MCLAGDCTL_PARA1_LEN];
uint8_t peer_link_state;
};

#define NEIGH_LOCAL 1
Expand Down