Skip to content

Commit

Permalink
Merge pull request #581 from mtomaschewski/team-4
Browse files Browse the repository at this point in the history
team: configurable teamd support and ctl detection (fate#318389)
  • Loading branch information
wipawel committed Aug 21, 2015
2 parents 3140c5f + b24750b commit 6948a3e
Show file tree
Hide file tree
Showing 18 changed files with 618 additions and 148 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ else
fi
AC_SUBST(use_nanny)

# Whether to disable teamd support
AC_ARG_ENABLE([teamd],
[AS_HELP_STRING([--disable-teamd],
[disable teamd support])],,
[enable_teamd=true])
if test "x$enable_teamd" = "xno" ; then
use_teamd="false"
else
use_teamd="true"
fi
AC_SUBST(use_teamd)

# Whether to enable system-v init script installation
AC_ARG_ENABLE([systemv],
[AS_HELP_STRING([--enable-systemv],
Expand Down
1 change: 1 addition & 0 deletions etc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ substitute_vars = \
-e "s|[@]wicked_configdir[@]|$(wicked_configdir)|g" \
-e "s|[@]wicked_supplicantdir[@]|$(wicked_supplicantdir)|g"\
-e "s|[@]wicked_extensionsdir[@]|$(wicked_extensionsdir)|g"\
-e "s|[@]use_teamd[@]|$(use_teamd)|g" \
-e "s|[@]use_nanny[@]|$(use_nanny)|g"

%.xml: %.xml.in $(top_builddir)/config.status
Expand Down
22 changes: 20 additions & 2 deletions etc/client.xml.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<!-- Client-specific configuration file -->
<!--
Client-specific (wicked binary) configuration file

This file sources common configuration options from common.xml.

Note:
If you want to make changes to this file, consider putting
your changes into @wicked_configdir@/client-local.xml instead.
Otherwise, you may lose your changes when applying future
maintenance updates.
-->
<config>
<include name="common.xml"/>

Expand All @@ -9,14 +19,22 @@
<script name="ibft" command="@wicked_extensionsdir@/ibft" />
</netif-firmware-discovery>

<!-- This specifies sources of client configuration.
<!-- This specifies sources of network interface configurations.

The ifconfig source specifies the type, location and the
priority/order of the interface configurations.
-->
<sources>
<!-- (bios ibft) firmware -->
<ifconfig location="firmware:" />

<!-- ifcfg interface configs -->
<ifconfig location="compat:" />

<!-- xml interface configs -->
<ifconfig location="wicked:" />
</sources>

<!-- client-local.xml permits to overwrite client options -->
<include name="client-local.xml" optional="true" />
</config>
17 changes: 10 additions & 7 deletions etc/common.xml.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- Common configuration file sourced by all application-specific files -->
<!--
Common configuration file sourced by all application-specific files

Note:
If you want to make changes to this file, consider putting
your changes into @wicked_configdir@/local.xml instead.
Otherwise, you may lose your changes when applying future
maintenance updates.
-->
<config>
<piddir path="@wicked_piddir@" mode="0755"/>
<statedir path="@wicked_statedir@" mode="0755"/>
Expand Down Expand Up @@ -28,11 +36,6 @@
-->
<use-nanny>@use_nanny@</use-nanny>

<!--
If you want to make changes to this file, consider putting
your changes into @wicked_configdir@/local.xml instead.
Otherwise, you may lose your changes when applying
future maintenance updates.
-->
<!-- local.xml permits to overwrite common options -->
<include name="local.xml" optional="true" />
</config>
13 changes: 12 additions & 1 deletion etc/nanny.xml.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- Configuration file for network-nanny -->
<!--
Nanny-specific (wickedd-nanny binanry) configuration

Note:
If you want to make changes to this file, consider putting
your changes into @wicked_configdir@/nanny-local.xml instead.
Otherwise, you may lose your changes when applying future
maintenance updates.
-->
<config>
<include name="common.xml"/>

Expand All @@ -7,4 +15,7 @@
<enable link-layer="ethernet" />
<enable link-layer="wireless" />
</nanny -->

<!-- nanny-local.xml permits to overwrite client options -->
<include name="nanny-local.xml" optional="true" />
</config>
16 changes: 15 additions & 1 deletion etc/server.xml.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<!--
Server-specific configuration file.
Server-specific (wickedd binary) configuration file.

This file sources common configuration options from common.xml.

Above and beyond this, it defines various extensions, and the
handling of resolver and other information received from
addrconf supplicants like dhcp.

Note:
If you want to make changes to this file, consider putting
your changes into @wicked_configdir@/server-local.xml instead.
Otherwise, you may lose your changes when applying future
maintenance updates.
-->
<config>
<include name="common.xml"/>
Expand Down Expand Up @@ -78,4 +85,11 @@
<action name="remove" command="@wicked_extensionsdir@/netconfig remove"/>
</system-updater>

<teamd>
<!-- enable/disable teamd support, see wicked-config(5) -->
<enabled>@use_teamd@</enabled>
</teamd>

<!-- server-local.xml permits to overwrite server options -->
<include name="server-local.xml" optional="true" />
</config>
23 changes: 23 additions & 0 deletions man/wicked-config.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,29 @@ by IPv6 Router Advertisement (RA) or require static configuration.
The current NIS / ypbind implementation does supported IPv6 at all.
.PP
.\" --------------------------------------------------------
.SH SERVER ONLY OPTIONS
.TP
.B teamd
.IP
The \fB<teamd>\fP element permits to enable or disable teamd support
(inclusive discovery of team device details) in its \fB<enable>\fP
sub-element. Disabled by default, \fBserver.xml\fP config enables it.
Further, it permits to specify the control interface to communicate
with teamd in the \fB<ctl>\fP sub-element, using the following options:
.IP
.TS
box;
l|l
lb|l.
Option Description
=
detect-once detect the control interface to use, once (\fBdefault\fP)
detect detect the control interface to use in each call
dbus communicate directly with teamd via dbus
unix use unix socket control interface via teamdctl tool
.TE
.PP
.\" --------------------------------------------------------
.SH EXTENSIONS
The functionality of \fBwickedd\fP can be extended through
external commands and shell scripts. All of these extensions
Expand Down
19 changes: 19 additions & 0 deletions src/appconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ typedef struct ni_config_rtnl_event {
unsigned int mesg_buff_length;
} ni_config_rtnl_event_t;

typedef enum {
NI_CONFIG_TEAMD_CTL_DETECT_ONCE = 0,
NI_CONFIG_TEAMD_CTL_DETECT,
NI_CONFIG_TEAMD_CTL_DBUS,
NI_CONFIG_TEAMD_CTL_UNIX,
} ni_config_teamd_ctl_t;

typedef struct ni_config_teamd {
ni_bool_t enabled;
ni_config_teamd_ctl_t ctl;
} ni_config_teamd_t;

typedef struct ni_config {
ni_config_fslocation_t piddir;
ni_config_fslocation_t storedir;
Expand Down Expand Up @@ -130,6 +142,7 @@ typedef struct ni_config {

ni_config_rtnl_event_t rtnl_event;

ni_config_teamd_t teamd;
} ni_config_t;

extern ni_config_t * ni_config_new();
Expand All @@ -140,6 +153,12 @@ extern ni_extension_t * ni_config_find_system_updater(ni_config_t *, const char
extern unsigned int ni_config_addrconf_update_mask(ni_addrconf_mode_t, unsigned int);
extern ni_bool_t ni_config_use_nanny(void);

extern ni_bool_t ni_config_teamd_enable(ni_config_teamd_ctl_t);
extern ni_bool_t ni_config_teamd_disable(void);
extern ni_bool_t ni_config_teamd_enabled(void);
extern ni_config_teamd_ctl_t ni_config_teamd_ctl(void);
extern const char * ni_config_teamd_ctl_type_to_name(ni_config_teamd_ctl_t);

extern ni_extension_t * ni_extension_list_find(ni_extension_t *, const char *);
extern void ni_extension_list_destroy(ni_extension_t **);
extern ni_extension_t * ni_extension_new(ni_extension_t **, const char *);
Expand Down
101 changes: 101 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static ni_bool_t ni_config_parse_system_updater(ni_extension_t **, xml_node_t *)
static ni_bool_t ni_config_parse_extension(ni_extension_t *, xml_node_t *);
static ni_bool_t ni_config_parse_sources(ni_config_t *, xml_node_t *);
static ni_bool_t ni_config_parse_rtnl_event(ni_config_rtnl_event_t *, xml_node_t *);
static ni_bool_t ni_config_parse_teamd(ni_config_teamd_t *, const xml_node_t *);
static ni_c_binding_t * ni_c_binding_new(ni_c_binding_t **, const char *name, const char *lib, const char *symbol);
static const char * ni_config_build_include(const char *, const char *);
static unsigned int ni_config_addrconf_update_mask_all(void);
Expand Down Expand Up @@ -74,6 +75,9 @@ ni_config_new()
conf->rtnl_event.recv_buff_length = 1024 * 1024;
conf->rtnl_event.mesg_buff_length = 0;

/* we enable it explicitly in wickedd only */
conf->teamd.enabled = FALSE;

return conf;
}

Expand Down Expand Up @@ -239,6 +243,10 @@ __ni_config_parse(ni_config_t *conf, const char *filename, ni_init_appdata_callb
if (!ni_config_parse_rtnl_event(&conf->rtnl_event, child))
goto failed;
} else
if (strcmp(child->name, "teamd") == 0) {
if (!ni_config_parse_teamd(&conf->teamd, child))
goto failed;
}
if (cb != NULL) {
if (!cb(appdata, child))
goto failed;
Expand Down Expand Up @@ -946,6 +954,99 @@ ni_config_parse_rtnl_event(ni_config_rtnl_event_t *conf, xml_node_t *node)
return TRUE;
}

/*
* teamd support config options
*/
static const ni_intmap_t config_teamd_ctl_names[] = {
{ "detect-once", NI_CONFIG_TEAMD_CTL_DETECT_ONCE },
{ "detect", NI_CONFIG_TEAMD_CTL_DETECT },
{ "dbus", NI_CONFIG_TEAMD_CTL_DBUS },
{ "unix", NI_CONFIG_TEAMD_CTL_UNIX },
{ NULL, -1U }
};

const char *
ni_config_teamd_ctl_type_to_name(ni_config_teamd_ctl_t type)
{
return ni_format_uint_mapped(type, config_teamd_ctl_names);
}

static ni_bool_t
ni_config_teamd_ctl_name_to_type(const char *name, ni_config_teamd_ctl_t *type)
{
unsigned int _type;

if (!name || !type)
return FALSE;

if (ni_parse_uint_mapped(name, config_teamd_ctl_names, &_type) != 0)
return FALSE;

*type = _type;
return TRUE;
}

ni_bool_t
ni_config_teamd_enabled(void)
{
return ni_global.config ? ni_global.config->teamd.enabled : FALSE;
}

ni_config_teamd_ctl_t
ni_config_teamd_ctl(void)
{
return ni_global.config ? ni_global.config->teamd.ctl : NI_CONFIG_TEAMD_CTL_DETECT_ONCE;
}

ni_bool_t
ni_config_teamd_enable(ni_config_teamd_ctl_t type)
{
if (ni_global.config && ni_config_teamd_ctl_type_to_name(type)) {
ni_global.config->teamd.enabled = TRUE;
ni_global.config->teamd.ctl = type;
return TRUE;
}
return FALSE;
}

ni_bool_t
ni_config_teamd_disable(void)
{
if (ni_global.config) {
ni_global.config->teamd.enabled = FALSE;
ni_global.config->teamd.ctl = NI_CONFIG_TEAMD_CTL_DETECT_ONCE;
return TRUE;
}
return FALSE;
}

static ni_bool_t
ni_config_parse_teamd(ni_config_teamd_t *conf, const xml_node_t *node)
{
const xml_node_t *child;

if (!conf || !node)
return FALSE;

for (child = node->children; child; child = child->next) {
if (ni_string_eq(child->name, "enabled")) {
if (ni_parse_boolean(child->cdata, &conf->enabled)) {
ni_error("%s: invalid <teamd><enable>%s</enable></teamd> option",
xml_node_location(child), child->cdata);
return FALSE;
}
}
if (ni_string_eq(child->name, "ctl")) {
if (!ni_config_teamd_ctl_name_to_type(child->cdata, &conf->ctl)) {
ni_error("%s: invalid <teamd><ctl>%s</ctl></teamd> option",
xml_node_location(child), child->cdata);
return FALSE;
}
}
}
return TRUE;
}

/*
* Extension handling
*/
Expand Down
4 changes: 3 additions & 1 deletion src/dbus-objects/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "netinfo_priv.h"
#include "dbus-common.h"
#include "xml-schema.h"
#include "appconfig.h"
#include "model.h"
#include "debug.h"

Expand Down Expand Up @@ -119,8 +120,9 @@ ni_objectmodel_register_netif_services(void)
ni_objectmodel_register_netif_service(NI_IFTYPE_INFINIBAND, &ni_objectmodel_ibparent_service);
ni_objectmodel_register_netif_service(NI_IFTYPE_INFINIBAND_CHILD, &ni_objectmodel_ibchild_service);

if (ni_config_teamd_enabled())
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_team_factory_service);
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_bond_factory_service);
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_team_factory_service);
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_bridge_factory_service);
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_vlan_factory_service);
ni_objectmodel_register_netif_factory_service(&ni_objectmodel_macvlan_factory_service);
Expand Down
Loading

0 comments on commit 6948a3e

Please sign in to comment.