summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-07-31 15:41:02 +0200
committerThomas Haller <thaller@redhat.com>2019-08-13 09:42:15 +0200
commitb53e261427c925034ada6b90278b7e9077e2ea43 (patch)
tree46821e90eadd0d7d98a9e27804aff400b97f13df
parent8d8cc0da3d29b3a064a5cbd883365817a56f8e9d (diff)
downloadNetworkManager-b53e261427c925034ada6b90278b7e9077e2ea43.tar.gz
dhcp: make "systemd" DHCP plugin configurable
We have the "internal" DHCP plugin. That's our preferred plugin, and eventually we may drop all other plugins. Currently, the "internal" plugin is based on code from systemd-networkd and implemented in "src/dhcp/nm-dhcp-systemd.c". As this code is forked we eventually want to switch to nettools' n-dhcp4 library (for IPv4). For that reason we already have "src/dhcp/nm-dhcp-nettools.c". Note that "nettools" can be configured as a DHCP plugin, but this configuration is only experimental and for testing. There is never supposed to be a "nettools" plugin, but eventually the "internal" plugin will switch implementation. We don't want to replace systemd-based implementation right away. Not until we are sure that nettools works well. For that reason we keep them both in parallel for a while. This commit makes "systemd" DHCP plugin explicitly configurable in NetworkManager.conf. Like "nettools" this is an undocumented option, only for testing. If you choose "internal" (the default), you get one of the implementations (currently the "systemd" one). But by selecting "systemd" or "nettools" explicitly, you can select the exact plugin.
-rw-r--r--src/dhcp/nm-dhcp-client.h5
-rw-r--r--src/dhcp/nm-dhcp-dhclient.c2
-rw-r--r--src/dhcp/nm-dhcp-dhcpcanon.c2
-rw-r--r--src/dhcp/nm-dhcp-dhcpcd.c2
-rw-r--r--src/dhcp/nm-dhcp-listener.c3
-rw-r--r--src/dhcp/nm-dhcp-manager.c12
-rw-r--r--src/dhcp/nm-dhcp-manager.h2
-rw-r--r--src/dhcp/nm-dhcp-nettools.c6
-rw-r--r--src/dhcp/nm-dhcp-systemd.c21
-rw-r--r--src/nm-iface-helper.c5
10 files changed, 42 insertions, 18 deletions
diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h
index 9eb76f33a8..551e2449a8 100644
--- a/src/dhcp/nm-dhcp-client.h
+++ b/src/dhcp/nm-dhcp-client.h
@@ -207,15 +207,18 @@ void nm_dhcp_client_set_client_id_bin (NMDhcpClient *self,
*****************************************************************************/
typedef struct {
- GType (*get_type)(void);
+ GType (*get_type) (void);
+ GType (*get_type_per_addr_family) (int addr_family);
const char *name;
const char *(*get_path) (void);
+ bool experimental:1;
} NMDhcpClientFactory;
extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcanon;
extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient;
extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd;
extern const NMDhcpClientFactory _nm_dhcp_client_factory_internal;
+extern const NMDhcpClientFactory _nm_dhcp_client_factory_systemd;
extern const NMDhcpClientFactory _nm_dhcp_client_factory_nettools;
#endif /* __NETWORKMANAGER_DHCP_CLIENT_H__ */
diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c
index 54b50479dd..72ea3d48f8 100644
--- a/src/dhcp/nm-dhcp-dhclient.c
+++ b/src/dhcp/nm-dhcp-dhclient.c
@@ -723,7 +723,7 @@ nm_dhcp_dhclient_class_init (NMDhcpDhclientClass *dhclient_class)
}
const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient = {
- .name = "dhclient",
+ .name = "dhclient",
.get_type = nm_dhcp_dhclient_get_type,
.get_path = nm_dhcp_dhclient_get_path,
};
diff --git a/src/dhcp/nm-dhcp-dhcpcanon.c b/src/dhcp/nm-dhcp-dhcpcanon.c
index 2d2113cc76..c193e36780 100644
--- a/src/dhcp/nm-dhcp-dhcpcanon.c
+++ b/src/dhcp/nm-dhcp-dhcpcanon.c
@@ -248,7 +248,7 @@ nm_dhcp_dhcpcanon_class_init (NMDhcpDhcpcanonClass *dhcpcanon_class)
}
const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcanon = {
- .name = "dhcpcanon",
+ .name = "dhcpcanon",
.get_type = nm_dhcp_dhcpcanon_get_type,
.get_path = nm_dhcp_dhcpcanon_get_path,
};
diff --git a/src/dhcp/nm-dhcp-dhcpcd.c b/src/dhcp/nm-dhcp-dhcpcd.c
index c300bbe2f0..b07d5a1bba 100644
--- a/src/dhcp/nm-dhcp-dhcpcd.c
+++ b/src/dhcp/nm-dhcp-dhcpcd.c
@@ -242,7 +242,7 @@ nm_dhcp_dhcpcd_class_init (NMDhcpDhcpcdClass *dhcpcd_class)
}
const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd = {
- .name = "dhcpcd",
+ .name = "dhcpcd",
.get_type = nm_dhcp_dhcpcd_get_type,
.get_path = nm_dhcp_dhcpcd_get_path,
};
diff --git a/src/dhcp/nm-dhcp-listener.c b/src/dhcp/nm-dhcp-listener.c
index 88aafeb0b1..ce86d55622 100644
--- a/src/dhcp/nm-dhcp-listener.c
+++ b/src/dhcp/nm-dhcp-listener.c
@@ -38,7 +38,7 @@
/*****************************************************************************/
-const NMDhcpClientFactory *const _nm_dhcp_manager_factories[5] = {
+const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = {
/* the order here matters, as we will try the plugins in this order to find
* the first available plugin. */
@@ -52,6 +52,7 @@ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[5] = {
&_nm_dhcp_client_factory_dhcpcd,
#endif
&_nm_dhcp_client_factory_internal,
+ &_nm_dhcp_client_factory_systemd,
&_nm_dhcp_client_factory_nettools,
};
diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c
index 507fc64359..3c78d7c2dc 100644
--- a/src/dhcp/nm-dhcp-manager.c
+++ b/src/dhcp/nm-dhcp-manager.c
@@ -119,7 +119,10 @@ _client_factory_get_gtype (const NMDhcpClientFactory *client_factory,
* to those plugins. But we don't intend to do so. The internal plugin is the way forward and
* not extending other plugins. */
- gtype = client_factory->get_type ();
+ if (client_factory->get_type_per_addr_family)
+ gtype = client_factory->get_type_per_addr_family (addr_family);
+ else
+ gtype = client_factory->get_type ();
if (client_factory == &_nm_dhcp_client_factory_internal) {
/* we are already using the internal plugin. Nothing to do. */
@@ -547,9 +550,10 @@ nm_dhcp_manager_init (NMDhcpManager *self)
if (!f)
continue;
- nm_log_dbg (LOGD_DHCP, "dhcp-init: enabled DHCP client '%s' (%s)%s",
- f->name, g_type_name (f->get_type ()),
- _client_factory_available (f) ? "" : " (not available)");
+ nm_log_dbg (LOGD_DHCP, "dhcp-init: enabled DHCP client '%s'%s%s",
+ f->name,
+ _client_factory_available (f) ? "" : " (not available)",
+ f->experimental ? " (undocumented internal plugin)" : "");
}
/* Client-specific setup */
diff --git a/src/dhcp/nm-dhcp-manager.h b/src/dhcp/nm-dhcp-manager.h
index ff0d6f5472..1e0a972b1f 100644
--- a/src/dhcp/nm-dhcp-manager.h
+++ b/src/dhcp/nm-dhcp-manager.h
@@ -86,7 +86,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
/* For testing only */
extern const char* nm_dhcp_helper_path;
-extern const NMDhcpClientFactory *const _nm_dhcp_manager_factories[5];
+extern const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6];
void nmtst_dhcp_manager_unget (gpointer singleton_instance);
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 3aa921807b..292cfecc01 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -1272,7 +1272,7 @@ nm_dhcp_nettools_class_init (NMDhcpNettoolsClass *class)
}
const NMDhcpClientFactory _nm_dhcp_client_factory_nettools = {
- .name = "nettools",
- .get_type = nm_dhcp_nettools_get_type,
- .get_path = NULL,
+ .name = "nettools",
+ .get_type = nm_dhcp_nettools_get_type,
+ .experimental = TRUE,
};
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index 073a6da051..0e30ab3883 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -1173,8 +1173,23 @@ nm_dhcp_systemd_class_init (NMDhcpSystemdClass *sdhcp_class)
client_class->stop = stop;
}
+const NMDhcpClientFactory _nm_dhcp_client_factory_systemd = {
+ .name = "systemd",
+ .get_type = nm_dhcp_systemd_get_type,
+ .experimental = TRUE,
+};
+
+/*****************************************************************************/
+
+static GType
+_get_type_per_addr_family (int addr_family)
+{
+ nm_assert_addr_family (addr_family);
+
+ return nm_dhcp_systemd_get_type ();
+}
+
const NMDhcpClientFactory _nm_dhcp_client_factory_internal = {
- .name = "internal",
- .get_type = nm_dhcp_systemd_get_type,
- .get_path = NULL,
+ .name = "internal",
+ .get_type_per_addr_family = _get_type_per_addr_family,
};
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index dd5bb327a0..239b46a140 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -596,9 +596,10 @@ main (int argc, char *argv[])
/*****************************************************************************/
-const NMDhcpClientFactory *const _nm_dhcp_manager_factories[5] = {
+const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = {
+ /* For nm-iface-helper there is no option to choose a DHCP plugin.
+ * It just uses the "internal" one. */
&_nm_dhcp_client_factory_internal,
- &_nm_dhcp_client_factory_nettools,
};
/*****************************************************************************/