Parser merge prep work, align final do_commandeb*() parts with do_commandx(). Signed-off-by: Phil Sutter <phil@xxxxxx> --- iptables/xtables-eb-translate.c | 24 +++++++++-------- iptables/xtables-eb.c | 46 ++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/iptables/xtables-eb-translate.c b/iptables/xtables-eb-translate.c index da7e5e3dda1f3..d0fec9c6d5ae3 100644 --- a/iptables/xtables-eb-translate.c +++ b/iptables/xtables-eb-translate.c @@ -497,23 +497,25 @@ static int do_commandeb_xlate(struct nft_handle *h, int argc, char *argv[], char cs.eb.ethproto = htons(cs.eb.ethproto); - if (command == 'P') { - return 0; - } else if (command == 'F') { - if (p.chain) { - printf("flush chain bridge %s %s\n", p.table, p.chain); - } else { - printf("flush table bridge %s\n", p.table); - } - ret = 1; - } else if (command == 'A') { + switch (command) { + case 'F': + if (p.chain) { + printf("flush chain bridge %s %s\n", p.table, p.chain); + } else { + printf("flush table bridge %s\n", p.table); + } + ret = 1; + break; + case 'A': ret = nft_rule_eb_xlate_add(h, &p, &cs, true); if (!ret) print_ebt_cmd(argc, argv); - } else if (command == 'I') { + break; + case 'I': ret = nft_rule_eb_xlate_add(h, &p, &cs, false); if (!ret) print_ebt_cmd(argc, argv); + break; } ebt_cs_clean(&cs); diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index ddbe1b5a3adc0..db75e65caa02a 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -1168,47 +1168,57 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table, * The kernel does not have to do this of course */ cs.eb.ethproto = htons(cs.eb.ethproto); - if (command == 'P') { + switch (command) { + case 'P': if (selected_chain >= NF_BR_NUMHOOKS) { ret = ebt_cmd_user_chain_policy(h, *table, chain, policy); - } else { - if (strcmp(policy, "RETURN") == 0) { - xtables_error(PARAMETER_PROBLEM, - "Policy RETURN only allowed for user defined chains"); - } - ret = nft_cmd_chain_set(h, *table, chain, policy, NULL); - if (ret < 0) - xtables_error(PARAMETER_PROBLEM, "Wrong policy"); + break; } - } else if (command == 'L') { + if (strcmp(policy, "RETURN") == 0) { + xtables_error(PARAMETER_PROBLEM, + "Policy RETURN only allowed for user defined chains"); + } + ret = nft_cmd_chain_set(h, *table, chain, policy, NULL); + if (ret < 0) + xtables_error(PARAMETER_PROBLEM, "Wrong policy"); + break; + case 'L': ret = list_rules(h, chain, *table, rule_nr, flags & OPT_VERBOSE, 0, /*flags&OPT_EXPANDED*/0, flags&LIST_N, flags&LIST_C); - } - if (flags & OPT_ZERO) { + if (!(flags & OPT_ZERO)) + break; + case 'Z': ret = nft_cmd_chain_zero_counters(h, chain, *table, flags & OPT_VERBOSE); - } else if (command == 'F') { + break; + case 'F': ret = nft_cmd_rule_flush(h, chain, *table, flags & OPT_VERBOSE); - } else if (command == 'A') { + break; + case 'A': ret = nft_cmd_rule_append(h, chain, *table, &cs, flags & OPT_VERBOSE); - } else if (command == 'I') { + break; + case 'I': ret = nft_cmd_rule_insert(h, chain, *table, &cs, rule_nr - 1, flags & OPT_VERBOSE); - } else if (command == 'D') { + break; + case 'D': ret = delete_entry(h, chain, *table, &cs, rule_nr - 1, rule_nr_end, flags & OPT_VERBOSE); - } else if (command == 14) { + break; + case 14: ret = nft_cmd_rule_check(h, chain, *table, &cs, flags & OPT_VERBOSE); - } else if (command == 'C') { + break; + case 'C': ret = change_entry_counters(h, chain, *table, &cs, rule_nr - 1, rule_nr_end, chcounter, flags & OPT_VERBOSE); + break; } ebt_cs_clean(&cs); -- 2.41.0