Skip to content

Commit 6e9eff4

Browse files
committed
ipv6: catch ipv6.disable=1 kernel command line
1 parent a52d118 commit 6e9eff4

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

include/wicked/ipv6.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct ni_ipv6_devinfo {
6161
ni_ipv6_ra_info_t radv;
6262
};
6363

64+
extern ni_bool_t ni_ipv6_supported(void);
65+
6466
extern ni_ipv6_devinfo_t * ni_netdev_get_ipv6(ni_netdev_t *);
6567
extern void ni_netdev_set_ipv6(ni_netdev_t *, ni_ipv6_devconf_t *);
6668

src/dbus-objects/ipv6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ ni_objectmodel_ipv6_change_protocol(ni_dbus_object_t *object, const ni_dbus_meth
5555
}
5656

5757
if (ni_system_ipv6_setup(nc, dev, &cfg->ipv6->conf) < 0) {
58-
dbus_set_error(error, DBUS_ERROR_FAILED, "failed to set up ethernet device");
58+
dbus_set_error(error, DBUS_ERROR_FAILED,
59+
"failed to configure ipv6 protocol");
5960
goto out;
6061
}
6162

src/ifconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ ni_system_ipv6_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_ipv6_devconf
13191319
* seems rather good at that.
13201320
* The only way to recover from that is by upping the interface briefly.
13211321
*/
1322-
if (!ni_sysctl_ipv6_ifconfig_is_present(dev->name)) {
1322+
if (ni_ipv6_supported() && !ni_sysctl_ipv6_ifconfig_is_present(dev->name)) {
13231323
if (__ni_rtnl_link_up(dev, NULL) >= 0) {
13241324
unsigned int count = 100;
13251325

src/ipv6.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@
99

1010
#include <wicked/netinfo.h>
1111
#include <wicked/logging.h>
12+
#include <errno.h>
1213

1314
#include "ipv6_priv.h"
1415
#include "util_priv.h"
1516
#include "sysfs.h"
1617

18+
#define NI_PROC_SYS_NET_IPV6_DIR "/proc/sys/net/ipv6"
19+
1720
#define NI_IPV6_RA_RDNSS_ADDRS_CHUNK 4
1821

22+
/*
23+
* Check if ipv6 is supported or disabled
24+
* via ipv6.disabled=1 kernel command line.
25+
*/
26+
ni_bool_t
27+
ni_ipv6_supported(void)
28+
{
29+
return ni_isdir(NI_PROC_SYS_NET_IPV6_DIR);
30+
}
31+
1932
/*
2033
* Reset to ipv6 config defaults
2134
*/
@@ -94,6 +107,13 @@ ni_system_ipv6_devinfo_get(ni_netdev_t *dev, ni_ipv6_devinfo_t *ipv6)
94107
if (ipv6 == NULL)
95108
ipv6 = ni_netdev_get_ipv6(dev);
96109

110+
if (!ni_ipv6_supported()) {
111+
__ni_ipv6_devconf_reset(&ipv6->conf);
112+
__ni_ipv6_ra_info_reset(&ipv6->radv);
113+
ipv6->conf.enabled = NI_TRISTATE_DISABLE;
114+
return 0;
115+
}
116+
97117
/*
98118
* dhcpcd does something very odd when shutting down an interface;
99119
* in addition to removing all IPv4 addresses, it also removes any
@@ -157,6 +177,15 @@ ni_system_ipv6_devinfo_set(ni_netdev_t *dev, const ni_ipv6_devconf_t *conf)
157177
if (!conf || !(ipv6 = ni_netdev_get_ipv6(dev)))
158178
return -1;
159179

180+
if (!ni_ipv6_supported()) {
181+
ipv6->conf.enabled = NI_TRISTATE_DISABLE;
182+
if (ni_tristate_is_enabled(conf->enabled)) {
183+
errno = EAFNOSUPPORT;
184+
return -1;
185+
}
186+
return 0;
187+
}
188+
160189
if (ni_tristate_is_set(conf->enabled)) {
161190
if (__ni_system_ipv6_devinfo_change_int(dev->name, "disable_ipv6",
162191
ni_tristate_is_enabled(conf->enabled) ? 0 : 1) < 0)

0 commit comments

Comments
 (0)