summaryrefslogtreecommitdiff
path: root/tools/iptables-test.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-09-22 15:39:30 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-22 15:22:47 +0200
commit1a7a3c975deb32ef04fdcbb658ca317639ede7e4 (patch)
treea823ce8bd6111de0656d5ee74b686120fac37748 /tools/iptables-test.c
parent6ad26540be397ebc1b50dda6b71e5cd78c9ebc24 (diff)
downloadconnman-1a7a3c975deb32ef04fdcbb658ca317639ede7e4.tar.gz
connman-1a7a3c975deb32ef04fdcbb658ca317639ede7e4.tar.bz2
connman-1a7a3c975deb32ef04fdcbb658ca317639ede7e4.zip
tools: Factorization of target reference update in iptables-test
Diffstat (limited to 'tools/iptables-test.c')
-rw-r--r--tools/iptables-test.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index b995afce..446331b6 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -278,13 +278,32 @@ static void update_offsets(struct connman_iptables *table)
}
}
+static void update_targets_reference(struct connman_iptables *table,
+ struct connman_iptables_entry *entry_before,
+ struct connman_iptables_entry *modified_entry)
+{
+ struct connman_iptables_entry *tmp;
+ struct xt_standard_target *t;
+ GList *list;
+
+ for (list = table->entries; list; list = list->next) {
+ tmp = list->data;
+
+ if (!is_jump(tmp))
+ continue;
+
+ t = (struct xt_standard_target *)ipt_get_target(tmp->entry);
+
+ if (t->verdict > entry_before->offset)
+ t->verdict += modified_entry->entry->next_offset;
+ }
+}
+
static int connman_add_entry(struct connman_iptables *table,
struct ipt_entry *entry, GList *before,
int builtin)
{
- GList *list;
- struct connman_iptables_entry *e, *tmp, *entry_before;
- struct xt_standard_target *t;
+ struct connman_iptables_entry *e, *entry_before;
if (table == NULL)
return -1;
@@ -312,17 +331,7 @@ static int connman_add_entry(struct connman_iptables *table,
* We've just appended/insterted a new entry. All references
* should be bumped accordingly.
*/
- for (list = table->entries; list; list = list->next) {
- tmp = list->data;
-
- if (!is_jump(tmp))
- continue;
-
- t = (struct xt_standard_target *)ipt_get_target(tmp->entry);
-
- if (t->verdict > entry_before->offset)
- t->verdict += entry->next_offset;
- }
+ update_targets_reference(table, entry_before, e);
update_offsets(table);