]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: conntrack: Reuse print_state() for old state match
authorPhil Sutter <phil@nwl.cc>
Fri, 26 Jul 2024 11:21:09 +0000 (13:21 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 31 Jul 2024 21:13:55 +0000 (23:13 +0200)
The extra bits supported by print_state() won't be set by the parser, no
functional change expected.

Signed-off-by: Phil Sutter <phil@nwl.cc>
extensions/libxt_conntrack.c

index ccbf731de7c4df0504366a78e5b0e68f1b03529e..04940154eb3140105a4332c13b4fa771ff2d4c97 100644 (file)
@@ -1102,32 +1102,6 @@ static void state_ct23_parse(struct xt_option_call *cb)
                sinfo->invert_flags |= XT_CONNTRACK_STATE;
 }
 
-static void state_print_state(unsigned int statemask)
-{
-       const char *sep = "";
-
-       if (statemask & XT_CONNTRACK_STATE_INVALID) {
-               printf("%sINVALID", sep);
-               sep = ",";
-       }
-       if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_NEW)) {
-               printf("%sNEW", sep);
-               sep = ",";
-       }
-       if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_RELATED)) {
-               printf("%sRELATED", sep);
-               sep = ",";
-       }
-       if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_ESTABLISHED)) {
-               printf("%sESTABLISHED", sep);
-               sep = ",";
-       }
-       if (statemask & XT_CONNTRACK_STATE_UNTRACKED) {
-               printf("%sUNTRACKED", sep);
-               sep = ",";
-       }
-}
-
 static void
 state_print(const void *ip,
       const struct xt_entry_match *match,
@@ -1135,16 +1109,16 @@ state_print(const void *ip,
 {
        const struct xt_state_info *sinfo = (const void *)match->data;
 
-       printf(" state ");
-       state_print_state(sinfo->statemask);
+       printf(" state");
+       print_state(sinfo->statemask);
 }
 
 static void state_save(const void *ip, const struct xt_entry_match *match)
 {
        const struct xt_state_info *sinfo = (const void *)match->data;
 
-       printf(" --state ");
-       state_print_state(sinfo->statemask);
+       printf(" --state");
+       print_state(sinfo->statemask);
 }
 
 static void state_xlate_print(struct xt_xlate *xl, unsigned int statemask, int inverted)