]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fw_add_masquerade: remove unused function arguments
authorFlorian Westphal <fw@strlen.de>
Fri, 19 Jun 2020 10:41:49 +0000 (12:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Dec 2020 10:05:14 +0000 (11:05 +0100)
Similar to the previous commit.  All callers pass NULL.  This will
ease initial nftables backend implementation (less features to cover).

Add the function parameters as local variables and let compiler
remove branches.  Followup patch can remove the if (NULL) conditionals.

src/network/networkd-address.c
src/shared/firewall-util.c
src/shared/firewall-util.h
src/test/test-firewall-util.c

index 92237c4e0f97e1d7b274c6fe0f54e8614a8a0c1c..c38443763ab432b180c1cb84588c5653941b1ca2 100644 (file)
@@ -266,7 +266,7 @@ static int address_set_masquerade(Address *address, bool add) {
         if (r < 0)
                 return r;
 
-        r = fw_add_masquerade(add, AF_INET, 0, &masked, address->prefixlen, NULL, NULL, 0);
+        r = fw_add_masquerade(add, AF_INET, &masked, address->prefixlen);
         if (r < 0)
                 return r;
 
index bcef7602ce51de4b86d6e6492e1852374748d835..974803903d9c734d0c77a57ddede53fb02ac3965 100644 (file)
@@ -81,12 +81,8 @@ static int entry_fill_basics(
 int fw_add_masquerade(
                 bool add,
                 int af,
-                int protocol,
                 const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const char *out_interface,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen) {
+                unsigned source_prefixlen) {
 
         static const xt_chainlabel chain = "POSTROUTING";
         _cleanup_(iptc_freep) struct xtc_handle *h = NULL;
@@ -94,14 +90,14 @@ int fw_add_masquerade(
         struct ipt_entry_target *t;
         size_t sz;
         struct nf_nat_ipv4_multi_range_compat *mr;
-        int r;
+        int r, protocol = 0;
+        const char *out_interface = NULL;
+        const union in_addr_union *destination = NULL;
+        unsigned destination_prefixlen = 0;
 
         if (af != AF_INET)
                 return -EOPNOTSUPP;
 
-        if (!IN_SET(protocol, 0, IPPROTO_TCP, IPPROTO_UDP))
-                return -EOPNOTSUPP;
-
         h = iptc_init("nat");
         if (!h)
                 return -errno;
index 01a3c8a8468753c5006ba09f8fd0091f2339f8dc..f7191ba006cc5f68d77881c5c57a2293c77071e4 100644 (file)
 int fw_add_masquerade(
                 bool add,
                 int af,
-                int protocol,
                 const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const char *out_interface,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen);
+                unsigned source_prefixlen);
 
 int fw_add_local_dnat(
                 bool add,
@@ -32,12 +28,8 @@ int fw_add_local_dnat(
 static inline int fw_add_masquerade(
                 bool add,
                 int af,
-                int protocol,
                 const union in_addr_union *source,
-                unsigned source_prefixlen,
-                const char *out_interface,
-                const union in_addr_union *destination,
-                unsigned destination_prefixlen) {
+                unsigned source_prefixlen) {
         return -EOPNOTSUPP;
 }
 
index 479669fe45ae8b18f7869f9c3520773e51396ba2..25c5a6cbf5d013b5ea327dd160386e579ba5dcf6 100644 (file)
@@ -10,15 +10,15 @@ int main(int argc, char *argv[]) {
         int r;
         test_setup_logging(LOG_DEBUG);
 
-        r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
+        r = fw_add_masquerade(true, AF_INET, NULL, 0);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
+        r = fw_add_masquerade(true, AF_INET, NULL, 0);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");
 
-        r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
+        r = fw_add_masquerade(false, AF_INET, NULL, 0);
         if (r < 0)
                 log_error_errno(r, "Failed to modify firewall: %m");