1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

network: link - simplify code a bit and remove some debug logging

This commit is contained in:
Tom Gundersen 2014-03-09 14:43:37 +01:00
parent 26abdc73a2
commit a748b692dd
3 changed files with 41 additions and 48 deletions

View File

@ -116,31 +116,6 @@ int link_get(Manager *m, int ifindex, Link **ret) {
return 0;
}
int link_add(Manager *m, struct udev_device *device, Link **ret) {
Link *link = NULL;
Network *network;
int r;
assert(m);
assert(device);
r = link_new(m, device, &link);
if (r < 0)
return r;
*ret = link;
r = network_get(m, device, &network);
if (r < 0)
return r == -ENOENT ? 0 : r;
r = network_apply(m, network, link);
if (r < 0)
return r;
return 0;
}
static int link_enter_configured(Link *link) {
assert(link);
assert(link->state == LINK_STATE_SETTING_ROUTES);
@ -994,10 +969,8 @@ static int link_update_flags(Link *link, unsigned flags) {
if (link->state == LINK_STATE_FAILED)
return 0;
if (link->flags == flags) {
log_debug_link(link, "link status unchanged: %#.8x", flags);
if (link->flags == flags)
return 0;
}
if ((link->flags & IFF_UP) != (flags & IFF_UP))
log_info_link(link,
@ -1038,8 +1011,8 @@ static int link_update_flags(Link *link, unsigned flags) {
}
}
log_debug_link(link,
"link status updated: %#.8x -> %#.8x", link->flags, flags);
log_debug_link(link, "link status updated: %#.8x -> %#.8x",
link->flags, flags);
link->flags = flags;
@ -1271,8 +1244,6 @@ static int link_getlink_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
return 1;
}
log_debug_link(link, "got link state");
link_update(link, m);
return 1;
@ -1306,38 +1277,59 @@ static int link_getlink(Link *link) {
return 0;
}
int link_configure(Link *link) {
static int link_configure(Link *link) {
int r;
assert(link);
assert(link->network);
assert(link->state == _LINK_STATE_INVALID);
r = link_getlink(link);
if (r < 0) {
link_enter_failed(link);
if (r < 0)
return r;
}
return link_enter_enslave(link);
}
int link_add(Manager *m, struct udev_device *device, Link **ret) {
Link *link = NULL;
Network *network;
int r;
assert(m);
assert(device);
r = link_new(m, device, &link);
if (r < 0)
return r;
*ret = link;
r = network_get(m, device, &network);
if (r < 0)
return r == -ENOENT ? 0 : r;
r = network_apply(m, network, link);
if (r < 0)
return r;
r = link_configure(link);
if (r < 0)
return r;
return 0;
}
int link_update(Link *link, sd_rtnl_message *m) {
unsigned flags;
int r;
assert(link);
assert(link->network);
assert(m);
if (link->state == LINK_STATE_FAILED)
return 0;
r = sd_rtnl_message_link_get_flags(m, &flags);
if (r < 0) {
log_warning_link(link, "Could not get link flags");
return r;
}
if (link->network->dhcp && link->network->dhcp_mtu &&
!link->original_mtu) {
r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
@ -1358,6 +1350,12 @@ int link_update(Link *link, sd_rtnl_message *m) {
link->mac.ether_addr_octet[5]);
}
r = sd_rtnl_message_link_get_flags(m, &flags);
if (r < 0) {
log_warning_link(link, "Could not get link flags");
return r;
}
return link_update_flags(link, flags);
}

View File

@ -208,10 +208,6 @@ int network_apply(Manager *manager, Network *network, Link *link) {
link->network = network;
r = link_configure(link);
if (r < 0)
return r;
if (network->dns) {
r = manager_update_resolv_conf(manager);
if (r < 0)

View File

@ -359,7 +359,6 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret);
void link_free(Link *link);
int link_get(Manager *m, int ifindex, Link **ret);
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);