Merge ~ddstreet/ubuntu/+source/systemd:use_gateway_default_ucd into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy
- Git
- lp:~ddstreet/ubuntu/+source/systemd
- use_gateway_default_ucd
- Merge into ubuntu-groovy
Proposed by
Dan Streetman
on 2020-05-08
Status: | Merged |
---|---|
Approved by: | Balint Reczey on 2020-05-11 |
Approved revision: | cb8bc8830fe8ffa60548634f880fd0efe17e15c7 |
Merged at revision: | cb8bc8830fe8ffa60548634f880fd0efe17e15c7 |
Proposed branch: | ~ddstreet/ubuntu/+source/systemd:use_gateway_default_ucd |
Merge into: | ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy |
Diff against target: |
699 lines (+550/-14) 9 files modified
debian/patches/debian/Ubuntu-UseDomains-by-default.patch (+3/-3) debian/patches/dhcp-Allow-setting-request-options-again.patch (+5/-5) debian/patches/lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch (+5/-5) debian/patches/network-change-UseGateway-default-to-UseRoutes-setting.patch (+84/-0) debian/patches/network-do-not-re-attach-sd-event-object.patch (+1/-1) debian/patches/network-honor-SetDNSRoutes-even-if-UseGateway-False.patch (+156/-0) debian/patches/series (+4/-0) debian/patches/test-modify-add-tests-for-UseRoutes-and-UseGateway-config.patch (+210/-0) debian/patches/test-verify-RoutesToDNS-is-independent-of-UseGateway.patch (+82/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Balint Reczey | 2020-05-08 | Pending | |
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Dan Streetman (ddstreet) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/debian/patches/debian/Ubuntu-UseDomains-by-default.patch b/debian/patches/debian/Ubuntu-UseDomains-by-default.patch |
2 | index ed670ff..01a92a3 100644 |
3 | --- a/debian/patches/debian/Ubuntu-UseDomains-by-default.patch |
4 | +++ b/debian/patches/debian/Ubuntu-UseDomains-by-default.patch |
5 | @@ -44,7 +44,7 @@ index 120347d..97f96f9 100644 |
6 | |
7 | <para>It is recommended to enable this option only on trusted networks, as setting this affects resolution |
8 | of all host names, in particular of single-label names. It is generally safer to use the supplied domain |
9 | -@@ -1729,7 +1729,7 @@ |
10 | +@@ -1730,7 +1730,7 @@ |
11 | the effect of the <option>Domains=</option> setting. If set to <literal>route</literal>, the domain name |
12 | received via IPv6 RA will be used for routing DNS queries only, but not for searching, similar to the |
13 | effect of the <option>Domains=</option> setting when the argument is prefixed with |
14 | @@ -57,7 +57,7 @@ diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c |
15 | index c643419..0604ada 100644 |
16 | --- a/src/network/networkd-network.c |
17 | +++ b/src/network/networkd-network.c |
18 | -@@ -387,6 +387,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi |
19 | +@@ -390,6 +390,7 @@ int network_load_one(Manager *manager, O |
20 | /* NOTE: this var might be overwritten by network_apply_anonymize_if_set */ |
21 | .dhcp_send_hostname = true, |
22 | .dhcp_send_release = true, |
23 | @@ -65,7 +65,7 @@ index c643419..0604ada 100644 |
24 | /* To enable/disable RFC7844 Anonymity Profiles */ |
25 | .dhcp_anonymize = false, |
26 | .dhcp_route_metric = DHCP_ROUTE_METRIC, |
27 | -@@ -448,6 +449,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi |
28 | +@@ -451,6 +452,7 @@ int network_load_one(Manager *manager, O |
29 | .multicast = -1, |
30 | .allmulticast = -1, |
31 | .ipv6_accept_ra_use_dns = true, |
32 | diff --git a/debian/patches/dhcp-Allow-setting-request-options-again.patch b/debian/patches/dhcp-Allow-setting-request-options-again.patch |
33 | index 683cef6..c2d3128 100644 |
34 | --- a/debian/patches/dhcp-Allow-setting-request-options-again.patch |
35 | +++ b/debian/patches/dhcp-Allow-setting-request-options-again.patch |
36 | @@ -15,7 +15,7 @@ diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd |
37 | index 4122d08..54a5dcc 100644 |
38 | --- a/src/libsystemd-network/sd-dhcp-client.c |
39 | +++ b/src/libsystemd-network/sd-dhcp-client.c |
40 | -@@ -188,8 +188,10 @@ int sd_dhcp_client_set_request_option(sd_dhcp_client *client, uint8_t option) { |
41 | +@@ -188,8 +188,10 @@ int sd_dhcp_client_set_request_option(sd |
42 | } |
43 | |
44 | for (i = 0; i < client->req_opts_size; i++) |
45 | @@ -32,7 +32,7 @@ diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/ |
46 | index 4e9b388..071a2c3 100644 |
47 | --- a/src/libsystemd-network/test-dhcp-client.c |
48 | +++ b/src/libsystemd-network/test-dhcp-client.c |
49 | -@@ -71,17 +71,17 @@ static void test_request_basic(sd_event *e) { |
50 | +@@ -71,17 +71,17 @@ static void test_request_basic(sd_event |
51 | assert_se(sd_dhcp_client_set_hostname(client, "~host.domain") == -EINVAL); |
52 | |
53 | assert_se(sd_dhcp_client_set_request_option(client, |
54 | @@ -55,7 +55,7 @@ index 4e9b388..071a2c3 100644 |
55 | |
56 | assert_se(sd_dhcp_client_set_request_option(client, |
57 | SD_DHCP_OPTION_PAD) == -EINVAL); |
58 | -@@ -101,9 +101,9 @@ static void test_request_basic(sd_event *e) { |
59 | +@@ -101,9 +101,9 @@ static void test_request_basic(sd_event |
60 | * Options not set by default (using or not anonymize) are option 17 |
61 | * (SD_DHCP_OPTION_ROOT_PATH) and 42 (SD_DHCP_OPTION_NTP_SERVER) */ |
62 | assert_se(sd_dhcp_client_set_request_option(client, 17) == 0); |
63 | @@ -67,7 +67,7 @@ index 4e9b388..071a2c3 100644 |
64 | |
65 | sd_dhcp_client_unref(client); |
66 | } |
67 | -@@ -126,7 +126,7 @@ static void test_request_anonymize(sd_event *e) { |
68 | +@@ -126,7 +126,7 @@ static void test_request_anonymize(sd_ev |
69 | assert_se(r >= 0); |
70 | |
71 | assert_se(sd_dhcp_client_set_request_option(client, |
72 | @@ -76,7 +76,7 @@ index 4e9b388..071a2c3 100644 |
73 | /* This PRL option is not set when using Anonymize */ |
74 | assert_se(sd_dhcp_client_set_request_option(client, |
75 | SD_DHCP_OPTION_HOST_NAME) == 0); |
76 | -@@ -137,7 +137,7 @@ static void test_request_anonymize(sd_event *e) { |
77 | +@@ -137,7 +137,7 @@ static void test_request_anonymize(sd_ev |
78 | /* RFC7844: option 101 (SD_DHCP_OPTION_NEW_TZDB_TIMEZONE) is not set in the |
79 | * default PRL when using Anonymize, */ |
80 | assert_se(sd_dhcp_client_set_request_option(client, 101) == 0); |
81 | diff --git a/debian/patches/lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch b/debian/patches/lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch |
82 | index d5b0db0..80edf92 100644 |
83 | --- a/debian/patches/lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch |
84 | +++ b/debian/patches/lp1860926-network-Change-IgnoreCarrierLoss-default-to-value-of.patch |
85 | @@ -35,7 +35,7 @@ diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-net |
86 | index d3dda3d..2fc7881 100644 |
87 | --- a/src/network/networkd-network-gperf.gperf |
88 | +++ b/src/network/networkd-network-gperf.gperf |
89 | -@@ -98,7 +98,7 @@ Network.ProxyARP, config_parse_tristate, |
90 | +@@ -98,7 +98,7 @@ Network.ProxyARP, |
91 | Network.IPv6ProxyNDPAddress, config_parse_ipv6_proxy_ndp_address, 0, 0 |
92 | Network.BindCarrier, config_parse_strv, 0, offsetof(Network, bind_carrier) |
93 | Network.ConfigureWithoutCarrier, config_parse_bool, 0, offsetof(Network, configure_without_carrier) |
94 | @@ -48,9 +48,9 @@ diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c |
95 | index 0604ada..c6dc3ea 100644 |
96 | --- a/src/network/networkd-network.c |
97 | +++ b/src/network/networkd-network.c |
98 | -@@ -265,6 +265,9 @@ int network_verify(Network *network) { |
99 | - network->dhcp_use_mtu = false; |
100 | - } |
101 | +@@ -268,6 +268,9 @@ int network_verify(Network *network) { |
102 | + if (network->dhcp_use_gateway < 0) |
103 | + network->dhcp_use_gateway = network->dhcp_use_routes; |
104 | |
105 | + if (network->ignore_carrier_loss < 0) |
106 | + network->ignore_carrier_loss = network->configure_without_carrier; |
107 | @@ -58,7 +58,7 @@ index 0604ada..c6dc3ea 100644 |
108 | if (network->dhcp_critical >= 0) { |
109 | if (network->keep_configuration >= 0) |
110 | log_warning("%s: Both KeepConfiguration= and deprecated CriticalConnection= are set. " |
111 | -@@ -455,6 +458,8 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi |
112 | +@@ -458,6 +461,8 @@ int network_load_one(Manager *manager, O |
113 | .ipv6_accept_ra_route_table = RT_TABLE_MAIN, |
114 | .ipv6_accept_ra_route_table_set = false, |
115 | |
116 | diff --git a/debian/patches/network-change-UseGateway-default-to-UseRoutes-setting.patch b/debian/patches/network-change-UseGateway-default-to-UseRoutes-setting.patch |
117 | new file mode 100644 |
118 | index 0000000..57ff350 |
119 | --- /dev/null |
120 | +++ b/debian/patches/network-change-UseGateway-default-to-UseRoutes-setting.patch |
121 | @@ -0,0 +1,84 @@ |
122 | +From: Dan Streetman <ddstreet@canonical.com> |
123 | +Date: Wed, 15 Apr 2020 14:40:21 -0400 |
124 | +Subject: network: change UseGateway= default to UseRoutes= setting |
125 | + |
126 | +Anyone previously using the UseRoutes=false parameter expected their |
127 | +dhcp4-provided gateway route to be ignored, as well. However, with |
128 | +the introduction of the UseGateway= parameter, this is no longer true. |
129 | + |
130 | +In order to keep backwards compatibility, this sets the UseGateway= |
131 | +default value to whatever UseRoutes= has been set to. |
132 | + |
133 | +(cherry picked from commit 589397a27759bd650b3674029cb0ef73347c913b) |
134 | +--- |
135 | + man/systemd.network.xml | 5 +++-- |
136 | + src/network/networkd-network-gperf.gperf | 2 +- |
137 | + src/network/networkd-network.c | 5 ++++- |
138 | + src/network/networkd-network.h | 2 +- |
139 | + 4 files changed, 9 insertions(+), 5 deletions(-) |
140 | + |
141 | +diff --git a/man/systemd.network.xml b/man/systemd.network.xml |
142 | +index 120347d..5175704 100644 |
143 | +--- a/man/systemd.network.xml |
144 | ++++ b/man/systemd.network.xml |
145 | +@@ -1477,8 +1477,9 @@ |
146 | + <varlistentry> |
147 | + <term><varname>UseGateway=</varname></term> |
148 | + <listitem> |
149 | +- <para>When true (the default), the gateway will be requested from the DHCP server and added to the |
150 | +- routing table with a metric of 1024, and a scope of "link".</para> |
151 | ++ <para>When true, the gateway will be requested from the DHCP server and added to the routing table with a |
152 | ++ metric of 1024, and a scope of "link". When unset, the value specified with <option>UseRoutes=</option> |
153 | ++ is used.</para> |
154 | + </listitem> |
155 | + </varlistentry> |
156 | + <varlistentry> |
157 | +diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf |
158 | +index d3dda3d..1a07ae9 100644 |
159 | +--- a/src/network/networkd-network-gperf.gperf |
160 | ++++ b/src/network/networkd-network-gperf.gperf |
161 | +@@ -162,7 +162,7 @@ DHCPv4.UseMTU, config_parse_bool, |
162 | + DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname) |
163 | + DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) |
164 | + DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes) |
165 | +-DHCPv4.UseGateway, config_parse_bool, 0, offsetof(Network, dhcp_use_gateway) |
166 | ++DHCPv4.UseGateway, config_parse_tristate, 0, offsetof(Network, dhcp_use_gateway) |
167 | + DHCPv4.RequestOptions, config_parse_dhcp_request_options, 0, 0 |
168 | + DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize) |
169 | + DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname) |
170 | +diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c |
171 | +index c643419..093d298 100644 |
172 | +--- a/src/network/networkd-network.c |
173 | ++++ b/src/network/networkd-network.c |
174 | +@@ -265,6 +265,9 @@ int network_verify(Network *network) { |
175 | + network->dhcp_use_mtu = false; |
176 | + } |
177 | + |
178 | ++ if (network->dhcp_use_gateway < 0) |
179 | ++ network->dhcp_use_gateway = network->dhcp_use_routes; |
180 | ++ |
181 | + if (network->dhcp_critical >= 0) { |
182 | + if (network->keep_configuration >= 0) |
183 | + log_warning("%s: Both KeepConfiguration= and deprecated CriticalConnection= are set. " |
184 | +@@ -383,7 +386,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi |
185 | + .dhcp_use_dns = true, |
186 | + .dhcp_use_hostname = true, |
187 | + .dhcp_use_routes = true, |
188 | +- .dhcp_use_gateway = true, |
189 | ++ .dhcp_use_gateway = -1, |
190 | + /* NOTE: this var might be overwritten by network_apply_anonymize_if_set */ |
191 | + .dhcp_send_hostname = true, |
192 | + .dhcp_send_release = true, |
193 | +diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h |
194 | +index 0d46dbb..6231618 100644 |
195 | +--- a/src/network/networkd-network.h |
196 | ++++ b/src/network/networkd-network.h |
197 | +@@ -110,7 +110,7 @@ struct Network { |
198 | + bool dhcp_use_sip; |
199 | + bool dhcp_use_mtu; |
200 | + bool dhcp_use_routes; |
201 | +- bool dhcp_use_gateway; |
202 | ++ int dhcp_use_gateway; |
203 | + bool dhcp_use_timezone; |
204 | + bool rapid_commit; |
205 | + bool dhcp_use_hostname; |
206 | diff --git a/debian/patches/network-do-not-re-attach-sd-event-object.patch b/debian/patches/network-do-not-re-attach-sd-event-object.patch |
207 | index 2bfd233..4cd9018 100644 |
208 | --- a/debian/patches/network-do-not-re-attach-sd-event-object.patch |
209 | +++ b/debian/patches/network-do-not-re-attach-sd-event-object.patch |
210 | @@ -14,7 +14,7 @@ diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c |
211 | index 3f65804..6419037 100644 |
212 | --- a/src/network/networkd-dhcp4.c |
213 | +++ b/src/network/networkd-dhcp4.c |
214 | -@@ -1337,11 +1337,11 @@ int dhcp4_configure(Link *link) { |
215 | +@@ -1336,11 +1336,11 @@ int dhcp4_configure(Link *link) { |
216 | return log_oom(); |
217 | if (r < 0) |
218 | return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to create DHCP4 client: %m"); |
219 | diff --git a/debian/patches/network-honor-SetDNSRoutes-even-if-UseGateway-False.patch b/debian/patches/network-honor-SetDNSRoutes-even-if-UseGateway-False.patch |
220 | new file mode 100644 |
221 | index 0000000..5035ed8 |
222 | --- /dev/null |
223 | +++ b/debian/patches/network-honor-SetDNSRoutes-even-if-UseGateway-False.patch |
224 | @@ -0,0 +1,156 @@ |
225 | +From: Dan Streetman <ddstreet@canonical.com> |
226 | +Date: Wed, 15 Apr 2020 18:05:14 -0400 |
227 | +Subject: network: honor SetDNSRoutes= even if UseGateway=False |
228 | + |
229 | +(cherry picked from commit 244490f5e0a98f83190e92033fbdaa1bbcd9b000) |
230 | +--- |
231 | + src/network/networkd-dhcp4.c | 129 +++++++++++++++++++++---------------------- |
232 | + 1 file changed, 64 insertions(+), 65 deletions(-) |
233 | + |
234 | +diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c |
235 | +index 3f65804..f2b9def 100644 |
236 | +--- a/src/network/networkd-dhcp4.c |
237 | ++++ b/src/network/networkd-dhcp4.c |
238 | +@@ -323,78 +323,77 @@ static int link_set_dhcp_routes(Link *link) { |
239 | + } |
240 | + } |
241 | + |
242 | +- if (!link->network->dhcp_use_gateway) |
243 | +- return 0; |
244 | +- |
245 | +- r = sd_dhcp_lease_get_router(link->dhcp_lease, &router); |
246 | +- if (IN_SET(r, 0, -ENODATA)) |
247 | +- log_link_info(link, "DHCP: No gateway received from DHCP server."); |
248 | +- else if (r < 0) |
249 | +- log_link_warning_errno(link, r, "DHCP error: could not get gateway: %m"); |
250 | +- else if (in4_addr_is_null(&router[0])) |
251 | +- log_link_info(link, "DHCP: Received gateway is null."); |
252 | +- |
253 | +- /* According to RFC 3442: If the DHCP server returns both a Classless Static Routes option and |
254 | +- a Router option, the DHCP client MUST ignore the Router option. */ |
255 | +- if (classless_route && static_route) |
256 | +- log_link_warning(link, "Classless static routes received from DHCP server: ignoring static-route option and router option"); |
257 | +- |
258 | +- if (r > 0 && !classless_route && !in4_addr_is_null(&router[0])) { |
259 | +- _cleanup_(route_freep) Route *route = NULL, *route_gw = NULL; |
260 | +- |
261 | +- r = route_new(&route_gw); |
262 | +- if (r < 0) |
263 | +- return log_link_error_errno(link, r, "Could not allocate route: %m"); |
264 | +- |
265 | +- /* The dhcp netmask may mask out the gateway. Add an explicit |
266 | +- * route for the gw host so that we can route no matter the |
267 | +- * netmask or existing kernel route tables. */ |
268 | +- route_gw->family = AF_INET; |
269 | +- route_gw->dst.in = router[0]; |
270 | +- route_gw->dst_prefixlen = 32; |
271 | +- route_gw->prefsrc.in = address; |
272 | +- route_gw->scope = RT_SCOPE_LINK; |
273 | +- route_gw->protocol = RTPROT_DHCP; |
274 | +- route_gw->priority = link->network->dhcp_route_metric; |
275 | +- route_gw->table = table; |
276 | +- route_gw->mtu = link->network->dhcp_route_mtu; |
277 | +- |
278 | +- r = dhcp_route_configure(&route_gw, link); |
279 | +- if (r < 0) |
280 | +- return log_link_error_errno(link, r, "Could not set host route: %m"); |
281 | ++ if (link->network->dhcp_use_gateway) { |
282 | ++ r = sd_dhcp_lease_get_router(link->dhcp_lease, &router); |
283 | ++ if (IN_SET(r, 0, -ENODATA)) |
284 | ++ log_link_info(link, "DHCP: No gateway received from DHCP server."); |
285 | ++ else if (r < 0) |
286 | ++ log_link_warning_errno(link, r, "DHCP error: could not get gateway: %m"); |
287 | ++ else if (in4_addr_is_null(&router[0])) |
288 | ++ log_link_info(link, "DHCP: Received gateway is null."); |
289 | ++ |
290 | ++ /* According to RFC 3442: If the DHCP server returns both a Classless Static Routes option and |
291 | ++ a Router option, the DHCP client MUST ignore the Router option. */ |
292 | ++ if (classless_route && static_route) |
293 | ++ log_link_warning(link, "Classless static routes received from DHCP server: ignoring static-route option and router option"); |
294 | ++ |
295 | ++ if (r > 0 && !classless_route && !in4_addr_is_null(&router[0])) { |
296 | ++ _cleanup_(route_freep) Route *route = NULL, *route_gw = NULL; |
297 | ++ |
298 | ++ r = route_new(&route_gw); |
299 | ++ if (r < 0) |
300 | ++ return log_link_error_errno(link, r, "Could not allocate route: %m"); |
301 | ++ |
302 | ++ /* The dhcp netmask may mask out the gateway. Add an explicit |
303 | ++ * route for the gw host so that we can route no matter the |
304 | ++ * netmask or existing kernel route tables. */ |
305 | ++ route_gw->family = AF_INET; |
306 | ++ route_gw->dst.in = router[0]; |
307 | ++ route_gw->dst_prefixlen = 32; |
308 | ++ route_gw->prefsrc.in = address; |
309 | ++ route_gw->scope = RT_SCOPE_LINK; |
310 | ++ route_gw->protocol = RTPROT_DHCP; |
311 | ++ route_gw->priority = link->network->dhcp_route_metric; |
312 | ++ route_gw->table = table; |
313 | ++ route_gw->mtu = link->network->dhcp_route_mtu; |
314 | ++ |
315 | ++ r = dhcp_route_configure(&route_gw, link); |
316 | ++ if (r < 0) |
317 | ++ return log_link_error_errno(link, r, "Could not set host route: %m"); |
318 | + |
319 | +- r = route_new(&route); |
320 | +- if (r < 0) |
321 | +- return log_link_error_errno(link, r, "Could not allocate route: %m"); |
322 | ++ r = route_new(&route); |
323 | ++ if (r < 0) |
324 | ++ return log_link_error_errno(link, r, "Could not allocate route: %m"); |
325 | + |
326 | +- route->family = AF_INET; |
327 | +- route->gw.in = router[0]; |
328 | +- route->prefsrc.in = address; |
329 | +- route->protocol = RTPROT_DHCP; |
330 | +- route->priority = link->network->dhcp_route_metric; |
331 | +- route->table = table; |
332 | +- route->mtu = link->network->dhcp_route_mtu; |
333 | ++ route->family = AF_INET; |
334 | ++ route->gw.in = router[0]; |
335 | ++ route->prefsrc.in = address; |
336 | ++ route->protocol = RTPROT_DHCP; |
337 | ++ route->priority = link->network->dhcp_route_metric; |
338 | ++ route->table = table; |
339 | ++ route->mtu = link->network->dhcp_route_mtu; |
340 | + |
341 | +- r = dhcp_route_configure(&route, link); |
342 | +- if (r < 0) |
343 | +- return log_link_error_errno(link, r, "Could not set router: %m"); |
344 | +- } |
345 | ++ r = dhcp_route_configure(&route, link); |
346 | ++ if (r < 0) |
347 | ++ return log_link_error_errno(link, r, "Could not set router: %m"); |
348 | ++ } |
349 | + |
350 | +- Route *rt; |
351 | +- LIST_FOREACH(routes, rt, link->network->static_routes) { |
352 | +- if (!rt->gateway_from_dhcp) |
353 | +- continue; |
354 | ++ Route *rt; |
355 | ++ LIST_FOREACH(routes, rt, link->network->static_routes) { |
356 | ++ if (!rt->gateway_from_dhcp) |
357 | ++ continue; |
358 | + |
359 | +- if (rt->family != AF_INET) |
360 | +- continue; |
361 | ++ if (rt->family != AF_INET) |
362 | ++ continue; |
363 | + |
364 | +- rt->gw.in = router[0]; |
365 | ++ rt->gw.in = router[0]; |
366 | + |
367 | +- r = route_configure(rt, link, dhcp4_route_handler); |
368 | +- if (r < 0) |
369 | +- return log_link_error_errno(link, r, "Could not set gateway: %m"); |
370 | +- if (r > 0) |
371 | +- link->dhcp4_messages++; |
372 | ++ r = route_configure(rt, link, dhcp4_route_handler); |
373 | ++ if (r < 0) |
374 | ++ return log_link_error_errno(link, r, "Could not set gateway: %m"); |
375 | ++ if (r > 0) |
376 | ++ link->dhcp4_messages++; |
377 | ++ } |
378 | + } |
379 | + |
380 | + return link_set_dns_routes(link, &address); |
381 | diff --git a/debian/patches/series b/debian/patches/series |
382 | index 48bcae4..7f1b7b8 100644 |
383 | --- a/debian/patches/series |
384 | +++ b/debian/patches/series |
385 | @@ -7,6 +7,10 @@ units-drop-systemd-remount-fs.service-dependency-from-mor.patch |
386 | units-make-sure-systemd-pstore-stops-at-shutdown.patch |
387 | network-add-a-flag-to-ignore-gateway-provided-by-DHCP-ser.patch |
388 | test-network-add-a-test-case-for-DHCPv4.UseGateway-no.patch |
389 | +network-change-UseGateway-default-to-UseRoutes-setting.patch |
390 | +test-modify-add-tests-for-UseRoutes-and-UseGateway-config.patch |
391 | +network-honor-SetDNSRoutes-even-if-UseGateway-False.patch |
392 | +test-verify-RoutesToDNS-is-independent-of-UseGateway.patch |
393 | userdb-when-doing-client-side-NSS-look-ups-optionally-avo.patch |
394 | basic-add-_cleanup_-wrappers-for-pthread_mutex_-lock-unlo.patch |
395 | nss-systemd-use-_cleanup_-for-pthread_mutex_-lock-unlock.patch |
396 | diff --git a/debian/patches/test-modify-add-tests-for-UseRoutes-and-UseGateway-config.patch b/debian/patches/test-modify-add-tests-for-UseRoutes-and-UseGateway-config.patch |
397 | new file mode 100644 |
398 | index 0000000..8bc1a27 |
399 | --- /dev/null |
400 | +++ b/debian/patches/test-modify-add-tests-for-UseRoutes-and-UseGateway-config.patch |
401 | @@ -0,0 +1,210 @@ |
402 | +From: Dan Streetman <ddstreet@canonical.com> |
403 | +Date: Wed, 15 Apr 2020 16:26:20 -0400 |
404 | +Subject: test: modify/add tests for UseRoutes= and UseGateway= configuration |
405 | + |
406 | +The last commit changed the UseGateway= default to the value of UseRoutes= |
407 | +so the tests need to check for all combinations of the two parameters. |
408 | + |
409 | +(cherry picked from commit 7c0d36ff5fc31d00e26661fd2ad45291ed0eb6f7) |
410 | +--- |
411 | + .../conf/dhcp-client-ipv4-use-gateway-no.network | 9 ---- |
412 | + .../conf/dhcp-client-ipv4-use-routes-no.network | 9 ---- |
413 | + ...dhcp-client-ipv4-use-routes-use-gateway.network | 9 ++++ |
414 | + .../use-gateway-False.conf | 2 + |
415 | + .../use-gateway-True.conf | 2 + |
416 | + .../use-routes-False.conf | 2 + |
417 | + .../use-routes-True.conf | 2 + |
418 | + test/test-network/systemd-networkd-tests.py | 58 +++++++++++++++------- |
419 | + 8 files changed, 56 insertions(+), 37 deletions(-) |
420 | + delete mode 100644 test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network |
421 | + delete mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-no.network |
422 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
423 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-False.conf |
424 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-True.conf |
425 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-False.conf |
426 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-True.conf |
427 | + |
428 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network b/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network |
429 | +deleted file mode 100644 |
430 | +index fb31772..0000000 |
431 | +--- a/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network |
432 | ++++ /dev/null |
433 | +@@ -1,9 +0,0 @@ |
434 | +-[Match] |
435 | +-Name=veth99 |
436 | +- |
437 | +-[Network] |
438 | +-DHCP=ipv4 |
439 | +-IPv6AcceptRA=false |
440 | +- |
441 | +-[DHCPv4] |
442 | +-UseGateway=no |
443 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-no.network b/test/test-network/conf/dhcp-client-ipv4-use-routes-no.network |
444 | +deleted file mode 100644 |
445 | +index 21e21fa..0000000 |
446 | +--- a/test/test-network/conf/dhcp-client-ipv4-use-routes-no.network |
447 | ++++ /dev/null |
448 | +@@ -1,9 +0,0 @@ |
449 | +-[Match] |
450 | +-Name=veth99 |
451 | +- |
452 | +-[Network] |
453 | +-DHCP=ipv4 |
454 | +-IPv6AcceptRA=false |
455 | +- |
456 | +-[DHCPv4] |
457 | +-UseRoutes=no |
458 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
459 | +new file mode 100644 |
460 | +index 0000000..b0d0d86 |
461 | +--- /dev/null |
462 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
463 | +@@ -0,0 +1,9 @@ |
464 | ++[Match] |
465 | ++Name=veth99 |
466 | ++ |
467 | ++[Network] |
468 | ++DHCP=ipv4 |
469 | ++IPv6AcceptRA=false |
470 | ++ |
471 | ++[DHCPv4] |
472 | ++RoutesToDNS=yes |
473 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-False.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-False.conf |
474 | +new file mode 100644 |
475 | +index 0000000..78d0493 |
476 | +--- /dev/null |
477 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-False.conf |
478 | +@@ -0,0 +1,2 @@ |
479 | ++[DHCPv4] |
480 | ++UseGateway=no |
481 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-True.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-True.conf |
482 | +new file mode 100644 |
483 | +index 0000000..f6f597b |
484 | +--- /dev/null |
485 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-gateway-True.conf |
486 | +@@ -0,0 +1,2 @@ |
487 | ++[DHCPv4] |
488 | ++UseGateway=yes |
489 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-False.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-False.conf |
490 | +new file mode 100644 |
491 | +index 0000000..38fa983 |
492 | +--- /dev/null |
493 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-False.conf |
494 | +@@ -0,0 +1,2 @@ |
495 | ++[DHCPv4] |
496 | ++UseRoutes=no |
497 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-True.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-True.conf |
498 | +new file mode 100644 |
499 | +index 0000000..3b2d0ab |
500 | +--- /dev/null |
501 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-routes-True.conf |
502 | +@@ -0,0 +1,2 @@ |
503 | ++[DHCPv4] |
504 | ++UseRoutes=yes |
505 | +diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py |
506 | +index f7b6974..798e155 100755 |
507 | +--- a/test/test-network/systemd-networkd-tests.py |
508 | ++++ b/test/test-network/systemd-networkd-tests.py |
509 | +@@ -3,6 +3,7 @@ |
510 | + # systemd-networkd tests |
511 | + |
512 | + import argparse |
513 | ++import itertools |
514 | + import os |
515 | + import re |
516 | + import shutil |
517 | +@@ -2826,8 +2827,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
518 | + 'dhcp-client-ipv4-dhcp-settings.network', |
519 | + 'dhcp-client-ipv4-only-ipv6-disabled.network', |
520 | + 'dhcp-client-ipv4-only.network', |
521 | +- 'dhcp-client-ipv4-use-gateway-no.network', |
522 | +- 'dhcp-client-ipv4-use-routes-no.network', |
523 | ++ 'dhcp-client-ipv4-use-routes-use-gateway.network', |
524 | + 'dhcp-client-ipv6-only.network', |
525 | + 'dhcp-client-ipv6-rapid-commit.network', |
526 | + 'dhcp-client-keep-configuration-dhcp-on-stop.network', |
527 | +@@ -2842,7 +2842,6 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
528 | + 'dhcp-client-use-dns-no.network', |
529 | + 'dhcp-client-use-dns-yes.network', |
530 | + 'dhcp-client-use-domains.network', |
531 | +- 'dhcp-client-use-routes-no.network', |
532 | + 'dhcp-client-vrf.network', |
533 | + 'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network', |
534 | + 'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network', |
535 | +@@ -2851,7 +2850,6 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
536 | + 'dhcp-server-decline.network', |
537 | + 'dhcp-server-veth-peer.network', |
538 | + 'dhcp-v4-server-veth-peer.network', |
539 | +- 'dhcp-client-use-domains.network', |
540 | + 'static.network'] |
541 | + |
542 | + def setUp(self): |
543 | +@@ -2932,8 +2930,21 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
544 | + self.assertRegex(output, r'192.168.5.7 proto dhcp scope link src 192.168.5.181 metric 1024') |
545 | + self.assertRegex(output, r'192.168.5.8 proto dhcp scope link src 192.168.5.181 metric 1024') |
546 | + |
547 | +- def test_dhcp_client_ipv4_use_routes_no(self): |
548 | +- copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-use-routes-no.network') |
549 | ++ def test_dhcp_client_ipv4_use_routes_gateway(self): |
550 | ++ for (routes, gateway) in itertools.product([True, False, None], repeat=2): |
551 | ++ self.setUp() |
552 | ++ with self.subTest(routes=routes, gateway=gateway): |
553 | ++ self._test_dhcp_client_ipv4_use_routes_gateway(routes, gateway) |
554 | ++ self.tearDown() |
555 | ++ |
556 | ++ def _test_dhcp_client_ipv4_use_routes_gateway(self, routes, gateway): |
557 | ++ testunit = 'dhcp-client-ipv4-use-routes-use-gateway.network' |
558 | ++ testunits = ['25-veth.netdev', 'dhcp-server-veth-peer.network', testunit] |
559 | ++ if routes != None: |
560 | ++ testunits.append(f'{testunit}.d/use-routes-{routes}.conf'); |
561 | ++ if gateway != None: |
562 | ++ testunits.append(f'{testunit}.d/use-gateway-{gateway}.conf'); |
563 | ++ copy_unit_to_networkd_unit_path(*testunits, dropins=False) |
564 | + |
565 | + start_networkd() |
566 | + self.wait_online(['veth-peer:carrier']) |
567 | +@@ -2942,22 +2953,31 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
568 | + |
569 | + output = check_output('ip route show dev veth99') |
570 | + print(output) |
571 | +- self.assertNotRegex(output, r'192.168.5.5') |
572 | +- self.assertRegex(output, r'default via 192.168.5.1 proto dhcp src 192.168.5.181 metric 1024') |
573 | +- self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024') |
574 | + |
575 | +- def test_dhcp_client_ipv4_use_gateway_no(self): |
576 | +- copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-use-gateway-no.network') |
577 | ++ # UseRoutes= defaults to true |
578 | ++ useroutes = routes in [True, None] |
579 | ++ # UseGateway= defaults to useroutes |
580 | ++ usegateway = useroutes if gateway == None else gateway |
581 | + |
582 | +- start_networkd() |
583 | +- self.wait_online(['veth-peer:carrier']) |
584 | +- start_dnsmasq(additional_options='--dhcp-option=option:dns-server,192.168.5.6,192.168.5.7', lease_time='2m') |
585 | +- self.wait_online(['veth99:routable', 'veth-peer:routable']) |
586 | ++ # Check UseRoutes= |
587 | ++ if useroutes: |
588 | ++ self.assertRegex(output, r'192.168.5.0/24 via 192.168.5.5 proto dhcp src 192.168.5.181 metric 1024') |
589 | ++ else: |
590 | ++ self.assertNotRegex(output, r'192.168.5.5') |
591 | + |
592 | +- output = check_output('ip route show dev veth99') |
593 | +- print(output) |
594 | +- self.assertRegex(output, r'192.168.5.0/24 via 192.168.5.5 proto dhcp src 192.168.5.181 metric 1024') |
595 | +- self.assertNotRegex(output, r'default via 192.168.5.1') |
596 | ++ # Check UseGateway= |
597 | ++ if usegateway: |
598 | ++ self.assertRegex(output, r'default via 192.168.5.1 proto dhcp src 192.168.5.181 metric 1024') |
599 | ++ else: |
600 | ++ self.assertNotRegex(output, r'default via 192.168.5.1') |
601 | ++ |
602 | ++ # check for routes to DNS server, only if using gateway |
603 | ++ if usegateway: |
604 | ++ self.assertRegex(output, r'192.168.5.6 proto dhcp scope link src 192.168.5.181 metric 1024') |
605 | ++ self.assertRegex(output, r'192.168.5.7 proto dhcp scope link src 192.168.5.181 metric 1024') |
606 | ++ else: |
607 | ++ self.assertNotRegex(output, r'192.168.5.6') |
608 | ++ self.assertNotRegex(output, r'192.168.5.7') |
609 | + |
610 | + def test_dhcp_client_ipv4_ipv6(self): |
611 | + copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network', |
612 | diff --git a/debian/patches/test-verify-RoutesToDNS-is-independent-of-UseGateway.patch b/debian/patches/test-verify-RoutesToDNS-is-independent-of-UseGateway.patch |
613 | new file mode 100644 |
614 | index 0000000..c0a58ac |
615 | --- /dev/null |
616 | +++ b/debian/patches/test-verify-RoutesToDNS-is-independent-of-UseGateway.patch |
617 | @@ -0,0 +1,82 @@ |
618 | +From: Dan Streetman <ddstreet@canonical.com> |
619 | +Date: Wed, 15 Apr 2020 18:30:33 -0400 |
620 | +Subject: test: verify RoutesToDNS= is independent of UseGateway= |
621 | + |
622 | +(cherry picked from commit 06c2b0c76bf7e2756f8e9ef18765c85dee99ae14) |
623 | +--- |
624 | + .../conf/dhcp-client-ipv4-use-routes-use-gateway.network | 3 --- |
625 | + .../use-dns-routes-False.conf | 2 ++ |
626 | + .../use-dns-routes-True.conf | 2 ++ |
627 | + test/test-network/systemd-networkd-tests.py | 14 ++++++++------ |
628 | + 4 files changed, 12 insertions(+), 9 deletions(-) |
629 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-False.conf |
630 | + create mode 100644 test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-True.conf |
631 | + |
632 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
633 | +index b0d0d86..c980bf9 100644 |
634 | +--- a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
635 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network |
636 | +@@ -4,6 +4,3 @@ Name=veth99 |
637 | + [Network] |
638 | + DHCP=ipv4 |
639 | + IPv6AcceptRA=false |
640 | +- |
641 | +-[DHCPv4] |
642 | +-RoutesToDNS=yes |
643 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-False.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-False.conf |
644 | +new file mode 100644 |
645 | +index 0000000..9c561fb |
646 | +--- /dev/null |
647 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-False.conf |
648 | +@@ -0,0 +1,2 @@ |
649 | ++[DHCPv4] |
650 | ++RoutesToDNS=no |
651 | +diff --git a/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-True.conf b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-True.conf |
652 | +new file mode 100644 |
653 | +index 0000000..2504c20 |
654 | +--- /dev/null |
655 | ++++ b/test/test-network/conf/dhcp-client-ipv4-use-routes-use-gateway.network.d/use-dns-routes-True.conf |
656 | +@@ -0,0 +1,2 @@ |
657 | ++[DHCPv4] |
658 | ++RoutesToDNS=yes |
659 | +diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py |
660 | +index 798e155..3c805ca 100755 |
661 | +--- a/test/test-network/systemd-networkd-tests.py |
662 | ++++ b/test/test-network/systemd-networkd-tests.py |
663 | +@@ -2931,19 +2931,21 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
664 | + self.assertRegex(output, r'192.168.5.8 proto dhcp scope link src 192.168.5.181 metric 1024') |
665 | + |
666 | + def test_dhcp_client_ipv4_use_routes_gateway(self): |
667 | +- for (routes, gateway) in itertools.product([True, False, None], repeat=2): |
668 | ++ for (routes, gateway, dnsroutes) in itertools.product([True, False, None], repeat=3): |
669 | + self.setUp() |
670 | +- with self.subTest(routes=routes, gateway=gateway): |
671 | +- self._test_dhcp_client_ipv4_use_routes_gateway(routes, gateway) |
672 | ++ with self.subTest(routes=routes, gateway=gateway, dnsroutes=dnsroutes): |
673 | ++ self._test_dhcp_client_ipv4_use_routes_gateway(routes, gateway, dnsroutes) |
674 | + self.tearDown() |
675 | + |
676 | +- def _test_dhcp_client_ipv4_use_routes_gateway(self, routes, gateway): |
677 | ++ def _test_dhcp_client_ipv4_use_routes_gateway(self, routes, gateway, dnsroutes): |
678 | + testunit = 'dhcp-client-ipv4-use-routes-use-gateway.network' |
679 | + testunits = ['25-veth.netdev', 'dhcp-server-veth-peer.network', testunit] |
680 | + if routes != None: |
681 | + testunits.append(f'{testunit}.d/use-routes-{routes}.conf'); |
682 | + if gateway != None: |
683 | + testunits.append(f'{testunit}.d/use-gateway-{gateway}.conf'); |
684 | ++ if dnsroutes != None: |
685 | ++ testunits.append(f'{testunit}.d/use-dns-routes-{dnsroutes}.conf'); |
686 | + copy_unit_to_networkd_unit_path(*testunits, dropins=False) |
687 | + |
688 | + start_networkd() |
689 | +@@ -2971,8 +2973,8 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): |
690 | + else: |
691 | + self.assertNotRegex(output, r'default via 192.168.5.1') |
692 | + |
693 | +- # check for routes to DNS server, only if using gateway |
694 | +- if usegateway: |
695 | ++ # Check RoutesToDNS=, which defaults to false |
696 | ++ if dnsroutes: |
697 | + self.assertRegex(output, r'192.168.5.6 proto dhcp scope link src 192.168.5.181 metric 1024') |
698 | + self.assertRegex(output, r'192.168.5.7 proto dhcp scope link src 192.168.5.181 metric 1024') |
699 | + else: |
Also have a Debian MR open: /salsa. debian. org/systemd- team/systemd/ -/merge_ requests/ 92
https:/