]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fw_add_local_dnat: remove unused function arguments
authorFlorian Westphal <fw@strlen.de>
Fri, 19 Jun 2020 11:33:19 +0000 (13:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Dec 2020 10:04:46 +0000 (11:04 +0100)
All users pass a NULL/0 for those, things haven't changed since 2015
when this was added originally, so remove the arguments.

THe paramters are re-added as local function variables, initalised
to NULL or 0.  A followup patch can then manually remove all
if (NULL) rather than leaving dead-branch optimization to compiler.

Reason for not doing it here is to ease patch review.

Not requiring support for this will ease initial nftables backend
implementation.
In case a use-case comues up later this feature can be re-added.

src/nspawn/nspawn-expose-ports.c
src/shared/firewall-util.c
src/shared/firewall-util.h
src/test/test-firewall-util.c

index d8a37a339988247ce3f59c8369734750a0a792a2..d1e29d7b82e96b611417f007471656bb3ece7ebc 100644 (file)
@@ -100,9 +100,6 @@ int expose_port_flush(ExposePort* l, union in_addr_union *exposed) {
                 r = fw_add_local_dnat(false,
                                       af,
                                       p->protocol,
-                                      NULL,
-                                      NULL, 0,
-                                      NULL, 0,
                                       p->host_port,
                                       exposed,
                                       p->container_port,
@@ -156,9 +153,6 @@ int expose_port_execute(sd_netlink *rtnl, ExposePort *l, union in_addr_union *ex
                 r = fw_add_local_dnat(true,
                                       af,
                                       p->protocol,
-                                      NULL,
-                                      NULL, 0,
-                                      NULL, 0,
                                       p->host_port,
                                       &new_exposed,
                                       p->container_port,
index 007d2cb39b44751f626f8c408268649ab2385160..bcef7602ce51de4b86d6e6492e1852374748d835 100644 (file)
@@ -158,11 +158,6 @@ int fw_add_local_dnat(
                 bool add,
                 int af,
                 int protocol,
-                const char *in_interface,
-                const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen,
                 uint16_t local_port,
                 const union in_addr_union *remote,
                 uint16_t remote_port,
@@ -177,6 +172,11 @@ int fw_add_local_dnat(
         struct nf_nat_ipv4_multi_range_compat *mr;
         size_t sz, msz;
         int r;
+        const char *in_interface = NULL;
+        const union in_addr_union *source = NULL;
+        unsigned source_prefixlen = 0;
+        const union in_addr_union *destination = NULL;
+        unsigned destination_prefixlen = 0;
 
         assert(add || !previous_remote);
 
index 0a51a3c692b0d4ec94fdcdd42bd36265438561bd..01a3c8a8468753c5006ba09f8fd0091f2339f8dc 100644 (file)
@@ -22,11 +22,6 @@ int fw_add_local_dnat(
                 bool add,
                 int af,
                 int protocol,
-                const char *in_interface,
-                const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen,
                 uint16_t local_port,
                 const union in_addr_union *remote,
                 uint16_t remote_port,
@@ -50,11 +45,6 @@ static inline int fw_add_local_dnat(
                 bool add,
                 int af,
                 int protocol,
-                const char *in_interface,
-                const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen,
                 uint16_t local_port,
                 const union in_addr_union *remote,
                 uint16_t remote_port,
index 64616e4391d655fafbead1ffcfd94aa62c5e4bdc..479669fe45ae8b18f7869f9c3520773e51396ba2 100644 (file)
@@ -22,19 +22,19 @@ int main(int argc, char *argv[]) {
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
+        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
+        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, &MAKE_IN_ADDR_UNION(1, 2, 3, 4));
+        r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, &MAKE_IN_ADDR_UNION(1, 2, 3, 4));
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_local_dnat(false, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, NULL);
+        r = fw_add_local_dnat(false, AF_INET, IPPROTO_TCP, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, NULL);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");