[rdc] remove empty subtargets directories
[openwrt.git] / target / linux / goldfish / patches-2.6.30 / 0082-sysfs_net_ipv4-Add-sysfs-based-knobs-for-controllin.patch
1 From 75090d40ffbd9b4863238e1d62b43f8598da5e5e Mon Sep 17 00:00:00 2001
2 From: Robert Love <rlove@google.com>
3 Date: Thu, 31 Jul 2008 11:12:44 -0400
4 Subject: [PATCH 082/134] sysfs_net_ipv4: Add sysfs-based knobs for controlling TCP window size
5
6 Add a family of knobs to /sys/kernel/ipv4 for controlling the TCP window size:
7
8 tcp_wmem_min
9 tcp_wmem_def
10 tcp_wmem_max
11 tcp_rmem_min
12 tcp_rmem_def
13 tcp_rmem_max
14
15 This six values mirror the sysctl knobs in /proc/sys/net/ipv4/tcp_wmem and
16 /proc/sys/net/ipv4/tcp_rmem.
17
18 Sysfs, unlike sysctl, allows us to set and manage the files' permissions and
19 owners.
20
21 Signed-off-by: Robert Love <rlove@google.com>
22 ---
23 net/ipv4/Makefile | 1 +
24 net/ipv4/sysfs_net_ipv4.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
25 2 files changed, 89 insertions(+), 0 deletions(-)
26 create mode 100644 net/ipv4/sysfs_net_ipv4.c
27
28 --- a/net/ipv4/Makefile
29 +++ b/net/ipv4/Makefile
30 @@ -14,6 +14,7 @@ obj-y := route.o inetpeer.o protocol
31 inet_fragment.o
32
33 obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
34 +obj-$(CONFIG_SYSFS) += sysfs_net_ipv4.o
35 obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
36 obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
37 obj-$(CONFIG_PROC_FS) += proc.o
38 --- /dev/null
39 +++ b/net/ipv4/sysfs_net_ipv4.c
40 @@ -0,0 +1,88 @@
41 +/*
42 + * net/ipv4/sysfs_net_ipv4.c
43 + *
44 + * sysfs-based networking knobs (so we can, unlike with sysctl, control perms)
45 + *
46 + * Copyright (C) 2008 Google, Inc.
47 + *
48 + * Robert Love <rlove@google.com>
49 + *
50 + * This software is licensed under the terms of the GNU General Public
51 + * License version 2, as published by the Free Software Foundation, and
52 + * may be copied, distributed, and modified under those terms.
53 + *
54 + * This program is distributed in the hope that it will be useful,
55 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 + * GNU General Public License for more details.
58 + */
59 +
60 +#include <linux/kobject.h>
61 +#include <linux/string.h>
62 +#include <linux/sysfs.h>
63 +#include <linux/init.h>
64 +#include <net/tcp.h>
65 +
66 +#define CREATE_IPV4_FILE(_name, _var) \
67 +static ssize_t _name##_show(struct kobject *kobj, \
68 + struct kobj_attribute *attr, char *buf) \
69 +{ \
70 + return sprintf(buf, "%d\n", _var); \
71 +} \
72 +static ssize_t _name##_store(struct kobject *kobj, \
73 + struct kobj_attribute *attr, \
74 + const char *buf, size_t count) \
75 +{ \
76 + int val, ret; \
77 + ret = sscanf(buf, "%d", &val); \
78 + if (ret != 1) \
79 + return -EINVAL; \
80 + if (val < 0) \
81 + return -EINVAL; \
82 + _var = val; \
83 + return count; \
84 +} \
85 +static struct kobj_attribute _name##_attr = \
86 + __ATTR(_name, 0644, _name##_show, _name##_store)
87 +
88 +CREATE_IPV4_FILE(tcp_wmem_min, sysctl_tcp_wmem[0]);
89 +CREATE_IPV4_FILE(tcp_wmem_def, sysctl_tcp_wmem[1]);
90 +CREATE_IPV4_FILE(tcp_wmem_max, sysctl_tcp_wmem[2]);
91 +
92 +CREATE_IPV4_FILE(tcp_rmem_min, sysctl_tcp_rmem[0]);
93 +CREATE_IPV4_FILE(tcp_rmem_def, sysctl_tcp_rmem[1]);
94 +CREATE_IPV4_FILE(tcp_rmem_max, sysctl_tcp_rmem[2]);
95 +
96 +static struct attribute *ipv4_attrs[] = {
97 + &tcp_wmem_min_attr.attr,
98 + &tcp_wmem_def_attr.attr,
99 + &tcp_wmem_max_attr.attr,
100 + &tcp_rmem_min_attr.attr,
101 + &tcp_rmem_def_attr.attr,
102 + &tcp_rmem_max_attr.attr,
103 + NULL
104 +};
105 +
106 +static struct attribute_group ipv4_attr_group = {
107 + .attrs = ipv4_attrs,
108 +};
109 +
110 +static __init int sysfs_ipv4_init(void)
111 +{
112 + struct kobject *ipv4_kobject;
113 + int ret;
114 +
115 + ipv4_kobject = kobject_create_and_add("ipv4", kernel_kobj);
116 + if (!ipv4_kobject)
117 + return -ENOMEM;
118 +
119 + ret = sysfs_create_group(ipv4_kobject, &ipv4_attr_group);
120 + if (ret) {
121 + kobject_put(ipv4_kobject);
122 + return ret;
123 + }
124 +
125 + return 0;
126 +}
127 +
128 +subsys_initcall(sysfs_ipv4_init);
This page took 0.045332 seconds and 5 git commands to generate.