GNOME Bugzilla – Bug 790726
Shared connection fails if /proc/sys is read-only
Last modified: 2017-11-24 16:17:42 UTC
Hello, I'm trying to create a connection with IPv4 method 'shared' inside a Docker container. Inside a container /proc/sys is mounted read-only, but I have manually set /proc/sys/net/ipv4/ip_forward is '1'. When I activate the shared connection, it fails ("share: error enabling IPv4 forwarding" in the logs). NM tries to write to /proc/sys/net/ipv4/ip_forward even though ip_forward is already set to '1'. Tested with NM 1.4.2 and 1.6.2. I have checked out 1.10 source and it seems to be the same. I have a homemade patch for this bug that makes ip_forward failure not fail the connection. I though it'd be reasonable to check for the current value of a sysctl before trying to write to it? Thanks Also : There are numerous similar errors (visible in the logs, log level=DEBUG) caused by /proc/sys being read-only. Only /proc/sys/net/ipv4/ip_forward seems to result in the connection failing, this might simply because I have set IPv6 method to 'ignore'.
Created attachment 364232 [details] [review] platform: preserve errno in nm_platform_sysctl_get_int_checked() It's not clear whether free() changes errno. Be sure about it.
Created attachment 364233 [details] [review] device: ignore errors setting ip_forward for IPv4 shared method /proc/sys might be read-only, so be more graceful and no longer fail activation, if we were unable to set ip_forward. Also, try to read the value first, and only set it if necessary. Also, downgrade the <error> messages to <warn>, only fatal errors warrant the <error> level.
> device: ignore errors setting ip_forward for IPv4 shared method > /proc/sys might be read-only, so be more graceful and no longer fail > activation, if we were unable to set ip_forward. If we can't enable forwarding, the connection should not succeed in my opinion because internet sharing won't work. > Also, try to read the value first, and only set it if necessary. I think this is enough.
makes sense. How about https://cgit.freedesktop.org/NetworkManager/NetworkManager/log/?h=th/shared-mode-failure-bgo790726 ? (with a new commit)
merged master: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=3d0c5b3bb8ecfb2e6e32d767405bd61b118f42d0 nm-1-10: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=af4fbf97f571924d96b9fd54705d61364db6adec