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

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

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..6e101ba
4--- /dev/null
5+++ b/debian/patches/lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch
6@@ -0,0 +1,146 @@
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+@@ -22,6 +22,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+@@ -1316,6 +1316,30 @@
72+ return 0;
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+@@ -1350,8 +1374,7 @@
103+ if (r < 0)
104+ return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set callback: %m");
105+
106+- r = sd_dhcp_client_set_request_broadcast(link->dhcp_client,
107+- link->network->dhcp_broadcast);
108++ r = sd_dhcp_client_set_request_broadcast(link->dhcp_client, link_needs_dhcp_broadcast(link));
109+ if (r < 0)
110+ return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for broadcast: %m");
111+
112+--- a/src/network/networkd-network-gperf.gperf
113++++ b/src/network/networkd-network-gperf.gperf
114+@@ -196,7 +196,7 @@
115+ DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
116+ DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
117+ DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
118+-DHCPv4.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
119++DHCPv4.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast)
120+ DHCPv4.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
121+ DHCPv4.MUDURL, config_parse_dhcp_mud_url, 0, 0
122+ DHCPv4.MaxAttempts, config_parse_dhcp_max_attempts, 0, 0
123+@@ -454,7 +454,7 @@
124+ DHCP.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
125+ DHCP.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
126+ DHCP.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
127+-DHCP.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
128++DHCP.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast)
129+ DHCP.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical)
130+ DHCP.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
131+ DHCP.UserClass, config_parse_dhcp_user_class, AF_INET, offsetof(Network, dhcp_user_class)
132+--- a/src/network/networkd-network.c
133++++ b/src/network/networkd-network.c
134+@@ -398,6 +398,7 @@
135+ .dhcp_use_mtu = false,
136+ /* NOTE: from man: UseTimezone=... Defaults to "no".*/
137+ .dhcp_use_timezone = false,
138++ .dhcp_broadcast = -1,
139+ .dhcp_ip_service_type = -1,
140+
141+ .dhcp6_rapid_commit = true,
142+--- a/src/network/networkd-network.h
143++++ b/src/network/networkd-network.h
144+@@ -140,7 +140,7 @@
145+ int dhcp_ip_service_type;
146+ bool dhcp_anonymize;
147+ bool dhcp_send_hostname;
148+- bool dhcp_broadcast;
149++ int dhcp_broadcast;
150+ bool dhcp_use_dns;
151+ bool dhcp_use_dns_set;
152+ bool dhcp_routes_to_dns;
153diff --git a/debian/patches/series b/debian/patches/series
154index 5f5cf90..3ab6e88 100644
155--- a/debian/patches/series
156+++ b/debian/patches/series
157@@ -94,3 +94,4 @@ lp1891215/0001-fs-util-add-conservative_rename-that-suppresses-unne.patch
158 lp1891215/0002-resolved-don-t-update-resolv.conf-snippets-unnecessa.patch
159 lp1891215/0003-fs-util-rename-conservative_rename-conservative_rena.patch
160 lp1891215/0004-fs-util-make-sure-conservative_renameat-properly-det.patch
161+lp1914740-network-enable-DHCP-broadcast-flag-if-required-by-in.patch

Subscribers

People subscribed via source and target branches