2014-07-22 12:38:20 -05:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
#include "nm-utils/nm-dedup-multi.h"
|
2018-04-11 08:54:10 +02:00
|
|
|
#include "nm-utils/unaligned.h"
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
#include "nm-utils.h"
|
2018-01-30 18:01:18 +01:00
|
|
|
#include "nm-config.h"
|
2014-07-22 12:38:20 -05:00
|
|
|
#include "nm-dhcp-utils.h"
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
#include "nm-core-utils.h"
|
2014-07-22 12:38:20 -05:00
|
|
|
#include "NetworkManagerUtils.h"
|
2016-11-21 00:43:52 +01:00
|
|
|
#include "platform/nm-platform.h"
|
2016-03-03 10:19:28 +01:00
|
|
|
#include "nm-dhcp-client-logging.h"
|
2016-09-27 13:35:29 +02:00
|
|
|
#include "systemd/nm-sd.h"
|
2016-02-28 11:38:51 +01:00
|
|
|
|
2016-10-01 16:19:24 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define NM_TYPE_DHCP_SYSTEMD (nm_dhcp_systemd_get_type ())
|
|
|
|
|
#define NM_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemd))
|
|
|
|
|
#define NM_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass))
|
|
|
|
|
#define NM_IS_DHCP_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_SYSTEMD))
|
|
|
|
|
#define NM_IS_DHCP_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_SYSTEMD))
|
|
|
|
|
#define NM_DHCP_SYSTEMD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_SYSTEMD, NMDhcpSystemdClass))
|
|
|
|
|
|
|
|
|
|
typedef struct _NMDhcpSystemd NMDhcpSystemd;
|
|
|
|
|
typedef struct _NMDhcpSystemdClass NMDhcpSystemdClass;
|
|
|
|
|
|
|
|
|
|
static GType nm_dhcp_systemd_get_type (void);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
typedef struct {
|
2016-01-26 17:22:54 +01:00
|
|
|
sd_dhcp_client *client4;
|
|
|
|
|
sd_dhcp6_client *client6;
|
2014-07-22 12:38:20 -05:00
|
|
|
char *lease_file;
|
|
|
|
|
|
|
|
|
|
guint request_count;
|
|
|
|
|
|
2018-02-14 14:58:52 +01:00
|
|
|
bool privacy:1;
|
2014-07-22 12:38:20 -05:00
|
|
|
} NMDhcpSystemdPrivate;
|
|
|
|
|
|
2016-09-28 15:58:24 +02:00
|
|
|
struct _NMDhcpSystemd {
|
|
|
|
|
NMDhcpClient parent;
|
|
|
|
|
NMDhcpSystemdPrivate _priv;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMDhcpSystemdClass {
|
|
|
|
|
NMDhcpClientClass parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (NMDhcpSystemd, nm_dhcp_systemd, NM_TYPE_DHCP_CLIENT)
|
|
|
|
|
|
|
|
|
|
#define NM_DHCP_SYSTEMD_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpSystemd, NM_IS_DHCP_SYSTEMD)
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
#define DHCP_OPTION_NIS_DOMAIN 40
|
|
|
|
|
#define DHCP_OPTION_NIS_SERVERS 41
|
|
|
|
|
|
|
|
|
|
/* Internal values */
|
|
|
|
|
#define DHCP_OPTION_IP_ADDRESS 1024
|
|
|
|
|
#define DHCP_OPTION_EXPIRY 1025
|
|
|
|
|
#define DHCP6_OPTION_IP_ADDRESS 1026
|
|
|
|
|
#define DHCP6_OPTION_PREFIXLEN 1027
|
|
|
|
|
#define DHCP6_OPTION_PREFERRED_LIFE 1028
|
|
|
|
|
#define DHCP6_OPTION_MAX_LIFE 1029
|
|
|
|
|
#define DHCP6_OPTION_STARTS 1030
|
|
|
|
|
#define DHCP6_OPTION_LIFE_STARTS 1031
|
|
|
|
|
#define DHCP6_OPTION_RENEW 1032
|
|
|
|
|
#define DHCP6_OPTION_REBIND 1033
|
|
|
|
|
#define DHCP6_OPTION_IAID 1034
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const char *name;
|
2018-11-26 16:49:13 +01:00
|
|
|
uint16_t option_num;
|
|
|
|
|
bool include;
|
2014-07-22 12:38:20 -05:00
|
|
|
} ReqOption;
|
|
|
|
|
|
|
|
|
|
#define REQPREFIX "requested_"
|
|
|
|
|
|
2018-11-26 16:49:13 +01:00
|
|
|
#define REQ(_num, _name, _include) \
|
|
|
|
|
{ \
|
|
|
|
|
.name = REQPREFIX""_name, \
|
|
|
|
|
.option_num = _num, \
|
|
|
|
|
.include = _include, \
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
static const ReqOption dhcp4_requests[] = {
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP_OPTION_SUBNET_MASK, "subnet_mask", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_TIME_OFFSET, "time_offset", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_DOMAIN_NAME_SERVER, "domain_name_servers", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_HOST_NAME, "host_name", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_DOMAIN_NAME, "domain_name", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_INTERFACE_MTU, "interface_mtu", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_BROADCAST, "broadcast_address", TRUE ),
|
2018-12-03 16:08:34 +01:00
|
|
|
|
|
|
|
|
/* RFC 3442: The Classless Static Routes option code MUST appear in the parameter
|
|
|
|
|
* request list prior to both the Router option code and the Static
|
|
|
|
|
* Routes option code, if present. */
|
|
|
|
|
REQ (SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, "rfc3442_classless_static_routes", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_ROUTER, "routers", TRUE ),
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP_OPTION_STATIC_ROUTE, "static_routes", TRUE ),
|
2018-12-03 16:08:34 +01:00
|
|
|
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (DHCP_OPTION_NIS_DOMAIN, "nis_domain", TRUE ),
|
|
|
|
|
REQ (DHCP_OPTION_NIS_SERVERS, "nis_servers", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_NTP_SERVER, "ntp_servers", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_SERVER_IDENTIFIER, "dhcp_server_identifier", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_DOMAIN_SEARCH_LIST, "domain_search", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE, "ms_classless_static_routes", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY, "wpad", TRUE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_ROOT_PATH, "root_path", TRUE ),
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
/* Internal values */
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, "expiry", FALSE ),
|
|
|
|
|
REQ (SD_DHCP_OPTION_CLIENT_IDENTIFIER, "dhcp_client_identifier", FALSE ),
|
|
|
|
|
REQ (DHCP_OPTION_IP_ADDRESS, "ip_address", FALSE ),
|
|
|
|
|
|
|
|
|
|
{ 0 }
|
2014-07-22 12:38:20 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const ReqOption dhcp6_requests[] = {
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP6_OPTION_CLIENTID, "dhcp6_client_id", FALSE ),
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
/* Don't request server ID by default; some servers don't reply to
|
|
|
|
|
* Information Requests that request the Server ID.
|
|
|
|
|
*/
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP6_OPTION_SERVERID, "dhcp6_server_id", FALSE ),
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (SD_DHCP6_OPTION_DNS_SERVERS, "dhcp6_name_servers", TRUE ),
|
|
|
|
|
REQ (SD_DHCP6_OPTION_DOMAIN_LIST, "dhcp6_domain_search", TRUE ),
|
|
|
|
|
REQ (SD_DHCP6_OPTION_SNTP_SERVERS, "dhcp6_sntp_servers", TRUE ),
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
/* Internal values */
|
2018-11-26 16:49:13 +01:00
|
|
|
REQ (DHCP6_OPTION_IP_ADDRESS, "ip6_address", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_PREFIXLEN, "ip6_prefixlen", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_PREFERRED_LIFE, "preferred_life", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_MAX_LIFE, "max_life", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_STARTS, "starts", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_LIFE_STARTS, "life_starts", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_RENEW, "renew", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_REBIND, "rebind", FALSE ),
|
|
|
|
|
REQ (DHCP6_OPTION_IAID, "iaid", FALSE ),
|
|
|
|
|
|
|
|
|
|
{ 0 }
|
2014-07-22 12:38:20 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
take_option (GHashTable *options,
|
|
|
|
|
const ReqOption *requests,
|
|
|
|
|
guint option,
|
|
|
|
|
char *value)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
|
2018-11-26 16:49:13 +01:00
|
|
|
nm_assert (options);
|
|
|
|
|
nm_assert (requests);
|
|
|
|
|
nm_assert (value);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
for (i = 0; requests[i].name; i++) {
|
2018-11-26 16:49:13 +01:00
|
|
|
nm_assert (g_str_has_prefix (requests[i].name, REQPREFIX));
|
|
|
|
|
if (requests[i].option_num == option) {
|
2014-07-22 12:38:20 -05:00
|
|
|
g_hash_table_insert (options,
|
2016-02-12 12:34:43 +01:00
|
|
|
(gpointer) (requests[i].name + NM_STRLEN (REQPREFIX)),
|
2014-07-22 12:38:20 -05:00
|
|
|
value);
|
2018-11-26 16:49:13 +01:00
|
|
|
return;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
}
|
2018-11-26 16:49:13 +01:00
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
/* Option should always be found */
|
2018-11-26 16:49:13 +01:00
|
|
|
nm_assert_not_reached ();
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_option (GHashTable *options, const ReqOption *requests, guint option, const char *value)
|
|
|
|
|
{
|
|
|
|
|
if (options)
|
|
|
|
|
take_option (options, requests, option, g_strdup (value));
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-21 13:53:25 -05:00
|
|
|
static void
|
|
|
|
|
add_option_u64 (GHashTable *options, const ReqOption *requests, guint option, guint64 value)
|
|
|
|
|
{
|
|
|
|
|
if (options)
|
|
|
|
|
take_option (options, requests, option, g_strdup_printf ("%" G_GUINT64_FORMAT, value));
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
static void
|
|
|
|
|
add_requests_to_options (GHashTable *options, const ReqOption *requests)
|
|
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
|
2018-11-26 16:49:13 +01:00
|
|
|
if (!options)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; requests[i].name; i++) {
|
2014-07-22 12:38:20 -05:00
|
|
|
if (requests[i].include)
|
|
|
|
|
g_hash_table_insert (options, (gpointer) requests[i].name, g_strdup ("1"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:08 +01:00
|
|
|
static GHashTable *
|
|
|
|
|
create_options_dict (void)
|
|
|
|
|
{
|
|
|
|
|
return g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
#define LOG_LEASE(domain, ...) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
if (log_lease) { \
|
2017-06-14 13:40:07 +02:00
|
|
|
_LOG2I ((domain), (iface), " "__VA_ARGS__); \
|
2014-07-22 12:38:20 -05:00
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
static NMIP4Config *
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
|
|
|
|
|
const char *iface,
|
2015-02-20 16:31:10 -06:00
|
|
|
int ifindex,
|
2015-01-19 18:33:10 +01:00
|
|
|
sd_dhcp_lease *lease,
|
2017-09-28 14:40:12 +02:00
|
|
|
guint32 route_table,
|
2017-09-28 14:51:14 +02:00
|
|
|
guint32 route_metric,
|
2014-07-22 12:38:20 -05:00
|
|
|
gboolean log_lease,
|
2018-11-27 13:47:08 +01:00
|
|
|
GHashTable **out_options,
|
2014-07-22 12:38:20 -05:00
|
|
|
GError **error)
|
|
|
|
|
{
|
2018-11-27 13:47:08 +01:00
|
|
|
gs_unref_object NMIP4Config *ip4_config = NULL;
|
|
|
|
|
gs_unref_hashtable GHashTable *options = NULL;
|
2014-07-22 12:38:20 -05:00
|
|
|
const struct in_addr *addr_list;
|
2018-11-26 16:49:51 +01:00
|
|
|
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
2017-06-14 13:32:55 +02:00
|
|
|
const char *s;
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_auto_free_gstring GString *str = NULL;
|
2016-01-26 17:22:54 +01:00
|
|
|
gs_free sd_dhcp_route **routes = NULL;
|
2017-06-14 14:14:56 +02:00
|
|
|
const char *const*search_domains = NULL;
|
2014-07-22 12:38:20 -05:00
|
|
|
guint16 mtu;
|
2018-11-27 13:47:13 +01:00
|
|
|
int i, num;
|
2015-09-16 16:53:25 +02:00
|
|
|
const void *data;
|
2015-08-12 12:53:13 +02:00
|
|
|
gsize data_len;
|
2015-05-06 14:07:21 +02:00
|
|
|
gboolean metered = FALSE;
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
gboolean has_router_from_classless = FALSE;
|
|
|
|
|
gboolean has_classless_route = FALSE;
|
|
|
|
|
gboolean has_static_route = FALSE;
|
2018-11-27 13:47:13 +01:00
|
|
|
const gint32 ts = nm_utils_get_monotonic_timestamp_s ();
|
|
|
|
|
gint64 ts_time = time (NULL);
|
|
|
|
|
struct in_addr a_address;
|
|
|
|
|
struct in_addr a_netmask;
|
|
|
|
|
struct in_addr a_router;
|
|
|
|
|
guint32 a_plen;
|
|
|
|
|
guint32 a_lifetime;
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2014-11-18 11:53:07 -05:00
|
|
|
g_return_val_if_fail (lease != NULL, NULL);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
ip4_config = nm_ip4_config_new (multi_idx, ifindex);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-11-27 13:47:08 +01:00
|
|
|
options = out_options ? create_options_dict () : NULL;
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_lease_get_address (lease, &a_address) < 0) {
|
|
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "could not get address from lease");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
nm_utils_inet4_ntop (a_address.s_addr, addr_str);
|
2018-11-26 16:49:51 +01:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "address %s", addr_str);
|
|
|
|
|
add_option (options, dhcp4_requests, DHCP_OPTION_IP_ADDRESS, addr_str);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_lease_get_netmask (lease, &a_netmask) < 0) {
|
|
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "could not get netmask from lease");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
a_plen = nm_utils_ip4_netmask_to_prefix (a_netmask.s_addr);
|
|
|
|
|
LOG_LEASE (LOGD_DHCP4, "plen %u", (guint) a_plen);
|
2014-07-22 12:38:20 -05:00
|
|
|
add_option (options,
|
|
|
|
|
dhcp4_requests,
|
2016-01-26 17:22:54 +01:00
|
|
|
SD_DHCP_OPTION_SUBNET_MASK,
|
2018-11-27 13:47:13 +01:00
|
|
|
nm_utils_inet4_ntop (a_netmask.s_addr, addr_str));
|
|
|
|
|
|
|
|
|
|
if (sd_dhcp_lease_get_lifetime (lease, &a_lifetime) < 0) {
|
|
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "could not get lifetime from lease");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
LOG_LEASE (LOGD_DHCP4, "expires in %u seconds (at %lld)",
|
|
|
|
|
(guint) a_lifetime,
|
|
|
|
|
(long long) (ts_time + a_lifetime));
|
2014-11-21 13:53:25 -05:00
|
|
|
add_option_u64 (options,
|
2014-07-22 12:38:20 -05:00
|
|
|
dhcp4_requests,
|
2016-01-26 17:22:54 +01:00
|
|
|
SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME,
|
2018-11-27 13:47:13 +01:00
|
|
|
(guint64) (ts_time + a_lifetime));
|
|
|
|
|
|
|
|
|
|
nm_ip4_config_add_address (ip4_config,
|
|
|
|
|
&((const NMPlatformIP4Address) {
|
|
|
|
|
.address = a_address.s_addr,
|
|
|
|
|
.peer_address = a_address.s_addr,
|
|
|
|
|
.plen = a_plen,
|
|
|
|
|
.addr_source = NM_IP_CONFIG_SOURCE_DHCP,
|
|
|
|
|
.timestamp = ts,
|
|
|
|
|
.lifetime = a_lifetime,
|
|
|
|
|
.preferred = a_lifetime,
|
|
|
|
|
}));
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
num = sd_dhcp_lease_get_dns (lease, &addr_list);
|
|
|
|
|
if (num > 0) {
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_gstring_prepare (&str);
|
2014-07-22 12:38:20 -05:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
if (addr_list[i].s_addr) {
|
|
|
|
|
nm_ip4_config_add_nameserver (ip4_config, addr_list[i].s_addr);
|
2018-11-26 16:49:51 +01:00
|
|
|
s = nm_utils_inet4_ntop (addr_list[i].s_addr, addr_str);
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "nameserver '%s'", s);
|
2017-06-14 13:32:55 +02:00
|
|
|
g_string_append_printf (str, "%s%s", str->len ? " " : "", s);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
}
|
2017-06-14 13:32:55 +02:00
|
|
|
if (str->len)
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME_SERVER, str->str);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2017-06-14 14:14:56 +02:00
|
|
|
num = sd_dhcp_lease_get_search_domains (lease, (char ***) &search_domains);
|
|
|
|
|
if (num > 0) {
|
|
|
|
|
nm_gstring_prepare (&str);
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
nm_ip4_config_add_search (ip4_config, search_domains[i]);
|
|
|
|
|
g_string_append_printf (str, "%s%s", str->len ? " " : "", search_domains[i]);
|
|
|
|
|
LOG_LEASE (LOGD_DHCP4, "domain search '%s'", search_domains[i]);
|
|
|
|
|
}
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_SEARCH_LIST, str->str);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if ( sd_dhcp_lease_get_domainname (lease, &s) >= 0
|
|
|
|
|
&& s) {
|
|
|
|
|
gs_strfreev char **domains = NULL;
|
2017-06-14 13:32:55 +02:00
|
|
|
char **d;
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
/* Multiple domains sometimes stuffed into option 15 "Domain Name".
|
|
|
|
|
* As systemd escapes such characters, split them at \\032. */
|
|
|
|
|
domains = g_strsplit (s, "\\032", 0);
|
2017-06-14 13:32:55 +02:00
|
|
|
for (d = domains; *d; d++) {
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "domain name '%s'", *d);
|
2017-06-14 13:32:55 +02:00
|
|
|
nm_ip4_config_add_domain (ip4_config, *d);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
2017-06-14 13:32:55 +02:00
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME, s);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_lease_get_hostname (lease, &s) >= 0) {
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "hostname '%s'", s);
|
2017-06-14 13:32:55 +02:00
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_HOST_NAME, s);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
num = sd_dhcp_lease_get_routes (lease, &routes);
|
|
|
|
|
if (num > 0) {
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
nm_auto_free_gstring GString *str_classless = NULL;
|
|
|
|
|
nm_auto_free_gstring GString *str_static = NULL;
|
|
|
|
|
guint32 default_route_metric = route_metric;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
switch (sd_dhcp_route_get_option (routes[i])) {
|
|
|
|
|
case SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE:
|
|
|
|
|
has_classless_route = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case SD_DHCP_OPTION_STATIC_ROUTE:
|
|
|
|
|
has_static_route = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (has_classless_route)
|
|
|
|
|
str_classless = g_string_sized_new (30);
|
|
|
|
|
if (has_static_route)
|
|
|
|
|
str_static = g_string_sized_new (30);
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
for (i = 0; i < num; i++) {
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
char network_net_str[NM_UTILS_INET_ADDRSTRLEN];
|
|
|
|
|
char gateway_str[NM_UTILS_INET_ADDRSTRLEN];
|
2018-11-27 13:47:13 +01:00
|
|
|
guint8 r_plen;
|
|
|
|
|
struct in_addr r_network;
|
|
|
|
|
struct in_addr r_gateway;
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
in_addr_t network_net;
|
|
|
|
|
int option;
|
|
|
|
|
guint32 m;
|
|
|
|
|
|
|
|
|
|
option = sd_dhcp_route_get_option (routes[i]);
|
|
|
|
|
if (!NM_IN_SET (option, SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE,
|
|
|
|
|
SD_DHCP_OPTION_STATIC_ROUTE))
|
|
|
|
|
continue;
|
2016-01-26 17:22:54 +01:00
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_route_get_destination (routes[i], &r_network) < 0)
|
2016-01-26 17:22:54 +01:00
|
|
|
continue;
|
2018-11-27 13:47:13 +01:00
|
|
|
if ( sd_dhcp_route_get_destination_prefix_length (routes[i], &r_plen) < 0
|
|
|
|
|
|| r_plen > 32)
|
2016-01-26 17:22:54 +01:00
|
|
|
continue;
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_route_get_gateway (routes[i], &r_gateway) < 0)
|
2016-01-26 17:22:54 +01:00
|
|
|
continue;
|
2016-02-15 11:28:58 +01:00
|
|
|
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
network_net = nm_utils_ip4_address_clear_host_address (r_network.s_addr,
|
|
|
|
|
r_plen);
|
|
|
|
|
nm_utils_inet4_ntop (network_net, network_net_str);
|
|
|
|
|
nm_utils_inet4_ntop (r_gateway.s_addr, gateway_str);
|
|
|
|
|
|
|
|
|
|
LOG_LEASE (LOGD_DHCP4,
|
|
|
|
|
"%sstatic route %s/%d gw %s",
|
|
|
|
|
option == SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE
|
|
|
|
|
? "classless "
|
|
|
|
|
: "",
|
|
|
|
|
network_net_str,
|
|
|
|
|
(int) r_plen,
|
|
|
|
|
gateway_str);
|
|
|
|
|
g_string_append_printf (nm_gstring_add_space_delimiter ( option == SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE
|
|
|
|
|
? str_classless
|
|
|
|
|
: str_static),
|
|
|
|
|
"%s/%d %s",
|
|
|
|
|
network_net_str,
|
|
|
|
|
(int) r_plen,
|
|
|
|
|
gateway_str);
|
|
|
|
|
|
|
|
|
|
if ( option == SD_DHCP_OPTION_STATIC_ROUTE
|
|
|
|
|
&& has_classless_route) {
|
|
|
|
|
/* RFC 3443: if the DHCP server returns both a Classless Static Routes
|
|
|
|
|
* option and a Static Routes option, the DHCP client MUST ignore the
|
|
|
|
|
* Static Routes option. */
|
|
|
|
|
continue;
|
2016-02-15 11:28:58 +01:00
|
|
|
}
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
|
|
|
|
|
if ( r_plen == 0
|
|
|
|
|
&& option == SD_DHCP_OPTION_STATIC_ROUTE) {
|
|
|
|
|
/* for option 33 (static route), RFC 2132 says:
|
|
|
|
|
*
|
|
|
|
|
* The default route (0.0.0.0) is an illegal destination for a static
|
|
|
|
|
* route. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (r_plen == 0) {
|
|
|
|
|
/* if there are multiple default routes, we add them with differing
|
|
|
|
|
* metrics. */
|
|
|
|
|
m = default_route_metric;
|
|
|
|
|
if (default_route_metric < G_MAXUINT32)
|
|
|
|
|
default_route_metric++;
|
|
|
|
|
|
|
|
|
|
has_router_from_classless = TRUE;
|
|
|
|
|
} else
|
|
|
|
|
m = route_metric;
|
|
|
|
|
|
|
|
|
|
nm_ip4_config_add_route (ip4_config,
|
|
|
|
|
&((const NMPlatformIP4Route) {
|
|
|
|
|
.network = network_net,
|
|
|
|
|
.plen = r_plen,
|
|
|
|
|
.gateway = r_gateway.s_addr,
|
|
|
|
|
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
|
|
|
|
|
.metric = m,
|
|
|
|
|
.table_coerced = nm_platform_route_table_coerce (route_table),
|
|
|
|
|
}),
|
|
|
|
|
NULL);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
if (str_classless && str_classless->len > 0)
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, str_classless->str);
|
|
|
|
|
if (str_static && str_static->len > 0)
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_STATIC_ROUTE, str_static->str);
|
2016-02-15 11:28:58 +01:00
|
|
|
}
|
|
|
|
|
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
/* FIXME: internal client only supports returing the first router. */
|
|
|
|
|
if (sd_dhcp_lease_get_router (lease, &a_router) >= 0) {
|
|
|
|
|
s = nm_utils_inet4_ntop (a_router.s_addr, addr_str);
|
2018-11-27 15:18:17 +01:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "gateway %s", s);
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROUTER, s);
|
dhcp: fix static-route handling for intenal client and support multiple default routes
Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host
Configuration Protocol (DHCP) version 4) states:
If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.
Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option.
Changes:
- sd_dhcp_lease_get_routes() returns the combination of both option 33
(static routes) and 121 (classless static routes). If classless static
routes are provided, the state routes must be ignored.
- we collect the options hash that we expose on D-Bus. For that purpose,
we must not merge both option types as classless static routes. Instead,
we want to expose the values like we received them originally: as two
different options.
- we continue our deviation from RFC 3442, when receiving classless static
routes with option 3 (Router), we only ignore the router if we didn't
already receive a default route via classless static routes.
- in the past, NetworkManager treated the default route specially, and
one device could only have one default route. That limitation was
already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91
(core: rework tracking of gateway/default-route in ip-config). However,
from DHCP we still would only accept one default route. Fix that for
internal client. Installing multiple default routes might make sense, as
kernel apparently can skip unreachable routers (as it notes via ICMP
messages) (rh#1634657).
https://bugzilla.redhat.com/show_bug.cgi?id=1634657
2018-11-27 12:56:40 +01:00
|
|
|
|
|
|
|
|
/* If the DHCP server returns both a Classless Static Routes option and a
|
|
|
|
|
* Router option, the DHCP client MUST ignore the Router option [RFC 3442].
|
|
|
|
|
*
|
|
|
|
|
* Be more lenient and ignore the Router option only if Classless Static
|
|
|
|
|
* Routes contain a default gateway (as other DHCP backends do).
|
|
|
|
|
*/
|
|
|
|
|
if (!has_router_from_classless) {
|
|
|
|
|
nm_ip4_config_add_route (ip4_config,
|
|
|
|
|
&((const NMPlatformIP4Route) {
|
|
|
|
|
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
|
|
|
|
|
.gateway = a_router.s_addr,
|
|
|
|
|
.table_coerced = nm_platform_route_table_coerce (route_table),
|
|
|
|
|
.metric = route_metric,
|
|
|
|
|
}),
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2018-11-27 13:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( sd_dhcp_lease_get_mtu (lease, &mtu) >= 0
|
|
|
|
|
&& mtu) {
|
2014-07-22 12:38:20 -05:00
|
|
|
nm_ip4_config_set_mtu (ip4_config, mtu, NM_IP_CONFIG_SOURCE_DHCP);
|
2018-11-26 16:49:13 +01:00
|
|
|
add_option_u64 (options, dhcp4_requests, SD_DHCP_OPTION_INTERFACE_MTU, mtu);
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "mtu %u", mtu);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 11:53:07 -05:00
|
|
|
num = sd_dhcp_lease_get_ntp (lease, &addr_list);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (num > 0) {
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_gstring_prepare (&str);
|
2014-07-22 12:38:20 -05:00
|
|
|
for (i = 0; i < num; i++) {
|
2018-11-26 16:49:51 +01:00
|
|
|
s = nm_utils_inet4_ntop (addr_list[i].s_addr, addr_str);
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "ntp server '%s'", s);
|
2017-06-14 13:32:55 +02:00
|
|
|
g_string_append_printf (str, "%s%s", str->len ? " " : "", s);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
2017-06-14 13:32:55 +02:00
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_NTP_SERVER, str->str);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_lease_get_root_path (lease, &s) >= 0) {
|
2018-08-13 18:37:02 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP4, "root path '%s'", s);
|
|
|
|
|
add_option (options, dhcp4_requests, SD_DHCP_OPTION_ROOT_PATH, s);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if (sd_dhcp_lease_get_vendor_specific (lease, &data, &data_len) >= 0)
|
2016-02-12 12:34:43 +01:00
|
|
|
metered = !!memmem (data, data_len, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED"));
|
2015-05-06 14:07:21 +02:00
|
|
|
nm_ip4_config_set_metered (ip4_config, metered);
|
|
|
|
|
|
2018-11-27 13:47:08 +01:00
|
|
|
NM_SET_OUT (out_options, g_steal_pointer (&options));
|
|
|
|
|
return g_steal_pointer (&ip4_config);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
static char *
|
2017-09-11 11:30:48 +02:00
|
|
|
get_leasefile_path (int addr_family, const char *iface, const char *uuid)
|
2014-07-22 12:38:20 -05:00
|
|
|
{
|
2018-01-30 18:01:18 +01:00
|
|
|
char *rundir_path;
|
|
|
|
|
char *statedir_path;
|
|
|
|
|
|
|
|
|
|
rundir_path = g_strdup_printf (NMRUNDIR "/internal%s-%s-%s.lease",
|
|
|
|
|
addr_family == AF_INET6 ? "6" : "",
|
|
|
|
|
uuid,
|
|
|
|
|
iface);
|
|
|
|
|
|
|
|
|
|
if (g_file_test (rundir_path, G_FILE_TEST_EXISTS))
|
|
|
|
|
return rundir_path;
|
|
|
|
|
|
|
|
|
|
statedir_path = g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease",
|
|
|
|
|
addr_family == AF_INET6 ? "6" : "",
|
|
|
|
|
uuid,
|
|
|
|
|
iface);
|
|
|
|
|
|
|
|
|
|
if ( g_file_test (statedir_path, G_FILE_TEST_EXISTS)
|
|
|
|
|
|| nm_config_get_configure_and_quit (nm_config_get ()) != NM_CONFIG_CONFIGURE_AND_QUIT_INITRD) {
|
|
|
|
|
g_free (rundir_path);
|
|
|
|
|
return statedir_path;
|
|
|
|
|
} else {
|
|
|
|
|
g_free (statedir_path);
|
|
|
|
|
return rundir_path;
|
|
|
|
|
}
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bound4_handle (NMDhcpSystemd *self)
|
|
|
|
|
{
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
|
|
|
|
const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self));
|
|
|
|
|
sd_dhcp_lease *lease;
|
2018-11-26 17:04:10 +01:00
|
|
|
gs_unref_object NMIP4Config *ip4_config = NULL;
|
|
|
|
|
gs_unref_hashtable GHashTable *options = NULL;
|
2014-07-22 12:38:20 -05:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if ( sd_dhcp_client_get_lease (priv->client4, &lease) < 0
|
|
|
|
|
|| !lease) {
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW ("no lease!");
|
2014-07-22 12:38:20 -05:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGD ("lease available");
|
|
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
ip4_config = lease_to_ip4_config (nm_dhcp_client_get_multi_idx (NM_DHCP_CLIENT (self)),
|
|
|
|
|
iface,
|
2015-02-20 16:31:10 -06:00
|
|
|
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
|
2015-01-19 18:33:10 +01:00
|
|
|
lease,
|
2017-09-28 14:40:12 +02:00
|
|
|
nm_dhcp_client_get_route_table (NM_DHCP_CLIENT (self)),
|
2017-09-28 14:51:14 +02:00
|
|
|
nm_dhcp_client_get_route_metric (NM_DHCP_CLIENT (self)),
|
2014-07-22 12:38:20 -05:00
|
|
|
TRUE,
|
2018-11-27 13:47:08 +01:00
|
|
|
&options,
|
2014-07-22 12:38:20 -05:00
|
|
|
&error);
|
2018-11-26 17:04:10 +01:00
|
|
|
if (!ip4_config) {
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW ("%s", error->message);
|
2014-07-22 12:38:20 -05:00
|
|
|
g_clear_error (&error);
|
2018-11-26 17:04:10 +01:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
|
|
|
|
|
return;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-26 17:04:10 +01:00
|
|
|
add_requests_to_options (options, dhcp4_requests);
|
|
|
|
|
dhcp_lease_save (lease, priv->lease_file);
|
|
|
|
|
|
|
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self),
|
|
|
|
|
NM_DHCP_STATE_BOUND,
|
|
|
|
|
NM_IP_CONFIG_CAST (ip4_config),
|
|
|
|
|
options);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp_event_cb (sd_dhcp_client *client, int event, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data);
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_assert (priv->client4 == client);
|
|
|
|
|
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGD ("client event %d", event);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
switch (event) {
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP_CLIENT_EVENT_EXPIRED:
|
core: better handle DHCP expiry/nak during initial lease acquisition (bgo #739482)
When dhclient trieds to request a previous lease and the server NAKs that
lease, dhclient emits the EXPIRE state. dhcpcd has also been known to emit
the 'nak' state for the same reason.
(systemd's DHCP client code does not push a NAK up to NetworkManager, but
jumps to the REBOOT state instead, so it is unaffected by this issue.)
NetworkManager saw the expire during IP configuration and treated that as
full activation failure. The connection would be restarted, the same lease
requested, and the same NAK delivered, over and over. Before a lease is
acquired, there is (by definition) no lease to expire, so these events
should be ignored.
We do, however, still want to handle abnormal failures, which is why
this patch splits the EXPIRE case from the FAIL case and handles them
separately.
https://bugzilla.gnome.org/show_bug.cgi?id=739482
2014-12-11 15:36:27 -06:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_EXPIRE, NULL, NULL);
|
|
|
|
|
break;
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP_CLIENT_EVENT_STOP:
|
2014-07-22 12:38:20 -05:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL);
|
|
|
|
|
break;
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP_CLIENT_EVENT_RENEW:
|
|
|
|
|
case SD_DHCP_CLIENT_EVENT_IP_CHANGE:
|
|
|
|
|
case SD_DHCP_CLIENT_EVENT_IP_ACQUIRE:
|
2014-07-22 12:38:20 -05:00
|
|
|
bound4_handle (self);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW ("unhandled DHCP event %d", event);
|
2014-07-22 12:38:20 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-09-10 12:22:20 +02:00
|
|
|
ip4_start (NMDhcpClient *client,
|
|
|
|
|
const char *dhcp_anycast_addr,
|
|
|
|
|
const char *last_ip4_address,
|
|
|
|
|
GError **error)
|
2014-07-22 12:38:20 -05:00
|
|
|
{
|
2018-11-02 10:18:23 +01:00
|
|
|
nm_auto (sd_dhcp_client_unrefp) sd_dhcp_client *sd_client = NULL;
|
2016-03-03 10:19:28 +01:00
|
|
|
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
2018-11-02 10:18:23 +01:00
|
|
|
gs_free char *lease_file = NULL;
|
2018-02-14 13:09:23 +01:00
|
|
|
GBytes *hwaddr;
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
const uint8_t *hwaddr_arr;
|
|
|
|
|
gsize hwaddr_len;
|
2018-12-14 08:45:09 +01:00
|
|
|
int arp_type;
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
GBytes *client_id;
|
|
|
|
|
gs_unref_bytes GBytes *client_id_new = NULL;
|
|
|
|
|
const uint8_t *client_id_arr;
|
|
|
|
|
size_t client_id_len;
|
2014-11-03 22:35:22 -06:00
|
|
|
struct in_addr last_addr = { 0 };
|
2017-04-26 11:49:30 +02:00
|
|
|
const char *hostname;
|
2014-07-22 12:38:20 -05:00
|
|
|
int r, i;
|
|
|
|
|
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
g_return_val_if_fail (!priv->client4, FALSE);
|
|
|
|
|
g_return_val_if_fail (!priv->client6, FALSE);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_new (&sd_client, FALSE);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to create dhcp-client: %s");
|
2014-07-22 12:38:20 -05:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
_LOGT ("dhcp-client4: set %p", sd_client);
|
2016-05-29 13:14:48 +02:00
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_attach_event (sd_client, NULL, 0);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to attach event: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hwaddr = nm_dhcp_client_get_hw_addr (client);
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
if ( !hwaddr
|
|
|
|
|
|| !(hwaddr_arr = g_bytes_get_data (hwaddr, &hwaddr_len))
|
2018-12-20 08:50:07 +01:00
|
|
|
|| (arp_type = nm_utils_arp_type_detect_from_hwaddrlen (hwaddr_len)) < 0) {
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
}
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_mac (sd_client,
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
hwaddr_arr,
|
|
|
|
|
hwaddr_len,
|
2018-12-14 08:45:09 +01:00
|
|
|
(guint16) arp_type);
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set MAC address: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_ifindex (sd_client,
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
nm_dhcp_client_get_ifindex (client));
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set ifindex: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
lease_file = get_leasefile_path (AF_INET,
|
|
|
|
|
nm_dhcp_client_get_iface (client),
|
|
|
|
|
nm_dhcp_client_get_uuid (client));
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2014-11-03 22:35:22 -06:00
|
|
|
if (last_ip4_address)
|
|
|
|
|
inet_pton (AF_INET, last_ip4_address, &last_addr);
|
2018-11-02 10:18:23 +01:00
|
|
|
else {
|
|
|
|
|
nm_auto (sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
|
|
|
|
|
|
|
|
|
|
dhcp_lease_load (&lease, lease_file);
|
|
|
|
|
if (lease)
|
|
|
|
|
sd_dhcp_lease_get_address (lease, &last_addr);
|
|
|
|
|
}
|
2014-11-03 22:35:22 -06:00
|
|
|
|
|
|
|
|
if (last_addr.s_addr) {
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_request_address (sd_client, &last_addr);
|
2014-11-03 22:35:22 -06:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set last IPv4 address: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
client_id = nm_dhcp_client_get_client_id (client);
|
|
|
|
|
if (!client_id) {
|
|
|
|
|
client_id_new = nm_utils_dhcp_client_id_systemd_node_specific (TRUE,
|
|
|
|
|
nm_dhcp_client_get_iface (client));
|
|
|
|
|
client_id = client_id_new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !(client_id_arr = g_bytes_get_data (client_id, &client_id_len))
|
|
|
|
|
|| client_id_len < 2) {
|
|
|
|
|
|
|
|
|
|
/* invalid client-ids are not expected. */
|
|
|
|
|
nm_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "no valid IPv4 client-id");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
}
|
|
|
|
|
|
2018-12-19 13:42:10 +01:00
|
|
|
/* Note that we always set a client-id. In particular for infiniband that is necessary,
|
|
|
|
|
* see https://tools.ietf.org/html/rfc4390#section-2.1 . */
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_client_id (sd_client,
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
client_id_arr[0],
|
|
|
|
|
client_id_arr + 1,
|
|
|
|
|
NM_MIN (client_id_len - 1, _NM_SD_MAX_CLIENT_ID_LEN));
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set IPv4 client-id: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
/* Add requested options */
|
|
|
|
|
for (i = 0; dhcp4_requests[i].name; i++) {
|
2018-11-26 16:49:13 +01:00
|
|
|
if (dhcp4_requests[i].include) {
|
|
|
|
|
nm_assert (dhcp4_requests[i].option_num <= 255);
|
|
|
|
|
r = sd_dhcp_client_set_request_option (sd_client, dhcp4_requests[i].option_num);
|
|
|
|
|
nm_assert (r >= 0 || r == -EEXIST);
|
|
|
|
|
}
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2014-11-03 18:12:25 -06:00
|
|
|
hostname = nm_dhcp_client_get_hostname (client);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (hostname) {
|
2017-04-28 11:40:51 +02:00
|
|
|
/* FIXME: sd-dhcp decides which hostname/FQDN option to send (12 or 81)
|
|
|
|
|
* only based on whether the hostname has a domain part or not. At the
|
|
|
|
|
* moment there is no way to force one or another.
|
|
|
|
|
*/
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_hostname (sd_client, hostname);
|
2017-04-28 11:40:51 +02:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set DHCP hostname: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2015-10-13 15:13:26 +02:00
|
|
|
}
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp_client_set_callback (sd_client, dhcp_event_cb, client);
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set callback: %s");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->client4 = g_steal_pointer (&sd_client);
|
|
|
|
|
|
|
|
|
|
g_free (priv->lease_file);
|
|
|
|
|
priv->lease_file = g_steal_pointer (&lease_file);
|
|
|
|
|
|
|
|
|
|
nm_dhcp_client_set_client_id (client, client_id);
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
r = sd_dhcp_client_start (priv->client4);
|
|
|
|
|
if (r < 0) {
|
2018-11-02 10:18:23 +01:00
|
|
|
sd_dhcp_client_set_callback (priv->client4, NULL, NULL);
|
|
|
|
|
nm_clear_pointer (&priv->client4, sd_dhcp_client_unref);
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to start DHCP client: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-01-25 09:46:58 +01:00
|
|
|
nm_dhcp_client_start_timeout (client);
|
2018-11-02 10:18:23 +01:00
|
|
|
return TRUE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-02-21 11:43:34 +01:00
|
|
|
static NMIP6Config *
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
lease_to_ip6_config (NMDedupMultiIndex *multi_idx,
|
|
|
|
|
const char *iface,
|
2016-02-21 11:43:34 +01:00
|
|
|
int ifindex,
|
|
|
|
|
sd_dhcp6_lease *lease,
|
|
|
|
|
gboolean log_lease,
|
|
|
|
|
gboolean info_only,
|
2018-11-27 13:47:08 +01:00
|
|
|
GHashTable **out_options,
|
2016-02-21 11:43:34 +01:00
|
|
|
GError **error)
|
|
|
|
|
{
|
2018-11-27 13:47:08 +01:00
|
|
|
gs_unref_object NMIP6Config *ip6_config = NULL;
|
|
|
|
|
gs_unref_hashtable GHashTable *options = NULL;
|
2016-02-21 11:43:34 +01:00
|
|
|
struct in6_addr tmp_addr, *dns;
|
|
|
|
|
uint32_t lft_pref, lft_valid;
|
2018-11-26 16:49:51 +01:00
|
|
|
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
|
2016-02-21 11:43:34 +01:00
|
|
|
char **domains;
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_auto_free_gstring GString *str = NULL;
|
2016-02-21 11:43:34 +01:00
|
|
|
int num, i;
|
2018-11-27 13:47:08 +01:00
|
|
|
const gint32 ts = nm_utils_get_monotonic_timestamp_s ();
|
2016-02-21 11:43:34 +01:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (lease, NULL);
|
2018-11-27 13:47:08 +01:00
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
ip6_config = nm_ip6_config_new (multi_idx, ifindex);
|
2018-11-27 13:47:08 +01:00
|
|
|
|
|
|
|
|
options = out_options ? create_options_dict () : NULL;
|
2016-02-21 11:43:34 +01:00
|
|
|
|
|
|
|
|
sd_dhcp6_lease_reset_address_iter (lease);
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_gstring_prepare (&str);
|
2016-02-21 11:43:34 +01:00
|
|
|
while (sd_dhcp6_lease_get_address (lease, &tmp_addr, &lft_pref, &lft_valid) >= 0) {
|
2018-11-27 13:47:13 +01:00
|
|
|
const NMPlatformIP6Address address = {
|
|
|
|
|
.plen = 128,
|
|
|
|
|
.address = tmp_addr,
|
|
|
|
|
.timestamp = ts,
|
|
|
|
|
.lifetime = lft_valid,
|
|
|
|
|
.preferred = lft_pref,
|
2016-04-11 13:09:52 +02:00
|
|
|
.addr_source = NM_IP_CONFIG_SOURCE_DHCP,
|
2016-02-21 11:43:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nm_ip6_config_add_address (ip6_config, &address);
|
|
|
|
|
|
2018-11-26 16:49:51 +01:00
|
|
|
nm_utils_inet6_ntop (&tmp_addr, addr_str);
|
|
|
|
|
if (str->len)
|
|
|
|
|
g_string_append_c (str, ' ');
|
|
|
|
|
g_string_append (str, addr_str);
|
2016-02-21 11:43:34 +01:00
|
|
|
|
|
|
|
|
LOG_LEASE (LOGD_DHCP6,
|
2017-06-14 13:40:07 +02:00
|
|
|
"address %s",
|
2016-02-21 11:43:34 +01:00
|
|
|
nm_platform_ip6_address_to_string (&address, NULL, 0));
|
|
|
|
|
};
|
|
|
|
|
|
2017-06-14 13:21:04 +02:00
|
|
|
if (str->len)
|
2016-02-21 11:43:34 +01:00
|
|
|
add_option (options, dhcp6_requests, DHCP6_OPTION_IP_ADDRESS, str->str);
|
|
|
|
|
|
2018-11-27 13:47:08 +01:00
|
|
|
if ( !info_only
|
|
|
|
|
&& nm_ip6_config_get_num_addresses (ip6_config) == 0) {
|
2016-02-21 11:43:34 +01:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_FAILED,
|
|
|
|
|
"no address received in managed mode");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
num = sd_dhcp6_lease_get_dns (lease, &dns);
|
|
|
|
|
if (num > 0) {
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_gstring_prepare (&str);
|
2016-02-21 11:43:34 +01:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
nm_ip6_config_add_nameserver (ip6_config, &dns[i]);
|
2018-11-26 16:49:51 +01:00
|
|
|
nm_utils_inet6_ntop (&dns[i], addr_str);
|
|
|
|
|
if (str->len)
|
|
|
|
|
g_string_append_c (str, ' ');
|
|
|
|
|
g_string_append (str, addr_str);
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP6, "nameserver %s", addr_str);
|
2016-02-21 11:43:34 +01:00
|
|
|
}
|
|
|
|
|
add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DNS_SERVERS, str->str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
num = sd_dhcp6_lease_get_domains (lease, &domains);
|
|
|
|
|
if (num > 0) {
|
2017-06-14 13:21:04 +02:00
|
|
|
nm_gstring_prepare (&str);
|
2016-02-21 11:43:34 +01:00
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
nm_ip6_config_add_search (ip6_config, domains[i]);
|
|
|
|
|
g_string_append_printf (str, "%s%s", str->len ? " " : "", domains[i]);
|
2017-06-14 13:40:07 +02:00
|
|
|
LOG_LEASE (LOGD_DHCP6, "domain name '%s'", domains[i]);
|
2016-02-21 11:43:34 +01:00
|
|
|
}
|
|
|
|
|
add_option (options, dhcp6_requests, SD_DHCP6_OPTION_DOMAIN_LIST, str->str);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:47:08 +01:00
|
|
|
NM_SET_OUT (out_options, g_steal_pointer (&options));
|
|
|
|
|
return g_steal_pointer (&ip6_config);
|
2016-02-21 11:43:34 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
static void
|
|
|
|
|
bound6_handle (NMDhcpSystemd *self)
|
|
|
|
|
{
|
2016-02-21 11:43:34 +01:00
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
|
|
|
|
const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self));
|
|
|
|
|
gs_unref_object NMIP6Config *ip6_config = NULL;
|
|
|
|
|
gs_unref_hashtable GHashTable *options = NULL;
|
|
|
|
|
gs_free_error GError *error = NULL;
|
|
|
|
|
sd_dhcp6_lease *lease;
|
|
|
|
|
|
2018-11-27 13:47:13 +01:00
|
|
|
if ( sd_dhcp6_client_get_lease (priv->client6, &lease) < 0
|
|
|
|
|
|| !lease) {
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW (" no lease!");
|
2016-02-21 11:43:34 +01:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGD ("lease available");
|
2016-02-21 11:43:34 +01:00
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
ip6_config = lease_to_ip6_config (nm_dhcp_client_get_multi_idx (NM_DHCP_CLIENT (self)),
|
|
|
|
|
iface,
|
2016-02-21 11:43:34 +01:00
|
|
|
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
|
|
|
|
|
lease,
|
|
|
|
|
TRUE,
|
2018-02-14 14:58:52 +01:00
|
|
|
nm_dhcp_client_get_info_only (NM_DHCP_CLIENT (self)),
|
2018-11-27 13:47:08 +01:00
|
|
|
&options,
|
2016-02-21 11:43:34 +01:00
|
|
|
&error);
|
|
|
|
|
|
2018-11-26 17:04:10 +01:00
|
|
|
if (!ip6_config) {
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW ("%s", error->message);
|
2016-02-21 11:43:34 +01:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
|
2018-11-26 17:04:10 +01:00
|
|
|
return;
|
2016-02-21 11:43:34 +01:00
|
|
|
}
|
2018-11-26 17:04:10 +01:00
|
|
|
|
|
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self),
|
|
|
|
|
NM_DHCP_STATE_BOUND,
|
|
|
|
|
NM_IP_CONFIG_CAST (ip6_config),
|
|
|
|
|
options);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data);
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_assert (priv->client6 == client);
|
|
|
|
|
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGD ("client event %d", event);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
switch (event) {
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX:
|
2014-07-22 12:38:20 -05:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_TIMEOUT, NULL, NULL);
|
|
|
|
|
break;
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE:
|
|
|
|
|
case SD_DHCP6_CLIENT_EVENT_STOP:
|
2014-07-22 12:38:20 -05:00
|
|
|
nm_dhcp_client_set_state (NM_DHCP_CLIENT (user_data), NM_DHCP_STATE_FAIL, NULL, NULL);
|
|
|
|
|
break;
|
2015-10-07 10:07:17 +02:00
|
|
|
case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE:
|
2016-04-25 15:39:50 -05:00
|
|
|
case SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST:
|
2014-07-22 12:38:20 -05:00
|
|
|
bound6_handle (self);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2016-03-03 10:19:28 +01:00
|
|
|
_LOGW ("unhandled event %d", event);
|
2014-07-22 12:38:20 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
ip6_start (NMDhcpClient *client,
|
|
|
|
|
const char *dhcp_anycast_addr,
|
2015-11-23 14:22:29 +01:00
|
|
|
const struct in6_addr *ll_addr,
|
2014-07-22 12:38:20 -05:00
|
|
|
NMSettingIP6ConfigPrivacy privacy,
|
2018-09-10 12:22:20 +02:00
|
|
|
guint needed_prefixes,
|
|
|
|
|
GError **error)
|
2014-07-22 12:38:20 -05:00
|
|
|
{
|
2016-03-03 10:19:28 +01:00
|
|
|
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
2018-11-02 10:18:23 +01:00
|
|
|
nm_auto (sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL;
|
2018-02-14 13:09:23 +01:00
|
|
|
GBytes *hwaddr;
|
2017-12-13 22:06:18 +01:00
|
|
|
const char *hostname;
|
2018-11-23 14:03:08 +01:00
|
|
|
const char *iface;
|
2014-07-22 12:38:20 -05:00
|
|
|
int r, i;
|
2018-04-11 08:54:10 +02:00
|
|
|
const guint8 *duid_arr;
|
2018-02-14 13:09:23 +01:00
|
|
|
gsize duid_len;
|
2018-10-24 15:37:55 +02:00
|
|
|
GBytes *duid;
|
2018-11-02 15:49:07 +01:00
|
|
|
const uint8_t *hwaddr_arr;
|
|
|
|
|
gsize hwaddr_len;
|
2018-12-14 08:45:09 +01:00
|
|
|
int arp_type;
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2018-10-24 15:37:55 +02:00
|
|
|
g_return_val_if_fail (!priv->client4, FALSE);
|
|
|
|
|
g_return_val_if_fail (!priv->client6, FALSE);
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
if ( !(duid = nm_dhcp_client_get_client_id (client))
|
|
|
|
|
|| !(duid_arr = g_bytes_get_data (duid, &duid_len))
|
|
|
|
|
|| duid_len < 2) {
|
|
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "missing DUID");
|
2018-02-14 13:09:23 +01:00
|
|
|
g_return_val_if_reached (FALSE);
|
2018-11-02 10:18:23 +01:00
|
|
|
}
|
2018-02-14 13:09:23 +01:00
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_new (&sd_client);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to create dhcp-client: %s");
|
2014-07-22 12:38:20 -05:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 23:30:37 +01:00
|
|
|
if (needed_prefixes > 0) {
|
2018-10-06 11:26:42 +02:00
|
|
|
_LOGW ("dhcp-client6: prefix delegation not yet supported, won't supply %d prefixes",
|
2016-10-31 23:30:37 +01:00
|
|
|
needed_prefixes);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
_LOGT ("dhcp-client6: set %p", sd_client);
|
2016-05-29 13:14:48 +02:00
|
|
|
|
2018-02-14 14:58:52 +01:00
|
|
|
if (nm_dhcp_client_get_info_only (client))
|
2018-11-02 10:18:23 +01:00
|
|
|
sd_dhcp6_client_set_information_request (sd_client, 1);
|
2016-04-25 15:39:50 -05:00
|
|
|
|
2018-11-23 14:03:08 +01:00
|
|
|
iface = nm_dhcp_client_get_iface (client);
|
|
|
|
|
|
|
|
|
|
r = sd_dhcp6_client_set_iaid (sd_client,
|
|
|
|
|
nm_utils_create_dhcp_iaid (TRUE,
|
|
|
|
|
(const guint8 *) iface,
|
|
|
|
|
strlen (iface)));
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set IAID: %s");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_set_duid (sd_client,
|
2018-04-11 08:54:10 +02:00
|
|
|
unaligned_read_be16 (&duid_arr[0]),
|
|
|
|
|
&duid_arr[2],
|
2018-02-14 13:09:23 +01:00
|
|
|
duid_len - 2);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set DUID: %s");
|
2014-07-22 12:38:20 -05:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_attach_event (sd_client, NULL, 0);
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to attach event: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hwaddr = nm_dhcp_client_get_hw_addr (client);
|
2018-11-02 15:49:07 +01:00
|
|
|
if ( !hwaddr
|
|
|
|
|
|| !(hwaddr_arr = g_bytes_get_data (hwaddr, &hwaddr_len))
|
2018-12-20 08:50:07 +01:00
|
|
|
|| (arp_type = nm_utils_arp_type_detect_from_hwaddrlen (hwaddr_len)) < 0) {
|
2018-11-02 15:49:07 +01:00
|
|
|
nm_utils_error_set_literal (error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
r = sd_dhcp6_client_set_mac (sd_client,
|
|
|
|
|
hwaddr_arr,
|
|
|
|
|
hwaddr_len,
|
2018-12-14 08:45:09 +01:00
|
|
|
(guint16) arp_type);
|
2018-11-02 15:49:07 +01:00
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set MAC address: %s");
|
|
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_set_ifindex (sd_client,
|
dhcp: cleanup initializing IPv4 client-id for internal DHCP
- if we leave the client-id of sd_dhcp_client unset, it will
anyway generate a node-specific client-id (and may fail if
"/etc/machine-id" is invalid).
Anticipate that, and don't let the client-id unset. In case
we have no client-id from configuration or lease, just generate
the id ourself (using the same algorithm). The advantage is,
that we know it upfront and can store the client-id in the
NMDhcpClient instance. We no longer need to peel it out from
the lease later.
- to generate the IPv4 client-id, we need a valid MAC address. Also,
sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket()
as well. Just require that a MAC address is always needed. Likewise,
we need a valid ifindex and ifname set.
- likewise for IPv6 and IPv4, cleanup detecting the arptype and
checking MAC address length. sd_dhcp_client_set_mac() is overly
strict at asserting input arguments, so we must validate them anyway.
- also, now that we always initialize the client-id when starting
the DHCP client, there is no need to retroactively extract it
again when we receive the first lease.
2018-10-29 12:11:26 +01:00
|
|
|
nm_dhcp_client_get_ifindex (client));
|
2014-07-22 12:38:20 -05:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set ifindex: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add requested options */
|
|
|
|
|
for (i = 0; dhcp6_requests[i].name; i++) {
|
2018-11-26 16:49:13 +01:00
|
|
|
if (dhcp6_requests[i].include) {
|
|
|
|
|
r = sd_dhcp6_client_set_request_option (sd_client, dhcp6_requests[i].option_num);
|
|
|
|
|
nm_assert (r >= 0 || r == -EEXIST);
|
|
|
|
|
}
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_set_local_address (sd_client, ll_addr);
|
2015-11-23 16:13:45 +01:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set local address: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2015-11-23 16:13:45 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-13 22:06:18 +01:00
|
|
|
hostname = nm_dhcp_client_get_hostname (client);
|
2018-11-02 10:18:23 +01:00
|
|
|
r = sd_dhcp6_client_set_fqdn (sd_client, hostname);
|
2017-12-13 22:06:18 +01:00
|
|
|
if (r < 0) {
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to set DHCP hostname: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r = sd_dhcp6_client_set_callback (sd_client, dhcp6_event_cb, client);
|
|
|
|
|
if (r < 0) {
|
|
|
|
|
nm_utils_error_set_errno (error, r, "failed to set callback: %s");
|
|
|
|
|
return FALSE;
|
2017-12-13 22:06:18 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-02 10:18:23 +01:00
|
|
|
priv->client6 = g_steal_pointer (&sd_client);
|
|
|
|
|
|
2014-07-22 12:38:20 -05:00
|
|
|
r = sd_dhcp6_client_start (priv->client6);
|
|
|
|
|
if (r < 0) {
|
2018-11-02 10:18:23 +01:00
|
|
|
sd_dhcp6_client_set_callback (priv->client6, NULL, NULL);
|
|
|
|
|
nm_clear_pointer (&priv->client6, sd_dhcp6_client_unref);
|
2018-09-10 12:22:20 +02:00
|
|
|
nm_utils_error_set_errno (error, r, "failed to start client: %s");
|
2018-11-02 10:18:23 +01:00
|
|
|
return FALSE;
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-08-24 14:57:35 +02:00
|
|
|
nm_dhcp_client_start_timeout (client);
|
2014-07-22 12:38:20 -05:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-24 15:37:55 +02:00
|
|
|
stop (NMDhcpClient *client, gboolean release)
|
2014-07-22 12:38:20 -05:00
|
|
|
{
|
2016-03-03 10:19:28 +01:00
|
|
|
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
|
|
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
|
2014-07-22 12:38:20 -05:00
|
|
|
int r = 0;
|
|
|
|
|
|
2018-10-24 15:37:55 +02:00
|
|
|
NM_DHCP_CLIENT_CLASS (nm_dhcp_systemd_parent_class)->stop (client, release);
|
2018-02-14 14:48:30 +01:00
|
|
|
|
2016-05-29 13:14:48 +02:00
|
|
|
_LOGT ("dhcp-client%d: stop %p",
|
|
|
|
|
priv->client4 ? '4' : '6',
|
|
|
|
|
priv->client4 ? (gpointer) priv->client4 : (gpointer) priv->client6);
|
|
|
|
|
|
2016-01-25 09:47:02 +01:00
|
|
|
if (priv->client4) {
|
|
|
|
|
sd_dhcp_client_set_callback (priv->client4, NULL, NULL);
|
2014-07-22 12:38:20 -05:00
|
|
|
r = sd_dhcp_client_stop (priv->client4);
|
2016-01-25 09:47:02 +01:00
|
|
|
} else if (priv->client6) {
|
|
|
|
|
sd_dhcp6_client_set_callback (priv->client6, NULL, NULL);
|
2014-07-22 12:38:20 -05:00
|
|
|
r = sd_dhcp6_client_stop (priv->client6);
|
2016-01-25 09:47:02 +01:00
|
|
|
}
|
2014-07-22 12:38:20 -05:00
|
|
|
|
2016-03-03 10:19:28 +01:00
|
|
|
if (r)
|
|
|
|
|
_LOGW ("failed to stop client (%d)", r);
|
2014-07-22 12:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dhcp_systemd_init (NMDhcpSystemd *self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
2016-09-28 15:58:24 +02:00
|
|
|
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE ((NMDhcpSystemd *) object);
|
2014-07-22 12:38:20 -05:00
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->lease_file, g_free);
|
|
|
|
|
|
|
|
|
|
if (priv->client4) {
|
|
|
|
|
sd_dhcp_client_stop (priv->client4);
|
|
|
|
|
sd_dhcp_client_unref (priv->client4);
|
|
|
|
|
priv->client4 = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->client6) {
|
|
|
|
|
sd_dhcp6_client_stop (priv->client6);
|
|
|
|
|
sd_dhcp6_client_unref (priv->client6);
|
|
|
|
|
priv->client6 = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_dhcp_systemd_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_dhcp_systemd_class_init (NMDhcpSystemdClass *sdhcp_class)
|
|
|
|
|
{
|
|
|
|
|
NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS (sdhcp_class);
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (sdhcp_class);
|
|
|
|
|
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
|
|
|
|
client_class->ip4_start = ip4_start;
|
|
|
|
|
client_class->ip6_start = ip6_start;
|
|
|
|
|
client_class->stop = stop;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-01 16:19:24 +02:00
|
|
|
const NMDhcpClientFactory _nm_dhcp_client_factory_internal = {
|
|
|
|
|
.name = "internal",
|
|
|
|
|
.get_type = nm_dhcp_systemd_get_type,
|
|
|
|
|
.get_path = NULL,
|
|
|
|
|
};
|