Skip to content

Commit

Permalink
Merge pull request #708 from mtomaschewski/dhcp-update-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Jun 28, 2017
2 parents bf7548e + 396e989 commit 42c43ba
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 134 deletions.
6 changes: 3 additions & 3 deletions client/compat.c
Expand Up @@ -120,20 +120,20 @@ ni_compat_netdev_new(const char *ifname)
compat->dev = ni_netdev_new(ifname, 0);

/* Apply defaults */
compat->dhcp4.update = ni_config_addrconf_update_mask(NI_ADDRCONF_DHCP, AF_INET);
compat->dhcp4.update = ni_config_addrconf_update(ifname, NI_ADDRCONF_DHCP, AF_INET);
compat->dhcp4.recover_lease = TRUE;
compat->dhcp4.release_lease = FALSE;
compat->dhcp4.user_class.format = -1U;
ni_dhcp_fqdn_init(&compat->dhcp4.fqdn);

compat->dhcp6.update = ni_config_addrconf_update_mask(NI_ADDRCONF_DHCP, AF_INET6);
compat->dhcp6.update = ni_config_addrconf_update(ifname, NI_ADDRCONF_DHCP, AF_INET6);
compat->dhcp6.mode = NI_DHCP6_MODE_AUTO;
compat->dhcp6.rapid_commit = TRUE;
compat->dhcp6.recover_lease = TRUE;
compat->dhcp6.release_lease = FALSE;
ni_dhcp_fqdn_init(&compat->dhcp6.fqdn);

compat->auto6.update = ni_config_addrconf_update_mask(NI_ADDRCONF_AUTOCONF, AF_INET6);
compat->auto6.update = ni_config_addrconf_update(ifname, NI_ADDRCONF_AUTOCONF, AF_INET6);

return compat;
}
Expand Down
35 changes: 30 additions & 5 deletions client/suse/compat-suse.c
Expand Up @@ -5052,6 +5052,17 @@ __ni_suse_addrconf_dhcp4_options(const ni_sysconfig_t *sc, ni_compat_netdev_t *c
ni_bool_t bvalue;
ni_bool_t ret = TRUE;

if ((string = ni_sysconfig_get_value(sc, "DHCLIENT_UPDATE")) != NULL) {
if (ni_addrconf_update_flags_parse(&uint, string, " \t,")) {
uint &= ni_config_addrconf_update_mask(NI_ADDRCONF_DHCP, AF_INET);
compat->dhcp4.update = uint;
} else {
ni_warn("%s: Unknown flags in DHCLIENT_UPDATE='%s'",
ni_basename(sc->pathname),
ni_print_suspect(string, ni_string_len(string)));
}
}

if ((string = ni_sysconfig_get_value(sc, "DHCLIENT_FQDN_ENABLED")) != NULL) {
if (ni_parse_boolean(string, &bvalue) == 0)
ni_tristate_set(&compat->dhcp4.fqdn.enabled, bvalue);
Expand Down Expand Up @@ -5173,6 +5184,18 @@ __ni_suse_addrconf_dhcp6_options(const ni_sysconfig_t *sc, ni_compat_netdev_t *c
const char *string;
ni_bool_t bvalue;

if ((string = ni_sysconfig_get_value(sc, "DHCLIENT6_UPDATE")) != NULL) {
if (ni_addrconf_update_flags_parse(&uint, string, " \t,")) {
uint &= ni_config_addrconf_update_mask(NI_ADDRCONF_DHCP, AF_INET6);
compat->dhcp6.update = uint;
} else {
ni_warn("%s: Unknown flags in DHCLIENT6_UPDATE='%s'",
ni_basename(sc->pathname),
ni_print_suspect(string, ni_string_len(string)));
ret = FALSE;
}
}

if ((string = ni_sysconfig_get_value(sc, "DHCLIENT6_MODE")) != NULL) {
if (ni_dhcp6_mode_name_to_type(string, &compat->dhcp6.mode) != 0) {
ni_warn("%s: Cannot parse DHCLIENT6_MODE='%s'",
Expand Down Expand Up @@ -5404,13 +5427,15 @@ __ni_suse_addrconf_auto6(const ni_sysconfig_t *sc, ni_compat_netdev_t *compat)
&compat->auto6.defer_timeout);

if ((value = ni_sysconfig_get_value(merged, "AUTO6_UPDATE"))) {
unsigned int temp = __NI_ADDRCONF_UPDATE_NONE;
unsigned int temp;

if (ni_addrconf_update_flags_parse(&temp, value, " \t"))
compat->auto6.update &= temp;
else
if (ni_addrconf_update_flags_parse(&temp, value, " \t,")) {
temp &= ni_config_addrconf_update_mask(NI_ADDRCONF_AUTOCONF, AF_INET6);
compat->auto6.update = temp;
} else {
ni_warn("ifcfg-%s: unknown flags in AUTO6_UPDATE='%s'",
dev->name, value);
dev->name, ni_print_suspect(value, ni_string_len(value)));
}
}
ni_sysconfig_destroy(merged);
}
Expand Down
34 changes: 34 additions & 0 deletions client/suse/config/sysconfig.dhcp-wicked
Expand Up @@ -39,6 +39,24 @@ DHCLIENT_FQDN_QUALIFY="yes"
#
DHCLIENT_FQDN_ENCODE="yes"

## Type: list(,default,none,all,dns,ntp,nis,tz,boot,smb,nds,slp,sip,log)
## Default: ""
#
# This variable permits to specify a space separated list of build-in
# facility names supported by the dhcp4 client modifying the default
# options used in requests and to update system settings (via netconfig).
#
# When empty, default settings configured in wicked-config(5) or built-in
# defaults are used. The special "default", "all", and "none" sets enable
# to request none, the built-in default set or all supported options,
# respectively. A "no-" or "-" in the front of a facility name permit to
# remove/disable it from the currently applied set, e.g. "default,-nis"
# disables request for nis options.
# More specific variables as DHCLIENT_SET_DEFAULT_ROUTE,_SET_HOSTNAME or
# the MTU option have higher precedence.
#
DHCLIENT_UPDATE=""

## Type: list(enabled,disabled,default,)
## Default: ""
#
Expand Down Expand Up @@ -69,3 +87,19 @@ DHCLIENT6_FQDN_UPDATE=""
#
DHCLIENT6_FQDN_QUALIFY="yes"

## Type: list(,default,none,all,dns,ntp,tz,boot,nis,sip)
## Default: ""
#
# This variable permits to specify a space separated list of build-in
# facility names supported by the dhcp6 client modifying the default
# options used in requests and to update system settings (via netconfig).
#
# When empty, default settings configured in wicked-config(5) or built-in
# defaults are used. The special "default", "all", and "none" sets enable
# to request none, the built-in default set or all supported options,
# respectively. A "no-" or "-" in the front of a facility name permit to
# remove/disable it from the currently applied set, e.g. "default,-nis"
# disables request for nis options.
# The more specific variable DHCLIENT6_SET_HOSTNAME has higher precedence.
#
DHCLIENT6_UPDATE=""
5 changes: 5 additions & 0 deletions include/wicked/addrconf.h
Expand Up @@ -24,6 +24,10 @@ enum {
NI_ADDRCONF_UPDATE_SLP,
NI_ADDRCONF_UPDATE_LOG,
NI_ADDRCONF_UPDATE_MTU,
NI_ADDRCONF_UPDATE_SIP,
NI_ADDRCONF_UPDATE_LPR,
NI_ADDRCONF_UPDATE_TZ,
NI_ADDRCONF_UPDATE_BOOT,
__NI_ADDRCONF_UPDATE_NONE = 0,
};

Expand Down Expand Up @@ -245,6 +249,7 @@ extern const char * ni_addrconf_flags_format(ni_stringbuf_t *, unsigned int, con
extern const char * ni_addrconf_update_flag_to_name(unsigned int);
extern ni_bool_t ni_addrconf_update_name_to_flag(const char *, unsigned int *);
extern void ni_addrconf_update_set(unsigned int *, unsigned int, ni_bool_t);
extern ni_bool_t ni_addrconf_update_flags_parse_names(unsigned int *, const ni_string_array_t *);
extern ni_bool_t ni_addrconf_update_flags_parse(unsigned int *, const char *, const char *);
extern const char * ni_addrconf_update_flags_format(ni_stringbuf_t *, unsigned int, const char *);

Expand Down
35 changes: 31 additions & 4 deletions man/ifcfg-dhcp.5.in
Expand Up @@ -74,10 +74,10 @@ This option allows to set a metric/priority for DHCPv4 routes. Default is 0.
.BR DHCLIENT_CLIENT_ID
Specifies a client identifier string. By default an id derived from the
hardware address of the network interface is sent as client identifier.
.TP
.BR DHCLIENT_VENDOR_CLASS_ID
Specifies the vendor class identifier string. The default is DHCP client
specific.
.\" .TP
.\" .BR DHCLIENT_VENDOR_CLASS_ID
.\" Specifies the vendor class identifier string. The default is DHCP client
.\" specific.
.TP
.BR DHCLIENT_USER_CLASS_FORMAT\ { string* | rfc3004 }
Specifies the format of the DHCLIENT_USER_CLASS_ID variable.
Expand Down Expand Up @@ -135,6 +135,20 @@ The DHCP client will stop processing / fail after this time when it does
not get a reply from the DHCP server. Before you set this variable, take a
look at DHCLIENT_WAIT_AT_BOOT allowing to continue in background instead.
Default value is 0.
.TP
.BR DHCLIENT_UPDATE\ {default,none,all,dns,ntp,nis,tz,boot,smb,nds,slp,sip,log}
This variable permits to specify a space separated list of build-in
facility names supported by the dhcp4 client modifying the default
options used in requests and to update system settings (via netconfig).

When empty, default settings configured in wicked-config(5) or built-in
defaults are used. The special "default", "all", and "none" sets enable
to request none, the built-in default set or all supported options,
respectively. A "no-" or "-" in the front of a facility name permit to
remove/disable it from the currently applied set, e.g. "default,-nis"
disables request for nis options.
More specific variables as DHCLIENT_SET_DEFAULT_ROUTE,DHCLIENT_SET_HOSTNAME
or the MTU option have higher precedence.

.SH DHCPv6 Specific Variables
.TP
Expand Down Expand Up @@ -241,6 +255,19 @@ The DHCPv6 client will stop processing / fail after this time when it does
not get a reply from the DHCPv6 server. Before you set this variable, take a
look at DHCLIENT6_WAIT_AT_BOOT allowing to continue in background instead.
.TP
.BR DHCLIENT6_UPDATE\ {default,none,all,dns,ntp,tz,boot,nis,sip}
This variable permits to specify a space separated list of build-in
facility names supported by the dhcp6 client modifying the default
options used in requests and to update system settings (via netconfig).

When empty, default settings configured in wicked-config(5) or built-in
defaults are used. The special "default", "all", and "none" sets enable
to request none, the built-in default set or all supported options,
respectively. A "no-" or "-" in the front of a facility name permit to
remove/disable it from the currently applied set, e.g. "default,-nis"
disables request for nis options.
The more specific variable DHCLIENT6_SET_HOSTNAME has higher precedence.
.TP

.SH COPYRIGHT
Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
Expand Down
108 changes: 91 additions & 17 deletions man/wicked-config.5.in
Expand Up @@ -224,18 +224,31 @@ information provided by address configuration to apply.
Most dynamic address configuration protocols, including DHCP, do not just provide
a list of addresses and routes to install for the managed network interface,
but can be used to provide information such as a list of DNS servers, directory
information (for e.g. NIS), etc. A system receiving that information is free
to reconfigure some of its services based on this information.
For instance, it makes a lot of sense to configure the resolver library
to use the DNS servers specified by a DHCP server. On the other hand,
for security reasons you may want to ignore any NIS information received
via DHCP.
.IP
The \fB<default-allow-update>\fP element allows you to control which
system services \fBwicked\fP will consider to update. It contains a list
of empty XML elements naming system facilities to update. The special
elements \fB<all>\fP and \fB<none>\fP enable and disable any and all
updates, respectively. Other valid updaters are:
information (for e.g. NIS), etc. A system receiving that information is free to
reconfigure some of its services based on this information.
For instance, it makes a lot of sense to configure the resolver library to use
the DNS servers specified by a DHCP server. On the other hand, you may want to
ignore any NIS information received via DHCP.
.IP
The \fB<default-allow-update>\fP is applied to static and intrinsic leases, which
do not have an own, type and address family specific \fB<allow-update>\fP element
as available under the \fB<dhcp6>\fP, \fB<dhcp4>\fP, \fB<auto6>\fP and \fB<auto4>\fP
sub-elements, which support a sub-set of the possible facilities listed here.
The \fB<default-allow-update>\fP and the type specific \fB<allow-update>\fR elements
enable you to control which system services \fBwicked\fP will (request and) consider
to update in the system.
.IP
It contains a list of either empty XML elements e.g. (<dns/><ntp/>) naming system
the facilities or alternatively, a space separated string list (dns ntp) with the
facility names.
The special elements \fBdefault\fR, \fBnone\fP and \fBall\fP enable and disable
the default, none and all updates, respectively. A \fBno-\fR or a \fB-\fR in the
front of a facility name permits to remove/disable a facility from the currently
applied set and enable further supported facilities, e.g. \fBdefault,-nis,slp\fR
is applying a modified \fBdefault\fR set with disabled \fBnis\fR and the optional
\fBslp\fR facility enabled additionally.
.IP
The following updater facilities are currently defined:
.IP
.TS
box;
Expand All @@ -248,9 +261,15 @@ hostname system hostname
dns update resolv.conf or dns server (via netconfig)
nis NIS client (via netconfig)
ntp NTP servers (via netconfig)
smb SMB client (not implemented)
slp SLP client (not implemented)
log syslog servers (not implemented)
smb SMB settings (no netconfig module implemented)
nds NDS servers (no netconfig module implemented)
slp SLP client (no netconfig module implemented)
sip SIP client (no netconfig module implemented)
log syslog servers (no netconfig module implemented)
lpr print servers (no netconfig module implemented)
tz posix time zone (no netconfig module implemented)
mtu adjust iterface mtu (dhcp4)
boot root-path (dhcp4)/boot-url (dhcp6) used in the initrd
.TE

.IP
Expand All @@ -265,6 +284,10 @@ supplicant. See below for a list of options.
.B dhcp6
This element can be used to control the behavior of the DHCP6
supplicant. See below for a list of options.
.TP
.B auto6
This element can be used to control the behavior of AUTO6 processing.
.TP
.\" --------------------------------------------------------
.SH DHCP4 SUPPLICANT OPTIONS
The DHCP4 client can be configured through the options listed below.
Expand Down Expand Up @@ -294,6 +317,7 @@ or inside a device name context like:
.B vendor-class
Specifies the string to be used as the vendor-class option in the DHCP
request. By default, no vendor-class option is sent.

.TP
.B lease-time
Specifies the lease time to request in the DHCP request, in seconds. This also
Expand All @@ -304,6 +328,7 @@ lease time to one hour:
.IP
.B " <lease-time>3600</lease-time>
.PP

.TP
.B ignore-server
Using the \fBip\fB attribute of this element, you can specify the
Expand All @@ -312,6 +337,7 @@ server that should be ignored:
.IP
.B " <ignore-server ip=\(dq192.168.8.1\(dq />
.B " <ignore-server mac=\(dq52:54:00:02:c2:67\(dq />

.TP
.B prefer-server
Specify a preferred DHCP server, together with a numeric value indicating its
Expand All @@ -337,11 +363,35 @@ The following example will ignore 192.168.8.1, always use the information from
.B " <prefer-server ip=\(dq192.168.8.10\(dq weight=\(dq100\(dq />
.B " <prefer-server ip=\(dq192.168.8.7\(dq weight=\(dq50\(dq />
.fi

.TP
.B allow-update
Specify the list of system services that \fBwicked\fP will configure based
on the DHCP lease received. For the syntax of this element, please refer
to the description of \fBdefault-allow-update\fP above.
to the description of \fBdefault-allow-update\fP above. \fBdhcp4\fR supports
all update facilities.
.TP
.B route-options
Specify a space separated list of routing options to request from dhcp4 server.
.IP
.TS
box;
l|l|l
lb|lb|lb.
Name Alias Description
=
classless csr RFC 3442 classless static route option 121
ms-classless mscsr MS classless static route option code 249 (pre RFC 3442)
static-routes class Obsolete option 33 requesting static class routes
.TE

.IP
The RFC 3442 classless static route option provides all routes with a netmask,
includes the default routers and has priority over other routing options.
By default, wicked requests classless (121) as well as class static routes (33)
and the default routers option (3) (when enabled in allow-update) to be
compatible to old servers or servers not configured to provide classless,
but only a default router option.

.TP
.B define
Expand Down Expand Up @@ -403,6 +453,7 @@ make sure to delete that file before restarting the DHCPv6 supplicant.
.\" vendor-class
.\" vendor-opts
.\"

.TP
.B lease-time
Specifies the lease time to request in the DHCP request, in seconds. This also
Expand All @@ -413,6 +464,7 @@ lease time to one hour:
.IP
.B " <lease-time>3600</lease-time>
.PP

.TP
.B ignore-server
Using the \fBip\fB attribute of this element, you can specify the
Expand All @@ -422,6 +474,7 @@ IP address of a faulty DHCP server that should be ignored:
.\" are almost always link-local addrs, not the global unicast
.\" address; thanks to relying on multicast exclusively).
.\"

.TP
.B prefer-server
Specify a preferred DHCP server, together with a numeric value indicating its
Expand Down Expand Up @@ -449,11 +502,32 @@ to the third if not:
.B " <prefer-server id=\(dq00:44:01:02:04:01\(dq weight=\(dq100\(dq />
.B " <prefer-server id=\(dq00:44:01:02:04:02\(dq weight=\(dq50\(dq />
.fi

.TP
.B allow-update
Specify the list of system services that \fBwicked\fP will configure based
on the DHCP lease received. For the syntax of this element, please refer
to the description of \fBdefault-allow-update\fP above.
to the description of \fBdefault-allow-update\fP above. \fBDHCPv6\fR allows
the following update facilities:
.IP
.TS
box;
l|l
lb|lb.
Name Description
=
hostname system hostname (fqdn)
dns update resolv.conf or dns server (via netconfig)
ntp NTP servers (via netconfig)
sip SIP client (optional, no netconfig module implemented)
nis NIS client (optional, no netconfig module, not supported by ypbind)
tz posix time zone (no netconfig module implemented)
boot boot-url used in the initrd
.TE

.IP
Note: \fBDHCPv6\fR protocol does not provide any options to request routing
settings, which are applied via a router advertisement (\fBIPv6 RA\fR).

.TP
.B define
Expand Down

0 comments on commit 42c43ba

Please sign in to comment.