/** * recv_notification - handle device updates from OS * * Change the state of the InfiniBand bearer (if any) associated with the * specified device. */ static int recv_notification(struct notifier_block *nb, unsigned long evt, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct ib_bearer *ib_ptr = &ib_bearers[0]; struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS]; if (!net_eq(dev_net(dev), &init_net)) return NOTIFY_DONE; while ((ib_ptr->dev != dev)) { if (++ib_ptr == stop) return NOTIFY_DONE; /* couldn't find device */ } if (!ib_ptr->bearer) return NOTIFY_DONE; /* bearer had been disabled */ ib_ptr->bearer->mtu = dev->mtu; switch (evt) { case NETDEV_CHANGE: if (netif_carrier_ok(dev)) tipc_continue(ib_ptr->bearer); else tipc_block_bearer(ib_ptr->bearer->name); break; case NETDEV_UP: tipc_continue(ib_ptr->bearer); break; case NETDEV_DOWN: tipc_block_bearer(ib_ptr->bearer->name); break; case NETDEV_CHANGEMTU: case NETDEV_CHANGEADDR: tipc_block_bearer(ib_ptr->bearer->name); tipc_continue(ib_ptr->bearer); break; case NETDEV_UNREGISTER: case NETDEV_CHANGENAME: tipc_disable_bearer(ib_ptr->bearer->name); break; } return NOTIFY_OK; }
static int recv_notification(struct notifier_block *nb, unsigned long evt, void *dv) { struct net_device *dev = (struct net_device *)dv; struct eth_bearer *eb_ptr = ð_bearers[0]; struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS]; while ((eb_ptr->dev != dev)) { if (++eb_ptr == stop) return NOTIFY_DONE; /* couldn't find device */ } if (!eb_ptr->bearer) return NOTIFY_DONE; /* bearer had been disabled */ eb_ptr->bearer->mtu = dev->mtu; switch (evt) { case NETDEV_CHANGE: if (netif_carrier_ok(dev)) tipc_continue(eb_ptr->bearer); else tipc_block_bearer(eb_ptr->bearer->name); break; case NETDEV_UP: tipc_continue(eb_ptr->bearer); break; case NETDEV_DOWN: tipc_block_bearer(eb_ptr->bearer->name); break; case NETDEV_CHANGEMTU: case NETDEV_CHANGEADDR: tipc_block_bearer(eb_ptr->bearer->name); tipc_continue(eb_ptr->bearer); break; case NETDEV_UNREGISTER: case NETDEV_CHANGENAME: tipc_disable_bearer(eb_ptr->bearer->name); break; } return NOTIFY_OK; }