Updated correct return error and target name 98/164098/1 accepted/tizen/unified/20171219.072626 submit/tizen/20171218.085650
authorhyunuktak <hyunuk.tak@samsung.com>
Fri, 15 Dec 2017 08:31:43 +0000 (17:31 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Fri, 15 Dec 2017 08:31:48 +0000 (17:31 +0900)
Change-Id: I562edf8699c41b1c83d14997a84fb7d5524375fb
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/stc-iptables-log.h
packaging/stc-iptables.spec
src/stc-iptables-util.c
test/stc_ipt_gdbus.c
test/stc_ipt_rule.c

index 1919190..c2db213 100755 (executable)
@@ -40,7 +40,7 @@ void stc_iptables_log_cleanup(void);
 #define STC_LOGW(format, args...) __LOG(LOG_WARN, format, ##args)
 #define STC_LOGE(format, args...) __LOG(LOG_ERROR, format, ##args)
        
-#define __STC_LOG_FUNC_ENTER__ __LOG(LOG_DEBUG, "Enter")
-#define __STC_LOG_FUNC_EXIT__ __LOG(LOG_DEBUG, "Quit")
+#define __STC_LOG_FUNC_ENTER__ /* __LOG(LOG_DEBUG, "Enter") */
+#define __STC_LOG_FUNC_EXIT__ /* __LOG(LOG_DEBUG, "Quit") */
 
 #endif /* __STC_IPTABLES_LOG_H__ */
index 2f4b907..29b61fa 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-iptables
 Summary:    STC(Smart Traffic Control) iptables
-Version:    0.0.9
+Version:    0.0.10
 Release:    0
 Group:      Network & Connectivity/Other
 License:    GPL-2.0+
index 7dd1638..78dac42 100755 (executable)
@@ -149,12 +149,16 @@ gboolean handle_iptables_add_rule(StcRule *object,
                                STC_LOGE("Failed add rule [%s:%d:%s:%d:%s:%s]", rule->chain,
                                         rule->type, rule->ifname, rule->classid,
                                         rule->nfacct_name, rule->target);
-                       }
 
-                       FREE(rule->chain);
-                       FREE(rule->ifname);
-                       FREE(rule->nfacct_name);
-                       FREE(rule->target);
+                               FREE(rule->chain);
+                               FREE(rule->ifname);
+                               FREE(rule->nfacct_name);
+                               FREE(rule->target);
+
+                               STC_IPTABLES_DBUS_REPLY_ERROR(invocation, ret);
+                               __STC_LOG_FUNC_EXIT__;
+                               return TRUE;
+                       }
                }
 
                g_variant_iter_free(iter);
@@ -200,12 +204,16 @@ gboolean handle_iptables_remove_rule(StcRule *object,
                                STC_LOGE("Failed remove rule [%s:%d:%s:%d:%s:%s]", rule->chain,
                                         rule->type, rule->ifname, rule->classid,
                                         rule->nfacct_name, rule->target);
-                       }
 
-                       FREE(rule->chain);
-                       FREE(rule->ifname);
-                       FREE(rule->nfacct_name);
-                       FREE(rule->target);
+                               FREE(rule->chain);
+                               FREE(rule->ifname);
+                               FREE(rule->nfacct_name);
+                               FREE(rule->target);
+
+                               STC_IPTABLES_DBUS_REPLY_ERROR(invocation, ret);
+                               __STC_LOG_FUNC_EXIT__;
+                               return TRUE;
+                       }
                }
 
                g_variant_iter_free(iter);
@@ -327,12 +335,16 @@ gboolean handle_ip6tables_add_rule(StcRule *object,
                                STC_LOGE("Failed add rule [%s:%d:%s:%d:%s:%s]", rule->chain,
                                         rule->type, rule->ifname, rule->classid,
                                         rule->nfacct_name, rule->target);
-                       }
 
-                       FREE(rule->chain);
-                       FREE(rule->ifname);
-                       FREE(rule->nfacct_name);
-                       FREE(rule->target);
+                               FREE(rule->chain);
+                               FREE(rule->ifname);
+                               FREE(rule->nfacct_name);
+                               FREE(rule->target);
+
+                               STC_IPTABLES_DBUS_REPLY_ERROR(invocation, ret);
+                               __STC_LOG_FUNC_EXIT__;
+                               return TRUE;
+                       }
                }
 
                g_variant_iter_free(iter);
@@ -378,12 +390,16 @@ gboolean handle_ip6tables_remove_rule(StcRule *object,
                                STC_LOGE("Failed remove rule [%s:%d:%s:%d:%s:%s]", rule->chain,
                                         rule->type, rule->ifname, rule->classid,
                                         rule->nfacct_name, rule->target);
-                       }
 
-                       FREE(rule->chain);
-                       FREE(rule->ifname);
-                       FREE(rule->nfacct_name);
-                       FREE(rule->target);
+                               FREE(rule->chain);
+                               FREE(rule->ifname);
+                               FREE(rule->nfacct_name);
+                               FREE(rule->target);
+
+                               STC_IPTABLES_DBUS_REPLY_ERROR(invocation, ret);
+                               __STC_LOG_FUNC_EXIT__;
+                               return TRUE;
+                       }
                }
 
                g_variant_iter_free(iter);
index c168743..73920ef 100755 (executable)
@@ -28,7 +28,7 @@ static __thread stc_ipt_dbus_conn_data_s g_stc_ipt_dbus_conn = { NULL, NULL };
 
 static int __stc_ipt_convert_error_string_to_enum(const char *error)
 {
-       msg("Passed error value [%s]", error);
+       /* msg("Passed error value [%s]", error); */
 
        if (NULL != strstr(error, "NoReply"))
                return STC_ERROR_INVALID_OPERATION;
index f9bab72..d486736 100755 (executable)
@@ -85,10 +85,14 @@ static void __test_print_rule(ipt_rule_s *rule)
                msg("Type   : [IN]");
        else if (rule->type == IPTABLES_RULE_OUT)
                msg("Type   : [OUT]");
-       msg("Ifname : [%s]", rule->ifname);
-       msg("Cgroup : [%d]", rule->classid);
-       msg("Nfacct : [%s]", rule->nfacct_name);
-       msg("Target : [%s]", rule->target);
+       if (rule->ifname)
+               msg("Ifname : [%s]", rule->ifname);
+       if (rule->classid > 0)
+               msg("Cgroup : [%d]", rule->classid);
+       if (rule->nfacct_name)
+               msg("Nfacct : [%s]", rule->nfacct_name);
+       if (rule->target)
+               msg("Target : [%s]", rule->target);
 
        msg(HR_SINGLE);
 }
@@ -101,7 +105,6 @@ static void __test_rule_free(ipt_rule_s *rule)
        FREE(rule->target);
 
        FREE(rule);
-       rule = NULL;
 }
 
 static int __test_set_rule(void)
@@ -146,7 +149,7 @@ static int __test_set_rule(void)
                g_rule->target = g_strdup(TARGET_DROP);
                break;
        default:
-               g_rule->target = NULL;
+               g_rule->target = g_strdup("");
                break;
        }
 
@@ -217,10 +220,8 @@ static int __stc_ipt_add_rule(void)
                        params,
                        &err);
 
-       if (message == NULL) {
-               msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+       if (message == NULL)
                return err;
-       }
 
        stc_ipt_exe_cmd(CHECK_IPTABLES);
 
@@ -252,10 +253,8 @@ static int __stc_ip6t_add_rule(void)
                        params,
                        &err);
 
-       if (message == NULL) {
-               msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+       if (message == NULL)
                return err;
-       }
 
        stc_ipt_exe_cmd(CHECK_IP6TABLES);
 
@@ -288,10 +287,8 @@ static int __stc_ipt_remove_rule(void)
                        params,
                        &err);
 
-       if (message == NULL) {
-               msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+       if (message == NULL)
                return err;
-       }
 
        stc_ipt_exe_cmd(CHECK_IPTABLES);
 
@@ -324,10 +321,8 @@ static int __stc_ip6t_remove_rule(void)
                        params,
                        &err);
 
-       if (message == NULL) {
-               msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+       if (message == NULL)
                return err;
-       }
 
        stc_ipt_exe_cmd(CHECK_IP6TABLES);