diff options
author | Stefan Rompf <stefan@loplof.de> | 2006-03-20 20:09:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-20 20:09:11 -0500 |
commit | b00055aacdb172c05067612278ba27265fcd05ce (patch) | |
tree | 4dbbee11b02d54cc0978113dfb07c53fdce17aa8 /net/core/net-sysfs.c | |
parent | e843b9e1bec4a953d848a319da6a18ca5c667f55 (diff) |
[NET] core: add RFC2863 operstate
this patch adds a dormant flag to network devices, RFC2863 operstate derived
from these flags and possibility for userspace interaction. It allows drivers
to signal that a device is unusable for user traffic without disabling
queueing (and therefore the possibility for protocol establishment traffic to
flow) and a userspace supplicant (WPA, 802.1X) to mark a device unusable
without changes to the driver.
It is the result of our long discussion. However I must admit that it
represents what Jamal and I agreed on with compromises towards Krzysztof, but
Thomas and Krzysztof still disagree with some parts. Anyway I think it should
be applied.
Signed-off-by: Stefan Rompf <stefan@loplof.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r-- | net/core/net-sysfs.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index e8b2acbc8ea2..21b68464cabb 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -91,6 +91,7 @@ NETDEVICE_SHOW(iflink, fmt_dec); | |||
91 | NETDEVICE_SHOW(ifindex, fmt_dec); | 91 | NETDEVICE_SHOW(ifindex, fmt_dec); |
92 | NETDEVICE_SHOW(features, fmt_long_hex); | 92 | NETDEVICE_SHOW(features, fmt_long_hex); |
93 | NETDEVICE_SHOW(type, fmt_dec); | 93 | NETDEVICE_SHOW(type, fmt_dec); |
94 | NETDEVICE_SHOW(link_mode, fmt_dec); | ||
94 | 95 | ||
95 | /* use same locking rules as GIFHWADDR ioctl's */ | 96 | /* use same locking rules as GIFHWADDR ioctl's */ |
96 | static ssize_t format_addr(char *buf, const unsigned char *addr, int len) | 97 | static ssize_t format_addr(char *buf, const unsigned char *addr, int len) |
@@ -133,6 +134,43 @@ static ssize_t show_carrier(struct class_device *dev, char *buf) | |||
133 | return -EINVAL; | 134 | return -EINVAL; |
134 | } | 135 | } |
135 | 136 | ||
137 | static ssize_t show_dormant(struct class_device *dev, char *buf) | ||
138 | { | ||
139 | struct net_device *netdev = to_net_dev(dev); | ||
140 | |||
141 | if (netif_running(netdev)) | ||
142 | return sprintf(buf, fmt_dec, !!netif_dormant(netdev)); | ||
143 | |||
144 | return -EINVAL; | ||
145 | } | ||
146 | |||
147 | static const char *operstates[] = { | ||
148 | "unknown", | ||
149 | "notpresent", /* currently unused */ | ||
150 | "down", | ||
151 | "lowerlayerdown", | ||
152 | "testing", /* currently unused */ | ||
153 | "dormant", | ||
154 | "up" | ||
155 | }; | ||
156 | |||
157 | static ssize_t show_operstate(struct class_device *dev, char *buf) | ||
158 | { | ||
159 | const struct net_device *netdev = to_net_dev(dev); | ||
160 | unsigned char operstate; | ||
161 | |||
162 | read_lock(&dev_base_lock); | ||
163 | operstate = netdev->operstate; | ||
164 | if (!netif_running(netdev)) | ||
165 | operstate = IF_OPER_DOWN; | ||
166 | read_unlock(&dev_base_lock); | ||
167 | |||
168 | if (operstate >= sizeof(operstates)) | ||
169 | return -EINVAL; /* should not happen */ | ||
170 | |||
171 | return sprintf(buf, "%s\n", operstates[operstate]); | ||
172 | } | ||
173 | |||
136 | /* read-write attributes */ | 174 | /* read-write attributes */ |
137 | NETDEVICE_SHOW(mtu, fmt_dec); | 175 | NETDEVICE_SHOW(mtu, fmt_dec); |
138 | 176 | ||
@@ -190,9 +228,12 @@ static struct class_device_attribute net_class_attributes[] = { | |||
190 | __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), | 228 | __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), |
191 | __ATTR(features, S_IRUGO, show_features, NULL), | 229 | __ATTR(features, S_IRUGO, show_features, NULL), |
192 | __ATTR(type, S_IRUGO, show_type, NULL), | 230 | __ATTR(type, S_IRUGO, show_type, NULL), |
231 | __ATTR(link_mode, S_IRUGO, show_link_mode, NULL), | ||
193 | __ATTR(address, S_IRUGO, show_address, NULL), | 232 | __ATTR(address, S_IRUGO, show_address, NULL), |
194 | __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), | 233 | __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), |
195 | __ATTR(carrier, S_IRUGO, show_carrier, NULL), | 234 | __ATTR(carrier, S_IRUGO, show_carrier, NULL), |
235 | __ATTR(dormant, S_IRUGO, show_dormant, NULL), | ||
236 | __ATTR(operstate, S_IRUGO, show_operstate, NULL), | ||
196 | __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), | 237 | __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), |
197 | __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), | 238 | __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), |
198 | __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, | 239 | __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, |