Beispiel #1
0
static int raw_release(struct socket *sock)
{
	struct sock *sk = sock->sk;
	struct raw_sock *ro = raw_sk(sk);

	unregister_netdevice_notifier(&ro->notifier);

	lock_sock(sk);

	/* remove current filters & unregister */
	if (ro->bound) {
		if (ro->ifindex) {
			struct net_device *dev;

			dev = dev_get_by_index(&init_net, ro->ifindex);
			if (dev) {
				raw_disable_allfilters(dev, sk);
				dev_put(dev);
			}
		} else
			raw_disable_allfilters(NULL, sk);
	}

	if (ro->count > 1)
		kfree(ro->filter);

	ro->ifindex = 0;
	ro->bound   = 0;
	ro->count   = 0;

	release_sock(sk);
	sock_put(sk);

	return 0;
}
Beispiel #2
0
static int __init br_init(void)
{
	int err;

	err = stp_proto_register(&br_stp_proto);
	if (err < 0) {
		pr_err("bridge: can't register sap for STP\n");
		return err;
	}

	err = br_fdb_init();
	if (err)
		goto err_out;

	err = register_pernet_subsys(&br_net_ops);
	if (err)
		goto err_out1;

	err = br_nf_core_init();
	if (err)
		goto err_out2;

	err = register_netdevice_notifier(&br_device_notifier);
	if (err)
		goto err_out3;

	err = register_netdev_switch_notifier(&br_netdev_switch_notifier);
	if (err)
		goto err_out4;

	err = br_netlink_init();
	if (err)
		goto err_out5;

	brioctl_set(br_ioctl_deviceless_stub);

#if IS_ENABLED(CONFIG_ATM_LANE)
	br_fdb_test_addr_hook = br_fdb_test_addr;
#endif

	pr_info("bridge: automatic filtering via arp/ip/ip6tables has been "
		"deprecated. Update your scripts to load br_netfilter if you "
		"need this.\n");

	return 0;

err_out5:
	unregister_netdev_switch_notifier(&br_netdev_switch_notifier);
err_out4:
	unregister_netdevice_notifier(&br_device_notifier);
err_out3:
	br_nf_core_fini();
err_out2:
	unregister_pernet_subsys(&br_net_ops);
err_out1:
	br_fdb_fini();
err_out:
	stp_proto_unregister(&br_stp_proto);
	return err;
}
Beispiel #3
0
static int __init vrf_init_module(void)
{
	int rc;

	vrf_dst_ops.kmem_cachep =
		kmem_cache_create("vrf_ip_dst_cache",
				  sizeof(struct rtable), 0,
				  SLAB_HWCACHE_ALIGN,
				  NULL);

	if (!vrf_dst_ops.kmem_cachep)
		return -ENOMEM;

	rc = init_dst_ops6_kmem_cachep();
	if (rc != 0)
		goto error2;

	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);
	free_dst_ops6_kmem_cachep();
error2:
	kmem_cache_destroy(vrf_dst_ops.kmem_cachep);
	return rc;
}
Beispiel #4
0
void ssh_interceptor_iface_uninit(SshInterceptor interceptor)
{
  /* Clear interface table and release net_device references. */
  ssh_interceptor_clear_ifaces(interceptor);

  if (interceptor->nf->iface_notifiers_installed == FALSE)
    return;

  SSH_ASSERT(in_softirq());
  local_bh_enable();
  SSH_ASSERT(!in_softirq());

  /* Unregister notifier callback */
  unregister_netdevice_notifier(&interceptor->nf->notifier_netdev);
  unregister_inetaddr_notifier(&interceptor->nf->notifier_inetaddr);
#ifdef SSH_LINUX_INTERCEPTOR_IPV6
  unregister_inet6addr_notifier(&interceptor->nf->notifier_inet6addr);
#endif /* SSH_LINUX_INTERCEPTOR_IPV6 */

  local_bh_disable();

  /* Due to lack of proper locking in linux kernel notifier code, 
     the unregister_*_notifier functions might leave the notifier 
     blocks out of sync, resulting in that the kernel may call an
     unregistered notifier function.

     Sleep for a while to decrease the possibility of the bug causing
     trouble (crash during module unloading). */
  mdelay(500);
  
  interceptor->nf->iface_notifiers_installed = FALSE;
}
Beispiel #5
0
static void packet_close(struct sock *sk, unsigned long timeout)
{
	/*
	 *	Stop more data and kill the socket off.
	 */

	lock_sock(sk);
	sk->state = TCP_CLOSE;

	/*
	 *	Unhook the notifier
	 */

	unregister_netdevice_notifier(&sk->protinfo.af_packet.notifier);

	if(sk->protinfo.af_packet.prot_hook)
	{
		/*
		 *	Remove the protocol hook
		 */
		 
		dev_remove_pack((struct packet_type *)sk->protinfo.af_packet.prot_hook);

		/*
		 *	Dispose of litter carefully.
		 */
	 
		kfree_s((void *)sk->protinfo.af_packet.prot_hook, sizeof(struct packet_type));
		sk->protinfo.af_packet.prot_hook = NULL;
	}
	
	release_sock(sk);
	destroy_sock(sk);
}
Beispiel #6
0
static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr)
{
	struct mlx4_en_dev *mdev = endev_ptr;
	int i;

	mutex_lock(&mdev->state_lock);
	mdev->device_up = false;
	mutex_unlock(&mdev->state_lock);

	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH)
		if (mdev->pndev[i])
			mlx4_en_destroy_netdev(mdev->pndev[i]);

	if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)
		mlx4_en_remove_timestamp(mdev);

	flush_workqueue(mdev->workqueue);
	destroy_workqueue(mdev->workqueue);
	(void) mlx4_mr_free(dev, &mdev->mr);
	iounmap(mdev->uar_map);
	mlx4_uar_free(dev, &mdev->priv_uar);
	mlx4_pd_free(dev, mdev->priv_pdn);
	if (mdev->nb.notifier_call)
		unregister_netdevice_notifier(&mdev->nb);
	kfree(mdev);
}
Beispiel #7
0
static void __exit vrf_cleanup_module(void)
{
	rtnl_link_unregister(&vrf_link_ops);
	unregister_netdevice_notifier(&vrf_notifier_block);
	kmem_cache_destroy(vrf_dst_ops.kmem_cachep);
	free_dst_ops6_kmem_cachep();
}
Beispiel #8
0
static void macvtap_exit(void)
{
	rtnl_link_unregister(&macvtap_link_ops);
	unregister_netdevice_notifier(&macvtap_notifier_block);
	class_unregister(&macvtap_class);
	tap_destroy_cdev(macvtap_major, &macvtap_cdev);
}
Beispiel #9
0
static int __init vlan_proto_init(void)
{
	int err;

	pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);

	err = register_pernet_subsys(&vlan_net_ops);
	if (err < 0)
		goto err0;

	err = register_netdevice_notifier(&vlan_notifier_block);
	if (err < 0)
		goto err2;

	err = vlan_gvrp_init();
	if (err < 0)
		goto err3;


	return 0;

err3:
	unregister_netdevice_notifier(&vlan_notifier_block);
err2:
	unregister_pernet_subsys(&vlan_net_ops);
err0:
	return err;
}
Beispiel #10
0
static void netdev_trig_deactivate(struct led_classdev *led_cdev)
{
	struct led_netdev_data *trigger_data = led_cdev->trigger_data;

	if (trigger_data) {
		unregister_netdevice_notifier(&trigger_data->notifier);

		device_remove_file(led_cdev->dev, &dev_attr_device_name);
		device_remove_file(led_cdev->dev, &dev_attr_mode);
		device_remove_file(led_cdev->dev, &dev_attr_interval);

		write_lock(&trigger_data->lock);

		if (trigger_data->net_dev) {
			dev_put(trigger_data->net_dev);
			trigger_data->net_dev = NULL;
		}

		write_unlock(&trigger_data->lock);

		del_timer_sync(&trigger_data->timer);

		kfree(trigger_data);
	}
}
Beispiel #11
0
static int macvtap_init(void)
{
	int err;

	err = tap_create_cdev(&macvtap_cdev, &macvtap_major, "macvtap");

	if (err)
		goto out1;

	err = class_register(&macvtap_class);
	if (err)
		goto out2;

	err = register_netdevice_notifier(&macvtap_notifier_block);
	if (err)
		goto out3;

	err = macvlan_link_register(&macvtap_link_ops);
	if (err)
		goto out4;

	return 0;

out4:
	unregister_netdevice_notifier(&macvtap_notifier_block);
out3:
	class_unregister(&macvtap_class);
out2:
	tap_destroy_cdev(macvtap_major, &macvtap_cdev);
out1:
	return err;
}
Beispiel #12
0
static int __init vlan_proto_init(void)
{
	int err;

	pr_info("%s v%s\n", vlan_fullname, vlan_version);

	err = register_pernet_subsys(&vlan_net_ops);
	if (err < 0)
		goto err0;

	err = register_netdevice_notifier(&vlan_notifier_block);
	if (err < 0)
		goto err2;

	err = vlan_gvrp_init();
	if (err < 0)
		goto err3;

	err = vlan_netlink_init();
	if (err < 0)
		goto err4;

	vlan_ioctl_set(vlan_ioctl_handler);
	return 0;

err4:
	vlan_gvrp_uninit();
err3:
	unregister_netdevice_notifier(&vlan_notifier_block);
err2:
	unregister_pernet_subsys(&vlan_net_ops);
err0:
	return err;
}
/*
 *     Module 'remove' entry point.
 *     o delete /proc/net/router directory and static entries.
 */ 
static void __exit vlan_cleanup_module(void)
{
	int i;

	/* This table must be empty if there are no module
	 * references left.
	 */
	for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) {
		if (vlan_group_hash[i] != NULL)
			BUG();
	}

	/* Un-register us from receiving netdevice events */
	unregister_netdevice_notifier(&vlan_notifier_block);

#ifdef CONFIG_VLAN_8021Q_FAST
	vlan_rx_hook = NULL;
	vlan_tx_hook = NULL;
#else
	dev_remove_pack(&vlan_packet_type);
#endif

	vlan_proc_cleanup();
	vlan_ioctl_hook = NULL;
}
Beispiel #14
0
static int __init br_netfilter_init(void)
{
	int ret;

	ret = register_pernet_subsys(&brnf_net_ops);
	if (ret < 0)
		return ret;

	ret = register_netdevice_notifier(&brnf_notifier);
	if (ret < 0) {
		unregister_pernet_subsys(&brnf_net_ops);
		return ret;
	}

#ifdef CONFIG_SYSCTL
	brnf_sysctl_header = register_net_sysctl(&init_net, "net/bridge", brnf_table);
	if (brnf_sysctl_header == NULL) {
		printk(KERN_WARNING
		       "br_netfilter: can't register to sysctl.\n");
		unregister_netdevice_notifier(&brnf_notifier);
		unregister_pernet_subsys(&brnf_net_ops);
		return -ENOMEM;
	}
#endif
	RCU_INIT_POINTER(nf_br_ops, &br_ops);
	printk(KERN_NOTICE "Bridge firewalling registered\n");
	return 0;
}
Beispiel #15
0
/* void */
int
ipsec_cleanup(void)
{
	int error = 0;

#ifdef CONFIG_SYSCTL
        ipsec_sysctl_unregister();
#endif                                                                          
	KLIPS_PRINT(debug_netlink, /* debug_tunnel & DB_TN_INIT, */
		    "klips_debug:ipsec_cleanup: "
		    "calling ipsec_tunnel_cleanup_devices.\n");
	error |= ipsec_tunnel_cleanup_devices();

	KLIPS_PRINT(debug_netlink, "called ipsec_tunnel_cleanup_devices");

/* we never actually link IPCOMP to the stack */
#ifdef IPCOMP_USED_ALONE
#ifdef CONFIG_IPSEC_IPCOMP
 	if (openswan_inet_del_protocol(&comp_protocol, IPPROTO_COMP) < 0)
		printk(KERN_INFO "klips_debug:ipsec_cleanup: "
		       "comp close: can't remove protocol\n");
#endif /* CONFIG_IPSEC_IPCOMP */
#endif /* IPCOMP_USED_ALONE */

#ifdef CONFIG_IPSEC_AH
 	if (openswan_inet_del_protocol(&ah_protocol, IPPROTO_AH) < 0)
		printk(KERN_INFO "klips_debug:ipsec_cleanup: "
		       "ah close: can't remove protocol\n");
#endif /* CONFIG_IPSEC_AH */

#ifdef CONFIG_IPSEC_ESP
 	if (openswan_inet_del_protocol(&esp_protocol, IPPROTO_ESP) < 0)
		printk(KERN_INFO "klips_debug:ipsec_cleanup: "
		       "esp close: can't remove protocol\n");
#endif /* CONFIG_IPSEC_ESP */

	error |= unregister_netdevice_notifier(&ipsec_dev_notifier);

	KLIPS_PRINT(debug_netlink, /* debug_tunnel & DB_TN_INIT, */
		    "klips_debug:ipsec_cleanup: "
		    "calling ipsec_sadb_cleanup.\n");
	error |= ipsec_sadb_cleanup(0);
	error |= ipsec_sadb_free();

	KLIPS_PRINT(debug_netlink, /* debug_tunnel & DB_TN_INIT, */
		    "klips_debug:ipsec_cleanup: "
		    "calling ipsec_radijcleanup.\n");
	error |= ipsec_radijcleanup();
	
	KLIPS_PRINT(debug_pfkey, /* debug_tunnel & DB_TN_INIT, */
		    "klips_debug:ipsec_cleanup: "
		    "calling pfkey_cleanup.\n");
	error |= pfkey_cleanup();

	ipsec_proc_cleanup();

	prng_final(&ipsec_prng);

	return error;
}
Beispiel #16
0
static void __exit asfctrl_exit(void)
{
	int ii;

	ASFCTRL_FUNC_ENTRY;


	if (g_cap.mode & fwMode)
		asfctrl_linux_unregister_ffp();

	asfctrl_sysfs_exit();


	/* Unregister the hook*/
	route_hook_fn_register(NULL);
#ifdef ASF_IPV6_FP_SUPPORT
	ipv6_route_hook_fn_register(NULL);
#endif
	//devfp_register_hook(NULL, NULL);
	devfp_deregister_rx_hook_veth();
	devfp_deregister_tx_hook_veth();
	unregister_netdevice_notifier(&asfctrl_dev_notifier);
	asfctrl_netns_vsg_deinit();

	for (ii = 0; ii < ASFCTRL_MAX_IFACES; ii++) {
		if (p_asfctrl_netdev_cii[ii])
			asfctrl_delete_dev_map(p_asfctrl_netdev_cii[ii]);
	}

	ASFRemove();

	ASFCTRL_INFO("ASF Control Module - Core Unloaded \n");
	ASFCTRL_FUNC_EXIT;
}
Beispiel #17
0
void
nm_os_ifnet_fini(void)
{
	if (nm_os_ifnet_registered) {
		unregister_netdevice_notifier(&linux_netmap_netdev_notifier);
		nm_os_ifnet_registered = 0;
	}
}
Beispiel #18
0
static void __exit ztdeth_exit(void)
{
	dahdi_dynamic_unregister_driver(&ztd_eth);
	unregister_netdevice_notifier(&ztdeth_nblock);
	dev_remove_pack(&ztdeth_ptype);

	skb_queue_purge(&skbs);
}
Beispiel #19
0
/**
 * rmnet_config_exit() - Cleans up all netlink related resources
 */
void rmnet_config_exit(void)
{
	int rc;
	netlink_kernel_release(nl_socket_handle);
	rc = unregister_netdevice_notifier(&rmnet_dev_notifier);
	if (rc != 0)
		LOGE("Failed to unregister device notifier; rc=%d", rc);
}
Beispiel #20
0
static void __exit send_garp_exit(void)
{
	unregister_netdevice_notifier(&nb_dev);

	if (debug == 1)
		printk(KERN_INFO "send_garp module unloaded\n");

}
Beispiel #21
0
static void __exit br_netfilter_fini(void)
{
	RCU_INIT_POINTER(nf_br_ops, NULL);
	unregister_netdevice_notifier(&brnf_notifier);
	unregister_pernet_subsys(&brnf_net_ops);
#ifdef CONFIG_SYSCTL
	unregister_net_sysctl_table(brnf_sysctl_header);
#endif
}
Beispiel #22
0
/**
 * tipc_ib_media_stop - deactivate InfiniBand bearer support
 */
void tipc_ib_media_stop(void)
{
    if (!ib_started)
        return;

    flush_scheduled_work();
    unregister_netdevice_notifier(&notifier);
    ib_started = 0;
}
Beispiel #23
0
static void __exit vti_fini(void)
{
	rtnl_link_unregister(&vti_link_ops);
	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);
	unregister_netdevice_notifier(&vti_notifier_block);
}
Beispiel #24
0
Datei: main.c Projekt: krzk/linux
static void nfp_flower_stop(struct nfp_app *app)
{
	struct nfp_flower_priv *app_priv = app->priv;

	if (app_priv->flower_ext_feats & NFP_FL_FEATS_LAG)
		unregister_netdevice_notifier(&app_priv->nfp_lag.lag_nb);

	nfp_tunnel_config_stop(app);
}
static void __exit br_deinit(void)
{
	unregister_netdevice_notifier(&br_device_notifier);
	br_call_ioctl_atomic(__br_clear_ioctl_hook);
	net_call_rx_atomic(__br_clear_frame_hook);
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
	br_fdb_get_hook = NULL;
	br_fdb_put_hook = NULL;
#endif
}
Beispiel #26
0
void __exit vlan_proto_exit(void)
{

	unregister_netdevice_notifier(&vlan_notifier_block);

	unregister_pernet_subsys(&vlan_net_ops);
	rcu_barrier(); /* Wait for completion of call_rcu()'s */

	vlan_gvrp_uninit();
}
Beispiel #27
0
void cleanup_module(void)
{
	extern struct atm_mpoa_ops atm_mpoa_ops;
	struct mpoa_client *mpc, *tmp;
	struct atm_mpoa_qos *qos, *nextqos;
	struct lec_priv *priv;

	if (MOD_IN_USE) {
		printk("mpc.c: module in use\n");
		return;
	}
#ifdef CONFIG_PROC_FS
	mpc_proc_clean();
#endif

	del_timer(&mpc_timer);
	unregister_netdevice_notifier(&mpoa_notifier);
	atm_mpoa_ops.mpoad_attach = NULL;
	atm_mpoa_ops.vcc_attach = NULL;

	mpc = mpcs;
	mpcs = NULL;
	while (mpc != NULL) {
		tmp = mpc->next;
		if (mpc->dev != NULL) {
			stop_mpc(mpc);
			priv = (struct lec_priv *)mpc->dev->priv;
			if (priv->lane2_ops != NULL)
				priv->lane2_ops->associate_indicator = NULL;
		}
		ddprintk("mpoa: cleanup_module: about to clear caches\n");
		mpc->in_ops->destroy_cache(mpc);
		mpc->eg_ops->destroy_cache(mpc);
		ddprintk("mpoa: cleanup_module: caches cleared\n");
		kfree(mpc->mps_macs);
		memset(mpc, 0, sizeof(struct mpoa_client));
		ddprintk("mpoa: cleanup_module: about to kfree %p\n", mpc);
		kfree(mpc);
		ddprintk("mpoa: cleanup_module: next mpc is at %p\n", tmp);
		mpc = tmp;
	}

	qos = qos_head;
	qos_head = NULL;
	while (qos != NULL) {
		nextqos = qos->next;
		dprintk("mpoa: cleanup_module: freeing qos entry %p\n", qos);
		kfree(qos);
		qos = nextqos;
	}

	return;
}
Beispiel #28
0
static void __exit vlan_cleanup_module(void)
{
	vlan_ioctl_set(NULL);
	vlan_netlink_fini();

	unregister_netdevice_notifier(&vlan_notifier_block);

	unregister_pernet_subsys(&vlan_net_ops);
	rcu_barrier(); /* Wait for completion of call_rcu()'s */

	vlan_gvrp_uninit();
}
Beispiel #29
0
static int __init br_init(void)
{
	int err;

	err = stp_proto_register(&br_stp_proto);
	if (err < 0) {
		printk(KERN_ERR "bridge: can't register sap for STP\n");
		return err;
	}

	err = br_fdb_init();
	if (err)
		goto err_out;

	err = register_pernet_subsys(&br_net_ops);
	if (err)
		goto err_out1;

	err = br_netfilter_init();
	if (err)
		goto err_out2;

	err = register_netdevice_notifier(&br_device_notifier);
	if (err)
		goto err_out3;

	err = br_netlink_init();
	if (err)
		goto err_out4;

	get_ve0()->features |= VE_FEATURE_BRIDGE;

	brioctl_set(br_ioctl_deviceless_stub);
	br_handle_frame_hook = br_handle_frame;
	br_hard_xmit_hook = br_xmit;

#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
	br_fdb_test_addr_hook = br_fdb_test_addr;
#endif

	return 0;
err_out4:
	unregister_netdevice_notifier(&br_device_notifier);
err_out3:
	br_netfilter_fini();
err_out2:
	unregister_pernet_subsys(&br_net_ops);
err_out1:
	br_fdb_fini();
err_out:
	stp_proto_unregister(&br_stp_proto);
	return err;
}
Beispiel #30
0
static int __init br_init(void)
{
	int err;

	err = stp_proto_register(&br_stp_proto);
	if (err < 0) {
		pr_err("bridge: can't register sap for STP\n");
		return err;
	}

	err = br_fdb_init();
	if (err)
		goto err_out;

	err = register_pernet_subsys(&br_net_ops);
	if (err)
		goto err_out1;

	err = br_netfilter_init();
	if (err)
		goto err_out2;

	err = register_netdevice_notifier(&br_device_notifier);
	if (err)
		goto err_out3;

	err = br_netlink_init();
	if (err)
		goto err_out4;

	brioctl_set(br_ioctl_deviceless_stub);

#if defined(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) || defined(CONFIG_NETFILTER_XT_MATCH_PHYSDEV_MODULE)
	br_fdb_get_port_hook = br_fdb_get_port;
#endif
#if IS_ENABLED(CONFIG_ATM_LANE)
	br_fdb_test_addr_hook = br_fdb_test_addr;
#endif

	return 0;
err_out4:
	unregister_netdevice_notifier(&br_device_notifier);
err_out3:
	br_netfilter_fini();
err_out2:
	unregister_pernet_subsys(&br_net_ops);
err_out1:
	br_fdb_fini();
err_out:
	stp_proto_unregister(&br_stp_proto);
	return err;
}