IPACM/IPANAT: Fix using syslog causing crash
Before IPACM/IPANAT use the same syslog
circular buffer to log messages, now they
write the info to different files using
circular memory instead.
Change-Id: I8b637be2aa12d7e4999799b4b780133446422d2a
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
Signed-off-by: Ravi Gummadidala <rgummadi@codeaurora.org>
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
old mode 100755
new mode 100644
index 4717db0..0decb50
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -300,7 +300,7 @@
/* Reset the matched entry */
memset(pNatIfaces[i].iface_name, 0, IPA_IFACE_NAME_LEN);
- for (i; i < ipa_nat_iface_entries - 1; i++)
+ for (; i < ipa_nat_iface_entries - 1; i++)
{
memcpy(pNatIfaces[i].iface_name,
pNatIfaces[i + 1].iface_name, IPA_IFACE_NAME_LEN);
diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp
old mode 100755
new mode 100644
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
old mode 100755
new mode 100644
index 56eeb4d..ace8a68
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -578,9 +578,9 @@
if(cnt == MAX_NAT_IFACES)
{
- IPACM_ConntrackClient::iptodot("ProcessTCPorUDPMsg(): ignoring iface with ip address",
- nat_iface_ipv4_addr[cnt]);
- return;
+ IPACM_ConntrackClient::iptodot("ProcessTCPorUDPMsg(): ignoring nat rule with private ip",
+ rule.private_ip);
+ return;
}
IPACMDBG("Nat Entry with below information will be added\n");
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
old mode 100755
new mode 100644
index f82d7da..3f027e3
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp
@@ -201,13 +201,11 @@
CHK_TBL_HDL();
-#ifdef IPACM_DEBUG
IPACMDBG("Received below nat entry for deletion\n");
IPACM_ConntrackClient::iptodot("Private IP", rule->private_ip);
IPACM_ConntrackClient::iptodot("Target IP", rule->target_ip);
IPACMDBG("Private Port: %d\t Target Port: %d\t", rule->private_port, rule->target_port);
IPACMDBG("protocolcol: %d\n", rule->protocol);
-#endif
for(; cnt < max_entries; cnt++)
{
@@ -345,8 +343,6 @@
return -1;
}
-
-#ifdef IPACM_DEBUG
if(cache[cnt].enabled == true)
{
IPACMDBG("Added below rule successfully\n");
@@ -356,7 +352,6 @@
IPACMDBG("Public Port:%d\n", rule->public_port);
IPACMDBG("protocol: %d\n", rule->protocol);
}
-#endif
return 0;
}
@@ -365,11 +360,9 @@
{
int ret;
-#ifdef IPACM_DEBUG
IPACM_ConntrackClient::iptodot("Private IP:", rule->private_ip);
IPACM_ConntrackClient::iptodot("Target IP:", rule->target_ip);
IPACMDBG("Private Port: %d, Target Port: %d\n", rule->private_port, rule->target_port);
-#endif
if(!ct_hdl)
{
@@ -603,14 +596,12 @@
}
cache[cnt].enabled = true;
-#ifdef IPACM_DEBUG
IPACMDBG("On power reset added below rule successfully\n");
IPACM_ConntrackClient::iptodot("Private IP", nat_rule.private_ip);
IPACM_ConntrackClient::iptodot("Target IP", nat_rule.target_ip);
IPACMDBG("Private Port:%d \t Target Port: %d\t", nat_rule.private_port, nat_rule.target_port);
IPACMDBG("Public Port:%d\n", nat_rule.public_port);
IPACMDBG("protocol: %d\n", nat_rule.protocol);
-#endif
}
}
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
old mode 100755
new mode 100644
index 3328a01..154e77a
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -526,10 +526,11 @@
int res = IPACM_SUCCESS, len = 0;
struct ipa_flt_rule_add flt_rule_entry;
ipa_ioc_add_flt_rule *m_pFilteringTable;
- /* Adding this hack because WLAN may not registered for Rx-endpoint, other ifaces will always have*/
- char *dev_wlan0="wlan0";
- char *dev_wlan1="wlan1";
- char *dev_ecm0="ecm0";
+
+ /* Adding this hack because WLAN may not registered for Rx-endpoint, other ifaces will always have*/
+ const char *dev_wlan0="wlan0";
+ const char *dev_wlan1="wlan1";
+ const char *dev_ecm0="ecm0";
/* update the iface ip-type to be IPA_IP_v4, IPA_IP_v6 or both*/
if (iptype == IPA_IP_v4)
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
old mode 100755
new mode 100644
diff --git a/ipacm/src/IPACM_Log.cpp b/ipacm/src/IPACM_Log.cpp
index b777540..72f71c5 100644
--- a/ipacm/src/IPACM_Log.cpp
+++ b/ipacm/src/IPACM_Log.cpp
@@ -41,75 +41,8 @@
#include <stdlib.h>
#include <unistd.h>
-/* write logging to a local file */
-#define LOG_USE_FILE "/etc/IPACM_LOG_F"
-#define FILE_NAME "/usr/ipacm_log.txt"
-
-/* To use syslog for logging and
- use logread cmd to read */
-#define LOG_USE_SYS "/etc/IPACM_LOG_S"
-
-/* Maximum log file size. 1MB(1048576) */
-#define MAX_LOG_FILE_SIZE (1048576ul/4)
-
-char log_buf[LOG_SIZE];
-
-void logmessage(char *msg, int log_level)
+void logmessage(int log_level)
{
-#ifdef DEBUG
- static FILE *fp = NULL;
- static bool is_sys_log_open = false;
- int log_sys = 0, log_file = 0;
-
- printf("%s\n", msg);
-
- if(access(LOG_USE_SYS, F_OK) != -1 )
- {
- log_sys = 1;
- }
- else if(access(LOG_USE_FILE, F_OK) != -1)
- {
- log_file = 1;
- }
- else
- {
- log_sys = 0;
- log_file = 0;
- }
-
- if(log_sys)
- {
- if(is_sys_log_open == false)
- {
- setlogmask(LOG_UPTO(LOG_DEBUG));
- openlog("IPACM", LOG_PID, LOG_LOCAL0);
-
- is_sys_log_open = true;
- }
- syslog(log_level, msg);
- }
- else if(log_file)
- {
- if(fp == NULL)
- {
- fp = fopen(FILE_NAME, "w+");
- if(fp == NULL)
- {
- printf("unable to open file\n");
- return;
- }
- }
-
- if(ftell(fp) > MAX_LOG_FILE_SIZE)
- {
- rewind(fp);
- fprintf(fp, "====Rewinding=====\n");
- }
-
- fprintf(fp, msg);
- fflush(fp);
- }
-#endif
return;
}
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
old mode 100755
new mode 100644
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
old mode 100755
new mode 100644
diff --git a/ipacm/src/IPACM_Xml.cpp b/ipacm/src/IPACM_Xml.cpp
old mode 100755
new mode 100644
diff --git a/ipacm/src/IPACM_cfg.xml b/ipacm/src/IPACM_cfg.xml
old mode 100755
new mode 100644
diff --git a/ipacm/src/Makefile.am b/ipacm/src/Makefile.am
index 1eac45a..3811c40 100644
--- a/ipacm/src/Makefile.am
+++ b/ipacm/src/Makefile.am
@@ -2,7 +2,7 @@
-I$(top_srcdir)/ipanat/inc \
${LIBXML_CFLAGS}
AM_CPPFLAGS += -Wall -Wundef -Wno-trigraphs
-AM_CPPFLAGS += -DDEBUG
+#AM_CPPFLAGS += -DDEBUG
ipacm_SOURCES = IPACM_Main.cpp \
IPACM_Conntrack_NATApp.cpp\