Commit
ba052f1f "iptables: Add split out iptables commands"
introduced a bug. __connman_iptables_append() should
call iptables_append_rule() instead of iptables_insert_rule().
-static int iptables_insert_rule(struct connman_iptables *table,
+static int iptables_append_rule(struct connman_iptables *table,
struct ipt_ip *ip, const char *chain_name,
const char *target_name,
struct xtables_target *xt_t,
struct ipt_ip *ip, const char *chain_name,
const char *target_name,
struct xtables_target *xt_t,
{
struct ipt_entry *new_entry;
int builtin = -1, ret;
{
struct ipt_entry *new_entry;
int builtin = -1, ret;
- chain_head = find_chain_head(table, chain_name);
- if (chain_head == NULL)
+ chain_tail = find_chain_tail(table, chain_name);
+ if (chain_tail == NULL)
return -EINVAL;
new_entry = prepare_rule_inclusion(table, ip, chain_name,
return -EINVAL;
new_entry = prepare_rule_inclusion(table, ip, chain_name,
if (new_entry == NULL)
return -EINVAL;
if (new_entry == NULL)
return -EINVAL;
- if (builtin == -1)
- chain_head = chain_head->next;
-
- ret = iptables_add_entry(table, new_entry, chain_head, builtin);
+ ret = iptables_add_entry(table, new_entry, chain_tail->prev, builtin);
if (ret < 0)
g_free(new_entry);
if (ret < 0)
g_free(new_entry);
else
target_name = ctx->xt_t->name;
else
target_name = ctx->xt_t->name;
- err = iptables_insert_rule(table, ctx->ip, chain,
+ err = iptables_append_rule(table, ctx->ip, chain,
target_name, ctx->xt_t, ctx->xt_rm);
out:
cleanup_parse_context(ctx);
target_name, ctx->xt_t, ctx->xt_rm);
out:
cleanup_parse_context(ctx);