firewall: use prefix length instead of netmask for iptables arguments

The form "address/netmask" is unnecessarily verbose. iptables
supports prefix length notation just fine.
This commit is contained in:
Thomas Haller 2021-05-05 18:45:28 +02:00
parent 734c82d789
commit f5e12f3915
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1637,14 +1637,13 @@ nm_utils_ip_routes_to_dbus(int addr_family,
/*****************************************************************************/
#define _SHARE_IPTABLES_SUBNET_TO_STR_LEN (INET_ADDRSTRLEN + 1 + INET_ADDRSTRLEN + 1)
#define _SHARE_IPTABLES_SUBNET_TO_STR_LEN (INET_ADDRSTRLEN + 1 + 2 + 1)
static const char *
_share_iptables_subnet_to_str(char buf[static _SHARE_IPTABLES_SUBNET_TO_STR_LEN],
in_addr_t addr,
guint8 plen)
{
char buf_mask[INET_ADDRSTRLEN];
char buf_addr[INET_ADDRSTRLEN];
in_addr_t netmask;
int l;
@ -1653,9 +1652,9 @@ _share_iptables_subnet_to_str(char buf[static _SHARE_IPTABLES_SUBNET_TO_STR
l = g_snprintf(buf,
_SHARE_IPTABLES_SUBNET_TO_STR_LEN,
"%s/%s",
"%s/%u",
_nm_utils_inet4_ntop(addr & netmask, buf_addr),
_nm_utils_inet4_ntop(netmask, buf_mask));
plen);
nm_assert(l < _SHARE_IPTABLES_SUBNET_TO_STR_LEN);
return buf;
}