From 5e77a1468e9388847c3a31f84725808aa0df63af Mon Sep 17 00:00:00 2001 From: juga0 Date: Thu, 3 Aug 2017 19:19:51 +0200 Subject: [PATCH] networkd: do not send more PRL options when Anonymize is true. * check that Client has reserved memory for PRL * do not send duplicated ROUTES option when Anonymize is true --- src/libsystemd-network/sd-dhcp-client.c | 17 ++++++++++++----- src/network/networkd-dhcp4.c | 7 ++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 9cc56364d2..b5f85399ad 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -615,11 +615,18 @@ static int client_message_init( it MUST include that list in any subsequent DHCPREQUEST messages. */ - r = dhcp_option_append(&packet->dhcp, optlen, &optoffset, 0, - SD_DHCP_OPTION_PARAMETER_REQUEST_LIST, - client->req_opts_size, client->req_opts); - if (r < 0) - return r; + + /* RFC7844 section 3: + MAY contain the Parameter Request List option. */ + /* NOTE: in case that there would be an option to do not send + * any PRL at all, the size should be checked before sending */ + if (client->req_opts_size > 0) { + r = dhcp_option_append(&packet->dhcp, optlen, &optoffset, 0, + SD_DHCP_OPTION_PARAMETER_REQUEST_LIST, + client->req_opts_size, client->req_opts); + if (r < 0) + return r; + } /* RFC2131 section 3.5: The client SHOULD include the ’maximum DHCP message size’ option to diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 07661e3fa9..9c69979c7b 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -624,7 +624,12 @@ int dhcp4_configure(Link *link) { return r; } - if (link->network->dhcp_use_routes) { + /* NOTE: when using Anonymity Profiles, routes PRL options are sent + * by default, so they should not be added again here. */ + /* NOTE: even if this variable is called "use", it also "sends" PRL + * options, maybe there should be a different configuration variable + * to send or not route options?. */ + if (link->network->dhcp_use_routes && !link->network->dhcp_anonymize) { r = sd_dhcp_client_set_request_option(link->dhcp_client, SD_DHCP_OPTION_STATIC_ROUTE); if (r < 0) -- 2.25.1