mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 09:50:17 +01:00
device: only set ip_forward sysctl if necessary
/proc/sys might be read-only but we want to set it for
enabling shared mode.
Check first if the sysctl already has the expected value,
and if so, do nothing.
https://bugzilla.gnome.org/show_bug.cgi?id=790726
(cherry picked from commit d841930d67)
This commit is contained in:
parent
26ca80ebf5
commit
a6b388d7d5
1 changed files with 6 additions and 2 deletions
|
|
@ -8393,7 +8393,9 @@ share_init (NMDevice *self, GError **error)
|
|||
char **iter;
|
||||
int errsv;
|
||||
|
||||
if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) {
|
||||
if (nm_platform_sysctl_get_int32 (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), -1) == 1) {
|
||||
/* nothing to do. */
|
||||
} else if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_forward"), "1")) {
|
||||
errsv = errno;
|
||||
_LOGD (LOGD_SHARING, "share: error enabling IPv4 forwarding: (%d) %s",
|
||||
errsv, g_strerror (errsv));
|
||||
|
|
@ -8402,7 +8404,9 @@ share_init (NMDevice *self, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) {
|
||||
if (nm_platform_sysctl_get_int32 (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), -1) == 1) {
|
||||
/* nothing to do. */
|
||||
} else if (!nm_platform_sysctl_set (nm_device_get_platform (self), NMP_SYSCTL_PATHID_ABSOLUTE ("/proc/sys/net/ipv4/ip_dynaddr"), "1")) {
|
||||
errsv = errno;
|
||||
_LOGD (LOGD_SHARING, "share: error enabling dynamic addresses: (%d) %s",
|
||||
errsv, strerror (errsv));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue