summaryrefslogtreecommitdiff
path: root/src/iptables.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-09-23 14:43:35 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-29 17:52:59 +0200
commitc5eaba9ad9c2948cf6537cf273abdea2e61e5f1c (patch)
tree80cd8c424a823148d8fc3f518cdf46d2a0728692 /src/iptables.c
parentda35161e6452fff93a5d1281bbc856a1ee3e89f3 (diff)
downloadconnman-c5eaba9ad9c2948cf6537cf273abdea2e61e5f1c.tar.gz
connman-c5eaba9ad9c2948cf6537cf273abdea2e61e5f1c.tar.bz2
connman-c5eaba9ad9c2948cf6537cf273abdea2e61e5f1c.zip
iptables: Added helper function to remove table entry
Diffstat (limited to 'src/iptables.c')
-rw-r--r--src/iptables.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/iptables.c b/src/iptables.c
index 45c71cdd..fec4fb8a 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -335,6 +335,22 @@ static int iptables_add_entry(struct connman_iptables *table,
return 0;
}
+static int remove_table_entry(struct connman_iptables *table,
+ struct connman_iptables_entry *entry)
+{
+ int removed = 0;
+
+ table->num_entries--;
+ table->size -= entry->entry->next_offset;
+ removed = entry->entry->next_offset;
+
+ g_free(entry->entry);
+
+ table->entries = g_list_remove(table->entries, entry);
+
+ return removed;
+}
+
static int iptables_flush_chain(struct connman_iptables *table,
char *name)
{
@@ -365,13 +381,7 @@ static int iptables_flush_chain(struct connman_iptables *table,
entry = list->data;
next = g_list_next(list);
- table->num_entries--;
- table->size -= entry->entry->next_offset;
- removed += entry->entry->next_offset;
-
- g_free(entry->entry);
-
- table->entries = g_list_remove(table->entries, list->data);
+ removed += remove_table_entry(table, entry);
list = next;
}