mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-20 03:30:09 +01:00
ip: restore IP forwarding on device deconfiguration
With the ipv4.forwarding property we may modify the forwarding sysctl of
the device on activation. In next commits, we will also modify it if the
connection is shared, instead of modifying the global forwarding.
Restore the forwarding value to the default one when the device is
deconfigured for any reason.
Fixes: a8a2e6d727 ('ip-config: Support configuring per-device IPv4 sysctl forwarding option')
This commit is contained in:
parent
f2a2e49d07
commit
d58d0a793e
1 changed files with 28 additions and 0 deletions
|
|
@ -13845,6 +13845,32 @@ _dev_ipshared6_start(NMDevice *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_dev_ipforwarding_cleanup(NMDevice *self, int addr_family, CleanupType cleanup_type)
|
||||
{
|
||||
gs_free const char *default_forwarding = NULL;
|
||||
gs_free const char *current_forwarding = NULL;
|
||||
|
||||
if (!NM_IS_IPv4(addr_family))
|
||||
return;
|
||||
|
||||
if (!NM_IN_SET(cleanup_type, CLEANUP_TYPE_DECONFIGURE, CLEANUP_TYPE_KEEP_REAPPLY))
|
||||
return;
|
||||
|
||||
default_forwarding = nm_platform_sysctl_get(
|
||||
nm_device_get_platform(self),
|
||||
NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv4/conf/default/forwarding"));
|
||||
|
||||
if (!default_forwarding)
|
||||
return; /* Non fatal */
|
||||
|
||||
current_forwarding = nm_device_sysctl_ip_conf_get(self, AF_INET, "forwarding");
|
||||
if (!nm_streq0(current_forwarding, default_forwarding))
|
||||
nm_device_sysctl_ip_conf_set(self, AF_INET, "forwarding", default_forwarding);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
act_request_set(NMDevice *self, NMActRequest *act_request)
|
||||
{
|
||||
|
|
@ -13957,6 +13983,8 @@ _cleanup_ip_pre(NMDevice *self, int addr_family, CleanupType cleanup_type, gbool
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
|
||||
gboolean keep_reapply = (cleanup_type == CLEANUP_TYPE_KEEP_REAPPLY);
|
||||
|
||||
_dev_ipforwarding_cleanup(self, addr_family, cleanup_type);
|
||||
|
||||
_dev_ipsharedx_cleanup(self, addr_family);
|
||||
|
||||
_dev_ipdev_cleanup(self, AF_UNSPEC);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue