From 67b3732a533a55968727ff52bbce789e9f88501c Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 19 Jun 2020 13:33:19 +0200 Subject: [PATCH] fw_add_local_dnat: remove unused function arguments 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 | 6 ------ src/shared/firewall-util.c | 10 +++++----- src/shared/firewall-util.h | 10 ---------- src/test/test-firewall-util.c | 8 ++++---- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index d8a37a3399..d1e29d7b82 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -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, diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c index 007d2cb39b..bcef7602ce 100644 --- a/src/shared/firewall-util.c +++ b/src/shared/firewall-util.c @@ -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); diff --git a/src/shared/firewall-util.h b/src/shared/firewall-util.h index 0a51a3c692..01a3c8a846 100644 --- a/src/shared/firewall-util.h +++ b/src/shared/firewall-util.h @@ -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, diff --git a/src/test/test-firewall-util.c b/src/test/test-firewall-util.c index 64616e4391..479669fe45 100644 --- a/src/test/test-firewall-util.c +++ b/src/test/test-firewall-util.c @@ -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");