2 * net/ipv4/sysfs_net_ipv4.c
4 * sysfs-based networking knobs (so we can, unlike with sysctl, control perms)
6 * Copyright (C) 2008 Google, Inc.
8 * Robert Love <rlove@google.com>
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/kobject.h>
21 #include <linux/string.h>
22 #include <linux/sysfs.h>
23 #include <linux/init.h>
26 #define CREATE_IPV4_FILE(_name, _var) \
27 static ssize_t _name##_show(struct kobject *kobj, \
28 struct kobj_attribute *attr, char *buf) \
30 return sprintf(buf, "%d\n", _var); \
32 static ssize_t _name##_store(struct kobject *kobj, \
33 struct kobj_attribute *attr, \
34 const char *buf, size_t count) \
37 ret = sscanf(buf, "%d", &val); \
45 static struct kobj_attribute _name##_attr = \
46 __ATTR(_name, 0644, _name##_show, _name##_store)
48 CREATE_IPV4_FILE(tcp_wmem_min, sysctl_tcp_wmem[0]);
49 CREATE_IPV4_FILE(tcp_wmem_def, sysctl_tcp_wmem[1]);
50 CREATE_IPV4_FILE(tcp_wmem_max, sysctl_tcp_wmem[2]);
52 CREATE_IPV4_FILE(tcp_rmem_min, sysctl_tcp_rmem[0]);
53 CREATE_IPV4_FILE(tcp_rmem_def, sysctl_tcp_rmem[1]);
54 CREATE_IPV4_FILE(tcp_rmem_max, sysctl_tcp_rmem[2]);
56 static struct attribute *ipv4_attrs[] = {
57 &tcp_wmem_min_attr.attr,
58 &tcp_wmem_def_attr.attr,
59 &tcp_wmem_max_attr.attr,
60 &tcp_rmem_min_attr.attr,
61 &tcp_rmem_def_attr.attr,
62 &tcp_rmem_max_attr.attr,
66 static struct attribute_group ipv4_attr_group = {
70 static __init int sysfs_ipv4_init(void)
72 struct kobject *ipv4_kobject;
75 ipv4_kobject = kobject_create_and_add("ipv4", kernel_kobj);
79 ret = sysfs_create_group(ipv4_kobject, &ipv4_attr_group);
81 kobject_put(ipv4_kobject);
88 subsys_initcall(sysfs_ipv4_init);