diff options
-rw-r--r-- | man/systemd.network.xml | 8 | ||||
-rw-r--r-- | src/network/networkd-dhcp4.c | 16 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 1 | ||||
-rw-r--r-- | src/network/networkd-network.c | 9 | ||||
-rw-r--r-- | src/network/networkd.h | 11 |
5 files changed, 45 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 60252e53a9..3522551293 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 c3d0e3d39d..38321905e6 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 b0c23a7898..93df83af08 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 0ba0c75714..f7f6eaf7fd 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 e75746f2c9..8bdc2bed82 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) */ |