Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen-Brcm committed Jun 14, 2021
1 parent 27e45d9 commit c2ac46b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 125 deletions.
2 changes: 1 addition & 1 deletion src/iccpd/src/iccp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int set_peer_link(int mid, const char* ifname)

if (len > MAX_L_PORT_NAME)
{
ICCPD_LOG_ERR(__FUNCTION__, "Peer-link %s, Strlen %d greater than MAX:%d ", ifname, strlen, MAX_L_PORT_NAME);
ICCPD_LOG_ERR(__FUNCTION__, "Peer-link %s, Strlen %d greater than MAX:%d ", ifname, len, MAX_L_PORT_NAME);
return MCLAG_ERROR;
}

Expand Down
22 changes: 11 additions & 11 deletions src/iccpd/src/iccp_cmd_show.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,23 +499,23 @@ int iccp_local_if_dump(char * *buf, int *num, int mclag_id)
mclagd_lif.ifindex = lif_peer->ifindex;

if (lif_peer->type == IF_T_UNKNOW)
memcpy(mclagd_lif.type, "Unknown", 6);
memcpy(mclagd_lif.type, "Unknown", strlen("unknown"));
else if (lif_peer->type == IF_T_PORT)
memcpy(mclagd_lif.type, "Ethernet", 8);
memcpy(mclagd_lif.type, "Ethernet", strlen("Ethernet"));
else if (lif_peer->type == IF_T_PORT_CHANNEL)
memcpy(mclagd_lif.type, "PortChannel", 11);

memcpy(mclagd_lif.name, lif_peer->name, MAX_L_PORT_NAME);
memcpy(mclagd_lif.mac_addr, lif_peer->mac_addr, ETHER_ADDR_LEN);

if (lif_peer->state == PORT_STATE_UP)
memcpy(mclagd_lif.state, "Up", 2);
memcpy(mclagd_lif.state, "Up", strlen("Up"));
else if (lif_peer->state == PORT_STATE_DOWN)
memcpy(mclagd_lif.state, "Down", 4);
memcpy(mclagd_lif.state, "Down", strlen("Down"));
else if (lif_peer->state == PORT_STATE_ADMIN_DOWN)
memcpy(mclagd_lif.state, "Admin-down", 10);
memcpy(mclagd_lif.state, "Admin-down", strlen("Admin-down"));
else if (lif_peer->state == PORT_STATE_TEST)
memcpy(mclagd_lif.state, "Test", 4);
memcpy(mclagd_lif.state, "Test", strlen("Test"));

memcpy(mclagd_lif.ipv4_addr, show_ip_str(lif_peer->ipv4_addr), 16);
mclagd_lif.prefixlen = lif_peer->prefixlen;
Expand All @@ -530,15 +530,15 @@ int iccp_local_if_dump(char * *buf, int *num, int mclag_id)
mclagd_lif.po_active = lif_peer->po_active;
/*mlacp_state*/
if (lif_peer->mlacp_state == MLACP_STATE_INIT)
memcpy(mclagd_lif.mlacp_state, "INIT", 4);
memcpy(mclagd_lif.mlacp_state, "INIT", strlen("INIT"));
else if (lif_peer->mlacp_state == MLACP_STATE_STAGE1)
memcpy(mclagd_lif.mlacp_state, "STAGE1", 6);
memcpy(mclagd_lif.mlacp_state, "STAGE1", strlen("STAGE1"));
else if (lif_peer->mlacp_state == MLACP_STATE_STAGE2)
memcpy(mclagd_lif.mlacp_state, "STAGE2", 6);
memcpy(mclagd_lif.mlacp_state, "STAGE2", strlen("STAGE2"));
else if (lif_peer->mlacp_state == MLACP_STATE_EXCHANGE)
memcpy(mclagd_lif.mlacp_state, "EXCHANGE", 8);
memcpy(mclagd_lif.mlacp_state, "EXCHANGE", strlen("EXCHANGE"));
else if (lif_peer->mlacp_state == MLACP_STATE_ERROR)
memcpy(mclagd_lif.mlacp_state, "ERROR", 5);
memcpy(mclagd_lif.mlacp_state, "ERROR", strlen("ERROR"));

mclagd_lif.isolate_to_peer_link = lif_peer->isolate_to_peer_link;
mclagd_lif.is_traffic_disable = lif_peer->is_traffic_disable;
Expand Down
1 change: 1 addition & 0 deletions src/iccpd/src/iccp_ifm.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ static void do_ndisc_learn_from_kernel(struct ndmsg *ndm, struct rtattr *tb[], i
{
ICCPD_LOG_DEBUG(__FUNCTION__, "Ignoring neighbor entry due to bcast lladdr");
msgtype = RTM_DELNEIGH;
return;
}

if ((strncmp(ndisc_msg->ifname, VLAN_PREFIX, strlen(VLAN_PREFIX)) == 0)) {
Expand Down
94 changes: 0 additions & 94 deletions src/iccpd/src/iccp_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,63 +1222,6 @@ int iccp_check_if_addr_from_netlink(int family, uint8_t *addr, struct LocalInter
return 0;
}

#if 0
int iccp_local_if_addr_update(struct nl_msg *msg, void *arg)
{
int len;
struct ifaddrmsg *ifa;
struct LocalInterface *lif;

struct nlmsghdr *n = nlmsg_hdr(msg);

if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR)
return 0;

ifa = NLMSG_DATA(n);

if (ifa->ifa_family != AF_INET )
return 0;

lif = local_if_find_by_ifindex(ifa->ifa_index);
if (!lif)
{
return 0;
}

if (n->nlmsg_type == RTM_DELADDR)
{
lif->ipv4_addr = 0;
lif->prefixlen = 0;
lif->l3_mode = 0;
memset(lif->l3_mac_addr, 0, ETHER_ADDR_LEN);
}

len = n->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));
if (len < 0)
return 0;

struct rtattr *rth = IFA_RTA(ifa);
int rtl = IFA_PAYLOAD(n);

while (rtl && RTA_OK(rth, rtl))
{
if (rth->rta_type == IFA_ADDRESS)
{
uint32_t ipaddr = ntohl(*((uint32_t *)RTA_DATA(rth)));
lif->ipv4_addr = ipaddr;
lif->prefixlen = ifa->ifa_prefixlen;
lif->l3_mode = 1;
lif->port_config_sync = 1;
update_if_ipmac_on_standby(lif);
ICCPD_LOG_DEBUG(__FUNCTION__, "If name %s index %d ip %s", lif->name, lif->ifindex, show_ip_str(htonl(lif->ipv4_addr)));
}
rth = RTA_NEXT(rth, rtl);
}

return 0;
}
#endif

int iccp_del_self_ip_from_neigh_table (struct LocalInterface *lif, int addr_family)
{
struct System *sys = NULL;
Expand Down Expand Up @@ -1788,44 +1731,7 @@ int iccp_system_init_netlink_socket()
ICCPD_LOG_ERR(__FUNCTION__, "Failed to set buffer size of netlink event sock.");
goto err_return;
}
#if 0
sys->family = genl_ctrl_resolve(sys->genric_sock, TEAM_GENL_NAME);
while (sys->family < 0)
{
sleep(1);
log_err_period++;
/*If no portchannel configuration, teamd will not started, genl_ctrl_resolve() will return <0 forever */
/*Only log error message 5 times*/
if (log_err_period == 1 && log_err_time < 5)
{
ICCPD_LOG_ERR(__FUNCTION__, "Failed to resolve netlink family. %d of TEAM_GENL_NAME %s ", sys->family, TEAM_GENL_NAME);
log_err_time++;
}
else
{
/*Log error message every 30s per time*/
if (log_err_period == 30)
log_err_period = 0;
}

sys->family = genl_ctrl_resolve(sys->genric_sock, TEAM_GENL_NAME);
}

grp_id = genl_ctrl_resolve_grp(sys->genric_sock, TEAM_GENL_NAME,
TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME);
if (grp_id < 0)
{
ICCPD_LOG_ERR(__FUNCTION__, "Failed to resolve netlink multicast groups. %d", grp_id);
goto err_return;
}

err = nl_socket_add_membership(sys->genric_event_sock, grp_id);
if (err < 0)
{
ICCPD_LOG_ERR(__FUNCTION__, "Failed to add netlink membership.");
goto err_return;
}
#endif
nl_socket_disable_seq_check(sys->genric_event_sock);
nl_socket_modify_cb(sys->genric_event_sock, NL_CB_VALID, NL_CB_CUSTOM,
iccp_genric_event_handler, sys);
Expand Down
2 changes: 1 addition & 1 deletion src/iccpd/src/mclagdctl/mclagdctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ int main(int argc, char **argv)

ret = EXIT_SUCCESS;

mclagdctl_disconnect:
mclagdctl_disconnect:
mclagdctl_sock_close();

if (rcv_buf)
Expand Down
6 changes: 0 additions & 6 deletions src/iccpd/src/mlacp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,12 +992,6 @@ void mlacp_enqueue_msg(struct CSM* csm, struct Msg* msg)
if (msg == NULL )
return;

#if 0
icc_hdr = (ICCHdr*)msg->buf;
icc_param = (ICCParameter*)&msg->buf[sizeof(ICCHdr)];
ICCPD_LOG_DEBUG("mlacp_fsm", " mLACP enqueue: tlv = 0x%04x", icc_param->type);
#endif

TAILQ_INSERT_TAIL(&(MLACP(csm).mlacp_msg_list), msg, tail);

return;
Expand Down
7 changes: 3 additions & 4 deletions src/iccpd/src/mlacp_sync_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ int mlacp_fsm_update_Agg_conf(struct CSM* csm, mLACPAggConfigTLV* portconf)
mlacp_peer_mlag_intf_delete_handler(csm, pif->name);

/* Delete remote interface info from STATE_DB */
if (csm)
mlacp_link_del_remote_if_info(csm->mlag_id, pif->name);
mlacp_link_del_remote_if_info(csm->mlag_id, pif->name);
peer_if_destroy(pif);
}
else
Expand Down Expand Up @@ -800,7 +799,7 @@ int mlacp_fsm_update_arp_entry(struct CSM* csm, struct ARPMsg *arp_entry)
if (err < 0)
{
if (err != ICCP_NLE_SEQ_MISMATCH) {
ICCPD_LOG_NOTICE(__FUNCTION__, "ARP add failure for %s %s %s, status %d",
ICCPD_LOG_ERR(__FUNCTION__, "ARP add failure for %s %s %s, status %d",
arp_entry->ifname, show_ip_str(arp_entry->ipv4_addr), mac_str, err);
return MCLAG_ERROR;
}
Expand All @@ -818,7 +817,7 @@ int mlacp_fsm_update_arp_entry(struct CSM* csm, struct ARPMsg *arp_entry)
if (err < 0)
{
if (err != ICCP_NLE_SEQ_MISMATCH) {
ICCPD_LOG_NOTICE(__FUNCTION__, "ARP delete failure for %s %s %s, status %d",
ICCPD_LOG_ERR(__FUNCTION__, "ARP delete failure for %s %s %s, status %d",
arp_entry->ifname, show_ip_str(arp_entry->ipv4_addr), mac_str, err);
return MCLAG_ERROR;
}
Expand Down
16 changes: 8 additions & 8 deletions src/iccpd/src/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int scheduler_csm_read_callback(struct CSM* csm)

return 1;

recv_err:
recv_err:
scheduler_session_disconnect_handler(csm);
return MCLAG_ERROR;
}
Expand Down Expand Up @@ -310,12 +310,12 @@ int scheduler_server_accept()
/* Accept*/
goto accept_client;

reject_client:
reject_client:
if (new_fd >= 0)
close(new_fd);
return MCLAG_ERROR;

accept_client:
accept_client:
session_conn_thread_lock(&csm->conn_mutex);
ICCPD_LOG_INFO(__FUNCTION__, "Server Accept, SocketFD [%d], %p", new_fd, csm);

Expand Down Expand Up @@ -522,7 +522,7 @@ int mlacp_sync_with_kernel_callback()
}
}

out:
out:
return 0;
}

Expand Down Expand Up @@ -642,13 +642,13 @@ void session_client_conn_handler(struct CSM *csm)
goto conn_ok;
}

conn_fail:
conn_fail:
if (connFd >= 0)
{
csm->sock_fd = -1;
close(connFd);
}
conn_ok:
conn_ok:
time(&csm->connTimePrev);
session_conn_thread_unlock(&csm->conn_mutex);
return;
Expand Down Expand Up @@ -701,11 +701,11 @@ int scheduler_prepare_session(struct CSM* csm)
session_conn_thread_unlock(&csm->conn_mutex);
}

time_update:
time_update:
time(&csm->connTimePrev);
return 0;

no_time_update:
no_time_update:
return 0;
}

Expand Down

0 comments on commit c2ac46b

Please sign in to comment.