Skip to content

Commit

Permalink
ipv6: catch ipv6.disable=1 kernel command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Mar 24, 2014
1 parent a52d118 commit 6e9eff4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/wicked/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct ni_ipv6_devinfo {
ni_ipv6_ra_info_t radv;
};

extern ni_bool_t ni_ipv6_supported(void);

extern ni_ipv6_devinfo_t * ni_netdev_get_ipv6(ni_netdev_t *);
extern void ni_netdev_set_ipv6(ni_netdev_t *, ni_ipv6_devconf_t *);

Expand Down
3 changes: 2 additions & 1 deletion src/dbus-objects/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ ni_objectmodel_ipv6_change_protocol(ni_dbus_object_t *object, const ni_dbus_meth
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/ifconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ ni_system_ipv6_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_ipv6_devconf
* seems rather good at that.
* The only way to recover from that is by upping the interface briefly.
*/
if (!ni_sysctl_ipv6_ifconfig_is_present(dev->name)) {
if (ni_ipv6_supported() && !ni_sysctl_ipv6_ifconfig_is_present(dev->name)) {
if (__ni_rtnl_link_up(dev, NULL) >= 0) {
unsigned int count = 100;

Expand Down
29 changes: 29 additions & 0 deletions src/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@

#include <wicked/netinfo.h>
#include <wicked/logging.h>
#include <errno.h>

#include "ipv6_priv.h"
#include "util_priv.h"
#include "sysfs.h"

#define NI_PROC_SYS_NET_IPV6_DIR "/proc/sys/net/ipv6"

#define NI_IPV6_RA_RDNSS_ADDRS_CHUNK 4

/*
* Check if ipv6 is supported or disabled
* via ipv6.disabled=1 kernel command line.
*/
ni_bool_t
ni_ipv6_supported(void)
{
return ni_isdir(NI_PROC_SYS_NET_IPV6_DIR);
}

/*
* Reset to ipv6 config defaults
*/
Expand Down Expand Up @@ -94,6 +107,13 @@ ni_system_ipv6_devinfo_get(ni_netdev_t *dev, ni_ipv6_devinfo_t *ipv6)
if (ipv6 == NULL)
ipv6 = ni_netdev_get_ipv6(dev);

if (!ni_ipv6_supported()) {
__ni_ipv6_devconf_reset(&ipv6->conf);
__ni_ipv6_ra_info_reset(&ipv6->radv);
ipv6->conf.enabled = NI_TRISTATE_DISABLE;
return 0;
}

/*
* dhcpcd does something very odd when shutting down an interface;
* in addition to removing all IPv4 addresses, it also removes any
Expand Down Expand Up @@ -157,6 +177,15 @@ ni_system_ipv6_devinfo_set(ni_netdev_t *dev, const ni_ipv6_devconf_t *conf)
if (!conf || !(ipv6 = ni_netdev_get_ipv6(dev)))
return -1;

if (!ni_ipv6_supported()) {
ipv6->conf.enabled = NI_TRISTATE_DISABLE;
if (ni_tristate_is_enabled(conf->enabled)) {
errno = EAFNOSUPPORT;
return -1;
}
return 0;
}

if (ni_tristate_is_set(conf->enabled)) {
if (__ni_system_ipv6_devinfo_change_int(dev->name, "disable_ipv6",
ni_tristate_is_enabled(conf->enabled) ? 0 : 1) < 0)
Expand Down

0 comments on commit 6e9eff4

Please sign in to comment.