Skip to content

Commit c2ac46b

Browse files
committed
Addressed review comments
1 parent 27e45d9 commit c2ac46b

File tree

8 files changed

+25
-125
lines changed

8 files changed

+25
-125
lines changed

src/iccpd/src/iccp_cli.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int set_peer_link(int mid, const char* ifname)
8585

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

src/iccpd/src/iccp_cmd_show.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -499,23 +499,23 @@ int iccp_local_if_dump(char * *buf, int *num, int mclag_id)
499499
mclagd_lif.ifindex = lif_peer->ifindex;
500500

501501
if (lif_peer->type == IF_T_UNKNOW)
502-
memcpy(mclagd_lif.type, "Unknown", 6);
502+
memcpy(mclagd_lif.type, "Unknown", strlen("unknown"));
503503
else if (lif_peer->type == IF_T_PORT)
504-
memcpy(mclagd_lif.type, "Ethernet", 8);
504+
memcpy(mclagd_lif.type, "Ethernet", strlen("Ethernet"));
505505
else if (lif_peer->type == IF_T_PORT_CHANNEL)
506506
memcpy(mclagd_lif.type, "PortChannel", 11);
507507

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

511511
if (lif_peer->state == PORT_STATE_UP)
512-
memcpy(mclagd_lif.state, "Up", 2);
512+
memcpy(mclagd_lif.state, "Up", strlen("Up"));
513513
else if (lif_peer->state == PORT_STATE_DOWN)
514-
memcpy(mclagd_lif.state, "Down", 4);
514+
memcpy(mclagd_lif.state, "Down", strlen("Down"));
515515
else if (lif_peer->state == PORT_STATE_ADMIN_DOWN)
516-
memcpy(mclagd_lif.state, "Admin-down", 10);
516+
memcpy(mclagd_lif.state, "Admin-down", strlen("Admin-down"));
517517
else if (lif_peer->state == PORT_STATE_TEST)
518-
memcpy(mclagd_lif.state, "Test", 4);
518+
memcpy(mclagd_lif.state, "Test", strlen("Test"));
519519

520520
memcpy(mclagd_lif.ipv4_addr, show_ip_str(lif_peer->ipv4_addr), 16);
521521
mclagd_lif.prefixlen = lif_peer->prefixlen;
@@ -530,15 +530,15 @@ int iccp_local_if_dump(char * *buf, int *num, int mclag_id)
530530
mclagd_lif.po_active = lif_peer->po_active;
531531
/*mlacp_state*/
532532
if (lif_peer->mlacp_state == MLACP_STATE_INIT)
533-
memcpy(mclagd_lif.mlacp_state, "INIT", 4);
533+
memcpy(mclagd_lif.mlacp_state, "INIT", strlen("INIT"));
534534
else if (lif_peer->mlacp_state == MLACP_STATE_STAGE1)
535-
memcpy(mclagd_lif.mlacp_state, "STAGE1", 6);
535+
memcpy(mclagd_lif.mlacp_state, "STAGE1", strlen("STAGE1"));
536536
else if (lif_peer->mlacp_state == MLACP_STATE_STAGE2)
537-
memcpy(mclagd_lif.mlacp_state, "STAGE2", 6);
537+
memcpy(mclagd_lif.mlacp_state, "STAGE2", strlen("STAGE2"));
538538
else if (lif_peer->mlacp_state == MLACP_STATE_EXCHANGE)
539-
memcpy(mclagd_lif.mlacp_state, "EXCHANGE", 8);
539+
memcpy(mclagd_lif.mlacp_state, "EXCHANGE", strlen("EXCHANGE"));
540540
else if (lif_peer->mlacp_state == MLACP_STATE_ERROR)
541-
memcpy(mclagd_lif.mlacp_state, "ERROR", 5);
541+
memcpy(mclagd_lif.mlacp_state, "ERROR", strlen("ERROR"));
542542

543543
mclagd_lif.isolate_to_peer_link = lif_peer->isolate_to_peer_link;
544544
mclagd_lif.is_traffic_disable = lif_peer->is_traffic_disable;

src/iccpd/src/iccp_ifm.c

+1
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ static void do_ndisc_learn_from_kernel(struct ndmsg *ndm, struct rtattr *tb[], i
436436
{
437437
ICCPD_LOG_DEBUG(__FUNCTION__, "Ignoring neighbor entry due to bcast lladdr");
438438
msgtype = RTM_DELNEIGH;
439+
return;
439440
}
440441

441442
if ((strncmp(ndisc_msg->ifname, VLAN_PREFIX, strlen(VLAN_PREFIX)) == 0)) {

src/iccpd/src/iccp_netlink.c

-94
Original file line numberDiff line numberDiff line change
@@ -1222,63 +1222,6 @@ int iccp_check_if_addr_from_netlink(int family, uint8_t *addr, struct LocalInter
12221222
return 0;
12231223
}
12241224

1225-
#if 0
1226-
int iccp_local_if_addr_update(struct nl_msg *msg, void *arg)
1227-
{
1228-
int len;
1229-
struct ifaddrmsg *ifa;
1230-
struct LocalInterface *lif;
1231-
1232-
struct nlmsghdr *n = nlmsg_hdr(msg);
1233-
1234-
if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR)
1235-
return 0;
1236-
1237-
ifa = NLMSG_DATA(n);
1238-
1239-
if (ifa->ifa_family != AF_INET )
1240-
return 0;
1241-
1242-
lif = local_if_find_by_ifindex(ifa->ifa_index);
1243-
if (!lif)
1244-
{
1245-
return 0;
1246-
}
1247-
1248-
if (n->nlmsg_type == RTM_DELADDR)
1249-
{
1250-
lif->ipv4_addr = 0;
1251-
lif->prefixlen = 0;
1252-
lif->l3_mode = 0;
1253-
memset(lif->l3_mac_addr, 0, ETHER_ADDR_LEN);
1254-
}
1255-
1256-
len = n->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));
1257-
if (len < 0)
1258-
return 0;
1259-
1260-
struct rtattr *rth = IFA_RTA(ifa);
1261-
int rtl = IFA_PAYLOAD(n);
1262-
1263-
while (rtl && RTA_OK(rth, rtl))
1264-
{
1265-
if (rth->rta_type == IFA_ADDRESS)
1266-
{
1267-
uint32_t ipaddr = ntohl(*((uint32_t *)RTA_DATA(rth)));
1268-
lif->ipv4_addr = ipaddr;
1269-
lif->prefixlen = ifa->ifa_prefixlen;
1270-
lif->l3_mode = 1;
1271-
lif->port_config_sync = 1;
1272-
update_if_ipmac_on_standby(lif);
1273-
ICCPD_LOG_DEBUG(__FUNCTION__, "If name %s index %d ip %s", lif->name, lif->ifindex, show_ip_str(htonl(lif->ipv4_addr)));
1274-
}
1275-
rth = RTA_NEXT(rth, rtl);
1276-
}
1277-
1278-
return 0;
1279-
}
1280-
#endif
1281-
12821225
int iccp_del_self_ip_from_neigh_table (struct LocalInterface *lif, int addr_family)
12831226
{
12841227
struct System *sys = NULL;
@@ -1788,44 +1731,7 @@ int iccp_system_init_netlink_socket()
17881731
ICCPD_LOG_ERR(__FUNCTION__, "Failed to set buffer size of netlink event sock.");
17891732
goto err_return;
17901733
}
1791-
#if 0
1792-
sys->family = genl_ctrl_resolve(sys->genric_sock, TEAM_GENL_NAME);
1793-
while (sys->family < 0)
1794-
{
1795-
sleep(1);
1796-
log_err_period++;
1797-
/*If no portchannel configuration, teamd will not started, genl_ctrl_resolve() will return <0 forever */
1798-
/*Only log error message 5 times*/
1799-
if (log_err_period == 1 && log_err_time < 5)
1800-
{
1801-
ICCPD_LOG_ERR(__FUNCTION__, "Failed to resolve netlink family. %d of TEAM_GENL_NAME %s ", sys->family, TEAM_GENL_NAME);
1802-
log_err_time++;
1803-
}
1804-
else
1805-
{
1806-
/*Log error message every 30s per time*/
1807-
if (log_err_period == 30)
1808-
log_err_period = 0;
1809-
}
18101734

1811-
sys->family = genl_ctrl_resolve(sys->genric_sock, TEAM_GENL_NAME);
1812-
}
1813-
1814-
grp_id = genl_ctrl_resolve_grp(sys->genric_sock, TEAM_GENL_NAME,
1815-
TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME);
1816-
if (grp_id < 0)
1817-
{
1818-
ICCPD_LOG_ERR(__FUNCTION__, "Failed to resolve netlink multicast groups. %d", grp_id);
1819-
goto err_return;
1820-
}
1821-
1822-
err = nl_socket_add_membership(sys->genric_event_sock, grp_id);
1823-
if (err < 0)
1824-
{
1825-
ICCPD_LOG_ERR(__FUNCTION__, "Failed to add netlink membership.");
1826-
goto err_return;
1827-
}
1828-
#endif
18291735
nl_socket_disable_seq_check(sys->genric_event_sock);
18301736
nl_socket_modify_cb(sys->genric_event_sock, NL_CB_VALID, NL_CB_CUSTOM,
18311737
iccp_genric_event_handler, sys);

src/iccpd/src/mclagdctl/mclagdctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ int main(int argc, char **argv)
12731273

12741274
ret = EXIT_SUCCESS;
12751275

1276-
mclagdctl_disconnect:
1276+
mclagdctl_disconnect:
12771277
mclagdctl_sock_close();
12781278

12791279
if (rcv_buf)

src/iccpd/src/mlacp_fsm.c

-6
Original file line numberDiff line numberDiff line change
@@ -992,12 +992,6 @@ void mlacp_enqueue_msg(struct CSM* csm, struct Msg* msg)
992992
if (msg == NULL )
993993
return;
994994

995-
#if 0
996-
icc_hdr = (ICCHdr*)msg->buf;
997-
icc_param = (ICCParameter*)&msg->buf[sizeof(ICCHdr)];
998-
ICCPD_LOG_DEBUG("mlacp_fsm", " mLACP enqueue: tlv = 0x%04x", icc_param->type);
999-
#endif
1000-
1001995
TAILQ_INSERT_TAIL(&(MLACP(csm).mlacp_msg_list), msg, tail);
1002996

1003997
return;

src/iccpd/src/mlacp_sync_update.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ int mlacp_fsm_update_Agg_conf(struct CSM* csm, mLACPAggConfigTLV* portconf)
111111
mlacp_peer_mlag_intf_delete_handler(csm, pif->name);
112112

113113
/* Delete remote interface info from STATE_DB */
114-
if (csm)
115-
mlacp_link_del_remote_if_info(csm->mlag_id, pif->name);
114+
mlacp_link_del_remote_if_info(csm->mlag_id, pif->name);
116115
peer_if_destroy(pif);
117116
}
118117
else
@@ -800,7 +799,7 @@ int mlacp_fsm_update_arp_entry(struct CSM* csm, struct ARPMsg *arp_entry)
800799
if (err < 0)
801800
{
802801
if (err != ICCP_NLE_SEQ_MISMATCH) {
803-
ICCPD_LOG_NOTICE(__FUNCTION__, "ARP add failure for %s %s %s, status %d",
802+
ICCPD_LOG_ERR(__FUNCTION__, "ARP add failure for %s %s %s, status %d",
804803
arp_entry->ifname, show_ip_str(arp_entry->ipv4_addr), mac_str, err);
805804
return MCLAG_ERROR;
806805
}
@@ -818,7 +817,7 @@ int mlacp_fsm_update_arp_entry(struct CSM* csm, struct ARPMsg *arp_entry)
818817
if (err < 0)
819818
{
820819
if (err != ICCP_NLE_SEQ_MISMATCH) {
821-
ICCPD_LOG_NOTICE(__FUNCTION__, "ARP delete failure for %s %s %s, status %d",
820+
ICCPD_LOG_ERR(__FUNCTION__, "ARP delete failure for %s %s %s, status %d",
822821
arp_entry->ifname, show_ip_str(arp_entry->ipv4_addr), mac_str, err);
823822
return MCLAG_ERROR;
824823
}

src/iccpd/src/scheduler.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int scheduler_csm_read_callback(struct CSM* csm)
252252

253253
return 1;
254254

255-
recv_err:
255+
recv_err:
256256
scheduler_session_disconnect_handler(csm);
257257
return MCLAG_ERROR;
258258
}
@@ -310,12 +310,12 @@ int scheduler_server_accept()
310310
/* Accept*/
311311
goto accept_client;
312312

313-
reject_client:
313+
reject_client:
314314
if (new_fd >= 0)
315315
close(new_fd);
316316
return MCLAG_ERROR;
317317

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

@@ -522,7 +522,7 @@ int mlacp_sync_with_kernel_callback()
522522
}
523523
}
524524

525-
out:
525+
out:
526526
return 0;
527527
}
528528

@@ -642,13 +642,13 @@ void session_client_conn_handler(struct CSM *csm)
642642
goto conn_ok;
643643
}
644644

645-
conn_fail:
645+
conn_fail:
646646
if (connFd >= 0)
647647
{
648648
csm->sock_fd = -1;
649649
close(connFd);
650650
}
651-
conn_ok:
651+
conn_ok:
652652
time(&csm->connTimePrev);
653653
session_conn_thread_unlock(&csm->conn_mutex);
654654
return;
@@ -701,11 +701,11 @@ int scheduler_prepare_session(struct CSM* csm)
701701
session_conn_thread_unlock(&csm->conn_mutex);
702702
}
703703

704-
time_update:
704+
time_update:
705705
time(&csm->connTimePrev);
706706
return 0;
707707

708-
no_time_update:
708+
no_time_update:
709709
return 0;
710710
}
711711

0 commit comments

Comments
 (0)