summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp4.c
diff options
context:
space:
mode:
authorMaxime de Roucy <maxime.deroucy@fr.clara.net>2021-08-14 22:50:14 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-08-16 19:40:18 +0200
commitd419ef0243ac88bba1e45e6dac5e8801077a0269 (patch)
treeb996c49bda9a1bf3210d0eeb973b5ec3136c07b1 /src/network/networkd-dhcp4.c
parentnetwork: allow users to forbid passthru MACVLAN from putting its link into pr... (diff)
downloadsystemd-d419ef0243ac88bba1e45e6dac5e8801077a0269.tar.xz
systemd-d419ef0243ac88bba1e45e6dac5e8801077a0269.zip
network: add address label on dhcpv4
Fixes: #13967
Diffstat (limited to 'src/network/networkd-dhcp4.c')
-rw-r--r--src/network/networkd-dhcp4.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 12fb85bf90..c35b5514a5 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -992,6 +992,12 @@ static int dhcp4_request_address(Link *link, bool announce) {
addr->route_metric = link->network->dhcp_route_metric;
addr->duplicate_address_detection = link->network->dhcp_send_decline ? ADDRESS_FAMILY_IPV4 : ADDRESS_FAMILY_NO;
+ if (link->network->dhcp_label) {
+ addr->label = strdup(link->network->dhcp_label);
+ if (!addr->label)
+ return log_oom();
+ }
+
if (address_get(link, addr, NULL) < 0)
link->dhcp4_configured = false;
@@ -1876,6 +1882,39 @@ int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
return 0;
}
+int config_parse_dhcp_label(
+ 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) {
+
+ char **label = data;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (isempty(rvalue)) {
+ *label = mfree(*label);
+ return 0;
+ }
+
+ if (!address_label_valid(rvalue)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Address label is too long or invalid, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ return free_and_strdup_warn(label, rvalue);
+}
+
static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
[DHCP_CLIENT_ID_MAC] = "mac",
[DHCP_CLIENT_ID_DUID] = "duid",