Merge ~schopin/ubuntu/+source/systemd/+git/systemd-1:impish/hipersocket-dhcp into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-impish

Proposed by Simon Chopin
Status: Merged
Merged at revision: 9e20d2f9d70b25782bdd1c7dbec0d179604b88cc
Proposed branch: ~schopin/ubuntu/+source/systemd/+git/systemd-1:impish/hipersocket-dhcp
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-impish
Diff against target: 160 lines (+146/-0)
2 files modified
debian/patches/lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch (+145/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Pending
Review via email: mp+405970@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Simon Chopin (schopin) wrote :

As for the hirsute and focal patches, there's a package available at https://launchpad.net/~schopin/+archive/ubuntu/test-ppa/+packages for testing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/patches/lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch b/debian/patches/lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch
2new file mode 100644
3index 0000000..71438cc
4--- /dev/null
5+++ b/debian/patches/lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch
6@@ -0,0 +1,145 @@
7+From 0fd173d4e50f9deddb76a66ab50deccc2dc8329d Mon Sep 17 00:00:00 2001
8+From: Viktor Mihajlovski <mihajlov@linux.ibm.com>
9+Date: Wed, 14 Apr 2021 13:01:35 +0200
10+Subject: [PATCH] network: enable DHCP broadcast flag if required by interface
11+
12+Some interfaces require that the DHCPOFFER message is sent via broadcast
13+if they can't receive unicast messages before they've been configured
14+with an IP address.
15+
16+E.g., s390 ccwgroup network interfaces operating in layer3 mode face
17+this limitation. This can prevent the interfaces from receiving an
18+IP address via DHCP, if the have been configured for layer3.
19+
20+To allow DHCP over such interfaces, we're introducing a new device
21+property ID_NET_DHCP_BROADCAST which can be set for those.
22+The networkd DHCP client will check whether this property is set
23+for an interface, and if so will set the broadcast flag, unless
24+the network configuration for the interface has an explicit
25+RequestBroadcast setting.
26+
27+Besides that, we're adding a udev rule to set this device property
28+for ccwgroup devices operating in layer3 mode, which is the case
29+if the ID_NET_DRIVER property is qeth_l3.
30+
31+Supercedes #18829
32+---
33+ rules.d/81-net-dhcp.rules | 14 ++++++++++++
34+ rules.d/meson.build | 1 +
35+ src/network/networkd-dhcp4.c | 27 ++++++++++++++++++++++--
36+ src/network/networkd-network-gperf.gperf | 4 ++--
37+ src/network/networkd-network.c | 1 +
38+ src/network/networkd-network.h | 2 +-
39+ 6 files changed, 44 insertions(+), 5 deletions(-)
40+ create mode 100644 rules.d/81-net-dhcp.rules
41+
42+--- /dev/null
43++++ b/rules.d/81-net-dhcp.rules
44+@@ -0,0 +1,14 @@
45++# do not edit this file, it will be overwritten on update
46++
47++ACTION=="remove", GOTO="net_dhcp_end"
48++SUBSYSTEM!="net", GOTO="net_dhcp_end"
49++
50++# Network interfaces requiring DHCPOFFER messages to be broadcast
51++# must set ID_NET_DHCP_BROADCAST to "1". This property will be
52++# checked by the networkd DHCP4 client to set the DHCP option
53++
54++# s390 ccwgroup interfaces in layer3 mode need broadcast DHCPOFFER
55++# using the link driver to detect this condition
56++ENV{ID_NET_DRIVER}=="qeth_l3", ENV{ID_NET_DHCP_BROADCAST}="1"
57++
58++LABEL="net_dhcp_end"
59+--- a/rules.d/meson.build
60++++ b/rules.d/meson.build
61+@@ -26,6 +26,7 @@
62+ 75-probe_mtd.rules
63+ 78-sound-card.rules
64+ 80-net-setup-link.rules
65++ 81-net-dhcp.rules
66+ '''.split())
67+
68+ if conf.get('HAVE_KMOD') == 1
69+--- a/src/network/networkd-dhcp4.c
70++++ b/src/network/networkd-dhcp4.c
71+@@ -1286,6 +1286,30 @@
72+ return sd_dhcp_client_set_request_address(link->dhcp_client, &a->in_addr.in);
73+ }
74+
75++static bool link_needs_dhcp_broadcast(Link *link) {
76++ const char *val;
77++ int r;
78++
79++ assert(link);
80++ assert(link->network);
81++
82++ /* Return the setting in DHCP[4].RequestBroadcast if specified. Otherwise return the device property
83++ * ID_NET_DHCP_BROADCAST setting, which may be set for interfaces requiring that the DHCPOFFER message
84++ * is being broadcast because they can't handle unicast messages while not fully configured.
85++ * If neither is set or a failure occurs, return false, which is the default for this flag.
86++ */
87++ r = link->network->dhcp_broadcast;
88++ if (r < 0 && link->sd_device && sd_device_get_property_value(link->sd_device, "ID_NET_DHCP_BROADCAST", &val) >= 0) {
89++ r = parse_boolean(val);
90++ if (r < 0)
91++ log_link_warning_errno(link, r, "DHCP4 CLIENT: Failed to parse ID_NET_DHCP_BROADCAST, ignoring: %m");
92++ else
93++ log_link_debug(link, "DHCP4 CLIENT: Detected ID_NET_DHCP_BROADCAST='%d'.", r);
94++
95++ }
96++ return r == true;
97++}
98++
99+ int dhcp4_configure(Link *link) {
100+ sd_dhcp_option *send_option;
101+ void *request_options;
102+@@ -1322,7 +1346,7 @@
103+ if (r < 0)
104+ return log_link_warning_errno(link, r, "DHCP4 CLIENT: Failed to set callback: %m");
105+
106+- r = sd_dhcp_client_set_request_broadcast(link->dhcp_client, link->network->dhcp_broadcast);
107++ r = sd_dhcp_client_set_request_broadcast(link->dhcp_client, link_needs_dhcp_broadcast(link));
108+ if (r < 0)
109+ return log_link_warning_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for broadcast: %m");
110+
111+--- a/src/network/networkd-network-gperf.gperf
112++++ b/src/network/networkd-network-gperf.gperf
113+@@ -206,7 +206,7 @@
114+ DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
115+ DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
116+ DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
117+-DHCPv4.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
118++DHCPv4.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast)
119+ DHCPv4.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
120+ DHCPv4.MUDURL, config_parse_dhcp_mud_url, 0, 0
121+ DHCPv4.MaxAttempts, config_parse_dhcp_max_attempts, 0, 0
122+@@ -472,7 +472,7 @@
123+ DHCP.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
124+ DHCP.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
125+ DHCP.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
126+-DHCP.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
127++DHCP.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast)
128+ DHCP.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical)
129+ DHCP.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
130+ DHCP.UserClass, config_parse_dhcp_user_or_vendor_class, AF_INET, offsetof(Network, dhcp_user_class)
131+--- a/src/network/networkd-network.c
132++++ b/src/network/networkd-network.c
133+@@ -383,6 +383,7 @@
134+ .dhcp_use_mtu = false,
135+ /* NOTE: from man: UseTimezone=... Defaults to "no".*/
136+ .dhcp_use_timezone = false,
137++ .dhcp_broadcast = -1,
138+ .dhcp_ip_service_type = -1,
139+
140+ .dhcp6_use_address = true,
141+--- a/src/network/networkd-network.h
142++++ b/src/network/networkd-network.h
143+@@ -135,7 +135,7 @@
144+ int dhcp_ip_service_type;
145+ bool dhcp_anonymize;
146+ bool dhcp_send_hostname;
147+- bool dhcp_broadcast;
148++ int dhcp_broadcast;
149+ bool dhcp_use_dns;
150+ bool dhcp_use_dns_set;
151+ bool dhcp_routes_to_dns;
152diff --git a/debian/patches/series b/debian/patches/series
153index dba1c7d..d281fb1 100644
154--- a/debian/patches/series
155+++ b/debian/patches/series
156@@ -53,3 +53,4 @@ lp1894622-Add-systemd-resolve-backwards-compatibility-section-.patch
157 lp1858210/0001-time-simplify-get_timezones.patch
158 lp1858210/0002-time-split-get_timezone-into-main-function-and-zone1.patch
159 lp1858210/0003-time-get-timezones-from-tzdata.zi.patch
160+lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch

Subscribers

People subscribed via source and target branches