[systemd-commits] src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Fri Jan 3 09:14:14 PST 2014
src/network/networkd-link.c | 12 ++++++++----
src/network/networkd-manager.c | 7 ++++---
src/network/networkd.h | 2 +-
3 files changed, 13 insertions(+), 8 deletions(-)
New commits:
commit aa3437a573ed2a2b2a03c9649fe11d27b40a772b
Author: Tom Gundersen <teg at jklm.no>
Date: Fri Jan 3 18:20:11 2014 +0100
networkd: print the ifindex of added links
This debug information may be useful when comapring to dropped rtnetlink messages.
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 889efc8..bc8ca21 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -89,7 +89,7 @@ void link_free(Link *link) {
free(link);
}
-int link_add(Manager *m, struct udev_device *device) {
+int link_add(Manager *m, struct udev_device *device, Link **ret) {
Link *link;
Network *network;
int r;
@@ -101,18 +101,22 @@ int link_add(Manager *m, struct udev_device *device) {
ifindex = udev_device_get_ifindex(device);
link = hashmap_get(m->links, &ifindex);
- if (link)
+ if (link) {
+ *ret = link;
return -EEXIST;
+ }
r = link_new(m, device, &link);
if (r < 0)
return r;
+ *ret = link;
+
devtype = udev_device_get_devtype(device);
if (streq_ptr(devtype, "bridge")) {
r = bridge_set_link(m, link);
- if (r < 0)
- return r == -ENOENT ? 0 : r;
+ if (r < 0 && r != -ENOENT)
+ return r;
}
r = network_get(m, device, &network);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 11c3efe..7b0c5d7 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -143,17 +143,18 @@ static int manager_process_link(Manager *m, struct udev_device *device) {
link_free(link);
} else {
- r = link_add(m, device);
+ r = link_add(m, device, &link);
if (r < 0) {
if (r == -EEXIST)
log_debug("%s: link already exists, ignoring",
- udev_device_get_sysname(device));
+ link->ifname);
else
log_error("%s: could not handle link: %s",
udev_device_get_sysname(device),
strerror(-r));
} else
- log_debug("%s: link added", udev_device_get_sysname(device));
+ log_debug("%s: link (with ifindex %" PRIu64") added",
+ link->ifname, link->ifindex);
}
return 0;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index cad81d9..3b29080 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -269,7 +269,7 @@ int config_parse_label(const char *unit, const char *filename, unsigned line,
int link_new(Manager *manager, struct udev_device *device, Link **ret);
void link_free(Link *link);
-int link_add(Manager *manager, struct udev_device *device);
+int link_add(Manager *manager, struct udev_device *device, Link **ret);
int link_configure(Link *link);
int link_update(Link *link, sd_rtnl_message *message);
More information about the systemd-commits
mailing list