firewall3: add UBUS support for redirect sections
[project/firewall3.git] / forwards.c
index 24b8e4d..9b369f3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * firewall3 - 3rd OpenWrt UCI firewall implementation
  *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ *   Copyright (C) 2013 Jo-Philipp Wich <jo@mein.io>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -54,7 +54,8 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
 
                forward->enabled = true;
 
-               fw3_parse_options(forward, fw3_forward_opts, s);
+               if (!fw3_parse_options(forward, fw3_forward_opts, s))
+                       warn_elem(e, "has invalid options");
 
                if (!forward->enabled)
                {
@@ -83,21 +84,18 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
                        continue;
                }
 
+               list_add_tail(&forward->list, &state->forwards);
+               continue;
+       }
+
+       list_for_each_entry(forward, &state->forwards, list)
+       {
                /* NB: forward family... */
                if (forward->_dest)
                {
-                       setbit(forward->_dest->flags[0], FW3_FLAG_ACCEPT);
-                       setbit(forward->_dest->flags[1], FW3_FLAG_ACCEPT);
-
-                       if (forward->_src &&
-                           (forward->_src->conntrack || forward->_dest->conntrack))
-                       {
-                               forward->_src->conntrack = forward->_dest->conntrack = true;
-                       }
+                       fw3_setbit(forward->_dest->flags[0], FW3_FLAG_ACCEPT);
+                       fw3_setbit(forward->_dest->flags[1], FW3_FLAG_ACCEPT);
                }
-
-               list_add_tail(&forward->list, &state->forwards);
-               continue;
        }
 }