mirror of
https://github.com/systemd/systemd.git
synced 2025-03-13 00:58:27 +03:00
fw_add_masquerade: remove unused function arguments
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.
This commit is contained in:
parent
67b3732a53
commit
7509c7fdf9
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -11,12 +11,8 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user