ipacm: Fix KW issue
Fix KW issue and remove conditional check
which is always true.
Change-Id: I902b56c3eab262798813e3c9c6d920665e5ecb99
diff --git a/ipacm/src/IPACM_CmdQueue.cpp b/ipacm/src/IPACM_CmdQueue.cpp
index c612b7f..3a2d470 100644
--- a/ipacm/src/IPACM_CmdQueue.cpp
+++ b/ipacm/src/IPACM_CmdQueue.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -123,6 +123,7 @@
MessageQueue *MsgQueueExternal = NULL;
Message *item = NULL;
param = NULL;
+ const char *eventName = NULL;
IPACMDBG("MessageQueue::Process()\n");
@@ -160,8 +161,12 @@
}
else
{
- IPACMDBG("Get event %s from internal queue.\n",
- IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event));
+ eventName = IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event);
+ if (eventName != NULL)
+ {
+ IPACMDBG("Get event %s from internal queue.\n",
+ eventName);
+ }
}
if(item == NULL)
@@ -196,7 +201,7 @@
return NULL;
}
- IPACMDBG("Processing item %p event ID: %d\n",item,item->evt.data.event);
+ IPACMDBG("Processing item %pK event ID: %d\n",item,item->evt.data.event);
item->evt.callback_ptr(&item->evt.data);
delete item;
item = NULL;
diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp
index 3eab6fa..8a2499c 100644
--- a/ipacm/src/IPACM_ConntrackClient.cpp
+++ b/ipacm/src/IPACM_ConntrackClient.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -177,8 +177,6 @@
/* retrieve bridge interface ipv4 address */
memset(&ifr, 0, sizeof(struct ifreq));
ifr.ifr_addr.sa_family = AF_INET;
- (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
- IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
if(strlen(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name) >= sizeof(ifr.ifr_name))
{
@@ -187,6 +185,8 @@
close(fd);
return -1;
}
+ (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
+ IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
ret = ioctl(fd, SIOCGIFADDR, &ifr);
if (ret < 0)
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 4a0c1c1..29a70b9 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -1037,9 +1037,9 @@
nat_entry.ct = ct;
nat_entry.type = type;
- memset(&rule, 0, sizeof(rule));
- IPACMDBG("Received type:%d with proto:%d\n", type, l4proto);
- status = nfct_get_attr_u32(ct, ATTR_STATUS);
+ memset(&rule, 0, sizeof(rule));
+ IPACMDBG("Received type:%d with proto:%d\n", type, l4proto);
+ status = nfct_get_attr_u32(ct, ATTR_STATUS);
/* Retrieve Protocol */
rule.protocol = nfct_get_attr_u8(ct, ATTR_REPL_L4PROTO);
@@ -1089,47 +1089,40 @@
#ifdef CT_OPT
HandleLan2Lan(ct, type, &rule);
#endif
- return;
+ IPACMDBG("Neither source Nor destination nat\n");
+ goto IGNORE;
}
- }
+ }
- if(IPS_DST_NAT == status || IPS_SRC_NAT == status)
- {
- PopulateTCPorUDPEntry(ct, status, &rule);
- rule.public_ip = wan_ipaddr;
- }
- else
- {
- IPACMDBG("Neither source Nor destination nat\n");
- goto IGNORE;
- }
+ PopulateTCPorUDPEntry(ct, status, &rule);
+ rule.public_ip = wan_ipaddr;
- if (rule.private_ip != wan_ipaddr)
- {
- isAdd = AddIface(&rule, &nat_entry.isTempEntry);
- if (!isAdd)
- {
- goto IGNORE;
- }
- }
- else
- {
- if (isStaMode)
- {
- IPACMDBG("In STA mode, ignore connections destinated to STA interface\n");
- goto IGNORE;
- }
+ if (rule.private_ip != wan_ipaddr)
+ {
+ isAdd = AddIface(&rule, &nat_entry.isTempEntry);
+ if (!isAdd)
+ {
+ goto IGNORE;
+ }
+ }
+ else
+ {
+ if (isStaMode)
+ {
+ IPACMDBG("In STA mode, ignore connections destinated to STA interface\n");
+ goto IGNORE;
+ }
- IPACMDBG("For embedded connections add dummy nat rule\n");
- IPACMDBG("Change private port %d to %d\n",
- rule.private_port, rule.public_port);
- rule.private_port = rule.public_port;
- }
+ IPACMDBG("For embedded connections add dummy nat rule\n");
+ IPACMDBG("Change private port %d to %d\n",
+ rule.private_port, rule.public_port);
+ rule.private_port = rule.public_port;
+ }
- CheckSTAClient(&rule, &nat_entry.isTempEntry);
- nat_entry.rule = &rule;
- AddORDeleteNatEntry(&nat_entry);
- return;
+ CheckSTAClient(&rule, &nat_entry.isTempEntry);
+ nat_entry.rule = &rule;
+ AddORDeleteNatEntry(&nat_entry);
+ return;
IGNORE:
IPACMDBG_H("ignoring below Nat Entry\n");
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
index 27bf95a..4004597 100644
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -94,11 +94,7 @@
}
memset(pALGPorts, 0, sizeof(ipacm_alg) * nALGPort);
- if(pConfig->GetAlgPorts(nALGPort, pALGPorts) != 0)
- {
- IPACMERR("Unable to retrieve ALG prots\n");
- goto fail;
- }
+ pConfig->GetAlgPorts(nALGPort, pALGPorts);
IPACMDBG("Printing %d alg ports information\n", nALGPort);
for(int cnt=0; cnt<nALGPort; cnt++)
@@ -106,12 +102,23 @@
IPACMDBG("%d: Proto[%d], port[%d]\n", cnt, pALGPorts[cnt].protocol, pALGPorts[cnt].port);
}
}
+ else
+ {
+ IPACMERR("Unable to retrieve ALG prot count\n");
+ goto fail;
+ }
return 0;
fail:
- free(cache);
- free(pALGPorts);
+ if(cache != NULL)
+ {
+ free(cache);
+ }
+ if(pALGPorts != NULL)
+ {
+ free(pALGPorts);
+ }
return -1;
}
diff --git a/ipacm/src/IPACM_EvtDispatcher.cpp b/ipacm/src/IPACM_EvtDispatcher.cpp
index edb5901..2914f66 100644
--- a/ipacm/src/IPACM_EvtDispatcher.cpp
+++ b/ipacm/src/IPACM_EvtDispatcher.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -92,7 +92,7 @@
IPACMDBG("Enqueing item\n");
MsgQueue->enqueue(item);
- IPACMDBG("Enqueued item %p\n", item);
+ IPACMDBG("Enqueued item %pK\n", item);
if(pthread_cond_signal(&cond_var) != 0)
{
@@ -141,7 +141,7 @@
if(data->evt_data != NULL)
{
- IPACMDBG("free the event:%d data: %p\n", data->event, data->evt_data);
+ IPACMDBG("free the event:%d data: %pK\n", data->event, data->evt_data);
free(data->evt_data);
}
return;
diff --git a/ipacm/src/IPACM_Filtering.cpp b/ipacm/src/IPACM_Filtering.cpp
index 411fe90..3545d81 100644
--- a/ipacm/src/IPACM_Filtering.cpp
+++ b/ipacm/src/IPACM_Filtering.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -87,7 +87,7 @@
retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE, ruleTable);
if (retval != 0)
{
- IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed adding Filtering rule %pK\n", ruleTable);
PERROR("unable to add filter rule:");
for (int cnt = 0; cnt < ruleTable->num_rules; cnt++)
@@ -110,7 +110,7 @@
}
}
- IPACMDBG("Added Filtering rule %p\n", ruleTable);
+ IPACMDBG("Added Filtering rule %pK\n", ruleTable);
return true;
}
@@ -138,13 +138,13 @@
if (retval != 0)
{
- IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed adding Filtering rule %pK\n", ruleTable);
return false;
}
- IPACMDBG("Added Filtering rule %p\n", ruleTable);
+ IPACMDBG("Added Filtering rule %pK\n", ruleTable);
#else
if (ruleTable)
- IPACMERR("Not support adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Not support adding Filtering rule %pK\n", ruleTable);
#endif
return true;
}
@@ -156,11 +156,11 @@
retval = ioctl(fd, IPA_IOC_DEL_FLT_RULE, ruleTable);
if (retval != 0)
{
- IPACMERR("Failed deleting Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed deleting Filtering rule %pK\n", ruleTable);
return false;
}
- IPACMDBG("Deleted Filtering rule %p\n", ruleTable);
+ IPACMDBG("Deleted Filtering rule %pK\n", ruleTable);
return true;
}
@@ -450,7 +450,7 @@
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg);
if (ret != 0)
{
- IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_ex_msg, ret);
+ IPACMERR("Failed adding Filtering rule %pK with ret %d\n ", &qmi_rule_ex_msg, ret);
close(fd_wwan_ioctl);
return false;
}
@@ -474,12 +474,12 @@
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_INDEX, table);
if (ret != 0)
{
- IPACMERR("Failed adding filtering rule index %p with ret %d\n", table, ret);
+ IPACMERR("Failed adding filtering rule index %pK with ret %d\n", table, ret);
close(fd_wwan_ioctl);
return false;
}
- IPACMDBG("Added Filtering rule index %p\n", table);
+ IPACMDBG("Added Filtering rule index %pK\n", table);
close(fd_wwan_ioctl);
return true;
}
@@ -520,7 +520,7 @@
ret = ioctl(fd, IPA_IOC_MDFY_FLT_RULE, ruleTable);
if (ret != 0)
{
- IPACMERR("Failed modifying filtering rule %p\n", ruleTable);
+ IPACMERR("Failed modifying filtering rule %pK\n", ruleTable);
for (i = 0; i < ruleTable->num_rules; i++)
{