diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2011-09-23 14:43:44 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-09-29 17:52:59 +0200 |
commit | 496d4c3bb4bcac81d55ca0372581a6782216b5e7 (patch) | |
tree | acdc7d0511fd18665315c6c9d9ff1e35c86480d8 /src/iptables.c | |
parent | 079495237ccad5c98a5fab36ad89eb921b4c884b (diff) | |
download | connman-496d4c3bb4bcac81d55ca0372581a6782216b5e7.tar.gz connman-496d4c3bb4bcac81d55ca0372581a6782216b5e7.tar.bz2 connman-496d4c3bb4bcac81d55ca0372581a6782216b5e7.zip |
iptables: Factorization of target reference update
Diffstat (limited to 'src/iptables.c')
-rw-r--r-- | src/iptables.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/iptables.c b/src/iptables.c index 48d72143..59c483ea 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -284,13 +284,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 iptables_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; @@ -318,17 +337,7 @@ static int iptables_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); |