Example #1
0
static struct sk_buff *cfg_disable_bearer(void)
{
	if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_BEARER_NAME))
		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);

	if (tipc_disable_bearer((char *)TLV_DATA(req_tlv_area)))
		return tipc_cfg_reply_error_string("unable to disable bearer");

	return tipc_cfg_reply_none();
}
Example #2
0
/**
 * 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;
}
Example #3
0
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 = &eth_bearers[0];
	struct eth_bearer *stop = &eth_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;
}
Example #4
0
File: bearer.c Project: 7799/linux
/**
 * tipc_l2_device_event - handle device events from network device
 * @nb: the context of the notification
 * @evt: the type of event
 * @ptr: the net device that the event was on
 *
 * This function is called by the Ethernet driver in case of link
 * change event.
 */
static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
				void *ptr)
{
	struct tipc_bearer *b_ptr;
	struct net_device *dev = netdev_notifier_info_to_dev(ptr);

	if (!net_eq(dev_net(dev), &init_net))
		return NOTIFY_DONE;

	rcu_read_lock();
	b_ptr = rcu_dereference(dev->tipc_ptr);
	if (!b_ptr) {
		rcu_read_unlock();
		return NOTIFY_DONE;
	}

	b_ptr->mtu = dev->mtu;

	switch (evt) {
	case NETDEV_CHANGE:
		if (netif_carrier_ok(dev))
			break;
	case NETDEV_DOWN:
	case NETDEV_CHANGEMTU:
		tipc_reset_bearer(b_ptr);
		break;
	case NETDEV_CHANGEADDR:
		tipc_l2_media_addr_set(b_ptr, &b_ptr->addr,
				       (char *)dev->dev_addr);
		tipc_reset_bearer(b_ptr);
		break;
	case NETDEV_UNREGISTER:
	case NETDEV_CHANGENAME:
		tipc_disable_bearer(b_ptr->name);
		break;
	}
	rcu_read_unlock();

	return NOTIFY_OK;
}