diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-bridge.c | 9 | ||||
-rw-r--r-- | src/network/networkd-link.c | 68 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 4 | ||||
-rw-r--r-- | src/network/networkd-network.c | 14 | ||||
-rw-r--r-- | src/shared/net-util.c | 45 |
5 files changed, 62 insertions, 78 deletions
diff --git a/src/network/networkd-bridge.c b/src/network/networkd-bridge.c index f110b8aa12..ac71cf39d8 100644 --- a/src/network/networkd-bridge.c +++ b/src/network/networkd-bridge.c @@ -112,7 +112,7 @@ static int bridge_enter_ready(Bridge *bridge) { bridge->state = BRIDGE_STATE_READY; - log_info("Bridge '%s' ready", bridge->name); + log_info("%s: bridge ready", bridge->name); LIST_FOREACH(callbacks, callback, bridge->callbacks) { /* join the links that were attempted to be joined befor the @@ -131,7 +131,7 @@ static int bridge_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda r = sd_rtnl_message_get_errno(m); if (r < 0) { - log_warning("Bridge '%s' failed: %s", bridge->name, strerror(-r)); + log_warning("%s: bridge failed: %s", bridge->name, strerror(-r)); bridge_enter_failed(bridge); return 1; @@ -196,7 +196,7 @@ static int bridge_create(Bridge *bridge) { return r; } - log_info("Creating bridge '%s'", bridge->name); + log_debug("%s: creating bridge", bridge->name); bridge->state = BRIDGE_STATE_CREATING; @@ -269,8 +269,7 @@ static int bridge_load_one(Manager *manager, const char *filename) { if (r < 0) { log_warning("Could not parse config file %s: %s", filename, strerror(-r)); return r; - } else - log_debug("Parsed configuration file %s", filename); + } if (!bridge->name) { log_warning("Bridge without Name configured in %s. Ignoring", filename); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index c0ca5f2d07..9d942f436b 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -132,7 +132,7 @@ static int link_enter_configured(Link *link) { assert(link); assert(link->state == LINK_STATE_SETTING_ROUTES); - log_info("Link '%s' configured", link->ifname); + log_info("%s: link configured", link->ifname); link->state = LINK_STATE_CONFIGURED; @@ -142,6 +142,8 @@ static int link_enter_configured(Link *link) { static void link_enter_failed(Link *link) { assert(link); + log_warning("%s: failed", link->ifname); + link->state = LINK_STATE_FAILED; } @@ -161,13 +163,13 @@ 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_warning("Could not set route on interface '%s': %s", + log_warning("%s: could not set route: %s", link->ifname, strerror(-r)); /* we might have received an old reply after moving back to SETTING_ADDRESSES, * ignore it */ if (link->route_messages == 0 && link->state == LINK_STATE_SETTING_ROUTES) { - log_info("Routes set for link '%s'", link->ifname); + log_debug("%s: routes set", link->ifname); link_enter_configured(link); } @@ -187,10 +189,12 @@ static int link_enter_set_routes(Link *link) { if (!link->network->static_routes && !link->dhcp_route) return link_enter_configured(link); + log_debug("%s: setting routes", link->ifname); + LIST_FOREACH(static_routes, route, link->network->static_routes) { r = route_configure(route, link, &route_handler); if (r < 0) { - log_warning("Could not set routes for link '%s'", link->ifname); + log_warning("%s: could not set routes", link->ifname); link_enter_failed(link); return r; } @@ -201,7 +205,7 @@ static int link_enter_set_routes(Link *link) { if (link->dhcp_route) { r = route_configure(link->dhcp_route, link, &route_handler); if (r < 0) { - log_warning("Could not set routes for link '%s'", link->ifname); + log_warning("%s: could not set routes", link->ifname); link_enter_failed(link); return r; } @@ -229,11 +233,11 @@ 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_warning("Could not set address on interface '%s': %s", + log_warning("%s: could not set address: %s", link->ifname, strerror(-r)); if (link->addr_messages == 0) { - log_info("Addresses set for link '%s'", link->ifname); + log_debug("%s: addresses set", link->ifname); link_enter_set_routes(link); } @@ -253,10 +257,12 @@ static int link_enter_set_addresses(Link *link) { if (!link->network->static_addresses && !link->dhcp_address) return link_enter_set_routes(link); + log_debug("%s: setting addresses", link->ifname); + LIST_FOREACH(static_addresses, address, link->network->static_addresses) { r = address_configure(address, link, &address_handler); if (r < 0) { - log_warning("Could not set addresses for link '%s'", link->ifname); + log_warning("%s: could not set addresses", link->ifname); link_enter_failed(link); return r; } @@ -267,7 +273,7 @@ static int link_enter_set_addresses(Link *link) { if (link->dhcp_address) { r = address_configure(link->dhcp_address, link, &address_handler); if (r < 0) { - log_warning("Could not set addresses for link '%s'", link->ifname); + log_warning("%s: could not set addresses", link->ifname); link_enter_failed(link); return r; } @@ -284,7 +290,7 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { r = sd_rtnl_message_get_errno(m); if (r < 0) { - log_warning("Could not bring up interface '%s': %s", + log_warning("%s: could not bring up interface: %s", link->ifname, strerror(-r)); link_enter_failed(link); } @@ -300,6 +306,8 @@ static int link_up(Link *link) { assert(link->manager); assert(link->manager->rtnl); + log_debug("%s: bringing up link", link->ifname); + r = sd_rtnl_message_link_new(RTM_SETLINK, link->ifindex, &req); if (r < 0) { log_error("Could not allocate RTM_SETLINK message"); @@ -356,12 +364,12 @@ static int bridge_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { r = sd_rtnl_message_get_errno(m); if (r < 0) { - log_warning("Could not join interface '%s' to bridge '%s': %s", + log_warning("%s: could not join bridge '%s': %s", link->ifname, link->network->bridge->name, strerror(-r)); link_enter_failed(link); return 1; } else - log_info("Join interface '%s' to bridge: %s", + log_debug("%s: joined bridge '%s'", link->ifname, link->network->bridge->name); link_bridge_joined(link); @@ -381,9 +389,11 @@ static int link_enter_join_bridge(Link *link) { if (!link->network->bridge) return link_bridge_joined(link); + log_debug("%s: joining bridge", link->ifname); + r = bridge_join(link->network->bridge, link, &bridge_handler); if (r < 0) { - log_warning("Could not join link '%s' to bridge '%s'", link->ifname, + log_warning("%s: could not join bridge '%s'", link->ifname, link->network->bridge->name); link_enter_failed(link); return r; @@ -398,7 +408,7 @@ static int link_get_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { r = sd_rtnl_message_get_errno(m); if (r < 0) { - log_warning("Could not get state of interface '%s': %s", + log_warning("%s: could not get state: %s", link->ifname, strerror(-r)); link_enter_failed(link); } @@ -416,6 +426,8 @@ static int link_get(Link *link) { assert(link->manager); assert(link->manager->rtnl); + log_debug("%s: requesting link status", link->ifname); + r = sd_rtnl_message_link_new(RTM_GETLINK, link->ifindex, &req); if (r < 0) { log_error("Could not allocate RTM_GETLINK message"); @@ -464,7 +476,7 @@ 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 != -EEXIST) - log_warning("Could not drop address from interface '%s': %s", + log_warning("%s: could not drop address: %s", link->ifname, strerror(-r)); return 1; @@ -482,13 +494,13 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { return; if (event < 0) { - log_warning("DHCP error: %s", strerror(-event)); + log_warning("%s: DHCP error: %s", link->ifname, strerror(-event)); link_enter_failed(link); return; } if (event == DHCP_EVENT_NO_LEASE) - log_info("IP address in use."); + log_debug("%s: IP address in use.", link->ifname); if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_EXPIRED || event == DHCP_EVENT_STOP) { @@ -503,28 +515,28 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { r = sd_dhcp_client_get_address(client, &address); if (r < 0) { - log_warning("DHCP error: no address"); + log_warning("%s: DHCP error: no address", link->ifname); link_enter_failed(link); return; } r = sd_dhcp_client_get_netmask(client, &netmask); if (r < 0) { - log_warning("DHCP error: no netmask"); + log_warning("%s: DHCP error: no netmask", link->ifname); link_enter_failed(link); return; } prefixlen = sd_dhcp_client_prefixlen(&netmask); if (prefixlen < 0) { - log_warning("DHCP error: no prefixlen"); + log_warning("%s: DHCP error: no prefixlen", link->ifname); link_enter_failed(link); return; } r = sd_dhcp_client_get_router(client, &gateway); if (r < 0) { - log_warning("DHCP error: no router"); + log_warning("%s: DHCP error: no router", link->ifname); link_enter_failed(link); return; } @@ -533,7 +545,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { _cleanup_address_free_ Address *addr = NULL; _cleanup_route_free_ Route *rt = NULL; - log_info("Received config over DHCPv4"); + log_info("%s: received config over DHCPv4", link->ifname); r = address_new_dynamic(&addr); if (r < 0) { @@ -611,17 +623,17 @@ int link_update(Link *link, sd_rtnl_message *m) { r = sd_rtnl_message_link_get_flags(m, &flags); if (r < 0) { - log_warning("Could not get link flags of '%s'", link->ifname); + log_warning("%s: could not get link flags", link->ifname); return r; } if (link->flags & IFF_UP && !(flags & IFF_UP)) - log_info("Interface '%s' is down", link->ifname); + log_info("%s: interface is down", link->ifname); else if (!(link->flags & IFF_UP) && flags & IFF_UP) - log_info("Interface '%s' is up", link->ifname); + log_info("%s: interface is up", link->ifname); if (link->flags & IFF_LOWER_UP && !(flags & IFF_LOWER_UP)) { - log_info("Interface '%s' is disconnected", link->ifname); + log_info("%s: disconnected", link->ifname); if (link->network->dhcp) { r = sd_dhcp_client_stop(link->dhcp); @@ -631,7 +643,7 @@ int link_update(Link *link, sd_rtnl_message *m) { } } } else if (!(link->flags & IFF_LOWER_UP) && flags & IFF_LOWER_UP) { - log_info("Interface '%s' is connected", link->ifname); + log_info("%s: connected", link->ifname); if (link->network && link->network->dhcp) { r = link_acquire_conf(link); @@ -644,5 +656,7 @@ int link_update(Link *link, sd_rtnl_message *m) { link->flags = flags; + log_debug("%s: updated state", link->ifname); + return 0; } diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index c48c0180ad..73e0c87f34 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -134,7 +134,7 @@ static int manager_process_link(Manager *m, struct udev_device *device) { if (streq_ptr(udev_device_get_action(device), "remove")) { uint64_t ifindex; - log_debug("Link removed: %s", udev_device_get_sysname(device)); + log_debug("%s: link removed", udev_device_get_sysname(device)); ifindex = udev_device_get_ifindex(device); link = hashmap_get(m->links, &ifindex); @@ -143,7 +143,7 @@ static int manager_process_link(Manager *m, struct udev_device *device) { link_free(link); } else { - log_debug("New link: %s", udev_device_get_sysname(device)); + log_debug("%s: link added", udev_device_get_sysname(device)); r = link_add(m, device); if (r < 0) { diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 56e5637a66..e0e3878f75 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -67,8 +67,7 @@ static int network_load_one(Manager *manager, const char *filename) { if (r < 0) { log_warning("Could not parse config file %s: %s", filename, strerror(-r)); return r; - } else - log_debug("Parsed configuration file %s", filename); + } LIST_PREPEND(networks, manager->networks, network); network = NULL; @@ -88,7 +87,7 @@ int network_load(Manager *manager) { r = conf_files_list_strv(&files, ".network", NULL, (const char **)manager->network_dirs); if (r < 0) { - log_error("failed to enumerate network files: %s", strerror(-r)); + log_error("Failed to enumerate network files: %s", strerror(-r)); return r; } @@ -153,9 +152,9 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) { udev_device_get_driver(device), udev_device_get_devtype(device), udev_device_get_sysname(device))) { - log_debug("Network file %s applies to link %s", - network->filename, - udev_device_get_sysname(device)); + log_debug("%s: found matching network '%s'", + udev_device_get_sysname(device), + network->filename); *ret = network; return 0; } @@ -169,9 +168,6 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) { int network_apply(Manager *manager, Network *network, Link *link) { int r; - log_info("Network '%s' being applied to link '%s'", - network->description, link->ifname); - link->network = network; r = link_configure(link); diff --git a/src/shared/net-util.c b/src/shared/net-util.c index fa89bd904f..8f8cfc9fdb 100644 --- a/src/shared/net-util.c +++ b/src/shared/net-util.c @@ -40,45 +40,20 @@ bool net_match_config(const struct ether_addr *match_mac, const char *dev_type, const char *dev_name) { - if (match_mac) { - if (!dev_mac || memcmp(match_mac, ether_aton(dev_mac), ETH_ALEN)) { - log_debug("Interface MAC address (%s) did not match MACAddress=%s", - dev_mac, ether_ntoa(match_mac)); - return 0; - } - } + if (match_mac && (!dev_mac || memcmp(match_mac, ether_aton(dev_mac), ETH_ALEN))) + return 0; - if (match_path) { - if (!streq_ptr(match_path, dev_path)) { - log_debug("Interface persistent path (%s) did not match Path=%s", - dev_path, match_path); - return 0; - } - } + if (match_path && !streq_ptr(match_path, dev_path)) + return 0; - if (match_driver) { - if (!streq_ptr(match_driver, dev_driver)) { - log_debug("Interface device driver (%s) did not match Driver=%s", - dev_driver, match_driver); - return 0; - } - } + if (match_driver && !streq_ptr(match_driver, dev_driver)) + return 0; - if (match_type) { - if (!streq_ptr(match_type, dev_type)) { - log_debug("Interface type (%s) did not match Type=%s", - dev_type, match_type); - return 0; - } - } + if (match_type && !streq_ptr(match_type, dev_type)) + return 0; - if (match_name) { - if (!streq_ptr(match_name, dev_name)) { - log_debug("Interface name (%s) did not match Name=%s", - dev_name, match_name); - return 0; - } - } + if (match_name && !streq_ptr(match_name, dev_name)) + return 0; return 1; } |