Exemplo n.º 1
0
static __init int can_dev_init(void)
{
	int err;

	can_led_notifier_init();

	err = rtnl_link_register(&can_link_ops);
	if (!err)
		printk(KERN_INFO MOD_DESC "\n");

	return err;
}
Exemplo n.º 2
0
Arquivo: ip_gre.c Projeto: 3null/linux
static int __init ipgre_init(void)
{
	int err;

	pr_info("GRE over IPv4 tunneling driver\n");

	err = register_pernet_device(&ipgre_net_ops);
	if (err < 0)
		return err;

	err = register_pernet_device(&ipgre_tap_net_ops);
	if (err < 0)
		goto pnet_tap_faied;

	err = gre_cisco_register(&ipgre_protocol);
	if (err < 0) {
		pr_info("%s: can't add protocol\n", __func__);
		goto add_proto_failed;
	}

	err = rtnl_link_register(&ipgre_link_ops);
	if (err < 0)
		goto rtnl_link_failed;

	err = rtnl_link_register(&ipgre_tap_ops);
	if (err < 0)
		goto tap_ops_failed;

	return 0;

tap_ops_failed:
	rtnl_link_unregister(&ipgre_link_ops);
rtnl_link_failed:
	gre_cisco_unregister(&ipgre_protocol);
add_proto_failed:
	unregister_pernet_device(&ipgre_tap_net_ops);
pnet_tap_faied:
	unregister_pernet_device(&ipgre_net_ops);
	return err;
}
Exemplo n.º 3
0
static int __init vti_init(void)
{
	const char *msg;
	int err;

	pr_info("IPv4 over IPsec tunneling driver\n");

	msg = "tunnel device";
	err = register_pernet_device(&vti_net_ops);
	if (err < 0)
		goto pernet_dev_failed;

	msg = "tunnel protocols";
	err = xfrm4_protocol_register(&vti_esp4_protocol, IPPROTO_ESP);
	if (err < 0)
		goto xfrm_proto_esp_failed;
	err = xfrm4_protocol_register(&vti_ah4_protocol, IPPROTO_AH);
	if (err < 0)
		goto xfrm_proto_ah_failed;
	err = xfrm4_protocol_register(&vti_ipcomp4_protocol, IPPROTO_COMP);
	if (err < 0)
		goto xfrm_proto_comp_failed;

	msg = "ipip tunnel";
	err = xfrm4_tunnel_register(&ipip_handler, AF_INET);
	if (err < 0) {
		pr_info("%s: cant't register tunnel\n",__func__);
		goto xfrm_tunnel_failed;
	}

	msg = "netlink interface";
	err = rtnl_link_register(&vti_link_ops);
	if (err < 0)
		goto rtnl_link_failed;

	return err;

rtnl_link_failed:
	xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);
xfrm_tunnel_failed:
	xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
xfrm_proto_comp_failed:
	xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
xfrm_proto_ah_failed:
	xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP);
xfrm_proto_esp_failed:
	unregister_pernet_device(&vti_net_ops);
pernet_dev_failed:
	pr_err("vti init: failed to register %s\n", msg);
	return err;
}
Exemplo n.º 4
0
int ovs_internal_dev_rtnl_link_register(void)
{
	int err;

	err = rtnl_link_register(&internal_dev_link_ops);
	if (err < 0)
		return err;

	err = ovs_vport_ops_register(&ovs_internal_vport_ops);
	if (err < 0)
		rtnl_link_unregister(&internal_dev_link_ops);

	return err;
}
Exemplo n.º 5
0
int __init br_netlink_init(void)
{
	int err;

	br_mdb_init();
	err = rtnl_link_register(&br_link_ops);
	if (err)
		goto out;

	return 0;
out:
	br_mdb_uninit();
	return err;
}
Exemplo n.º 6
0
Arquivo: ip_vti.c Projeto: 7799/linux
static int __init vti_init(void)
{
	int err;

	pr_info("IPv4 over IPSec tunneling driver\n");

	err = register_pernet_device(&vti_net_ops);
	if (err < 0)
		return err;
	err = xfrm4_protocol_register(&vti_esp4_protocol, IPPROTO_ESP);
	if (err < 0) {
		unregister_pernet_device(&vti_net_ops);
		pr_info("vti init: can't register tunnel\n");

		return err;
	}

	err = xfrm4_protocol_register(&vti_ah4_protocol, IPPROTO_AH);
	if (err < 0) {
		xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP);
		unregister_pernet_device(&vti_net_ops);
		pr_info("vti init: can't register tunnel\n");

		return err;
	}

	err = xfrm4_protocol_register(&vti_ipcomp4_protocol, IPPROTO_COMP);
	if (err < 0) {
		xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
		xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP);
		unregister_pernet_device(&vti_net_ops);
		pr_info("vti init: can't register tunnel\n");

		return err;
	}

	err = rtnl_link_register(&vti_link_ops);
	if (err < 0)
		goto rtnl_link_failed;

	return err;

rtnl_link_failed:
	xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);
	xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
	xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP);
	unregister_pernet_device(&vti_net_ops);
	return err;
}
Exemplo n.º 7
0
static int __init rmnet_init(void)
{
	int rc;

	rc = register_netdevice_notifier(&rmnet_dev_notifier);
	if (rc != 0)
		return rc;

	rc = rtnl_link_register(&rmnet_link_ops);
	if (rc != 0) {
		unregister_netdevice_notifier(&rmnet_dev_notifier);
		return rc;
	}
	return rc;
}
Exemplo n.º 8
0
static int __init vrf_init_module(void)
{
	int rc;

	register_netdevice_notifier(&vrf_notifier_block);

	rc = rtnl_link_register(&vrf_link_ops);
	if (rc < 0)
		goto error;

	return 0;

error:
	unregister_netdevice_notifier(&vrf_notifier_block);
	return rc;
}
Exemplo n.º 9
0
static int
vhost_netlink_init(void)
{
    int ret;

    if (vhost_drv_inited)
        return 0;

    ret = rtnl_link_register(&vhost_link_ops);
    if (ret) {
        return ret;
    }

    vhost_drv_inited = true;

    return 0;
}
Exemplo n.º 10
0
static int __init vti_init(void)
{
	const char *msg;
	int err;

	pr_info("IPv4 over IPsec tunneling driver\n");

	register_netdevice_notifier(&vti_notifier_block);

	msg = "tunnel device";
	err = register_pernet_device(&vti_net_ops);
	if (err < 0)
		goto pernet_dev_failed;

	msg = "tunnel protocols";
	err = xfrm4_protocol_register(&vti_esp4_protocol, IPPROTO_ESP);
	if (err < 0)
		goto xfrm_proto_esp_failed;
	err = xfrm4_protocol_register(&vti_ah4_protocol, IPPROTO_AH);
	if (err < 0)
		goto xfrm_proto_ah_failed;
	err = xfrm4_protocol_register(&vti_ipcomp4_protocol, IPPROTO_COMP);
	if (err < 0)
		goto xfrm_proto_comp_failed;

	msg = "netlink interface";
	err = rtnl_link_register(&vti_link_ops);
	if (err < 0)
		goto rtnl_link_failed;

	return err;

rtnl_link_failed:
	xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP);
xfrm_proto_comp_failed:
	xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH);
xfrm_proto_ah_failed:
	xfrm4_protocol_deregister(&vti_esp4_protocol, IPPROTO_ESP);
xfrm_proto_esp_failed:
	unregister_pernet_device(&vti_net_ops);
pernet_dev_failed:
	unregister_netdevice_notifier(&vti_notifier_block);
	pr_err("vti init: failed to register %s\n", msg);
	return err;
}
Exemplo n.º 11
0
int __init hsr_netlink_init(void)
{
    int rc;

    rc = rtnl_link_register(&hsr_link_ops);
    if (rc)
        goto fail_rtnl_link_register;

    rc = genl_register_family_with_ops_groups(&hsr_genl_family, hsr_ops,
            hsr_mcgrps);
    if (rc)
        goto fail_genl_register_family;

    return 0;

fail_genl_register_family:
    rtnl_link_unregister(&hsr_link_ops);
fail_rtnl_link_register:

    return rc;
}
Exemplo n.º 12
0
static int __init ipip_init(void)
{
	int err;

	pr_info("ipip: IPv4 and MPLS over IPv4 tunneling driver\n");

	err = register_pernet_device(&ipip_net_ops);
	if (err < 0)
		return err;
	err = xfrm4_tunnel_register(&ipip_handler, AF_INET);
	if (err < 0) {
		pr_info("%s: can't register tunnel\n", __func__);
		goto xfrm_tunnel_ipip_failed;
	}
#if IS_ENABLED(CONFIG_MPLS)
	err = xfrm4_tunnel_register(&mplsip_handler, AF_MPLS);
	if (err < 0) {
		pr_info("%s: can't register tunnel\n", __func__);
		goto xfrm_tunnel_mplsip_failed;
	}
#endif
	err = rtnl_link_register(&ipip_link_ops);
	if (err < 0)
		goto rtnl_link_failed;

out:
	return err;

rtnl_link_failed:
#if IS_ENABLED(CONFIG_MPLS)
	xfrm4_tunnel_deregister(&mplsip_handler, AF_INET);
xfrm_tunnel_mplsip_failed:

#endif
	xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
xfrm_tunnel_ipip_failed:
	unregister_pernet_device(&ipip_net_ops);
	goto out;
}
Exemplo n.º 13
0
static __init int deth_init(void)
{
    int rc;

    printk(KERN_DEBUG "[Module %s %s loaded]\n", DRV_NAME, DRV_VERSION);

    rc = register_pernet_subsys(&deth_net_ops);

    if (rc != 0)
    {
        return rc;
    }

    rc = rtnl_link_register(&deth_link_ops);

    if (rc != 0)
    {
        unregister_pernet_subsys(&deth_net_ops);
    }

    return rc;
}
Exemplo n.º 14
0
int __init br_netlink_init(void)
{
	int err;

	err = rtnl_link_register(&br_link_ops);
	if (err < 0)
		goto err1;

	err = __rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL,
			      br_dump_ifinfo, NULL);
	if (err)
		goto err2;
	err = __rtnl_register(PF_BRIDGE, RTM_SETLINK,
			      br_rtm_setlink, NULL, NULL);
	if (err)
		goto err3;
	err = __rtnl_register(PF_BRIDGE, RTM_NEWNEIGH,
			      br_fdb_add, NULL, NULL);
	if (err)
		goto err3;
	err = __rtnl_register(PF_BRIDGE, RTM_DELNEIGH,
			      br_fdb_delete, NULL, NULL);
	if (err)
		goto err3;
	err = __rtnl_register(PF_BRIDGE, RTM_GETNEIGH,
			      NULL, br_fdb_dump, NULL);
	if (err)
		goto err3;

	return 0;

err3:
	rtnl_unregister_all(PF_BRIDGE);
err2:
	rtnl_link_unregister(&br_link_ops);
err1:
	return err;
}
Exemplo n.º 15
0
static int __init nsim_module_init(void)
{
	int err;

	err = nsim_dev_init();
	if (err)
		return err;

	err = nsim_bus_init();
	if (err)
		goto err_dev_exit;

	err = rtnl_link_register(&nsim_link_ops);
	if (err)
		goto err_bus_exit;

	return 0;

err_bus_exit:
	nsim_bus_exit();
err_dev_exit:
	nsim_dev_exit();
	return err;
}
Exemplo n.º 16
0
static __init int veth_init(void)
{
	return rtnl_link_register(&veth_link_ops);
}
Exemplo n.º 17
0
int __init ipoib_netlink_init(void)
{
	return rtnl_link_register(&ipoib_link_ops);
}
Exemplo n.º 18
0
static __init int nlmon_register(void)
{
	return rtnl_link_register(&nlmon_link_ops);
}
Exemplo n.º 19
0
int ovs_internal_dev_rtnl_link_register(void)
{
	return rtnl_link_register(&internal_dev_link_ops);
}
Exemplo n.º 20
0
Arquivo: vxcan.c Projeto: Lyude/linux
static __init int vxcan_init(void)
{
	pr_info("vxcan: Virtual CAN Tunnel driver\n");

	return rtnl_link_register(&vxcan_link_ops);
}
Exemplo n.º 21
0
static int
micveth_probe_int(micveth_info_t *veth_info, mic_ctx_t *mic_ctx)
{
	struct net_device *dev_veth;
	ring_queue_t *queue;
	ring_desc_t *desc;
	ring_packet_t *packet;
	int idx;
	int err = 0;

	veth_info->vi_pdev = mic_ctx->bi_pdev;
	veth_info->vi_sbox = (uint8_t *)((unsigned long)mic_ctx->mmio.va +
					 HOST_SBOX_BASE_ADDRESS);
	veth_info->vi_scratch14 = (uint32_t *)((unsigned long)mic_ctx->mmio.va +
					       HOST_SBOX_BASE_ADDRESS + SBOX_SCRATCH14);
	veth_info->vi_scratch15 = (uint32_t *)((unsigned long)mic_ctx->mmio.va +
					       HOST_SBOX_BASE_ADDRESS + SBOX_SCRATCH15);
	veth_info->mic_ctx = mic_ctx;
	mic_ctx->bi_vethinfo = (void *)veth_info;

	spin_lock_init(&veth_info->vi_txlock);
	spin_lock_init(&veth_info->vi_rxlock);

	if (mic_vnet_mode == VNET_MODE_POLL)
		INIT_DELAYED_WORK(&veth_info->vi_poll, micveth_poll);

	// Set the current sk_buff allocation size
	veth_info->vi_skb_mtu = MICVETH_MAX_PACKET_SIZE + 32;

	// Get the physical memory address for the ring descriptors
	veth_info->vi_ring.phys = mic_ctx_map_single(veth_to_ctx(veth_info), &veth_info->vi_ring.ring,
						     sizeof(veth_ring_t));
	veth_info->vi_ring.length = sizeof(veth_ring_t);

	queue = &veth_info->vi_ring.ring.r_tx;
	queue->rq_head = 0;
	queue->rq_tail = 0;
	queue->rq_length = MICVETH_TRANSFER_FIFO_SIZE;

	veth_info->vi_pend = 0;

	packet = &veth_info->vi_tx_desc[0];
	for (idx = 0; idx < queue->rq_length; idx++) {
		desc = &queue->rq_descs[idx];
		packet[idx].pd_skb = NULL;
		packet[idx].pd_phys = 0;
		packet[idx].pd_length = 0;

		desc->rd_phys = 0;
		desc->rd_length = 0;
		desc->rd_valid = 0;
	}

	// This is the recieve end.
	queue = &veth_info->vi_ring.ring.r_rx;
	queue->rq_head = 0;
	queue->rq_tail = 0;
	queue->rq_length = MICVETH_TRANSFER_FIFO_SIZE;

	packet = &veth_info->vi_rx_desc[0];
	for (idx = 0; idx < queue->rq_length; idx++) {
		desc = &queue->rq_descs[idx];
		if (!(packet[idx].pd_skb = dev_alloc_skb(veth_info->vi_skb_mtu)))
			return -ENOMEM;
		packet[idx].pd_phys = mic_ctx_map_single(veth_to_ctx(veth_info), packet[idx].pd_skb->data,
							 veth_info->vi_skb_mtu);
		packet[idx].pd_length = veth_info->vi_skb_mtu;

		desc->rd_phys = packet[idx].pd_phys;
		desc->rd_length = packet[idx].pd_length;
		desc->rd_valid = 1;
	}

#if LINUX_VERSION_CODE > KERNEL_VERSION(3,14,4)
	if ((dev_veth = alloc_netdev(sizeof(micveth_info_t), "mic%d", NET_NAME_ENUM,  micveth_setup)) == NULL) {
#else
	if ((dev_veth = alloc_netdev(sizeof(micveth_info_t), "mic%d", micveth_setup)) == NULL) {
#endif
		return -ENOMEM;
	}

	veth_info->vi_netdev = dev_veth;
	dev_veth->ml_priv = veth_info;
	dev_veth->rtnl_link_ops = &micveth_link_ops;

	if ((err = register_netdev(dev_veth)) < 0) {
		printk("register netdev failed %d\n", err);
		free_netdev(dev_veth);
		return err;
	}

	veth_info->vi_state = VETH_STATE_INITIALIZED;
	return 0;
}

static ssize_t show_veth(struct device *dev,
			 struct device_attribute *attr, char *buf);
DEVICE_ATTR(veth, (S_IRUGO|S_IWUGO)&(~S_IWOTH), show_veth, NULL);

static int
micveth_init_int(int num_bds, struct device *dev)
{
	int bd;
	int err = 0;

	micveth.lv_num_interfaces = num_bds;
	micveth.lv_num_clients = num_bds;
	micveth.lv_active_clients = 0;
	micveth.lv_num_links_remaining = num_bds;

	BUG_ON(rtnl_link_register(&micveth_link_ops));

	// Allocate space for the control of each device in the system.
	micveth.lv_info = kmalloc(sizeof(micveth_info_t) * num_bds, GFP_KERNEL);

	// Initialize state mutex.  Overloaded use for several fields.
	mutex_init(&micveth.lv_state_mutex);

	// Setup of timer for probeing active mic clients.  When the total active board
	// count is zero the poll is not running.
	micveth.lv_pollstate = CLIENT_POLL_STOPPED;
	INIT_DELAYED_WORK(&micveth.lv_poll, micveth_clientpoll);
	init_waitqueue_head(&micveth.lv_wq);

	// Init each of the existing boards.
	for (bd = 0; bd < num_bds; bd++) {
		micveth_probe_int(&micveth.lv_info[bd], &mic_data.dd_bi[bd]->bi_ctx);
	}

	err = device_create_file(dev, &dev_attr_veth);
	return err;
}
Exemplo n.º 22
0
Arquivo: veth.c Projeto: E-LLP/n900
static __init int veth_init(void)
{
	register_netdevice_notifier(&veth_notifier_block);
	return rtnl_link_register(&veth_link_ops);
}