[systemd-commits] 3 commits - man/systemd.network.xml src/libsystemd-network src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Wed Mar 4 02:01:59 PST 2015
man/systemd.network.xml | 8 ++++++++
src/libsystemd-network/sd-dhcp6-client.c | 18 ++++++++++++------
src/network/networkd-dhcp4.c | 16 ++++++++++++++++
src/network/networkd-netdev.c | 2 +-
src/network/networkd-network-gperf.gperf | 1 +
src/network/networkd-network.c | 9 +++++++++
src/network/networkd.h | 11 +++++++++++
7 files changed, 58 insertions(+), 7 deletions(-)
New commits:
commit cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3
Author: Thomas Haller <thaller at redhat.com>
Date: Tue Mar 3 21:06:29 2015 +0100
sd-dhcp6-client: delay setting the DUID and don't fail constructor
sd_dhcp6_client_new() tried to set the DUID based on the machine id.
If the host has no /etc/machine-id, the constructor would fail
making it impossible to create an sd_dhcp6_client instance.
Relax this and create a DUID only later as needed. This way a caller
caller can workaround a missing machine-id file and set a DUID of his
choosing via sd_dhcp6_client_set_duid().
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index a432bbf..3db1cb0 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -158,6 +158,13 @@ int sd_dhcp6_client_set_mac(sd_dhcp6_client *client, const uint8_t *addr,
return 0;
}
+static int client_ensure_duid(sd_dhcp6_client *client)
+{
+ if (client->duid_len != 0)
+ return 0;
+ return dhcp_identifier_set_duid_en(&client->duid, &client->duid_len);
+}
+
int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *duid,
size_t duid_len)
{
@@ -378,6 +385,7 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
if (r < 0)
return r;
+ assert (client->duid_len);
r = dhcp6_option_append(&opt, &optlen, DHCP6_OPTION_CLIENTID,
client->duid_len, &client->duid);
if (r < 0)
@@ -1108,6 +1116,10 @@ int sd_dhcp6_client_start(sd_dhcp6_client *client)
if (r < 0)
return r;
+ r = client_ensure_duid(client);
+ if (r < 0)
+ return r;
+
r = dhcp6_network_bind_udp_socket(client->index, NULL);
if (r < 0)
return r;
@@ -1205,7 +1217,6 @@ sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client) {
int sd_dhcp6_client_new(sd_dhcp6_client **ret)
{
_cleanup_dhcp6_client_unref_ sd_dhcp6_client *client = NULL;
- int r;
size_t t;
assert_return(ret, -EINVAL);
@@ -1222,11 +1233,6 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret)
client->fd = -1;
- /* initialize DUID */
- r = dhcp_identifier_set_duid_en(&client->duid, &client->duid_len);
- if (r < 0)
- return r;
-
client->req_opts_len = ELEMENTSOF(default_req_opts);
client->req_opts = new0(be16_t, client->req_opts_len);
commit 3e43b2cd97bd82efe6a09e8b9b2e6b5f33f578a0
Author: Jan Janssen <medhefgo at web.de>
Date: Tue Mar 3 19:49:48 2015 +0100
networkd: Make DHCP client ID creation configurable
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 60252e5..3522551 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -564,6 +564,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><varname>ClientIdentifier=</varname></term>
+ <listitem>
+ <para>DHCP client identifier to use. Either <literal>mac</literal>
+ to use the MAC address of the link or <literal>duid</literal>
+ (the default) to use a RFC4361-complient Client ID.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>VendorClassIdentifier=</varname></term>
<listitem>
<para>The vendor class identifier used to identify vendor
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index c3d0e3d..3832190 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -661,5 +661,21 @@ int dhcp4_configure(Link *link) {
return r;
}
+ switch (link->network->dhcp_client_identifier) {
+ case DHCP_CLIENT_ID_DUID:
+ /* Library defaults to this. */
+ break;
+ case DHCP_CLIENT_ID_MAC:
+ r = sd_dhcp_client_set_client_id(link->dhcp_client,
+ ARPHRD_ETHER,
+ (const uint8_t *) &link->mac,
+ sizeof (link->mac));
+ if (r < 0)
+ return r;
+ break;
+ default:
+ assert_not_reached("Unknown client identifier type.");
+ }
+
return 0;
}
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index b0c23a7..93df83a 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -58,6 +58,7 @@ Route.Destination, config_parse_destination, 0,
Route.Source, config_parse_destination, 0, 0
Route.Metric, config_parse_route_priority, 0, 0
Route.Scope, config_parse_route_scope, 0, 0
+DHCP.ClientIdentifier, config_parse_dhcp_client_identifier,0, offsetof(Network, dhcp_client_identifier)
DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns)
DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu)
DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 0ba0c75..f7f6eaf 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -103,6 +103,7 @@ static int network_load_one(Manager *manager, const char *filename) {
network->dhcp_routes = true;
network->dhcp_sendhost = true;
network->dhcp_route_metric = DHCP_ROUTE_METRIC;
+ network->dhcp_client_identifier = DHCP_CLIENT_ID_DUID;
network->llmnr = LLMNR_SUPPORT_YES;
@@ -600,6 +601,14 @@ int config_parse_dhcp(
return 0;
}
+static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
+ [DHCP_CLIENT_ID_MAC] = "mac",
+ [DHCP_CLIENT_ID_DUID] = "duid"
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_client_identifier, DCHPClientIdentifier);
+DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_client_identifier, dhcp_client_identifier, DCHPClientIdentifier, "Failed to parse client identifier type");
+
static const char* const llmnr_support_table[_LLMNR_SUPPORT_MAX] = {
[LLMNR_SUPPORT_NO] = "no",
[LLMNR_SUPPORT_YES] = "yes",
diff --git a/src/network/networkd.h b/src/network/networkd.h
index e75746f..8bdc2be 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -83,6 +83,13 @@ typedef enum LinkOperationalState {
_LINK_OPERSTATE_INVALID = -1
} LinkOperationalState;
+typedef enum DCHPClientIdentifier {
+ DHCP_CLIENT_ID_MAC,
+ DHCP_CLIENT_ID_DUID,
+ _DHCP_CLIENT_ID_MAX,
+ _DHCP_CLIENT_ID_INVALID = -1,
+} DCHPClientIdentifier;
+
struct FdbEntry {
Network *network;
unsigned section;
@@ -115,6 +122,7 @@ struct Network {
NetDev *bond;
Hashmap *stacked_netdevs;
AddressFamilyBoolean dhcp;
+ DCHPClientIdentifier dhcp_client_identifier;
char *dhcp_vendor_class_identifier;
bool dhcp_dns;
bool dhcp_ntp;
@@ -403,6 +411,9 @@ int config_parse_fdb_vlan_id(const char *unit, const char *filename, unsigned li
int config_parse_dhcp(const char *unit, const char *filename, unsigned line,
const char *section, unsigned section_line, const char *lvalue,
int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_dhcp_client_identifier(const char *unit, const char *filename, unsigned line,
+ const char *section, unsigned section_line, const char *lvalue,
+ int ltype, const char *rvalue, void *data, void *userdata);
/* IPv4LL support (legacy) */
commit ff88a301e93cf1bddbaa7faa981f390a2a81a4bb
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Mar 4 10:33:50 2015 +0100
networkd: netdev - inform when we take over an existing netdev
The crucial point here is that we will not change the settings of a netdev created by someone else
we simply use it as is and trust it was set up as intended.
This is confusing in the case of the pre-created netdev's (bond0 etc.), the solution should probably
be to simply make the kernel stop creating these devices as they are pretty useless.
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 3d7cc73..e98040d 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -260,7 +260,7 @@ static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda
r = sd_rtnl_message_get_errno(m);
if (r == -EEXIST)
- log_netdev_debug(netdev, "netdev exists, using existing");
+ log_info_netdev(netdev, "netdev exists, using existing without changing its parameters");
else if (r < 0) {
log_warning_netdev(netdev, "netdev could not be created: %s", strerror(-r));
netdev_drop(netdev);
More information about the systemd-commits
mailing list