about summary refs log tree commit diff
path: root/src/nm-iface-helper.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-05-11 22:08:45 +0200
committerMichael Biebl <biebl@debian.org>2018-05-11 22:08:45 +0200
commitee9c73a923909e23a649407be77e25235d769e25 (patch)
treee21c923621fa278e737da693df9eb60ea31a6067 /src/nm-iface-helper.c
parentf60117b41d5433be1b4a96d82cd11d0c3dce9b63 (diff)
New upstream version 1.10.8 upstream/1.10.8
Diffstat (limited to 'src/nm-iface-helper.c')
-rw-r--r--src/nm-iface-helper.c115
1 files changed, 26 insertions, 89 deletions
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 601c72ac..1493ef19 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -33,8 +33,6 @@
 #include <signal.h>
 #include <linux/rtnetlink.h>
 
-#include "nm-utils/nm-c-list.h"
-
 #include "main-utils.h"
 #include "NetworkManagerUtils.h"
 #include "platform/nm-linux-platform.h"
@@ -57,9 +55,6 @@
 static struct {
 	GMainLoop *main_loop;
 	int ifindex;
-
-	guint dad_failed_id;
-	CList dad_failed_lst_head;
 } gl/*obal*/ = {
 	.ifindex = -1,
 };
@@ -125,7 +120,7 @@ dhcp4_state_changed (NMDhcpClient *client,
 		g_assert (nm_ip4_config_get_ifindex (ip4_config) == gl.ifindex);
 
 		existing = nm_ip4_config_capture (nm_platform_get_multi_idx (NM_PLATFORM_GET),
-		                                  NM_PLATFORM_GET, gl.ifindex);
+		                                  NM_PLATFORM_GET, gl.ifindex, FALSE);
 		if (last_config)
 			nm_ip4_config_subtract (existing, last_config, 0);
 
@@ -171,7 +166,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
 	NMIP6Config *existing;
 
 	existing = nm_ip6_config_capture (nm_platform_get_multi_idx (NM_PLATFORM_GET),
-	                                  NM_PLATFORM_GET, gl.ifindex, global_opt.tempaddr);
+	                                  NM_PLATFORM_GET, gl.ifindex, FALSE, global_opt.tempaddr);
 	if (ndisc_config)
 		nm_ip6_config_subtract (existing, ndisc_config, 0);
 	else {
@@ -321,58 +316,19 @@ do_early_setup (int *argc, char **argv[])
 	return TRUE;
 }
 
-typedef struct {
-	NMPlatform *platform;
-	NMNDisc *ndisc;
-} DadFailedHandleData;
-
-static gboolean
-dad_failed_handle_idle (gpointer user_data)
-{
-	DadFailedHandleData *data = user_data;
-	NMCListElem *elem;
-
-	while ((elem = c_list_first_entry (&gl.dad_failed_lst_head, NMCListElem, lst))) {
-		nm_auto_nmpobj const NMPObject *obj = elem->data;
-
-		nm_c_list_elem_free (elem);
-
-		if (nm_ndisc_dad_addr_is_fail_candidate (data->platform, obj)) {
-			nm_ndisc_dad_failed (data->ndisc,
-			                     &NMP_OBJECT_CAST_IP6_ADDRESS (obj)->address);
-		}
-	}
-
-	gl.dad_failed_id = 0;
-	return G_SOURCE_REMOVE;
-}
-
 static void
 ip6_address_changed (NMPlatform *platform,
                      int obj_type_i,
                      int iface,
-                     const NMPlatformIP6Address *addr,
+                     NMPlatformIP6Address *addr,
                      int change_type_i,
                      NMNDisc *ndisc)
 {
 	const NMPlatformSignalChangeType change_type = change_type_i;
-	DadFailedHandleData *data;
-
-	if (!nm_ndisc_dad_addr_is_fail_candidate_event (change_type, addr))
-		return;
-
-	c_list_link_tail (&gl.dad_failed_lst_head,
-	                  &nm_c_list_elem_new_stale ((gpointer) nmp_object_ref (NMP_OBJECT_UP_CAST (addr)))->lst);
-	if (gl.dad_failed_id)
-		return;
-
-	data = g_slice_new (DadFailedHandleData);
-	data->platform = platform;
-	data->ndisc = ndisc;
-	gl.dad_failed_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
-	                                    dad_failed_handle_idle,
-	                                    data,
-	                                    nm_g_slice_free_fcn (DadFailedHandleData));
+
+	if (   (change_type == NM_PLATFORM_SIGNAL_CHANGED && addr->n_ifa_flags & IFA_F_DADFAILED)
+	    || (change_type == NM_PLATFORM_SIGNAL_REMOVED && addr->n_ifa_flags & IFA_F_TENTATIVE))
+		nm_ndisc_dad_failed (ndisc, &addr->address);
 }
 
 int
@@ -384,13 +340,14 @@ main (int argc, char *argv[])
 	gs_free char *pidfile = NULL;
 	gs_unref_object NMDhcpClient *dhcp4_client = NULL;
 	gs_unref_object NMNDisc *ndisc = NULL;
-	gs_unref_bytes GBytes *hwaddr = NULL;
-	gs_unref_bytes GBytes *client_id = NULL;
+	GByteArray *hwaddr = NULL;
+	size_t hwaddr_len = 0;
+	gconstpointer tmp;
 	gs_free NMUtilsIPv6IfaceId *iid = NULL;
 	guint sd_id;
 	char sysctl_path_buf[NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE];
 
-	c_list_init (&gl.dad_failed_lst_head);
+	nm_g_type_init ();
 
 	setpgid (getpid (), getpid ());
 
@@ -474,7 +431,11 @@ main (int argc, char *argv[])
 	/* Set up platform interaction layer */
 	nm_linux_platform_setup ();
 
-	hwaddr = nm_platform_link_get_address_as_bytes (NM_PLATFORM_GET, gl.ifindex);
+	tmp = nm_platform_link_get_address (NM_PLATFORM_GET, gl.ifindex, &hwaddr_len);
+	if (tmp) {
+		hwaddr = g_byte_array_sized_new (hwaddr_len);
+		g_byte_array_append (hwaddr, tmp, hwaddr_len);
+	}
 
 	if (global_opt.iid_str) {
 		GBytes *bytes;
@@ -488,16 +449,6 @@ main (int argc, char *argv[])
 		iid = g_bytes_unref_to_data (bytes, &ignored);
 	}
 
-	if (global_opt.dhcp4_clientid) {
-		/* this string is just a plain hex-string. Unlike ipv4.dhcp-client-id, which
-		 * is parsed via nm_dhcp_utils_client_id_string_to_bytes(). */
-		client_id = nm_utils_hexstr2bin (global_opt.dhcp4_clientid);
-		if (!client_id || g_bytes_get_size (client_id) < 2) {
-			fprintf (stderr, _("(%s): Invalid DHCP client-id %s\n"), global_opt.ifname, global_opt.dhcp4_clientid);
-			return 1;
-		}
-	}
-
 	if (global_opt.dhcp4_address) {
 		nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_sysctl_ip_conf_path (AF_INET, sysctl_path_buf, global_opt.ifname, "promote_secondaries")), "1");
 
@@ -512,7 +463,7 @@ main (int argc, char *argv[])
 		                                          !!global_opt.dhcp4_hostname,
 		                                          global_opt.dhcp4_hostname,
 		                                          global_opt.dhcp4_fqdn,
-		                                          client_id,
+		                                          global_opt.dhcp4_clientid,
 		                                          NM_DHCP_TIMEOUT_DEFAULT,
 		                                          NULL,
 		                                          global_opt.dhcp4_address);
@@ -572,8 +523,7 @@ main (int argc, char *argv[])
 
 	g_main_loop_run (gl.main_loop);
 
-	nm_clear_g_source (&gl.dad_failed_id);
-	nm_c_list_elem_free_all (&gl.dad_failed_lst_head, (GDestroyNotify) nmp_object_unref);
+	g_clear_pointer (&hwaddr, g_byte_array_unref);
 
 	if (pidfile && wrote_pidfile)
 		unlink (pidfile);
@@ -597,7 +547,7 @@ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[4] = {
 #include "nm-config.h"
 #include "devices/nm-device.h"
 #include "nm-active-connection.h"
-#include "nm-dbus-manager.h"
+#include "nm-bus-manager.h"
 
 void
 nm_main_config_reload (int signal)
@@ -629,34 +579,21 @@ nm_config_get_configure_and_quit (NMConfig *config)
 	return TRUE;
 }
 
-NMDBusManager *
-nm_dbus_manager_get (void)
-{
-	return NULL;
-}
-
-void
-_nm_dbus_manager_obj_export (NMDBusObject *obj)
-{
-}
-
-void
-_nm_dbus_manager_obj_unexport (NMDBusObject *obj)
+NMBusManager *
+nm_bus_manager_get (void)
 {
+	return GUINT_TO_POINTER (1);
 }
 
 void
-_nm_dbus_manager_obj_notify (NMDBusObject *obj,
-                             guint n_pspecs,
-                             const GParamSpec *const*pspecs)
+nm_bus_manager_register_object (NMBusManager *bus_manager,
+                                GDBusObjectSkeleton *object)
 {
 }
 
 void
-_nm_dbus_manager_obj_emit_signal (NMDBusObject *obj,
-                                  const NMDBusInterfaceInfoExtended *interface_info,
-                                  const GDBusSignalInfo *signal_info,
-                                  GVariant *args)
+nm_bus_manager_unregister_object (NMBusManager *bus_manager,
+                                  GDBusObjectSkeleton *object)
 {
 }