Пример #1
0
static __init int sysctl_ipv4_init(void)
{
	struct ctl_table_header *hdr;

	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
	if (!hdr)
		return -ENOMEM;

	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
		unregister_net_sysctl_table(hdr);
		return -ENOMEM;
	}

	return 0;
}
Пример #2
0
int ipv6_sysctl_register(void)
{
	int err = -ENOMEM;

	ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable);
	if (!ip6_header)
		goto out;

	err = register_pernet_subsys(&ipv6_sysctl_net_ops);
	if (err)
		goto err_pernet;
out:
	return err;

err_pernet:
	unregister_net_sysctl_table(ip6_header);
	goto out;
}
Пример #3
0
int sctp_sysctl_net_register(struct net *net)
{
	struct ctl_table *table;
	int i;

	table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
	if (!table)
		return -ENOMEM;

	for (i = 0; table[i].data; i++)
		table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;

	net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
	if (net->sctp.sysctl_header == NULL) {
		kfree(table);
		return -ENOMEM;
	}
	return 0;
}
Пример #4
0
static int netfilter_log_sysctl_init(struct net *net)
{
	int i;
	struct ctl_table *table;

	table = nf_log_sysctl_table;
	if (!net_eq(net, &init_net)) {
		table = kmemdup(nf_log_sysctl_table,
				 sizeof(nf_log_sysctl_table),
				 GFP_KERNEL);
		if (!table)
			goto err_alloc;
	} else {
		for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) {
			snprintf(nf_log_sysctl_fnames[i],
				 3, "%d", i);
			nf_log_sysctl_table[i].procname	=
				nf_log_sysctl_fnames[i];
			nf_log_sysctl_table[i].data = NULL;
			nf_log_sysctl_table[i].maxlen = NFLOGGER_NAME_LEN;
			nf_log_sysctl_table[i].mode = 0644;
			nf_log_sysctl_table[i].proc_handler =
				nf_log_proc_dostring;
			nf_log_sysctl_table[i].extra1 =
				(void *)(unsigned long) i;
		}
	}

	net->nf.nf_log_dir_header = register_net_sysctl(net,
						"net/netfilter/nf_log",
						table);
	if (!net->nf.nf_log_dir_header)
		goto err_reg;

	return 0;

err_reg:
	if (!net_eq(net, &init_net))
		kfree(table);
err_alloc:
	return -ENOMEM;
}
int __net_init unix_sysctl_register(struct net *net)
{
	struct ctl_table *table;

	table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
	if (table == NULL)
		goto err_alloc;

	table[0].data = &net->unx.sysctl_max_dgram_qlen;
	net->unx.ctl = register_net_sysctl(net, "net/unix", table);
	if (net->unx.ctl == NULL)
		goto err_reg;

	return 0;

err_reg:
	kfree(table);
err_alloc:
	return -ENOMEM;
}
Пример #6
0
static int __init br_netfilter_init(void)
{
	int ret;

	ret = nf_register_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
	if (ret < 0)
		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");
		nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
		return -ENOMEM;
	}
#endif
	printk(KERN_NOTICE "Bridge firewalling registered\n");
	return 0;
}
static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
{
	struct ctl_table *table;
	struct ctl_table_header *hdr;
	struct netns_ieee802154_lowpan *ieee802154_lowpan =
		net_ieee802154_lowpan(net);

	table = lowpan_frags_ns_ctl_table;
	if (!net_eq(net, &init_net)) {
		table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
				GFP_KERNEL);
		if (table == NULL)
			goto err_alloc;

		table[0].data = &ieee802154_lowpan->frags.high_thresh;
		table[0].extra1 = &ieee802154_lowpan->frags.low_thresh;
		table[0].extra2 = &init_net.ieee802154_lowpan.frags.high_thresh;
		table[1].data = &ieee802154_lowpan->frags.low_thresh;
		table[1].extra2 = &ieee802154_lowpan->frags.high_thresh;
		table[2].data = &ieee802154_lowpan->frags.timeout;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
		/* Don't export sysctls to unprivileged users */
		if (net->user_ns != &init_user_ns)
			table[0].procname = NULL;
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,8,0) */
	}

	hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
	if (hdr == NULL)
		goto err_reg;

	ieee802154_lowpan->sysctl.frags_hdr = hdr;
	return 0;

err_reg:
	if (!net_eq(net, &init_net))
		kfree(table);
err_alloc:
	return -ENOMEM;
}
Пример #8
0
void __init xfrm4_init(int rt_max_size)
{
	/*
	 * Select a default value for the gc_thresh based on the main route
	 * table hash size.  It seems to me the worst case scenario is when
	 * we have ipsec operating in transport mode, in which we create a
	 * dst_entry per socket.  The xfrm gc algorithm starts trying to remove
	 * entries at gc_thresh, and prevents new allocations as 2*gc_thresh
	 * so lets set an initial xfrm gc_thresh value at the rt_max_size/2.
	 * That will let us store an ipsec connection per route table entry,
	 * and start cleaning when were 1/2 full
	 */
	xfrm4_dst_ops.gc_thresh = rt_max_size/2;
	dst_entries_init(&xfrm4_dst_ops);

	xfrm4_state_init();
	xfrm4_policy_init();
#ifdef CONFIG_SYSCTL
	sysctl_hdr = register_net_sysctl(&init_net, "net/ipv4",
					 xfrm4_policy_table);
#endif
}
Пример #9
0
static __net_init int ipv4_sysctl_init_net(struct net *net)
{
    struct ctl_table *table;

    table = ipv4_net_table;
    if (!net_eq(net, &init_net)) {
        int i;

        table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
        if (!table)
            goto err_alloc;

        /* Update the variables to point into the current struct net */
        for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
            table[i].data += (void *)net - (void *)&init_net;
    }

    net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
    if (!net->ipv4.ipv4_hdr)
        goto err_reg;

    net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
    if (!net->ipv4.sysctl_local_reserved_ports)
        goto err_ports;

    net->ipv4.sysctl_ip_default_ttl = IPDEFTTL;
    net->ipv4.sysctl_ip_dynaddr = 0;
    net->ipv4.sysctl_ip_early_demux = 1;

    return 0;

err_ports:
    unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
err_reg:
    if (!net_eq(net, &init_net))
        kfree(table);
err_alloc:
    return -ENOMEM;
}
Пример #10
0
static __net_init int dccp_net_init(struct net *net)
{
	struct dccp_net *dn = dccp_pernet(net);

	/* default values */
	dn->dccp_loose = 1;
	dn->dccp_timeout[CT_DCCP_REQUEST]	= 2 * DCCP_MSL;
	dn->dccp_timeout[CT_DCCP_RESPOND]	= 4 * DCCP_MSL;
	dn->dccp_timeout[CT_DCCP_PARTOPEN]	= 4 * DCCP_MSL;
	dn->dccp_timeout[CT_DCCP_OPEN]		= 12 * 3600 * HZ;
	dn->dccp_timeout[CT_DCCP_CLOSEREQ]	= 64 * HZ;
	dn->dccp_timeout[CT_DCCP_CLOSING]	= 64 * HZ;
	dn->dccp_timeout[CT_DCCP_TIMEWAIT]	= 2 * DCCP_MSL;

#ifdef CONFIG_SYSCTL
	dn->sysctl_table = kmemdup(dccp_sysctl_table,
			sizeof(dccp_sysctl_table), GFP_KERNEL);
	if (!dn->sysctl_table)
		return -ENOMEM;

	dn->sysctl_table[0].data = &dn->dccp_timeout[CT_DCCP_REQUEST];
	dn->sysctl_table[1].data = &dn->dccp_timeout[CT_DCCP_RESPOND];
	dn->sysctl_table[2].data = &dn->dccp_timeout[CT_DCCP_PARTOPEN];
	dn->sysctl_table[3].data = &dn->dccp_timeout[CT_DCCP_OPEN];
	dn->sysctl_table[4].data = &dn->dccp_timeout[CT_DCCP_CLOSEREQ];
	dn->sysctl_table[5].data = &dn->dccp_timeout[CT_DCCP_CLOSING];
	dn->sysctl_table[6].data = &dn->dccp_timeout[CT_DCCP_TIMEWAIT];
	dn->sysctl_table[7].data = &dn->dccp_loose;

	dn->sysctl_header = register_net_sysctl(net, "net/netfilter",
						dn->sysctl_table);
	if (!dn->sysctl_header) {
		kfree(dn->sysctl_table);
		return -ENOMEM;
	}
#endif

	return 0;
}
Пример #11
0
static int __net_init ip4_frags_ns_ctl_register(struct net *net)
{
	struct ctl_table *table;
	struct ctl_table_header *hdr;

	table = ip4_frags_ns_ctl_table;
	if (!net_eq(net, &init_net)) {
		table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
		if (!table)
			goto err_alloc;

		table[0].data = &net->ipv4.frags.high_thresh;
		table[0].extra1 = &net->ipv4.frags.low_thresh;
		table[0].extra2 = &init_net.ipv4.frags.high_thresh;
		table[1].data = &net->ipv4.frags.low_thresh;
		table[1].extra2 = &net->ipv4.frags.high_thresh;
		table[2].data = &net->ipv4.frags.timeout;

		/* Don't export sysctls to unprivileged users */
		if (net->user_ns != &init_user_ns)
			table[0].procname = NULL;
	}

	hdr = register_net_sysctl(net, "net/ipv4", table);
	if (!hdr)
		goto err_reg;

	net->ipv4.frags_hdr = hdr;
	return 0;

err_reg:
	if (!net_eq(net, &init_net))
		kfree(table);
err_alloc:
	return -ENOMEM;
}
Пример #12
0
int __net_init unix_sysctl_register(struct net *net)
{
	ctl_table_no_const *table;

	table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
	if (table == NULL)
		goto err_alloc;

	/* Don't export sysctls to unprivileged users */
	if (net->user_ns != &init_user_ns)
		table[0].procname = NULL;

	table[0].data = &net->unx.sysctl_max_dgram_qlen;
	net->unx.ctl = register_net_sysctl(net, "net/unix", table);
	if (net->unx.ctl == NULL)
		goto err_reg;

	return 0;

err_reg:
	kfree(table);
err_alloc:
	return -ENOMEM;
}
static int nf_conntrack_tstamp_init_sysctl(struct net *net)
{
	struct ctl_table *table;

	table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
			GFP_KERNEL);
	if (!table)
		goto out;

	table[0].data = &net->ct.sysctl_tstamp;

	net->ct.tstamp_sysctl_header = register_net_sysctl(net,	"net/netfilter",
							   table);
	if (!net->ct.tstamp_sysctl_header) {
		printk(KERN_ERR "nf_ct_tstamp: can't register to sysctl.\n");
		goto out_register;
	}
	return 0;

out_register:
	kfree(table);
out:
	return -ENOMEM;
}
Пример #14
0
void __init x25_register_sysctl(void)
{
	x25_table_header = register_net_sysctl(&init_net, "net/x25", x25_table);
}
Пример #15
0
void __init nr_register_sysctl(void)
{
    nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table);
}
Пример #16
0
static __net_init int ipv4_sysctl_init_net(struct net *net)
{
    struct ctl_table *table;

    table = ipv4_net_table;
    if (!net_eq(net, &init_net)) {
        table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
        if (table == NULL)
            goto err_alloc;

        table[0].data =
            &net->ipv4.sysctl_icmp_echo_ignore_all;
        table[1].data =
            &net->ipv4.sysctl_icmp_echo_ignore_broadcasts;
        table[2].data =
            &net->ipv4.sysctl_icmp_ignore_bogus_error_responses;
        table[3].data =
            &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr;
        table[4].data =
            &net->ipv4.sysctl_icmp_ratelimit;
        table[5].data =
            &net->ipv4.sysctl_icmp_ratemask;
        table[6].data =
            &net->ipv4.sysctl_ping_group_range;
        table[7].data =
            &net->ipv4.sysctl_tcp_ecn;
        table[8].data =
            &net->ipv4_sysctl_local_ports.range;

        /* Don't export sysctls to unprivileged users */
        if (net->user_ns != &init_user_ns)
            table[0].procname = NULL;
    }

    /*
     * Sane defaults - nobody may create ping sockets.
     * Boot scripts should set this to distro-specific group.
     */
    net->ipv4.sysctl_ping_group_range[0] = make_kgid(&init_user_ns, 1);
    net->ipv4.sysctl_ping_group_range[1] = make_kgid(&init_user_ns, 0);

    /*
     * Set defaults for local port range
     */
    seqlock_init(&net->ipv4_sysctl_local_ports.lock);
    net->ipv4_sysctl_local_ports.range[0] =  32768;
    net->ipv4_sysctl_local_ports.range[1] =  61000;

    tcp_init_mem(net);

    net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
    if (net->ipv4.ipv4_hdr == NULL)
        goto err_reg;

    return 0;

err_reg:
    if (!net_eq(net, &init_net))
        kfree(table);
err_alloc:
    return -ENOMEM;
}
void __init rose_register_sysctl(void)
{
	rose_table_header = register_net_sysctl(&init_net, "net/rose", rose_table);
}
Пример #18
0
void dn_register_sysctl(void)
{
	dn_table_header = register_net_sysctl(&init_net, "net/decnet", dn_table);
}
Пример #19
0
/* Sysctl registration.  */
void sctp_sysctl_register(void)
{
	sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
}
Пример #20
0
int __init phonet_sysctl_init(void)
{
	phonet_table_hrd = register_net_sysctl(&init_net, "net/phonet", phonet_table);
	return phonet_table_hrd == NULL ? -ENOMEM : 0;
}
Пример #21
0
static void ip4_frags_ctl_register(void)
{
	register_net_sysctl(&init_net, "net/ipv4", ip4_frags_ctl_table);
}
static __init int sysctl_core_init(void)
{
	register_net_sysctl(&init_net, "net/core", net_core_table);
	return register_pernet_subsys(&sysctl_core_ops);
}
Пример #23
0
static int ip6_frags_sysctl_register(void)
{
	ip6_ctl_header = register_net_sysctl(&init_net, "net/ipv6",
			ip6_frags_ctl_table);
	return ip6_ctl_header == NULL ? -ENOMEM : 0;
}