networkd: Make DHCP client ID creation configurable
This commit is contained in:
parent
ff88a301e9
commit
3e43b2cd97
|
@ -563,6 +563,14 @@
|
||||||
false.</para>
|
false.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term><varname>VendorClassIdentifier=</varname></term>
|
<term><varname>VendorClassIdentifier=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -661,5 +661,21 @@ int dhcp4_configure(Link *link) {
|
||||||
return r;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ Route.Destination, config_parse_destination, 0,
|
||||||
Route.Source, config_parse_destination, 0, 0
|
Route.Source, config_parse_destination, 0, 0
|
||||||
Route.Metric, config_parse_route_priority, 0, 0
|
Route.Metric, config_parse_route_priority, 0, 0
|
||||||
Route.Scope, config_parse_route_scope, 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.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns)
|
||||||
DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu)
|
DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu)
|
||||||
DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname)
|
DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname)
|
||||||
|
|
|
@ -103,6 +103,7 @@ static int network_load_one(Manager *manager, const char *filename) {
|
||||||
network->dhcp_routes = true;
|
network->dhcp_routes = true;
|
||||||
network->dhcp_sendhost = true;
|
network->dhcp_sendhost = true;
|
||||||
network->dhcp_route_metric = DHCP_ROUTE_METRIC;
|
network->dhcp_route_metric = DHCP_ROUTE_METRIC;
|
||||||
|
network->dhcp_client_identifier = DHCP_CLIENT_ID_DUID;
|
||||||
|
|
||||||
network->llmnr = LLMNR_SUPPORT_YES;
|
network->llmnr = LLMNR_SUPPORT_YES;
|
||||||
|
|
||||||
|
@ -600,6 +601,14 @@ int config_parse_dhcp(
|
||||||
return 0;
|
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] = {
|
static const char* const llmnr_support_table[_LLMNR_SUPPORT_MAX] = {
|
||||||
[LLMNR_SUPPORT_NO] = "no",
|
[LLMNR_SUPPORT_NO] = "no",
|
||||||
[LLMNR_SUPPORT_YES] = "yes",
|
[LLMNR_SUPPORT_YES] = "yes",
|
||||||
|
|
|
@ -83,6 +83,13 @@ typedef enum LinkOperationalState {
|
||||||
_LINK_OPERSTATE_INVALID = -1
|
_LINK_OPERSTATE_INVALID = -1
|
||||||
} LinkOperationalState;
|
} LinkOperationalState;
|
||||||
|
|
||||||
|
typedef enum DCHPClientIdentifier {
|
||||||
|
DHCP_CLIENT_ID_MAC,
|
||||||
|
DHCP_CLIENT_ID_DUID,
|
||||||
|
_DHCP_CLIENT_ID_MAX,
|
||||||
|
_DHCP_CLIENT_ID_INVALID = -1,
|
||||||
|
} DCHPClientIdentifier;
|
||||||
|
|
||||||
struct FdbEntry {
|
struct FdbEntry {
|
||||||
Network *network;
|
Network *network;
|
||||||
unsigned section;
|
unsigned section;
|
||||||
|
@ -115,6 +122,7 @@ struct Network {
|
||||||
NetDev *bond;
|
NetDev *bond;
|
||||||
Hashmap *stacked_netdevs;
|
Hashmap *stacked_netdevs;
|
||||||
AddressFamilyBoolean dhcp;
|
AddressFamilyBoolean dhcp;
|
||||||
|
DCHPClientIdentifier dhcp_client_identifier;
|
||||||
char *dhcp_vendor_class_identifier;
|
char *dhcp_vendor_class_identifier;
|
||||||
bool dhcp_dns;
|
bool dhcp_dns;
|
||||||
bool dhcp_ntp;
|
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,
|
int config_parse_dhcp(const char *unit, const char *filename, unsigned line,
|
||||||
const char *section, unsigned section_line, const char *lvalue,
|
const char *section, unsigned section_line, const char *lvalue,
|
||||||
int ltype, const char *rvalue, void *data, void *userdata);
|
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) */
|
/* IPv4LL support (legacy) */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue