aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2012-11-01 05:10:04 -0400
committerDavid S. Miller <davem@davemloft.net>2012-11-02 21:34:05 -0400
commit4197f24b5bd8be03e84d23920e90f6a1313f4b79 (patch)
tree47e398311668cb2f9d1b45b1f7dec205e31ffba1 /net/bridge
parent3ba368c43565f31528b3aea585bb4119fded4eb1 (diff)
bridge: Use is_link_local() in store_group_addr()
Parse the string into an array of bytes rather than ints, so we can use is_link_local() rather than reimplementing it. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/br_sysfs_br.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index e157b0dbcd82..82385fd2f187 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -298,23 +298,18 @@ static ssize_t store_group_addr(struct device *d,
298 const char *buf, size_t len) 298 const char *buf, size_t len)
299{ 299{
300 struct net_bridge *br = to_bridge(d); 300 struct net_bridge *br = to_bridge(d);
301 unsigned int new_addr[6]; 301 u8 new_addr[6];
302 int i; 302 int i;
303 303
304 if (!capable(CAP_NET_ADMIN)) 304 if (!capable(CAP_NET_ADMIN))
305 return -EPERM; 305 return -EPERM;
306 306
307 if (sscanf(buf, "%x:%x:%x:%x:%x:%x", 307 if (sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
308 &new_addr[0], &new_addr[1], &new_addr[2], 308 &new_addr[0], &new_addr[1], &new_addr[2],
309 &new_addr[3], &new_addr[4], &new_addr[5]) != 6) 309 &new_addr[3], &new_addr[4], &new_addr[5]) != 6)
310 return -EINVAL; 310 return -EINVAL;
311 311
312 /* Must be 01:80:c2:00:00:0X */ 312 if (!is_link_local(new_addr))
313 for (i = 0; i < 5; i++)
314 if (new_addr[i] != br_reserved_address[i])
315 return -EINVAL;
316
317 if (new_addr[5] & ~0xf)
318 return -EINVAL; 313 return -EINVAL;
319 314
320 if (new_addr[5] == 1 || /* 802.3x Pause address */ 315 if (new_addr[5] == 1 || /* 802.3x Pause address */