Move iprule flushing to the init function to make the timing predictable
[project/netifd.git] / iprule.c
index c3fdcfc..0ff02de 100644 (file)
--- a/iprule.c
+++ b/iprule.c
@@ -28,7 +28,6 @@
 #include "system.h"
 
 struct vlist_tree iprules;
-static bool iprules_flushed = false;
 static unsigned int iprules_counter[2];
 
 enum {
@@ -199,13 +198,6 @@ iprule_add(struct blob_attr *attr, bool v6)
                rule->flags |= IPRULE_GOTO;
        }
 
-       /* trigger flush of existing rules when adding first uci rule the first time */
-       if (!iprules_flushed)
-       {
-               system_flush_iprules();
-               iprules_flushed = true;
-       }
-
        vlist_add(&iprules, &rule->node, &rule->flags);
        return;
 
@@ -255,5 +247,6 @@ iprule_update_rule(struct vlist_tree *tree,
 static void __init
 iprule_init_list(void)
 {
+       system_flush_iprules();
        vlist_init(&iprules, rule_cmp, iprule_update_rule);
 }