[systemd-commits] 3 commits - src/network
Tom Gundersen
tomegun at kemper.freedesktop.org
Thu May 15 09:25:47 PDT 2014
src/network/networkd-link.c | 110 ++++++++++++++++++--------------
src/network/networkd-netdev-gperf.gperf | 2
src/network/networkd-netdev.c | 22 +++---
src/network/networkd-network.c | 5 -
src/network/networkd-tunnel.c | 4 -
src/network/networkd.h | 10 +-
6 files changed, 89 insertions(+), 64 deletions(-)
New commits:
commit 987efa17dd5c9be156d8f49ddd942df20a72dcb1
Author: Tom Gundersen <teg at jklm.no>
Date: Thu May 15 17:43:14 2014 +0200
networkd: logging - align messages
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 0a74c94..8dd742a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -257,7 +257,8 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not set route: %s",
+ "MESSAGE=%*s: could not set route: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -422,7 +423,8 @@ static int route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -ESRCH)
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not drop route: %s",
+ "MESSAGE=%*s: could not drop route: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -453,7 +455,8 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not set address: %s",
+ "MESSAGE=%*s: could not set address: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -599,7 +602,8 @@ static int address_update_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userd
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -ENOENT)
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not update address: %s",
+ "MESSAGE=%*s: could not update address: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -625,7 +629,8 @@ static int address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdat
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not drop address: %s",
+ "MESSAGE=%*s: could not drop address: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -648,7 +653,7 @@ static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata,
r = sd_bus_message_get_errno(m);
if (r < 0)
- log_warning("Could not set hostname: %s", strerror(-r));
+ log_warning_link(link, "Could not set hostname: %s", strerror(-r));
link_unref(link);
@@ -827,7 +832,7 @@ static int dhcp_lease_lost(Link *link) {
if (r >= 0 && hostname) {
r = link_set_hostname(link, "");
if (r < 0)
- log_error("Failed to reset transient hostname");
+ log_error_link(link, "Failed to reset transient hostname");
}
}
@@ -880,7 +885,8 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (r >= 0)
log_struct_link(LOG_INFO, link,
- "MESSAGE=%s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
+ "MESSAGE=%*s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
+ IFNAMSIZ,
link->ifname,
ADDRESS_FMT_VAL(address),
prefixlen,
@@ -894,7 +900,8 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
NULL);
else
log_struct_link(LOG_INFO, link,
- "MESSAGE=%s: DHCPv4 address %u.%u.%u.%u/%u",
+ "MESSAGE=%*s: DHCPv4 address %u.%u.%u.%u/%u",
+ IFNAMSIZ,
link->ifname,
ADDRESS_FMT_VAL(address),
prefixlen,
@@ -911,7 +918,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (r >= 0) {
r = manager_update_resolv_conf(link->manager);
if (r < 0)
- log_error("Failed to update resolv.conf");
+ log_error_link(link, "Failed to update resolv.conf");
}
}
@@ -934,7 +941,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (r >= 0) {
r = link_set_hostname(link, hostname);
if (r < 0)
- log_error("Failed to set transient hostname "
+ log_error_link(link, "Failed to set transient hostname "
"to '%s'", hostname);
}
}
@@ -1129,7 +1136,8 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
return r;
log_struct_link(LOG_INFO, link,
- "MESSAGE=%s: IPv4 link-local address %u.%u.%u.%u",
+ "MESSAGE=%*s: IPv4 link-local address %u.%u.%u.%u",
+ IFNAMSIZ,
link->ifname,
ADDRESS_FMT_VAL(address),
NULL);
@@ -1348,7 +1356,8 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
/* we warn but don't fail the link, as it may
be brought up later */
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not bring up interface: %s",
+ "MESSAGE=%*s: could not bring up interface: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -1434,7 +1443,8 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0) {
log_struct_link(LOG_ERR, link,
- "MESSAGE=%s: could not enslave: %s",
+ "MESSAGE=%*s: could not enslave: %s",
+ IFNAMSIZ,
link->ifname, strerror(-r),
"ERRNO=%d", -r,
NULL);
@@ -1475,7 +1485,8 @@ static int link_enter_enslave(Link *link) {
if (link->network->bond) {
log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%s: enslaving by '%s'",
+ "MESSAGE=%*s: enslaving by '%s'",
+ IFNAMSIZ,
link->ifname, link->network->bond->ifname,
NETDEV(link->network->bond),
NULL);
@@ -1483,7 +1494,8 @@ static int link_enter_enslave(Link *link) {
r = netdev_enslave(link->network->bond, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not enslave by '%s': %s",
+ IFNAMSIZ,
link->ifname, link->network->bond->ifname, strerror(-r),
NETDEV(link->network->bond),
NULL);
@@ -1497,7 +1509,8 @@ static int link_enter_enslave(Link *link) {
if (link->network->bridge) {
log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%s: enslaving by '%s'",
+ "MESSAGE=%*s: enslaving by '%s'",
+ IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
NETDEV(link->network->bridge),
NULL);
@@ -1505,7 +1518,8 @@ static int link_enter_enslave(Link *link) {
r = netdev_enslave(link->network->bridge, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not enslave by '%s': %s",
+ IFNAMSIZ,
link->ifname, link->network->bridge->ifname, strerror(-r),
NETDEV(link->network->bridge),
NULL);
@@ -1519,7 +1533,8 @@ static int link_enter_enslave(Link *link) {
if (link->network->tunnel) {
log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%s: enslaving by '%s'",
+ "MESSAGE=%*s: enslaving by '%s'",
+ IFNAMSIZ,
link->ifname, link->network->tunnel->ifname,
NETDEV(link->network->tunnel),
NULL);
@@ -1527,7 +1542,8 @@ static int link_enter_enslave(Link *link) {
r = netdev_enslave(link->network->tunnel, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not enslave by '%s': %s",
+ IFNAMSIZ,
link->ifname, link->network->tunnel->ifname, strerror(-r),
NETDEV(link->network->tunnel),
NULL);
@@ -1541,13 +1557,15 @@ static int link_enter_enslave(Link *link) {
HASHMAP_FOREACH(vlan, link->network->vlans, i) {
log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%s: enslaving by '%s'",
+ "MESSAGE=%*s: enslaving by '%s'",
+ IFNAMSIZ,
link->ifname, vlan->ifname, NETDEV(vlan), NULL);
r = netdev_enslave(vlan, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not enslave by '%s': %s",
+ IFNAMSIZ,
link->ifname, vlan->ifname, strerror(-r),
NETDEV(vlan), NULL);
link_enter_failed(link);
@@ -1560,13 +1578,15 @@ static int link_enter_enslave(Link *link) {
HASHMAP_FOREACH(macvlan, link->network->macvlans, i) {
log_struct_link(LOG_DEBUG, link,
- "MESSAGE=%s: enslaving by '%s'",
+ "MESSAGE=%*s: enslaving by '%s'",
+ IFNAMSIZ,
link->ifname, macvlan->ifname, NETDEV(macvlan), NULL);
r = netdev_enslave(macvlan, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
- "MESSAGE=%s: could not enslave by '%s': %s",
+ "MESSAGE=%*s: could not enslave by '%s': %s",
+ IFNAMSIZ,
link->ifname, macvlan->ifname, strerror(-r),
NETDEV(macvlan), NULL);
link_enter_failed(link);
@@ -1726,13 +1746,13 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
r = sd_rtnl_message_addr_get_family(message, &address->family);
if (r < 0 || !IN_SET(address->family, AF_INET, AF_INET6)) {
- log_warning("rtnl: received address with invalid family, ignoring");
+ log_warning_link(link, "rtnl: received address with invalid family, ignoring");
return 0;
}
r = sd_rtnl_message_addr_get_prefixlen(message, &address->prefixlen);
if (r < 0) {
- log_warning("rtnl: recevied address with invalid prefixlen, ignoring");
+ log_warning_link(link, "rtnl: recevied address with invalid prefixlen, ignoring");
return 0;
}
@@ -1740,7 +1760,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
case AF_INET:
r = sd_rtnl_message_read_in_addr(message, IFA_LOCAL, &address->in_addr.in);
if (r < 0) {
- log_warning("rtnl: received address without valid address, ignoring");
+ log_warning_link(link, "rtnl: received address without valid address, ignoring");
return 0;
}
@@ -1749,7 +1769,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
case AF_INET6:
r = sd_rtnl_message_read_in6_addr(message, IFA_ADDRESS, &address->in_addr.in6);
if (r < 0) {
- log_warning("rtnl: received address without valid address, ignoring");
+ log_warning_link(link, "rtnl: received address without valid address, ignoring");
return 0;
}
@@ -1760,19 +1780,19 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *use
}
if (!inet_ntop(address->family, &address->in_addr, buf, INET6_ADDRSTRLEN)) {
- log_warning("could not print address");
+ log_warning_link(link, "could not print address");
return 0;
}
switch (type) {
case RTM_NEWADDR:
- log_info("added address: %s/%u to ifindex %d", buf,
- address->prefixlen, ifindex);
+ log_info_link(link, "added address: %s/%u", buf,
+ address->prefixlen);
break;
case RTM_DELADDR:
- log_info("removed address: %s/%u from ifindex %d", buf,
- address->prefixlen, ifindex);
+ log_info_link(link, "removed address: %s/%u", buf,
+ address->prefixlen);
break;
default:
assert_not_reached("Received invalid RTNL message type");
@@ -1987,7 +2007,7 @@ int link_save(Link *link) {
finish:
if (r < 0)
- log_error("Failed to save link data to %s: %s", link->state_file, strerror(-r));
+ log_error_link(link, "Failed to save link data to %s: %s", link->state_file, strerror(-r));
return r;
}
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 8deef0d..8623274 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -19,6 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <net/if.h>
+
#include "networkd.h"
#include "network-internal.h"
#include "path-util.h"
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 91b1e3c..76381c4 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -20,6 +20,7 @@
***/
#include <ctype.h>
+#include <net/if.h>
#include "networkd.h"
#include "network-internal.h"
@@ -220,7 +221,7 @@ int network_get(Manager *manager, struct udev_device *device,
udev_device_get_property_value(device, "ID_NET_DRIVER"),
udev_device_get_devtype(device),
ifname)) {
- log_debug("%s: found matching network '%s'", ifname,
+ log_debug("%*s: found matching network '%s'", IFNAMSIZ, ifname,
network->filename);
*ret = network;
return 0;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index c5f2d07..f250f19 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -424,7 +424,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* Macros which append INTERFACE= to the message */
-#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%s: " fmt, link->ifname, ##__VA_ARGS__)
+#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
@@ -435,7 +435,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* More macros which append INTERFACE= to the message */
-#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%s: " fmt, netdev->ifname, ##__VA_ARGS__)
+#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
commit 5261692fe5a4ac82f9783d57a07b0a4786dc01ab
Author: Tom Gundersen <teg at jklm.no>
Date: Thu May 15 15:54:28 2014 +0200
networkd: log ifindices when links and netdevs are added
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 930011a..0a74c94 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1822,7 +1822,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
link = *ret;
- log_debug_link(link, "link added");
+ log_debug_link(link, "link %"PRIu64" added", link->ifindex);
r = sd_rtnl_message_new_addr(m->rtnl, &req, RTM_GETADDR, link->ifindex, 0);
if (r < 0)
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 3bd6c07..8deef0d 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -505,6 +505,8 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
netdev->ifindex = ifindex;
+ log_debug_netdev(netdev, "netdev has index %d", netdev->ifindex);
+
netdev_enter_ready(netdev);
return 0;
commit af4e9e2c563047d524b207e0e3d6816385693a16
Author: Tom Gundersen <teg at jklm.no>
Date: Thu May 15 15:48:37 2014 +0200
networkd: rename NetDev variable for consistency with Link
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 6ce965b..930011a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1476,7 +1476,7 @@ static int link_enter_enslave(Link *link) {
if (link->network->bond) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
- link->ifname, link->network->bond->name,
+ link->ifname, link->network->bond->ifname,
NETDEV(link->network->bond),
NULL);
@@ -1484,7 +1484,7 @@ static int link_enter_enslave(Link *link) {
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%s: could not enslave by '%s': %s",
- link->ifname, link->network->bond->name, strerror(-r),
+ link->ifname, link->network->bond->ifname, strerror(-r),
NETDEV(link->network->bond),
NULL);
link_enter_failed(link);
@@ -1498,7 +1498,7 @@ static int link_enter_enslave(Link *link) {
if (link->network->bridge) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
- link->ifname, link->network->bridge->name,
+ link->ifname, link->network->bridge->ifname,
NETDEV(link->network->bridge),
NULL);
@@ -1506,7 +1506,7 @@ static int link_enter_enslave(Link *link) {
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%s: could not enslave by '%s': %s",
- link->ifname, link->network->bridge->name, strerror(-r),
+ link->ifname, link->network->bridge->ifname, strerror(-r),
NETDEV(link->network->bridge),
NULL);
link_enter_failed(link);
@@ -1520,7 +1520,7 @@ static int link_enter_enslave(Link *link) {
if (link->network->tunnel) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
- link->ifname, link->network->tunnel->name,
+ link->ifname, link->network->tunnel->ifname,
NETDEV(link->network->tunnel),
NULL);
@@ -1528,7 +1528,7 @@ static int link_enter_enslave(Link *link) {
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%s: could not enslave by '%s': %s",
- link->ifname, link->network->tunnel->name, strerror(-r),
+ link->ifname, link->network->tunnel->ifname, strerror(-r),
NETDEV(link->network->tunnel),
NULL);
link_enter_failed(link);
@@ -1542,13 +1542,13 @@ static int link_enter_enslave(Link *link) {
HASHMAP_FOREACH(vlan, link->network->vlans, i) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
- link->ifname, vlan->name, NETDEV(vlan), NULL);
+ link->ifname, vlan->ifname, NETDEV(vlan), NULL);
r = netdev_enslave(vlan, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%s: could not enslave by '%s': %s",
- link->ifname, vlan->name, strerror(-r),
+ link->ifname, vlan->ifname, strerror(-r),
NETDEV(vlan), NULL);
link_enter_failed(link);
return r;
@@ -1561,13 +1561,13 @@ static int link_enter_enslave(Link *link) {
HASHMAP_FOREACH(macvlan, link->network->macvlans, i) {
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%s: enslaving by '%s'",
- link->ifname, macvlan->name, NETDEV(macvlan), NULL);
+ link->ifname, macvlan->ifname, NETDEV(macvlan), NULL);
r = netdev_enslave(macvlan, link, &enslave_handler);
if (r < 0) {
log_struct_link(LOG_WARNING, link,
"MESSAGE=%s: could not enslave by '%s': %s",
- link->ifname, macvlan->name, strerror(-r),
+ link->ifname, macvlan->ifname, strerror(-r),
NETDEV(macvlan), NULL);
link_enter_failed(link);
return r;
diff --git a/src/network/networkd-netdev-gperf.gperf b/src/network/networkd-netdev-gperf.gperf
index 7e6b885..29889cd 100644
--- a/src/network/networkd-netdev-gperf.gperf
+++ b/src/network/networkd-netdev-gperf.gperf
@@ -20,7 +20,7 @@ Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZ
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(NetDev, match_kernel)
Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(NetDev, match_arch)
NetDev.Description, config_parse_string, 0, offsetof(NetDev, description)
-NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, name)
+NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu)
VLAN.Id, config_parse_uint64, 0, offsetof(NetDev, vlanid)
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 62e1a3e..3bd6c07 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -81,13 +81,13 @@ static void netdev_free(NetDev *netdev) {
netdev_cancel_callbacks(netdev);
- if (netdev->name)
- hashmap_remove(netdev->manager->netdevs, netdev->name);
+ if (netdev->ifname)
+ hashmap_remove(netdev->manager->netdevs, netdev->ifname);
free(netdev->filename);
free(netdev->description);
- free(netdev->name);
+ free(netdev->ifname);
condition_free_list(netdev->match_host);
condition_free_list(netdev->match_virt);
@@ -195,7 +195,7 @@ static int netdev_enter_ready(NetDev *netdev) {
netdev_enslave_callback *callback;
assert(netdev);
- assert(netdev->name);
+ assert(netdev->ifname);
if (netdev->state != NETDEV_STATE_CREATING)
return 0;
@@ -267,7 +267,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
assert(netdev);
assert(!(netdev->kind == NETDEV_KIND_VLAN || netdev->kind == NETDEV_KIND_MACVLAN) ||
(link && callback));
- assert(netdev->name);
+ assert(netdev->ifname);
assert(netdev->manager);
assert(netdev->manager->rtnl);
@@ -289,7 +289,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
}
}
- r = sd_rtnl_message_append_string(req, IFLA_IFNAME, netdev->name);
+ r = sd_rtnl_message_append_string(req, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IFNAME attribute: %s",
@@ -464,7 +464,7 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
return r;
}
- if (!streq(netdev->name, received_name)) {
+ if (!streq(netdev->ifname, received_name)) {
log_error_netdev(netdev, "Received newlink with wrong IFNAME %s",
received_name);
netdev_enter_failed(netdev);
@@ -555,7 +555,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
return 0;
}
- if (!netdev->name) {
+ if (!netdev->ifname) {
log_warning("NetDev without Name configured in %s. Ignoring", filename);
return 0;
}
@@ -588,7 +588,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
return 0;
- r = hashmap_put(netdev->manager->netdevs, netdev->name, netdev);
+ r = hashmap_put(netdev->manager->netdevs, netdev->ifname, netdev);
if (r < 0)
return r;
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index d6b06e8..91b1e3c 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -315,7 +315,7 @@ int config_parse_netdev(const char *unit,
break;
case NETDEV_KIND_MACVLAN:
- r = hashmap_put(network->macvlans, netdev->name, netdev);
+ r = hashmap_put(network->macvlans, netdev->ifname, netdev);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Can not add MACVLAN to network: %s", rvalue);
diff --git a/src/network/networkd-tunnel.c b/src/network/networkd-tunnel.c
index 0ecb1c9..5ea2878 100644
--- a/src/network/networkd-tunnel.c
+++ b/src/network/networkd-tunnel.c
@@ -43,7 +43,7 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
netdev = link->network->tunnel;
- r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->name);
+ r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
log_error_netdev(netdev,
"Could not append IFLA_IFNAME, attribute: %s",
@@ -141,7 +141,7 @@ int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback) {
netdev = link->network->tunnel;
assert(netdev);
- assert(netdev->name);
+ assert(netdev->ifname);
assert(netdev->manager);
assert(netdev->manager->rtnl);
assert(netdev->manager->kmod_ctx);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 11d0056..c5f2d07 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -97,7 +97,7 @@ struct NetDev {
Condition *match_arch;
char *description;
- char *name;
+ char *ifname;
size_t mtu;
NetDevKind kind;
@@ -435,16 +435,16 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* More macros which append INTERFACE= to the message */
-#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->name, "%s: " fmt, netdev->name, ##__VA_ARGS__)
+#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%s: " fmt, netdev->ifname, ##__VA_ARGS__)
#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
#define log_warning_netdev(netdev, ...) log_full_netdev(LOG_WARNING, netdev,## __VA_ARGS__)
#define log_error_netdev(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__)
-#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->name, __VA_ARGS__)
+#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__)
-#define NETDEV(netdev) "INTERFACE=%s", netdev->name
+#define NETDEV(netdev) "INTERFACE=%s", netdev->ifname
#define ADDRESS_FMT_VAL(address) \
(address).s_addr & 0xFF, \
((address).s_addr >> 8) & 0xFF, \
More information about the systemd-commits
mailing list