From 1d5df139159749e99e475f6112c9afd395ddd543 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Thu, 21 Sep 2017 14:15:51 +0900 Subject: [PATCH] Set STC_DEBUG_LOG flag Change-Id: Ic4cfd5f7eb3fa1014db9486479d567e092486e1c Signed-off-by: hyunuktak --- include/stc-manager.h | 2 ++ packaging/stc-manager.spec | 2 +- src/helper/helper-cgroup.c | 6 ++++++ src/helper/helper-nfacct-rule.c | 14 ++++++++++---- src/monitor/stc-monitor.c | 8 ++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/stc-manager.h b/include/stc-manager.h index 990db68..37e5d97 100755 --- a/include/stc-manager.h +++ b/include/stc-manager.h @@ -31,6 +31,8 @@ #define STC_TOTAL_IPV4 "TOTAL_IPV4" #define STC_TOTAL_IPV6 "TOTAL_IPV6" +#define STC_DEBUG_LOG 0 + typedef enum { STC_CANCEL = 0, /**< cancel */ STC_CONTINUE = 1, /**< continue */ diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 4a256b3..d0e6065 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.0.34 +Version: 0.0.35 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/helper/helper-cgroup.c b/src/helper/helper-cgroup.c index aa01d16..c636bc2 100755 --- a/src/helper/helper-cgroup.c +++ b/src/helper/helper-cgroup.c @@ -116,7 +116,9 @@ int cgroup_write_node_uint32(const char *cgroup_name, { char buf[MAX_PATH_LENGTH]; snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); +#if STC_DEBUG_LOG STC_LOGD("cgroup_buf %s, value %d\n", buf, value); +#endif return fwrite_uint(buf, value); } @@ -125,7 +127,9 @@ int cgroup_write_node_str(const char *cgroup_name, { char buf[MAX_PATH_LENGTH]; snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); +#if STC_DEBUG_LOG STC_LOGD("cgroup_buf %s, string %s\n", buf, string); +#endif return fwrite_str(buf, string); } @@ -136,7 +140,9 @@ int cgroup_read_node_uint32(const char *cgroup_name, int ret; snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name); ret = fread_uint(buf, value); +#if STC_DEBUG_LOG STC_LOGD("cgroup_buf %s, value %d\n", buf, *value); +#endif return ret; } diff --git a/src/helper/helper-nfacct-rule.c b/src/helper/helper-nfacct-rule.c index a2a598f..a8474a1 100755 --- a/src/helper/helper-nfacct-rule.c +++ b/src/helper/helper-nfacct-rule.c @@ -156,7 +156,9 @@ stc_error_e nfacct_send_del(nfacct_rule_s *counter) { struct genl req; +#if STC_DEBUG_LOG STC_LOGD("send remove request for %s", counter->name); +#endif prepare_netlink_msg(&req, NFNL_MSG_ACCT_DEL, NLM_F_ACK); add_string_attr(&req, counter->name, NFACCT_NAME); @@ -432,7 +434,9 @@ static bool is_rule_present(const char *cmd_buf) strncpy(exec_buf + (cmd_pos - cmd_buf), IPTABLES_CHECK, sizeof(IPTABLES_CHECK) - 1); +#if STC_DEBUG_LOG STC_LOGD("check rule %s", exec_buf); +#endif args = g_strsplit_set(exec_buf, " ", -1); @@ -468,8 +472,9 @@ stc_error_e exec_iptables_cmd(const char *cmd_buf, pid_t *cmd_pid) int ret; char *save_ptr = NULL; - STC_LOGD("executing iptables cmd %s in forked process", - cmd_buf); +#if STC_DEBUG_LOG + STC_LOGD("executing iptables cmd %s in forked process", cmd_buf); +#endif if (is_rule_present(cmd_buf)) { STC_LOGD("Rule %s already present", cmd_buf); @@ -518,8 +523,9 @@ stc_error_e exec_ip6tables_cmd(const char *cmd_buf, pid_t *cmd_pid) int ret; char *save_ptr = NULL; - STC_LOGD("executing ip6tables cmd %s in forked process", - cmd_buf); +#if STC_DEBUG_LOG + STC_LOGD("executing ip6tables cmd %s in forked process", cmd_buf); +#endif if (is_rule_present(cmd_buf)) { STC_LOGD("Rule %s already present", cmd_buf); diff --git a/src/monitor/stc-monitor.c b/src/monitor/stc-monitor.c index fc7b7bb..0e34821 100755 --- a/src/monitor/stc-monitor.c +++ b/src/monitor/stc-monitor.c @@ -292,6 +292,7 @@ static void __processes_tree_printall(GTree *processes) g_tree_foreach(processes, __processes_tree_foreach_print, NULL); } +#if STC_DEBUG_LOG static gboolean __apps_tree_foreach_print(gpointer key, gpointer value, gpointer data) { @@ -308,6 +309,7 @@ static gboolean __apps_tree_foreach_print(gpointer key, gpointer value, __processes_tree_printall(app_value->processes); return FALSE; } +#endif #if 0 static void __apps_tree_printall(void) @@ -323,7 +325,9 @@ static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value, stc_app_value_s *app_value = (stc_app_value_s *)value; if (!g_tree_remove(app_value->processes, context->proc_key)) { +#if STC_DEBUG_LOG STC_LOGD("key not found"); +#endif return FALSE; } @@ -964,14 +968,18 @@ static void __app_counter_update(stc_app_key_s *app_key, app_value->counter.in_bytes = context->bytes; g_system->apps_tree_updated = TRUE; +#if STC_DEBUG_LOG __apps_tree_foreach_print(app_key, app_value, NULL); +#endif break; case NFACCT_COUNTER_OUT: app_value->data_usage.out_bytes += context->bytes; app_value->counter.out_bytes = context->bytes; g_system->apps_tree_updated = TRUE; +#if STC_DEBUG_LOG __apps_tree_foreach_print(app_key, app_value, NULL); +#endif break; default: STC_LOGE("unknown iotype"); -- 2.7.4