summaryrefslogtreecommitdiffstats
path: root/iptables/xshared.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@inai.de>2023-05-30 18:11:09 +0200
committerPhil Sutter <phil@nwl.cc>2023-06-16 18:20:21 +0200
commit15919abe32092561c6318ebe2b0a9aa51e746bde (patch)
tree8ab8bc3ca435e0cd3977ef30d16e8db24ed961d7 /iptables/xshared.c
parent69278f9602b43df80821c55c21c0666f5c6f7e2f (diff)
xshared: dissolve should_load_proto
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>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r--iptables/xshared.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 17aed04e..a2350103 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -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);