assert(link);
assert(link->state == LINK_STATE_SETTING_ROUTES);
- log_link_info(link, "link configured");
+ log_info_link(link, "link configured");
link->state = LINK_STATE_CONFIGURED;
static void link_enter_failed(Link *link) {
assert(link);
- log_link_warning(link, "failed");
+ log_warning_link(link, "failed");
link->state = LINK_STATE_FAILED;
}
/* 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_link_debug(link, "routes set");
+ log_debug_link(link, "routes set");
link_enter_configured(link);
}
if (!link->network->static_routes && !link->dhcp_route)
return link_enter_configured(link);
- log_link_debug(link, "setting routes");
+ log_debug_link(link, "setting routes");
LIST_FOREACH(static_routes, route, link->network->static_routes) {
r = route_configure(route, link, &route_handler);
NULL);
if (link->addr_messages == 0) {
- log_link_debug(link, "addresses set");
+ log_debug_link(link, "addresses set");
link_enter_set_routes(link);
}
if (!link->network->static_addresses && !link->dhcp_address)
return link_enter_set_routes(link);
- log_link_debug(link, "setting addresses");
+ log_debug_link(link, "setting addresses");
LIST_FOREACH(static_addresses, address, link->network->static_addresses) {
r = address_configure(address, link, &address_handler);
int r;
assert(link);
+ assert(link->network);
if (link->state == LINK_STATE_FAILED)
return;
}
if (event == DHCP_EVENT_NO_LEASE)
- log_link_debug(link, "IP address in use.");
+ log_debug_link(link, "IP address in use.");
if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_EXPIRED ||
event == DHCP_EVENT_STOP) {
r = sd_dhcp_client_get_address(client, &address);
if (r < 0) {
- log_link_warning(link, "DHCP error: no address");
+ log_warning_link(link, "DHCP error: no address");
link_enter_failed(link);
return;
}
r = sd_dhcp_client_get_netmask(client, &netmask);
if (r < 0) {
- log_link_warning(link, "DHCP error: no netmask");
+ log_warning_link(link, "DHCP error: no netmask");
link_enter_failed(link);
return;
}
prefixlen = sd_dhcp_client_prefixlen(&netmask);
if (prefixlen < 0) {
- log_link_warning(link, "DHCP error: no prefixlen");
+ log_warning_link(link, "DHCP error: no prefixlen");
link_enter_failed(link);
return;
}
r = sd_dhcp_client_get_router(client, &gateway);
if (r < 0) {
- log_link_warning(link, "DHCP error: no router");
+ log_warning_link(link, "DHCP error: no router");
link_enter_failed(link);
return;
}
if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_IP_ACQUIRE) {
_cleanup_address_free_ Address *addr = NULL;
_cleanup_route_free_ Route *rt = NULL;
-
- log_link_info(link, "received config over DHCPv4");
+ struct in_addr **nameservers;
+
+ log_struct_link(LOG_INFO, link,
+ "MESSAGE=%s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
+ link->ifname,
+ ADDRESS_FMT_VAL(address),
+ prefixlen,
+ ADDRESS_FMT_VAL(gateway),
+ "ADDRESS=%u.%u.%u.%u",
+ ADDRESS_FMT_VAL(address),
+ "PREFIXLEN=%u",
+ prefixlen,
+ "GATEWAY=%u.%u.%u.%u",
+ ADDRESS_FMT_VAL(gateway),
+ NULL);
r = address_new_dynamic(&addr);
if (r < 0) {
- log_link_error(link, "Could not allocate address");
+ log_error_link(link, "Could not allocate address");
link_enter_failed(link);
return;
}
r = route_new_dynamic(&rt);
if (r < 0) {
- log_link_error(link, "Could not allocate route");
+ log_error_link(link, "Could not allocate route");
link_enter_failed(link);
return;
}
addr = NULL;
rt = NULL;
+ if (link->network->dhcp_dns) {
+ r = sd_dhcp_client_get_dns(client, &nameservers);
+ if (r >= 0) {
+ r = manager_update_resolv_conf(link->manager);
+ if (r < 0)
+ log_error("Failed to update resolv.conf");
+ }
+ }
+
link_enter_set_addresses(link);
}
return r;
}
+ log_debug_link(link, "acquiring DHCPv4 lease");
+
r = sd_dhcp_client_start(link->dhcp);
if (r < 0)
return r;
return 0;
if (link->flags == flags) {
- log_debug_link(link, "link status unchanged: %#x", flags);
+ log_debug_link(link, "link status unchanged: %#.8x", flags);
return 0;
}
if ((link->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) {
if (flags & IFF_LOWER_UP) {
- log_link_info(link, "carrier on");
+ log_info_link(link, "carrier on");
if (link->network->dhcp) {
r = link_acquire_conf(link);
}
}
} else {
- log_link_info(link, "carrier off");
+ log_info_link(link, "carrier off");
if (link->network->dhcp) {
r = sd_dhcp_client_stop(link->dhcp);
}
log_debug_link(link,
- "link status updated: %#x -> %#x", link->flags, flags);
+ "link status updated: %#.8x -> %#.8x", link->flags, flags);
link->flags = flags;
assert(link->manager);
assert(link->manager->rtnl);
- log_link_debug(link, "bringing link up");
+ log_debug_link(link, "bringing link up");
r = sd_rtnl_message_link_new(RTM_SETLINK, link->ifindex, &req);
if (r < 0) {
- log_link_error(link, "Could not allocate RTM_SETLINK message");
+ log_error_link(link, "Could not allocate RTM_SETLINK message");
return r;
}
link->network->bridge->name,
BRIDGE(link->network->bridge),
NULL);
+
link_bridge_joined(link);
return 1;
link->network->bridge->name,
BRIDGE(link->network->bridge),
NULL);
- log_link_debug(link, "joining bridge");
+ log_debug_link(link, "joining bridge");
r = bridge_join(link->network->bridge, link, &bridge_handler);
if (r < 0) {
link_enter_failed(link);
}
- log_link_debug(link, "got link state");
+ log_debug_link(link, "got link state");
link_update(link, m);
assert(link->manager);
assert(link->manager->rtnl);
- log_link_debug(link, "requesting link status");
+ log_debug_link(link, "requesting link status");
r = sd_rtnl_message_link_new(RTM_GETLINK, link->ifindex, &req);
if (r < 0) {
- log_link_error(link, "Could not allocate RTM_GETLINK message");
+ log_error_link(link, "Could not allocate RTM_GETLINK message");
return r;
}
r = sd_rtnl_message_link_get_flags(m, &flags);
if (r < 0) {
- log_link_warning(link, "could not get link flags");
+ log_warning_link(link, "could not get link flags");
return r;
}