mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 02:30:08 +01:00
dhcp: dhclient: reset the request list if conf file contains 'request'
After commit2049e97d9e("dhcp: refactor parsing of 'request' and 'also request' options") NM parses all the existing 'request' and 'also request' from the original configuration file and appends them as 'also request' to avoid duplicates and conflicts. So if the original file contains 'request x' (which means "request only option x instead of builtin defaults"), we would translate it into 'also request x', which appends the option to the builtin defaults, causing duplicates in the DHCP request as dhclient seems not smart enough to sanitize the list by itself. To fix this, ensure that the request list is reset if the configuration file contains a 'request'. Fixes:2049e97d9ehttps://bugzilla.gnome.org/show_bug.cgi?id=778430
This commit is contained in:
parent
5a03de7051
commit
f71e1379d6
2 changed files with 5 additions and 0 deletions
|
|
@ -245,6 +245,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
{
|
||||
GString *new_contents;
|
||||
GPtrArray *fqdn_opts, *reqs;
|
||||
gboolean reset_reqlist = FALSE;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (!anycast_addr || nm_utils_hwaddr_valid (anycast_addr, ETH_ALEN), NULL);
|
||||
|
|
@ -302,6 +303,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
in_req = TRUE;
|
||||
p += strlen (REQ_TAG);
|
||||
g_ptr_array_set_size (reqs, 0);
|
||||
reset_reqlist = TRUE;
|
||||
}
|
||||
|
||||
/* Save all request options for later use */
|
||||
|
|
@ -345,6 +347,8 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
add_request (reqs, "ntp-servers");
|
||||
}
|
||||
|
||||
if (reset_reqlist)
|
||||
g_string_append (new_contents, "request; # override dhclient defaults\n");
|
||||
/* And add it to the dhclient configuration */
|
||||
for (i = 0; i < reqs->len; i++)
|
||||
g_string_append_printf (new_contents, "also request %s;\n", (char *) reqs->pdata[i]);
|
||||
|
|
|
|||
|
|
@ -511,6 +511,7 @@ static const char *existing_req_expected = \
|
|||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
"option wpad code 252 = string;\n"
|
||||
"\n"
|
||||
"request; # override dhclient defaults\n"
|
||||
"also request another-thing;\n"
|
||||
"also request yet-another-thing;\n"
|
||||
"also request rfc3442-classless-static-routes;\n"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue