Creating seperate chains[STC_IN, STC_OUT, STC_FRWD] for STC Framework's rules.
[platform/core/connectivity/stc-manager.git] / src / monitor / stc-monitor.c
index 8b18657..268c5cf 100755 (executable)
@@ -23,6 +23,7 @@
 #include "helper-nfacct-rule.h"
 #include "helper-net-cls.h"
 #include "helper-cgroup.h"
+#include "helper-iptables.h"
 #include "counter.h"
 #include "table-statistics.h"
 #include "table-counters.h"
@@ -526,6 +527,10 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        char *default_ifname = stc_default_connection_get_ifname();
                        struct nfacct_rule counter;
                        stc_s *stc = stc_get_manager();
+                       if (!stc) {
+                               g_free(default_ifname);
+                               return;
+                       }
 
                        if (!stc->carg) {
                                stc->carg = MALLOC0(counter_arg_s, 1);
@@ -568,6 +573,10 @@ static void __process_restriction(enum traffic_restriction_type rst_type,
                        char *default_ifname = stc_default_connection_get_ifname();
                        struct nfacct_rule counter;
                        stc_s *stc = stc_get_manager();
+                       if (!stc) {
+                               g_free(default_ifname);
+                               return;
+                       }
 
                        if (!stc->carg) {
                                stc->carg = MALLOC0(counter_arg_s, 1);
@@ -1870,6 +1879,8 @@ void stc_monitor_update_rstn_by_default_connection(void *data)
                        g_tree_foreach(g_system->rstns,
                                       __remove_restriction,
                                       (gpointer)&old_connection);
+
+               iptables_flush_chains();
        }
 
        FREE(old_connection.path);