diff options
author | Thomas Haller <thaller@redhat.com> | 2015-03-15 17:18:59 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-03-20 11:43:30 +0100 |
commit | e36bfaadf74ee2f4080d6416f979897b000ba94e (patch) | |
tree | 841ab9e3e493346182671a8220189d996e2d7a1d /src/nm-iface-helper.c | |
parent | 95786a4e4e307dfd2c961280e65d16d5138050d6 (diff) | |
download | NetworkManager-e36bfaadf74ee2f4080d6416f979897b000ba94e.tar.gz |
nm-iface-helper: fix pidfile name and obtain the ifindex earlier
The @ifindex is needed for the @pidfile. Obtain the @ifindex earlier
without resorting to platform.
Diffstat (limited to 'src/nm-iface-helper.c')
-rw-r--r-- | src/nm-iface-helper.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index d26e05665c..33ba269236 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -34,6 +34,10 @@ #include <sys/stat.h> #include <signal.h> +/* Cannot include <net/if.h> due to conflict with <linux/if.h>. + * Forward declare if_nametoindex. */ +extern unsigned int if_nametoindex (const char *__ifname); + #include "gsystem-local-alloc.h" #include "NetworkManagerUtils.h" #include "nm-linux-platform.h" @@ -391,6 +395,11 @@ main (int argc, char *argv[]) nm_main_utils_ensure_rundir (); + ifindex = if_nametoindex (global_opt.ifname); + if (ifindex <= 0) { + fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno)); + exit (1); + } pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex); nm_main_utils_ensure_not_running_pidfile (pidfile); @@ -419,12 +428,6 @@ main (int argc, char *argv[]) /* Set up platform interaction layer */ nm_linux_platform_setup (); - ifindex = nm_platform_link_get_ifindex (global_opt.ifname); - if (ifindex <= 0) { - fprintf (stderr, _("Failed to find interface index for %s\n"), global_opt.ifname); - exit (1); - } - tmp = nm_platform_link_get_address (ifindex, &hwaddr_len); if (tmp) { hwaddr = g_byte_array_sized_new (hwaddr_len); |