staticunsignedint default_operstate(conststruct net_device *dev)
{ if (netif_testing(dev)) return IF_OPER_TESTING;
/* Some uppers (DSA) have additional sources for being down, so * first check whether lower is indeed the source of its down state.
*/ if (!netif_carrier_ok(dev)) { struct net_device *peer; int iflink;
/* If called from netdev_run_todo()/linkwatch_sync_dev(), * dev_net(dev) can be already freed, and RTNL is not held.
*/ if (dev->reg_state <= NETREG_REGISTERED)
iflink = dev_get_iflink(dev); else
iflink = dev->ifindex;
if (iflink == dev->ifindex) return IF_OPER_DOWN;
ASSERT_RTNL();
peer = __dev_get_by_index(dev_net(dev), iflink); if (!peer) return IF_OPER_DOWN;
if (test_bit(LW_URGENT, &linkwatch_flags)) return;
/* Minimise down-time: drop delay for up event. */ if (urgent) { if (test_and_set_bit(LW_URGENT, &linkwatch_flags)) return;
delay = 0;
}
/* If we wrap around we'll delay it by at most HZ. */ if (delay > HZ)
delay = 0;
/* * If urgent, schedule immediate execution; otherwise, don't * override the existing timer.
*/ if (test_bit(LW_URGENT, &linkwatch_flags))
mod_delayed_work(system_unbound_wq, &linkwatch_work, 0); else
queue_delayed_work(system_unbound_wq, &linkwatch_work, delay);
}
staticvoid linkwatch_do_dev(struct net_device *dev)
{ /* * Make sure the above read is complete since it can be * rewritten as soon as we clear the bit below.
*/
smp_mb__before_atomic();
/* We are about to handle this device, * so new events can be accepted
*/
clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
rfc2863_policy(dev); if (dev->flags & IFF_UP) { if (netif_carrier_ok(dev))
dev_activate(dev); else
dev_deactivate(dev);
netif_state_change(dev);
} /* Note: our callers are responsible for calling netdev_tracker_free(). * This is the reason we use __dev_put() instead of dev_put().
*/
__dev_put(dev);
}
int do_dev = MAX_DO_DEV_PER_LOOP; /* Use a local list here since we add non-urgent * events back to the global one when called with * urgent_only=1.
*/
LIST_HEAD(wrk);
/* Give urgent case more budget */ if (urgent_only)
do_dev += MAX_DO_DEV_PER_LOOP;
/* * Limit the number of linkwatch events to one * per second so that a runaway driver does not * cause a storm of messages on the netlink * socket. This limit does not apply to up events * while the device qdisc is down.
*/ if (!urgent_only)
linkwatch_nextevent = jiffies + HZ; /* Limit wrap-around effect on delay. */ elseif (time_after(linkwatch_nextevent, jiffies + HZ))
linkwatch_nextevent = jiffies;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.