diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-05-11 10:49:53 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-05-11 10:49:53 +0200 |
commit | b341431f87991c487663be6220a3ce7e77f03e69 (patch) | |
tree | b5f1253393913e4a58fdd8f03233b53f609a98a8 | |
parent | 6fba9fd2e55216ba12c77e4567c48d79289cc9b7 (diff) | |
parent | db923366b21d5eb6c86e15d25cc060fd00ab6535 (diff) | |
download | NetworkManager-b341431f87991c487663be6220a3ce7e77f03e69.tar.gz |
ipv4ll: merge branch 'bg/ipv4ll-bgo747463'
https://bugzilla.gnome.org/show_bug.cgi?id=747463
-rw-r--r-- | callouts/Makefile.am | 14 | ||||
-rw-r--r-- | callouts/nm-avahi-autoipd-action.c | 126 | ||||
-rw-r--r-- | callouts/nm-avahi-autoipd.conf | 13 | ||||
-rw-r--r-- | contrib/fedora/rpm/NetworkManager.spec | 3 | ||||
-rw-r--r-- | man/NetworkManager.conf.xml.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/devices/nm-device.c | 296 | ||||
-rw-r--r-- | src/devices/nm-device.h | 7 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhcpcd.c | 2 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/nm-manager.c | 57 | ||||
-rw-r--r-- | src/systemd/src/libsystemd-network/ipv4ll-internal.h | 2 | ||||
-rw-r--r-- | src/systemd/src/libsystemd-network/ipv4ll-network.c | 2 | ||||
-rw-r--r-- | src/systemd/src/libsystemd-network/ipv4ll-packet.c | 3 | ||||
-rw-r--r-- | src/systemd/src/libsystemd-network/sd-ipv4ll.c | 2 | ||||
-rw-r--r-- | src/systemd/src/systemd/sd-ipv4ll.h | 2 |
16 files changed, 155 insertions, 382 deletions
diff --git a/callouts/Makefile.am b/callouts/Makefile.am index cc38e01a82..7bc7273032 100644 --- a/callouts/Makefile.am +++ b/callouts/Makefile.am @@ -22,20 +22,10 @@ noinst_LTLIBRARIES = \ dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = \ - nm-dispatcher.conf \ - nm-avahi-autoipd.conf + nm-dispatcher.conf libexec_PROGRAMS = \ - nm-dispatcher \ - nm-avahi-autoipd.action - - -nm_avahi_autoipd_action_SOURCES = \ - nm-avahi-autoipd-action.c - -nm_avahi_autoipd_action_LDADD = \ - $(DBUS_LIBS) \ - $(GLIB_LIBS) + nm-dispatcher nm_dispatcher_SOURCES = \ diff --git a/callouts/nm-avahi-autoipd-action.c b/callouts/nm-avahi-autoipd-action.c deleted file mode 100644 index b28dae5d21..0000000000 --- a/callouts/nm-avahi-autoipd-action.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * 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 of the License, 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 2008, 2014 Red Hat, Inc. - */ - -#include "config.h" - -#include <stdlib.h> -#include <string.h> - -#include <gio/gio.h> - -#define NM_AVAHI_AUTOIPD_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" -#define NM_AVAHI_AUTOIPD_DBUS_INTERFACE "org.freedesktop.nm_avahi_autoipd" - -static void -on_name_acquired (GDBusConnection *connection, - const gchar *name, - gpointer loop) -{ - g_main_loop_quit (loop); -} - -static void -on_name_lost (GDBusConnection *connection, - const gchar *name, - gpointer user_data) -{ - g_printerr ("Error: Could not acquire the NM autoipd service."); - exit (1); -} - -int -main (int argc, char *argv[]) -{ - GDBusConnection *connection; - char *event, *iface, *address; - GMainLoop *loop; - GError *error = NULL; - -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - if (argc != 4) { - g_printerr ("Error: expected 3 arguments (event, interface, address).\n"); - exit (1); - } - - event = argv[1]; - iface = argv[2]; - address = argv[3] ? argv[3] : ""; - - if (!event || !iface || !strlen (event) || !strlen (iface)) { - g_printerr ("Error: unexpected arguments received from avahi-autoipd.\n"); - exit (1); - } - - /* Get a connection to the system bus */ - connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - if (error) { - char *remote_error = g_dbus_error_get_remote_error (error); - - g_dbus_error_strip_remote_error (error); - g_printerr ("Error: could not get the system bus. Make sure " - "the message bus daemon is running! Message: (%s) %s\n", - remote_error, error->message); - g_free (remote_error); - g_error_free (error); - return 1; - } - - /* Acquire the bus name */ - loop = g_main_loop_new (NULL, FALSE); - g_bus_own_name_on_connection (connection, - NM_AVAHI_AUTOIPD_DBUS_SERVICE, - 0, - on_name_acquired, - on_name_lost, - loop, NULL); - g_main_loop_run (loop); - g_main_loop_unref (loop); - - /* Send the signal */ - if (!g_dbus_connection_emit_signal (connection, - NULL, - "/", - NM_AVAHI_AUTOIPD_DBUS_INTERFACE, - "Event", - g_variant_new ("(sss)", - event, - iface, - address), - &error)) { - g_dbus_error_strip_remote_error (error); - g_printerr ("Error: Could not send autoipd Event signal: %s\n", error->message); - g_error_free (error); - return 1; - } - - if (!g_dbus_connection_flush_sync (connection, NULL, &error)) { - g_dbus_error_strip_remote_error (error); - g_printerr ("Error: Could not flush D-Bus connection: %s\n", error->message); - g_error_free (error); - return 1; - } - - g_object_unref (connection); - return 0; -} - diff --git a/callouts/nm-avahi-autoipd.conf b/callouts/nm-avahi-autoipd.conf deleted file mode 100644 index 485ab42929..0000000000 --- a/callouts/nm-avahi-autoipd.conf +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE busconfig PUBLIC - "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - <policy user="root"> - <allow own="org.freedesktop.nm_avahi_autoipd"/> - </policy> - <policy context="default"> - <deny own="org.freedesktop.nm_avahi_autoipd"/> - <deny send_destination="org.freedesktop.nm_avahi_autoipd"/> - </policy> -</busconfig> - diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index a488ca3648..2937b26b41 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -107,7 +107,6 @@ Requires: dhclient >= 12:4.1.0 Requires: libnl3 >= %{libnl3_version} Requires: %{name}-libnm%{?_isa} = %{epoch}:%{version}-%{release} Requires: ppp = %{ppp_version} -Requires: avahi-autoipd Requires: dnsmasq Requires: udev Requires: iptables @@ -519,7 +518,6 @@ fi %defattr(-,root,root,0755) %doc COPYING NEWS AUTHORS README CONTRIBUTING TODO %{_sysconfdir}/dbus-1/system.d/org.freedesktop.NetworkManager.conf -%{_sysconfdir}/dbus-1/system.d/nm-avahi-autoipd.conf %{_sysconfdir}/dbus-1/system.d/nm-dispatcher.conf %{_sysconfdir}/dbus-1/system.d/nm-ifcfg-rh.conf %{_sbindir}/%{name} @@ -536,7 +534,6 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/NetworkManager.conf %{_bindir}/nm-online %{_libexecdir}/nm-dhcp-helper -%{_libexecdir}/nm-avahi-autoipd.action %{_libexecdir}/nm-dispatcher %{_libexecdir}/nm-iface-helper %dir %{_libdir}/NetworkManager diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in index 7807b1bf9d..054f84202b 100644 --- a/man/NetworkManager.conf.xml.in +++ b/man/NetworkManager.conf.xml.in @@ -401,7 +401,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth <member>WIFI_SCAN : Wi-Fi scanning operations</member> <member>IP4 : IPv4-related operations</member> <member>IP6 : IPv6-related operations</member> - <member>AUTOIP4 : AutoIP (avahi) operations</member> + <member>AUTOIP4 : AutoIP operations</member> <member>DNS : Domain Name System related operations</member> <member>VPN : Virtual Private Network connections and operations</member> <member>SHARING : Connection sharing</member> diff --git a/src/Makefile.am b/src/Makefile.am index 0008351de3..caf688083c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -81,6 +81,10 @@ libsystemd_nm_la_SOURCES = \ systemd/src/libsystemd-network/dhcp6-protocol.h \ systemd/src/libsystemd-network/dhcp-lease-internal.h \ systemd/src/libsystemd-network/sd-dhcp6-client.c \ + systemd/src/libsystemd-network/ipv4ll-internal.h \ + systemd/src/libsystemd-network/sd-ipv4ll.c \ + systemd/src/libsystemd-network/ipv4ll-packet.c \ + systemd/src/libsystemd-network/ipv4ll-network.c \ systemd/src/shared/async.h \ systemd/src/shared/time-util.h \ systemd/src/shared/siphash24.h \ @@ -112,6 +116,7 @@ libsystemd_nm_la_SOURCES = \ systemd/src/systemd/sd-dhcp6-client.h \ systemd/src/systemd/sd-event.h \ systemd/src/systemd/_sd-common.h \ + systemd/src/systemd/sd-ipv4ll.h \ systemd/nm-sd-adapt.h \ systemd/nm-sd-adapt.c diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a10ff18469..f764f013d3 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -68,6 +68,7 @@ #include "nm-core-internal.h" #include "nm-default-route-manager.h" #include "nm-route-manager.h" +#include "sd-ipv4ll.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF (NMDevice); @@ -279,10 +280,9 @@ typedef struct { /* Firewall */ NMFirewallPendingCall fw_call; - /* avahi-autoipd stuff */ - GPid aipd_pid; - guint aipd_watch; - guint aipd_timeout; + /* IPv4LL stuff */ + sd_ipv4ll * ipv4ll; + guint ipv4ll_timeout; /* IP6 configuration info */ NMIP6Config * ip6_config; @@ -2695,40 +2695,72 @@ nm_device_activate_schedule_stage2_device_config (NMDevice *self) _LOGD (LOGD_DEVICE, "Activation: Stage 2 of 5 (Device Configure) scheduled..."); } -/*********************************************/ -/* avahi-autoipd stuff */ - +/* + * nm_device_check_ip_failed + * + * Progress the device to appropriate state if both IPv4 and IPv6 failed + */ static void -aipd_timeout_remove (NMDevice *self) +nm_device_check_ip_failed (NMDevice *self, gboolean may_fail) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDeviceState state; - if (priv->aipd_timeout) { - g_source_remove (priv->aipd_timeout); - priv->aipd_timeout = 0; + if ( priv->ip4_state != IP_FAIL + || priv->ip6_state != IP_FAIL) + return; + + if (nm_device_uses_assumed_connection (self)) { + /* We have assumed configuration, but couldn't + * redo it. No problem, move to check state. */ + priv->ip4_state = priv->ip6_state = IP_DONE; + state = NM_DEVICE_STATE_IP_CHECK; + } else if ( may_fail + && get_ip_config_may_fail (self, AF_INET) + && get_ip_config_may_fail (self, AF_INET6)) { + /* Couldn't start either IPv6 and IPv4 autoconfiguration, + * but both are allowed to fail. */ + state = NM_DEVICE_STATE_SECONDARIES; + } else { + /* Autoconfiguration attempted without success. */ + state = NM_DEVICE_STATE_FAILED; } + + nm_device_state_changed (self, + state, + NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } +/*********************************************/ +/* IPv4LL stuff */ + static void -aipd_cleanup (NMDevice *self) +ipv4ll_timeout_remove (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->aipd_watch) { - g_source_remove (priv->aipd_watch); - priv->aipd_watch = 0; + if (priv->ipv4ll_timeout) { + g_source_remove (priv->ipv4ll_timeout); + priv->ipv4ll_timeout = 0; } +} + +static void +ipv4ll_cleanup (NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->aipd_pid > 0) { - nm_utils_kill_child_sync (priv->aipd_pid, SIGKILL, LOGD_AUTOIP4, "avahi-autoipd", NULL, 0, 0); - priv->aipd_pid = -1; + if (priv->ipv4ll) { + sd_ipv4ll_set_callback (priv->ipv4ll, NULL, NULL); + sd_ipv4ll_stop (priv->ipv4ll); + priv->ipv4ll = sd_ipv4ll_unref (priv->ipv4ll); } - aipd_timeout_remove (self); + ipv4ll_timeout_remove (self); } static NMIP4Config * -aipd_get_ip4_config (NMDevice *self, guint32 lla) +ipv4ll_get_ip4_config (NMDevice *self, guint32 lla) { NMIP4Config *config = NULL; NMPlatformIP4Address address; @@ -2757,17 +2789,16 @@ aipd_get_ip4_config (NMDevice *self, guint32 lla) #define IPV4LL_NETWORK (htonl (0xA9FE0000L)) #define IPV4LL_NETMASK (htonl (0xFFFF0000L)) -void -nm_device_handle_autoip4_event (NMDevice *self, - const char *event, - const char *address) +static void +nm_device_handle_ipv4ll_event (sd_ipv4ll *ll, int event, void *data) { + NMDevice *self = data; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMConnection *connection = NULL; const char *method; - NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; - - g_return_if_fail (event != NULL); + struct in_addr address; + NMIP4Config *config; + int r; if (priv->act_request == NULL) return; @@ -2780,86 +2811,62 @@ nm_device_handle_autoip4_event (NMDevice *self, if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0) return; - if (strcmp (event, "BIND") == 0) { - guint32 lla; - NMIP4Config *config; - - if (inet_pton (AF_INET, address, &lla) <= 0) { - _LOGE (LOGD_AUTOIP4, "invalid address %s received from avahi-autoipd.", address); - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR); + switch (event) { + case IPV4LL_EVENT_BIND: + r = sd_ipv4ll_get_address (ll, &address); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "invalid IPv4 link-local address received, error %d.", r); + priv->ip4_state = IP_FAIL; + nm_device_check_ip_failed (self, FALSE); return; } - if ((lla & IPV4LL_NETMASK) != IPV4LL_NETWORK) { - _LOGE (LOGD_AUTOIP4, "invalid address %s received from avahi-autoipd (not link-local).", address); - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR); + if ((address.s_addr & IPV4LL_NETMASK) != IPV4LL_NETWORK) { + _LOGE (LOGD_AUTOIP4, "invalid address %08x received (not link-local).", address.s_addr); + priv->ip4_state = IP_FAIL; + nm_device_check_ip_failed (self, FALSE); return; } - config = aipd_get_ip4_config (self, lla); + config = ipv4ll_get_ip4_config (self, address.s_addr); if (config == NULL) { - _LOGE (LOGD_AUTOIP4, "failed to get autoip config"); - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + _LOGE (LOGD_AUTOIP4, "failed to get IPv4LL config"); + priv->ip4_state = IP_FAIL; + nm_device_check_ip_failed (self, FALSE); return; } if (priv->ip4_state == IP_CONF) { - aipd_timeout_remove (self); + ipv4ll_timeout_remove (self); nm_device_activate_schedule_ip4_config_result (self, config); } else if (priv->ip4_state == IP_DONE) { - if (!ip4_config_merge_and_apply (self, config, TRUE, &reason)) { + if (!ip4_config_merge_and_apply (self, config, TRUE, NULL)) { _LOGE (LOGD_AUTOIP4, "failed to update IP4 config for autoip change."); - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason); + priv->ip4_state = IP_FAIL; + nm_device_check_ip_failed (self, FALSE); } } else g_assert_not_reached (); g_object_unref (config); - } else { - _LOGW (LOGD_AUTOIP4, "autoip address %s no longer valid because '%s'.", address, event); - - /* The address is gone; terminate the connection or fail activation */ - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED); + break; + default: + _LOGW (LOGD_AUTOIP4, "IPv4LL address no longer valid after event %d.", event); + priv->ip4_state = IP_FAIL; + nm_device_check_ip_failed (self, FALSE); } } -static void -aipd_watch_cb (GPid pid, gint status, gpointer user_data) -{ - NMDevice *self = NM_DEVICE (user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - NMDeviceState state; - - if (!priv->aipd_watch) - return; - priv->aipd_watch = 0; - - if (WIFEXITED (status)) - _LOGD (LOGD_AUTOIP4, "avahi-autoipd exited with error code %d", WEXITSTATUS (status)); - else if (WIFSTOPPED (status)) - _LOGW (LOGD_AUTOIP4, "avahi-autoipd stopped unexpectedly with signal %d", WSTOPSIG (status)); - else if (WIFSIGNALED (status)) - _LOGW (LOGD_AUTOIP4, "avahi-autoipd died with signal %d", WTERMSIG (status)); - else - _LOGW (LOGD_AUTOIP4, "avahi-autoipd died from an unknown cause"); - - aipd_cleanup (self); - - state = nm_device_get_state (self); - if (nm_device_is_activating (self) || (state == NM_DEVICE_STATE_ACTIVATED)) - nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_FAILED); -} - static gboolean -aipd_timeout_cb (gpointer user_data) +ipv4ll_timeout_cb (gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->aipd_timeout) { - _LOGI (LOGD_AUTOIP4, "avahi-autoipd timed out."); - priv->aipd_timeout = 0; - aipd_cleanup (self); + if (priv->ipv4ll_timeout) { + _LOGI (LOGD_AUTOIP4, "IPv4LL configuration timed out."); + priv->ipv4ll_timeout = 0; + ipv4ll_cleanup (self); if (priv->ip4_state == IP_CONF) nm_device_activate_schedule_ip4_config_timeout (self); @@ -2868,66 +2875,69 @@ aipd_timeout_cb (gpointer user_data) return FALSE; } -/* default to installed helper, but can be modified for testing */ -const char *nm_device_autoipd_helper_path = LIBEXECDIR "/nm-avahi-autoipd.action"; - static NMActStageReturn -aipd_start (NMDevice *self, NMDeviceStateReason *reason) +ipv4ll_start (NMDevice *self, NMDeviceStateReason *reason) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - const char *argv[6]; - char *cmdline; - const char *aipd_binary; - int i = 0; - GError *error = NULL; + const struct ether_addr *addr; + int ifindex, r; + size_t addr_len; - aipd_cleanup (self); + ipv4ll_cleanup (self); - /* Find avahi-autoipd */ - aipd_binary = nm_utils_find_helper ("avahi-autoipd", NULL, NULL); - if (!aipd_binary) { - _LOGW (LOGD_DEVICE | LOGD_AUTOIP4, - "Activation: Stage 3 of 5 (IP Configure Start) failed" - " to start avahi-autoipd: not found"); - *reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED; - return NM_ACT_STAGE_RETURN_FAILURE; + r = sd_ipv4ll_new (&priv->ipv4ll); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: new() failed with error %d", r); + goto fail; } - argv[i++] = aipd_binary; - argv[i++] = "--script"; - argv[i++] = nm_device_autoipd_helper_path; + r = sd_ipv4ll_attach_event (priv->ipv4ll, NULL, 0); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: attach_event() failed with error %d", r); + goto fail; + } + + ifindex = nm_device_get_ip_ifindex (self); + addr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addr_len); + if (!addr || addr_len != ETH_ALEN) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: can't retrieve hardware address"); + goto fail; + } - if (nm_logging_enabled (LOGL_DEBUG, LOGD_AUTOIP4)) - argv[i++] = "--debug"; - argv[i++] = nm_device_get_ip_iface (self); - argv[i++] = NULL; + r = sd_ipv4ll_set_mac (priv->ipv4ll, addr); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: set_mac() failed with error %d", r); + goto fail; + } - cmdline = g_strjoinv (" ", (char **) argv); - _LOGD (LOGD_AUTOIP4, "running: %s", cmdline); - g_free (cmdline); + r = sd_ipv4ll_set_index (priv->ipv4ll, ifindex); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: set_index() failed with error %d", r); + goto fail; + } - if (!g_spawn_async ("/", (char **) argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, - nm_utils_setpgid, NULL, &(priv->aipd_pid), &error)) { - _LOGW (LOGD_DEVICE | LOGD_AUTOIP4, - "Activation: Stage 3 of 5 (IP Configure Start) failed" - " to start avahi-autoipd: %s", - error && error->message ? error->message : "(unknown)"); - g_clear_error (&error); - aipd_cleanup (self); - return NM_ACT_STAGE_RETURN_FAILURE; + r = sd_ipv4ll_set_callback (priv->ipv4ll, nm_device_handle_ipv4ll_event, self); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: set_callback() failed with error %d", r); + goto fail; } - _LOGD (LOGD_DEVICE | LOGD_AUTOIP4, - "Activation: Stage 3 of 5 (IP Configure Start) started" - " avahi-autoipd..."); + r = sd_ipv4ll_start (priv->ipv4ll); + if (r < 0) { + _LOGE (LOGD_AUTOIP4, "IPv4LL: start() failed with error %d", r); + goto fail; + } - /* Monitor the child process so we know when it dies */ - priv->aipd_watch = g_child_watch_add (priv->aipd_pid, aipd_watch_cb, self); + _LOGI (LOGD_DEVICE | LOGD_AUTOIP4, + "Activation: Stage 3 of 5 (IP Configure Start) IPv4LL started"); /* Start a timeout to bound the address attempt */ - priv->aipd_timeout = g_timeout_add_seconds (20, aipd_timeout_cb, self); + priv->ipv4ll_timeout = g_timeout_add_seconds (20, ipv4ll_timeout_cb, self); return NM_ACT_STAGE_RETURN_POSTPONE; +fail: + *reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED; + return NM_ACT_STAGE_RETURN_FAILURE; } /*********************************************/ @@ -3574,7 +3584,7 @@ act_stage3_ip4_config_start (NMDevice *self, if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) ret = dhcp4_start (self, connection, reason); else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) - ret = aipd_start (self, reason); + ret = ipv4ll_start (self, reason); else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) { /* Use only IPv4 config from the connection data */ *out_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); @@ -4907,42 +4917,6 @@ nm_device_activate_stage3_ip6_start (NMDevice *self) } /* - * nm_device_check_ip_failed - * - * Progress the device to appropriate state if both IPv4 and IPv6 failed - */ -static void -nm_device_check_ip_failed (NMDevice *self, gboolean may_fail) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - NMDeviceState state; - - if ( priv->ip4_state != IP_FAIL - || priv->ip6_state != IP_FAIL) - return; - - if (nm_device_uses_assumed_connection (self)) { - /* We have assumed configuration, but couldn't - * redo it. No problem, move to check state. */ - priv->ip4_state = priv->ip6_state = IP_DONE; - state = NM_DEVICE_STATE_IP_CHECK; - } else if ( may_fail - && get_ip_config_may_fail (self, AF_INET) - && get_ip_config_may_fail (self, AF_INET6)) { - /* Couldn't start either IPv6 and IPv4 autoconfiguration, - * but both are allowed to fail. */ - state = NM_DEVICE_STATE_SECONDARIES; - } else { - /* Autoconfiguration attempted without success. */ - state = NM_DEVICE_STATE_FAILED; - } - - nm_device_state_changed (self, - state, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); -} - -/* * nm_device_activate_stage3_ip_config_start * * Begin automatic/manual IP configuration @@ -7518,7 +7492,7 @@ _cleanup_ip_pre (NMDevice *self, gboolean deconfigure) linklocal6_cleanup (self); addrconf6_cleanup (self); dnsmasq_cleanup (self); - aipd_cleanup (self); + ipv4ll_cleanup (self); } static void diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 218faa4fa1..ad79376f47 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -394,10 +394,6 @@ gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps); gboolean nm_device_get_autoconnect (NMDevice *device); -void nm_device_handle_autoip4_event (NMDevice *self, - const char *event, - const char *address); - void nm_device_state_changed (NMDevice *device, NMDeviceState state, NMDeviceStateReason reason); @@ -442,7 +438,4 @@ void nm_device_spawn_iface_helper (NMDevice *self); G_END_DECLS -/* For testing only */ -extern const char* nm_device_autoipd_helper_path; - #endif /* NM_DEVICE_H */ diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.c b/src/dhcp-manager/nm-dhcp-dhcpcd.c index 86aba4dac1..bea89dc981 100644 --- a/src/dhcp-manager/nm-dhcp-dhcpcd.c +++ b/src/dhcp-manager/nm-dhcp-dhcpcd.c @@ -95,7 +95,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last g_ptr_array_add (argv, (gpointer) "-K"); /* Disable built-in carrier detection */ - g_ptr_array_add (argv, (gpointer) "-L"); /* Disable built-in IPv4LL since we use avahi-autoipd */ + g_ptr_array_add (argv, (gpointer) "-L"); /* Disable built-in IPv4LL */ /* --noarp. Don't request or claim the address by ARP; this also disables IPv4LL. */ g_ptr_array_add (argv, (gpointer) "-A"); diff --git a/src/main.c b/src/main.c index a5851dc558..49f0cd1d33 100644 --- a/src/main.c +++ b/src/main.c @@ -323,7 +323,6 @@ main (int argc, char *argv[]) /* don't free these strings, we need them for the entire * process lifetime */ nm_dhcp_helper_path = g_strdup_printf ("%s/src/dhcp-manager/nm-dhcp-helper", path); - nm_device_autoipd_helper_path = g_strdup_printf ("%s/callouts/nm-avahi-autoipd.action", path); g_free (path); } diff --git a/src/nm-manager.c b/src/nm-manager.c index 848ccd26bf..4a7c1f9aa2 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -59,9 +59,6 @@ #include "nm-core-internal.h" #include "nm-config.h" -#define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" -#define NM_AUTOIP_DBUS_IFACE "org.freedesktop.nm_avahi_autoipd" - static gboolean impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err); @@ -183,7 +180,6 @@ typedef struct { NMVpnManager *vpn_manager; - GDBusProxy *aipd_proxy; NMSleepMonitor *sleep_monitor; GSList *auth_chains; @@ -826,40 +822,6 @@ device_removed_cb (NMDevice *device, gpointer user_data) remove_device (NM_MANAGER (user_data), device, FALSE, TRUE); } -static void -aipd_handle_event (GDBusProxy *proxy, - const char *event, - const char *iface, - const char *address, - gpointer user_data) -{ - NMManager *manager = NM_MANAGER (user_data); - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); - GSList *iter; - gboolean handled = FALSE; - - if ( (strcmp (event, "BIND") != 0) - && (strcmp (event, "CONFLICT") != 0) - && (strcmp (event, "UNBIND") != 0) - && (strcmp (event, "STOP") != 0)) { - nm_log_warn (LOGD_AUTOIP4, "unknown event '%s' received from avahi-autoipd", event); - return; - } - - for (iter = priv->devices; iter; iter = g_slist_next (iter)) { - NMDevice *candidate = NM_DEVICE (iter->data); - - if (!strcmp (nm_device_get_iface (candidate), iface)) { - nm_device_handle_autoip4_event (candidate, event, address); - handled = TRUE; - break; - } - } - - if (!handled) - nm_log_warn (LOGD_AUTOIP4, "(%s): unhandled avahi-autoipd event", iface); -} - NMState nm_manager_get_state (NMManager *manager) { @@ -4594,7 +4556,6 @@ nm_manager_init (NMManager *manager) NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); guint i; GFile *file; - GError *error = NULL; /* Initialize rfkill structures and states */ memset (priv->radio_states, 0, sizeof (priv->radio_states)); @@ -4635,23 +4596,6 @@ nm_manager_init (NMManager *manager) priv->vpn_manager = g_object_ref (nm_vpn_manager_get ()); - /* avahi-autoipd stuff */ - priv->aipd_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, - NM_AUTOIP_DBUS_SERVICE, - "/", - NM_AUTOIP_DBUS_IFACE, - NULL, &error); - if (priv->aipd_proxy) { - _nm_dbus_signal_connect (priv->aipd_proxy, "Event", G_VARIANT_TYPE ("(sss)"), - G_CALLBACK (aipd_handle_event), manager); - } else { - nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy: %s", - error->message); - g_clear_error (&error); - } - /* sleep/wake handling */ priv->sleep_monitor = g_object_ref (nm_sleep_monitor_get ()); g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING, @@ -4878,7 +4822,6 @@ dispose (GObject *object) priv->dbus_mgr = NULL; } - g_clear_object (&priv->aipd_proxy); if (priv->sleep_monitor) { g_signal_handlers_disconnect_by_func (priv->sleep_monitor, sleeping_cb, manager); g_signal_handlers_disconnect_by_func (priv->sleep_monitor, resuming_cb, manager); diff --git a/src/systemd/src/libsystemd-network/ipv4ll-internal.h b/src/systemd/src/libsystemd-network/ipv4ll-internal.h index ae0ce43985..3a0668fab4 100644 --- a/src/systemd/src/libsystemd-network/ipv4ll-internal.h +++ b/src/systemd/src/libsystemd-network/ipv4ll-internal.h @@ -21,6 +21,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "nm-sd-adapt.h" + #include <netinet/if_ether.h> #include "sparse-endian.h" diff --git a/src/systemd/src/libsystemd-network/ipv4ll-network.c b/src/systemd/src/libsystemd-network/ipv4ll-network.c index 93ffed408f..de1e9ddfd4 100644 --- a/src/systemd/src/libsystemd-network/ipv4ll-network.c +++ b/src/systemd/src/libsystemd-network/ipv4ll-network.c @@ -17,6 +17,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "nm-sd-adapt.h" + #include <linux/filter.h> #include "util.h" diff --git a/src/systemd/src/libsystemd-network/ipv4ll-packet.c b/src/systemd/src/libsystemd-network/ipv4ll-packet.c index 2b6c73ab4b..5e89a119b0 100644 --- a/src/systemd/src/libsystemd-network/ipv4ll-packet.c +++ b/src/systemd/src/libsystemd-network/ipv4ll-packet.c @@ -16,6 +16,9 @@ You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ + +#include "nm-sd-adapt.h" + #include <arpa/inet.h> #include "util.h" diff --git a/src/systemd/src/libsystemd-network/sd-ipv4ll.c b/src/systemd/src/libsystemd-network/sd-ipv4ll.c index 02f2f9e0a9..ccd6bdf0b0 100644 --- a/src/systemd/src/libsystemd-network/sd-ipv4ll.c +++ b/src/systemd/src/libsystemd-network/sd-ipv4ll.c @@ -17,6 +17,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "nm-sd-adapt.h" + #include <stdlib.h> #include <errno.h> #include <string.h> diff --git a/src/systemd/src/systemd/sd-ipv4ll.h b/src/systemd/src/systemd/sd-ipv4ll.h index d017158154..10725a1184 100644 --- a/src/systemd/src/systemd/sd-ipv4ll.h +++ b/src/systemd/src/systemd/sd-ipv4ll.h @@ -22,6 +22,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "nm-sd-adapt.h" + #include <stdbool.h> #include <netinet/in.h> #include <net/ethernet.h> |