]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xshared: dissolve should_load_proto
authorJan Engelhardt <jengelh@inai.de>
Tue, 30 May 2023 16:11:09 +0000 (18:11 +0200)
committerPhil Sutter <phil@nwl.cc>
Fri, 16 Jun 2023 16:20:21 +0000 (18:20 +0200)
cs->proto_used already tells whether -p foo was turned into an
implicit -m foo once, so I do not think should_load_proto() has a
reason to exist.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/xshared.c

index 17aed04e02b0905f0ad72aaaa62bf523e5ac88b6..a235010311d93ec9d16753090756216fa5ac006a 100644 (file)
@@ -111,20 +111,13 @@ find_proto(const char *pname, enum xtables_tryload tryload,
  *   [think of ip6tables-restore!]
  * - the protocol extension can be successively loaded
  */
-static bool should_load_proto(struct iptables_command_state *cs)
-{
-       if (cs->protocol == NULL)
-               return false;
-       if (find_proto(cs->protocol, XTF_DONT_LOAD,
-           cs->options & OPT_NUMERIC, NULL) == NULL)
-               return true;
-       return !cs->proto_used;
-}
-
 static struct xtables_match *load_proto(struct iptables_command_state *cs)
 {
-       if (!should_load_proto(cs))
+       if (cs->protocol == NULL)
                return NULL;
+       if (cs->proto_used)
+               return NULL;
+       cs->proto_used = true;
        return find_proto(cs->protocol, XTF_TRY_LOAD,
                          cs->options & OPT_NUMERIC, &cs->matches);
 }
@@ -157,13 +150,10 @@ static int command_default(struct iptables_command_state *cs,
                return 0;
        }
 
-       /* Try loading protocol */
        m = load_proto(cs);
        if (m != NULL) {
                size_t size;
 
-               cs->proto_used = 1;
-
                size = XT_ALIGN(sizeof(struct xt_entry_match)) + m->size;
 
                m->m = xtables_calloc(1, size);