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.
This commit is contained in:
parent
140105b730
commit
67b3732a53
|
@ -100,9 +100,6 @@ int expose_port_flush(ExposePort* l, union in_addr_union *exposed) {
|
||||||
r = fw_add_local_dnat(false,
|
r = fw_add_local_dnat(false,
|
||||||
af,
|
af,
|
||||||
p->protocol,
|
p->protocol,
|
||||||
NULL,
|
|
||||||
NULL, 0,
|
|
||||||
NULL, 0,
|
|
||||||
p->host_port,
|
p->host_port,
|
||||||
exposed,
|
exposed,
|
||||||
p->container_port,
|
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,
|
r = fw_add_local_dnat(true,
|
||||||
af,
|
af,
|
||||||
p->protocol,
|
p->protocol,
|
||||||
NULL,
|
|
||||||
NULL, 0,
|
|
||||||
NULL, 0,
|
|
||||||
p->host_port,
|
p->host_port,
|
||||||
&new_exposed,
|
&new_exposed,
|
||||||
p->container_port,
|
p->container_port,
|
||||||
|
|
|
@ -158,11 +158,6 @@ int fw_add_local_dnat(
|
||||||
bool add,
|
bool add,
|
||||||
int af,
|
int af,
|
||||||
int protocol,
|
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,
|
uint16_t local_port,
|
||||||
const union in_addr_union *remote,
|
const union in_addr_union *remote,
|
||||||
uint16_t remote_port,
|
uint16_t remote_port,
|
||||||
|
@ -177,6 +172,11 @@ int fw_add_local_dnat(
|
||||||
struct nf_nat_ipv4_multi_range_compat *mr;
|
struct nf_nat_ipv4_multi_range_compat *mr;
|
||||||
size_t sz, msz;
|
size_t sz, msz;
|
||||||
int r;
|
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);
|
assert(add || !previous_remote);
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,6 @@ int fw_add_local_dnat(
|
||||||
bool add,
|
bool add,
|
||||||
int af,
|
int af,
|
||||||
int protocol,
|
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,
|
uint16_t local_port,
|
||||||
const union in_addr_union *remote,
|
const union in_addr_union *remote,
|
||||||
uint16_t remote_port,
|
uint16_t remote_port,
|
||||||
|
@ -50,11 +45,6 @@ static inline int fw_add_local_dnat(
|
||||||
bool add,
|
bool add,
|
||||||
int af,
|
int af,
|
||||||
int protocol,
|
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,
|
uint16_t local_port,
|
||||||
const union in_addr_union *remote,
|
const union in_addr_union *remote,
|
||||||
uint16_t remote_port,
|
uint16_t remote_port,
|
||||||
|
|
|
@ -22,19 +22,19 @@ int main(int argc, char *argv[]) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to modify firewall: %m");
|
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)
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to modify firewall: %m");
|
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)
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to modify firewall: %m");
|
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)
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to modify firewall: %m");
|
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)
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to modify firewall: %m");
|
log_error_errno(r, "Failed to modify firewall: %m");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue