diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-30 00:26:57 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-11-03 09:27:09 +0100 |
commit | 9eb6c68275de12a2c3a030c969b8ad594d7050d2 (patch) | |
tree | d7dea46ba1ca54e797a91a350f2e12848d7aee7a | |
parent | fcd546f425f0a92bd24f13bc611c13430822788b (diff) | |
download | connman-9eb6c68275de12a2c3a030c969b8ad594d7050d2.tar.gz connman-9eb6c68275de12a2c3a030c969b8ad594d7050d2.tar.bz2 connman-9eb6c68275de12a2c3a030c969b8ad594d7050d2.zip |
iptables: Update entries offsets
-rw-r--r-- | src/iptables.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/iptables.c b/src/iptables.c index 04f39704..936accc8 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -88,7 +88,7 @@ struct ipt_error_target { }; struct connman_iptables_entry { - int jump_offset; + int offset; struct ipt_entry *entry; }; @@ -226,6 +226,29 @@ static GList *find_chain_tail(struct connman_iptables *table, return g_list_last(table->entries); } + +static void update_offsets(struct connman_iptables *table) +{ + GList *list, *prev; + struct connman_iptables_entry *entry, *prev_entry; + + for (list = table->entries; list; list = list->next) { + entry = list->data; + + if (list == table->entries) { + entry->offset = 0; + + continue; + } + + prev = list->prev; + prev_entry = prev->data; + + entry->offset = prev_entry->offset + + prev_entry->entry->next_offset; + } +} + static int iptables_add_entry(struct connman_iptables *table, struct ipt_entry *entry, GList *before) { @@ -244,6 +267,8 @@ static int iptables_add_entry(struct connman_iptables *table, table->num_entries++; table->size += entry->next_offset; + update_offsets(table); + return 0; } |