summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-05-11 19:10:09 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2021-05-14 09:26:41 +0200
commite320beb33060e8684cf8b484b270d917de739dcc (patch)
tree61af3449c3571c7d954d620e141ee08f0d9795e4
parentd7594ae9c91fde37489e93edb3133a03d4770f85 (diff)
downloadNetworkManager-bg/dhcp-nettools-option249.tar.gz
dhcp: nettools: support option 249 (Microsoft Classless Static Route)bg/dhcp-nettools-option249
From [1]: The length and the data format for the Microsoft Classless Static Route Option are exactly the same as those specified for the Classless Static Route Option in [RFC3442]; the only difference is that Option Code 249 should be used instead of or in addition to Option Code 121. Use routes from option 249 when option 121 is not present, as already done by the dhclient backend. [1] https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dhcpe/f9c19c79-1c7f-4746-b555-0c0fc523f3f9 https://bugzilla.redhat.com/show_bug.cgi?id=1959461 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/851
-rw-r--r--src/core/dhcp/nm-dhcp-nettools.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c
index c1a26eca62..ac1179de85 100644
--- a/src/core/dhcp/nm-dhcp-nettools.c
+++ b/src/core/dhcp/nm-dhcp-nettools.c
@@ -342,16 +342,16 @@ lease_parse_routes(NDhcp4ClientLease *lease,
const guint8 *l_data;
gsize l_data_len;
int r;
+ guint i;
- r = _client_lease_query(lease,
- NM_DHCP_OPTION_DHCP4_CLASSLESS_STATIC_ROUTE,
- &l_data,
- &l_data_len);
- if (r == 0) {
- nm_str_buf_reset(sbuf);
+ for (i = 0; i < 2; i++) {
+ const guint8 option_code = (i == 0) ? NM_DHCP_OPTION_DHCP4_CLASSLESS_STATIC_ROUTE
+ : NM_DHCP_OPTION_DHCP4_PRIVATE_CLASSLESS_STATIC_ROUTE;
- has_classless = TRUE;
+ if (_client_lease_query(lease, option_code, &l_data, &l_data_len) != 0)
+ continue;
+ nm_str_buf_reset(sbuf);
while (lease_option_consume_route(&l_data, &l_data_len, TRUE, &dest, &plen, &gateway)) {
_nm_utils_inet4_ntop(dest, dest_str);
_nm_utils_inet4_ntop(gateway, gateway_str);
@@ -359,6 +359,11 @@ lease_parse_routes(NDhcp4ClientLease *lease,
nm_str_buf_append_required_delimiter(sbuf, ' ');
nm_str_buf_append_printf(sbuf, "%s/%d %s", dest_str, (int) plen, gateway_str);
+ if (has_classless) {
+ /* Ignore private option if the standard one is present */
+ continue;
+ }
+
if (plen == 0) {
/* if there are multiple default routes, we add them with differing
* metrics. */
@@ -384,10 +389,8 @@ lease_parse_routes(NDhcp4ClientLease *lease,
NULL);
}
- nm_dhcp_option_add_option(options,
- AF_INET,
- NM_DHCP_OPTION_DHCP4_CLASSLESS_STATIC_ROUTE,
- nm_str_buf_get_str(sbuf));
+ has_classless = TRUE;
+ nm_dhcp_option_add_option(options, AF_INET, option_code, nm_str_buf_get_str(sbuf));
}
r = _client_lease_query(lease, NM_DHCP_OPTION_DHCP4_STATIC_ROUTE, &l_data, &l_data_len);