]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables: Merge OPT_* flags with xshared ones
authorPhil Sutter <phil@nwl.cc>
Tue, 27 Sep 2022 17:46:47 +0000 (19:46 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 28 Sep 2022 12:21:13 +0000 (14:21 +0200)
Despite also including xshared.h, xtables-eb.c defined its own OPT_*
flags with clashing values. Albeit ugly, this wasn't a problem in
practice until commit 51d9d9e081344 ("ebtables: Support verbose mode")
which introduced use of OPT_VERBOSE from xshared - with same value as
the local OPT_PROTOCOL define.

Eliminate the clash by appending ebtables-specific flags to the xshared
enum and adjust for the different names of some others.

Fixes: 51d9d9e081344 ("ebtables: Support verbose mode")
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/xshared.h
iptables/xtables-eb.c

index 1a019a7c0488240c9af86dcb09b17b94b95ed746..f43c28f519a9c9a7bb9154d886f2a9c673276831 100644 (file)
@@ -37,6 +37,11 @@ enum {
        OPT_OPCODE      = 1 << 15,
        OPT_H_TYPE      = 1 << 16,
        OPT_P_TYPE      = 1 << 17,
+       /* below are for ebtables only */
+       OPT_LOGICALIN   = 1 << 18,
+       OPT_LOGICALOUT  = 1 << 19,
+       OPT_COMMAND     = 1 << 20,
+       OPT_ZERO        = 1 << 21,
 };
 
 enum {
index 9aab35977396f09026d6ff75c18cb15e5ca765ec..631a3cebf11a77af928fc0fcbcfc021061c79550 100644 (file)
@@ -157,18 +157,6 @@ int ebt_get_current_chain(const char *chain)
 /* Checks whether a command has already been specified */
 #define OPT_COMMANDS (flags & OPT_COMMAND || flags & OPT_ZERO)
 
-#define OPT_COMMAND    0x01
-#define OPT_IN         0x04
-#define OPT_OUT                0x08
-#define OPT_JUMP       0x10
-#define OPT_PROTOCOL   0x20
-#define OPT_SOURCE     0x40
-#define OPT_DEST       0x80
-#define OPT_ZERO       0x100
-#define OPT_LOGICALIN  0x200
-#define OPT_LOGICALOUT 0x400
-#define OPT_COUNT      0x1000 /* This value is also defined in libebtc.c */
-
 /* Default command line options. Do not mess around with the already
  * assigned numbers unless you know what you are doing */
 struct option ebt_original_options[] =
@@ -923,7 +911,7 @@ print_zero:
                                xtables_error(PARAMETER_PROBLEM,
                                              "Command and option do not match");
                        if (c == 'i') {
-                               ebt_check_option2(&flags, OPT_IN);
+                               ebt_check_option2(&flags, OPT_VIANAMEIN);
                                if (selected_chain > 2 && selected_chain < NF_BR_BROUTING)
                                        xtables_error(PARAMETER_PROBLEM,
                                                      "Use -i only in INPUT, FORWARD, PREROUTING and BROUTING chains");
@@ -943,7 +931,7 @@ print_zero:
                                ebtables_parse_interface(optarg, cs.eb.logical_in);
                                break;
                        } else if (c == 'o') {
-                               ebt_check_option2(&flags, OPT_OUT);
+                               ebt_check_option2(&flags, OPT_VIANAMEOUT);
                                if (selected_chain < 2 || selected_chain == NF_BR_BROUTING)
                                        xtables_error(PARAMETER_PROBLEM,
                                                      "Use -o only in OUTPUT, FORWARD and POSTROUTING chains");
@@ -980,7 +968,7 @@ print_zero:
                                cs.eb.bitmask |= EBT_SOURCEMAC;
                                break;
                        } else if (c == 'd') {
-                               ebt_check_option2(&flags, OPT_DEST);
+                               ebt_check_option2(&flags, OPT_DESTINATION);
                                if (ebt_check_inverse2(optarg, argc, argv))
                                        cs.eb.invflags |= EBT_IDEST;
 
@@ -991,7 +979,7 @@ print_zero:
                                cs.eb.bitmask |= EBT_DESTMAC;
                                break;
                        } else if (c == 'c') {
-                               ebt_check_option2(&flags, OPT_COUNT);
+                               ebt_check_option2(&flags, OPT_COUNTERS);
                                if (ebt_check_inverse2(optarg, argc, argv))
                                        xtables_error(PARAMETER_PROBLEM,
                                                      "Unexpected '!' after -c");