Merge pull request #16271 from yuwata/network-cleanups-around-link-get

network: several tiny cleanups around link_get()
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-06-25 09:06:49 +02:00
committed by GitHub
3 changed files with 8 additions and 2 deletions

View File

@@ -364,7 +364,7 @@ static int netdev_enslave(NetDev *netdev, Link *link, link_netlink_message_handl
if (r >= 0)
callback(netdev->manager->rtnl, m, link);
} else {
/* the netdev is not yet read, save this request for when it is */
/* the netdev is not yet ready, save this request for when it is */
netdev_join_callback *cb;
cb = new(netdev_join_callback, 1);

View File

@@ -346,6 +346,9 @@ static void link_update_master_operstate(Link *link, NetDev *netdev) {
if (!netdev)
return;
if (netdev->ifindex <= 0)
return;
if (link_get(link->manager, netdev->ifindex, &master) < 0)
return;
@@ -752,7 +755,7 @@ int link_get(Manager *m, int ifindex, Link **ret) {
Link *link;
assert(m);
assert(ifindex);
assert(ifindex > 0);
assert(ret);
link = hashmap_get(m->links, INT_TO_PTR(ifindex));

View File

@@ -1272,6 +1272,9 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message,
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get NHA_OIF attribute, ignoring: %m");
return 0;
} else if (tmp->oif <= 0) {
log_warning("rtnl: received nexthop message with invalid ifindex %d, ignoring.", tmp->oif);
return 0;
}
r = link_get(m, tmp->oif, &link);