diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-04-10 23:10:33 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:09 -0400 |
commit | e71a4783aae059931f63b2d4e7013e36529badef (patch) | |
tree | d9c2bad69b8d0512e12c8ff786237319990fbd00 /net | |
parent | add459aa1afe05472abc96f6a29aefd0c84e73d6 (diff) |
[NET] core: whitespace cleanup
Fix whitespace around keywords. Fix indentation especially of switch
statements.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/compat.c | 30 | ||||
-rw-r--r-- | net/core/ethtool.c | 4 | ||||
-rw-r--r-- | net/core/net-sysfs.c | 4 | ||||
-rw-r--r-- | net/core/pktgen.c | 16 | ||||
-rw-r--r-- | net/core/sock.c | 712 | ||||
-rw-r--r-- | net/core/wireless.c | 297 | ||||
-rw-r--r-- | net/socket.c | 2 |
7 files changed, 530 insertions, 535 deletions
diff --git a/net/compat.c b/net/compat.c index 2fc6d9bb622b..0e407563ae85 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -34,11 +34,11 @@ static inline int iov_from_user_compat_to_kern(struct iovec *kiov, | |||
34 | { | 34 | { |
35 | int tot_len = 0; | 35 | int tot_len = 0; |
36 | 36 | ||
37 | while(niov > 0) { | 37 | while (niov > 0) { |
38 | compat_uptr_t buf; | 38 | compat_uptr_t buf; |
39 | compat_size_t len; | 39 | compat_size_t len; |
40 | 40 | ||
41 | if(get_user(len, &uiov32->iov_len) || | 41 | if (get_user(len, &uiov32->iov_len) || |
42 | get_user(buf, &uiov32->iov_base)) { | 42 | get_user(buf, &uiov32->iov_base)) { |
43 | tot_len = -EFAULT; | 43 | tot_len = -EFAULT; |
44 | break; | 44 | break; |
@@ -78,12 +78,12 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, | |||
78 | { | 78 | { |
79 | int tot_len; | 79 | int tot_len; |
80 | 80 | ||
81 | if(kern_msg->msg_namelen) { | 81 | if (kern_msg->msg_namelen) { |
82 | if(mode==VERIFY_READ) { | 82 | if (mode==VERIFY_READ) { |
83 | int err = move_addr_to_kernel(kern_msg->msg_name, | 83 | int err = move_addr_to_kernel(kern_msg->msg_name, |
84 | kern_msg->msg_namelen, | 84 | kern_msg->msg_namelen, |
85 | kern_address); | 85 | kern_address); |
86 | if(err < 0) | 86 | if (err < 0) |
87 | return err; | 87 | return err; |
88 | } | 88 | } |
89 | kern_msg->msg_name = kern_address; | 89 | kern_msg->msg_name = kern_address; |
@@ -93,7 +93,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, | |||
93 | tot_len = iov_from_user_compat_to_kern(kern_iov, | 93 | tot_len = iov_from_user_compat_to_kern(kern_iov, |
94 | (struct compat_iovec __user *)kern_msg->msg_iov, | 94 | (struct compat_iovec __user *)kern_msg->msg_iov, |
95 | kern_msg->msg_iovlen); | 95 | kern_msg->msg_iovlen); |
96 | if(tot_len >= 0) | 96 | if (tot_len >= 0) |
97 | kern_msg->msg_iov = kern_iov; | 97 | kern_msg->msg_iov = kern_iov; |
98 | 98 | ||
99 | return tot_len; | 99 | return tot_len; |
@@ -146,8 +146,8 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
146 | kcmlen = 0; | 146 | kcmlen = 0; |
147 | kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; | 147 | kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; |
148 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); | 148 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); |
149 | while(ucmsg != NULL) { | 149 | while (ucmsg != NULL) { |
150 | if(get_user(ucmlen, &ucmsg->cmsg_len)) | 150 | if (get_user(ucmlen, &ucmsg->cmsg_len)) |
151 | return -EFAULT; | 151 | return -EFAULT; |
152 | 152 | ||
153 | /* Catch bogons. */ | 153 | /* Catch bogons. */ |
@@ -160,7 +160,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
160 | kcmlen += tmp; | 160 | kcmlen += tmp; |
161 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); | 161 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); |
162 | } | 162 | } |
163 | if(kcmlen == 0) | 163 | if (kcmlen == 0) |
164 | return -EINVAL; | 164 | return -EINVAL; |
165 | 165 | ||
166 | /* The kcmlen holds the 64-bit version of the control length. | 166 | /* The kcmlen holds the 64-bit version of the control length. |
@@ -176,7 +176,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
176 | /* Now copy them over neatly. */ | 176 | /* Now copy them over neatly. */ |
177 | memset(kcmsg, 0, kcmlen); | 177 | memset(kcmsg, 0, kcmlen); |
178 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); | 178 | ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); |
179 | while(ucmsg != NULL) { | 179 | while (ucmsg != NULL) { |
180 | if (__get_user(ucmlen, &ucmsg->cmsg_len)) | 180 | if (__get_user(ucmlen, &ucmsg->cmsg_len)) |
181 | goto Efault; | 181 | goto Efault; |
182 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) | 182 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) |
@@ -219,7 +219,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat | |||
219 | struct compat_cmsghdr cmhdr; | 219 | struct compat_cmsghdr cmhdr; |
220 | int cmlen; | 220 | int cmlen; |
221 | 221 | ||
222 | if(cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { | 222 | if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { |
223 | kmsg->msg_flags |= MSG_CTRUNC; | 223 | kmsg->msg_flags |= MSG_CTRUNC; |
224 | return 0; /* XXX: return error? check spec. */ | 224 | return 0; /* XXX: return error? check spec. */ |
225 | } | 225 | } |
@@ -233,7 +233,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat | |||
233 | } | 233 | } |
234 | 234 | ||
235 | cmlen = CMSG_COMPAT_LEN(len); | 235 | cmlen = CMSG_COMPAT_LEN(len); |
236 | if(kmsg->msg_controllen < cmlen) { | 236 | if (kmsg->msg_controllen < cmlen) { |
237 | kmsg->msg_flags |= MSG_CTRUNC; | 237 | kmsg->msg_flags |= MSG_CTRUNC; |
238 | cmlen = kmsg->msg_controllen; | 238 | cmlen = kmsg->msg_controllen; |
239 | } | 239 | } |
@@ -241,9 +241,9 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat | |||
241 | cmhdr.cmsg_type = type; | 241 | cmhdr.cmsg_type = type; |
242 | cmhdr.cmsg_len = cmlen; | 242 | cmhdr.cmsg_len = cmlen; |
243 | 243 | ||
244 | if(copy_to_user(cm, &cmhdr, sizeof cmhdr)) | 244 | if (copy_to_user(cm, &cmhdr, sizeof cmhdr)) |
245 | return -EFAULT; | 245 | return -EFAULT; |
246 | if(copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) | 246 | if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) |
247 | return -EFAULT; | 247 | return -EFAULT; |
248 | cmlen = CMSG_COMPAT_SPACE(len); | 248 | cmlen = CMSG_COMPAT_SPACE(len); |
249 | kmsg->msg_control += cmlen; | 249 | kmsg->msg_control += cmlen; |
@@ -646,7 +646,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args) | |||
646 | a0 = a[0]; | 646 | a0 = a[0]; |
647 | a1 = a[1]; | 647 | a1 = a[1]; |
648 | 648 | ||
649 | switch(call) { | 649 | switch (call) { |
650 | case SYS_SOCKET: | 650 | case SYS_SOCKET: |
651 | ret = sys_socket(a0, a1, a[2]); | 651 | ret = sys_socket(a0, a1, a[2]); |
652 | break; | 652 | break; |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 6168edd137dd..8d5e5a09b576 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -836,7 +836,7 @@ int dev_ethtool(struct ifreq *ifr) | |||
836 | return -EPERM; | 836 | return -EPERM; |
837 | } | 837 | } |
838 | 838 | ||
839 | if(dev->ethtool_ops->begin) | 839 | if (dev->ethtool_ops->begin) |
840 | if ((rc = dev->ethtool_ops->begin(dev)) < 0) | 840 | if ((rc = dev->ethtool_ops->begin(dev)) < 0) |
841 | return rc; | 841 | return rc; |
842 | 842 | ||
@@ -952,7 +952,7 @@ int dev_ethtool(struct ifreq *ifr) | |||
952 | rc = -EOPNOTSUPP; | 952 | rc = -EOPNOTSUPP; |
953 | } | 953 | } |
954 | 954 | ||
955 | if(dev->ethtool_ops->complete) | 955 | if (dev->ethtool_ops->complete) |
956 | dev->ethtool_ops->complete(dev); | 956 | dev->ethtool_ops->complete(dev); |
957 | 957 | ||
958 | if (old_features != dev->features) | 958 | if (old_features != dev->features) |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 4cbb1290a6a3..221a64ab64f7 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -352,8 +352,8 @@ static ssize_t wireless_show(struct device *d, char *buf, | |||
352 | 352 | ||
353 | read_lock(&dev_base_lock); | 353 | read_lock(&dev_base_lock); |
354 | if (dev_isalive(dev)) { | 354 | if (dev_isalive(dev)) { |
355 | if(dev->wireless_handlers && | 355 | if (dev->wireless_handlers && |
356 | dev->wireless_handlers->get_wireless_stats) | 356 | dev->wireless_handlers->get_wireless_stats) |
357 | iw = dev->wireless_handlers->get_wireless_stats(dev); | 357 | iw = dev->wireless_handlers->get_wireless_stats(dev); |
358 | if (iw != NULL) | 358 | if (iw != NULL) |
359 | ret = (*format)(iw, buf); | 359 | ret = (*format)(iw, buf); |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 895739fdfac3..10d33fc233b3 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -645,7 +645,7 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
645 | if (pkt_dev->nr_labels) { | 645 | if (pkt_dev->nr_labels) { |
646 | unsigned i; | 646 | unsigned i; |
647 | seq_printf(seq, " mpls: "); | 647 | seq_printf(seq, " mpls: "); |
648 | for(i = 0; i < pkt_dev->nr_labels; i++) | 648 | for (i = 0; i < pkt_dev->nr_labels; i++) |
649 | seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]), | 649 | seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]), |
650 | i == pkt_dev->nr_labels-1 ? "\n" : ", "); | 650 | i == pkt_dev->nr_labels-1 ? "\n" : ", "); |
651 | } | 651 | } |
@@ -750,7 +750,7 @@ static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, __u32 | |||
750 | int i = 0; | 750 | int i = 0; |
751 | *num = 0; | 751 | *num = 0; |
752 | 752 | ||
753 | for(; i < maxlen; i++) { | 753 | for (; i < maxlen; i++) { |
754 | char c; | 754 | char c; |
755 | *num <<= 4; | 755 | *num <<= 4; |
756 | if (get_user(c, &user_buffer[i])) | 756 | if (get_user(c, &user_buffer[i])) |
@@ -858,7 +858,7 @@ static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev) | |||
858 | n++; | 858 | n++; |
859 | if (n >= MAX_MPLS_LABELS) | 859 | if (n >= MAX_MPLS_LABELS) |
860 | return -E2BIG; | 860 | return -E2BIG; |
861 | } while(c == ','); | 861 | } while (c == ','); |
862 | 862 | ||
863 | pkt_dev->nr_labels = n; | 863 | pkt_dev->nr_labels = n; |
864 | return i; | 864 | return i; |
@@ -1487,7 +1487,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1487 | if (len < 0) { return len; } | 1487 | if (len < 0) { return len; } |
1488 | i += len; | 1488 | i += len; |
1489 | offset = sprintf(pg_result, "OK: mpls="); | 1489 | offset = sprintf(pg_result, "OK: mpls="); |
1490 | for(n = 0; n < pkt_dev->nr_labels; n++) | 1490 | for (n = 0; n < pkt_dev->nr_labels; n++) |
1491 | offset += sprintf(pg_result + offset, | 1491 | offset += sprintf(pg_result + offset, |
1492 | "%08x%s", ntohl(pkt_dev->labels[n]), | 1492 | "%08x%s", ntohl(pkt_dev->labels[n]), |
1493 | n == pkt_dev->nr_labels-1 ? "" : ","); | 1493 | n == pkt_dev->nr_labels-1 ? "" : ","); |
@@ -2148,7 +2148,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2148 | 2148 | ||
2149 | if (pkt_dev->flags & F_MPLS_RND) { | 2149 | if (pkt_dev->flags & F_MPLS_RND) { |
2150 | unsigned i; | 2150 | unsigned i; |
2151 | for(i = 0; i < pkt_dev->nr_labels; i++) | 2151 | for (i = 0; i < pkt_dev->nr_labels; i++) |
2152 | if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) | 2152 | if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) |
2153 | pkt_dev->labels[i] = MPLS_STACK_BOTTOM | | 2153 | pkt_dev->labels[i] = MPLS_STACK_BOTTOM | |
2154 | ((__force __be32)random32() & | 2154 | ((__force __be32)random32() & |
@@ -2281,7 +2281,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2281 | static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) | 2281 | static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) |
2282 | { | 2282 | { |
2283 | unsigned i; | 2283 | unsigned i; |
2284 | for(i = 0; i < pkt_dev->nr_labels; i++) { | 2284 | for (i = 0; i < pkt_dev->nr_labels; i++) { |
2285 | *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; | 2285 | *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; |
2286 | } | 2286 | } |
2287 | mpls--; | 2287 | mpls--; |
@@ -2341,7 +2341,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
2341 | mpls_push(mpls, pkt_dev); | 2341 | mpls_push(mpls, pkt_dev); |
2342 | 2342 | ||
2343 | if (pkt_dev->vlan_id != 0xffff) { | 2343 | if (pkt_dev->vlan_id != 0xffff) { |
2344 | if(pkt_dev->svlan_id != 0xffff) { | 2344 | if (pkt_dev->svlan_id != 0xffff) { |
2345 | svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); | 2345 | svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); |
2346 | *svlan_tci = build_tci(pkt_dev->svlan_id, | 2346 | *svlan_tci = build_tci(pkt_dev->svlan_id, |
2347 | pkt_dev->svlan_cfi, | 2347 | pkt_dev->svlan_cfi, |
@@ -2677,7 +2677,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
2677 | mpls_push(mpls, pkt_dev); | 2677 | mpls_push(mpls, pkt_dev); |
2678 | 2678 | ||
2679 | if (pkt_dev->vlan_id != 0xffff) { | 2679 | if (pkt_dev->vlan_id != 0xffff) { |
2680 | if(pkt_dev->svlan_id != 0xffff) { | 2680 | if (pkt_dev->svlan_id != 0xffff) { |
2681 | svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); | 2681 | svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); |
2682 | *svlan_tci = build_tci(pkt_dev->svlan_id, | 2682 | *svlan_tci = build_tci(pkt_dev->svlan_id, |
2683 | pkt_dev->svlan_cfi, | 2683 | pkt_dev->svlan_cfi, |
diff --git a/net/core/sock.c b/net/core/sock.c index cb48fa0e1249..792ae39804a2 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -361,8 +361,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
361 | } | 361 | } |
362 | #endif | 362 | #endif |
363 | 363 | ||
364 | if(optlen<sizeof(int)) | 364 | if (optlen < sizeof(int)) |
365 | return(-EINVAL); | 365 | return -EINVAL; |
366 | 366 | ||
367 | if (get_user(val, (int __user *)optval)) | 367 | if (get_user(val, (int __user *)optval)) |
368 | return -EFAULT; | 368 | return -EFAULT; |
@@ -371,265 +371,263 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
371 | 371 | ||
372 | lock_sock(sk); | 372 | lock_sock(sk); |
373 | 373 | ||
374 | switch(optname) | 374 | switch(optname) { |
375 | { | 375 | case SO_DEBUG: |
376 | case SO_DEBUG: | 376 | if (val && !capable(CAP_NET_ADMIN)) { |
377 | if(val && !capable(CAP_NET_ADMIN)) | 377 | ret = -EACCES; |
378 | { | 378 | } |
379 | ret = -EACCES; | 379 | else if (valbool) |
380 | } | 380 | sock_set_flag(sk, SOCK_DBG); |
381 | else if (valbool) | 381 | else |
382 | sock_set_flag(sk, SOCK_DBG); | 382 | sock_reset_flag(sk, SOCK_DBG); |
383 | else | 383 | break; |
384 | sock_reset_flag(sk, SOCK_DBG); | 384 | case SO_REUSEADDR: |
385 | break; | 385 | sk->sk_reuse = valbool; |
386 | case SO_REUSEADDR: | 386 | break; |
387 | sk->sk_reuse = valbool; | 387 | case SO_TYPE: |
388 | break; | 388 | case SO_ERROR: |
389 | case SO_TYPE: | 389 | ret = -ENOPROTOOPT; |
390 | case SO_ERROR: | 390 | break; |
391 | ret = -ENOPROTOOPT; | 391 | case SO_DONTROUTE: |
392 | break; | 392 | if (valbool) |
393 | case SO_DONTROUTE: | 393 | sock_set_flag(sk, SOCK_LOCALROUTE); |
394 | if (valbool) | 394 | else |
395 | sock_set_flag(sk, SOCK_LOCALROUTE); | 395 | sock_reset_flag(sk, SOCK_LOCALROUTE); |
396 | else | 396 | break; |
397 | sock_reset_flag(sk, SOCK_LOCALROUTE); | 397 | case SO_BROADCAST: |
398 | break; | 398 | sock_valbool_flag(sk, SOCK_BROADCAST, valbool); |
399 | case SO_BROADCAST: | 399 | break; |
400 | sock_valbool_flag(sk, SOCK_BROADCAST, valbool); | 400 | case SO_SNDBUF: |
401 | break; | 401 | /* Don't error on this BSD doesn't and if you think |
402 | case SO_SNDBUF: | 402 | about it this is right. Otherwise apps have to |
403 | /* Don't error on this BSD doesn't and if you think | 403 | play 'guess the biggest size' games. RCVBUF/SNDBUF |
404 | about it this is right. Otherwise apps have to | 404 | are treated in BSD as hints */ |
405 | play 'guess the biggest size' games. RCVBUF/SNDBUF | 405 | |
406 | are treated in BSD as hints */ | 406 | if (val > sysctl_wmem_max) |
407 | 407 | val = sysctl_wmem_max; | |
408 | if (val > sysctl_wmem_max) | ||
409 | val = sysctl_wmem_max; | ||
410 | set_sndbuf: | 408 | set_sndbuf: |
411 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; | 409 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; |
412 | if ((val * 2) < SOCK_MIN_SNDBUF) | 410 | if ((val * 2) < SOCK_MIN_SNDBUF) |
413 | sk->sk_sndbuf = SOCK_MIN_SNDBUF; | 411 | sk->sk_sndbuf = SOCK_MIN_SNDBUF; |
414 | else | 412 | else |
415 | sk->sk_sndbuf = val * 2; | 413 | sk->sk_sndbuf = val * 2; |
416 | 414 | ||
417 | /* | 415 | /* |
418 | * Wake up sending tasks if we | 416 | * Wake up sending tasks if we |
419 | * upped the value. | 417 | * upped the value. |
420 | */ | 418 | */ |
421 | sk->sk_write_space(sk); | 419 | sk->sk_write_space(sk); |
422 | break; | 420 | break; |
423 | 421 | ||
424 | case SO_SNDBUFFORCE: | 422 | case SO_SNDBUFFORCE: |
425 | if (!capable(CAP_NET_ADMIN)) { | 423 | if (!capable(CAP_NET_ADMIN)) { |
426 | ret = -EPERM; | 424 | ret = -EPERM; |
427 | break; | 425 | break; |
428 | } | 426 | } |
429 | goto set_sndbuf; | 427 | goto set_sndbuf; |
430 | 428 | ||
431 | case SO_RCVBUF: | 429 | case SO_RCVBUF: |
432 | /* Don't error on this BSD doesn't and if you think | 430 | /* Don't error on this BSD doesn't and if you think |
433 | about it this is right. Otherwise apps have to | 431 | about it this is right. Otherwise apps have to |
434 | play 'guess the biggest size' games. RCVBUF/SNDBUF | 432 | play 'guess the biggest size' games. RCVBUF/SNDBUF |
435 | are treated in BSD as hints */ | 433 | are treated in BSD as hints */ |
436 | 434 | ||
437 | if (val > sysctl_rmem_max) | 435 | if (val > sysctl_rmem_max) |
438 | val = sysctl_rmem_max; | 436 | val = sysctl_rmem_max; |
439 | set_rcvbuf: | 437 | set_rcvbuf: |
440 | sk->sk_userlocks |= SOCK_RCVBUF_LOCK; | 438 | sk->sk_userlocks |= SOCK_RCVBUF_LOCK; |
441 | /* | 439 | /* |
442 | * We double it on the way in to account for | 440 | * We double it on the way in to account for |
443 | * "struct sk_buff" etc. overhead. Applications | 441 | * "struct sk_buff" etc. overhead. Applications |
444 | * assume that the SO_RCVBUF setting they make will | 442 | * assume that the SO_RCVBUF setting they make will |
445 | * allow that much actual data to be received on that | 443 | * allow that much actual data to be received on that |
446 | * socket. | 444 | * socket. |
447 | * | 445 | * |
448 | * Applications are unaware that "struct sk_buff" and | 446 | * Applications are unaware that "struct sk_buff" and |
449 | * other overheads allocate from the receive buffer | 447 | * other overheads allocate from the receive buffer |
450 | * during socket buffer allocation. | 448 | * during socket buffer allocation. |
451 | * | 449 | * |
452 | * And after considering the possible alternatives, | 450 | * And after considering the possible alternatives, |
453 | * returning the value we actually used in getsockopt | 451 | * returning the value we actually used in getsockopt |
454 | * is the most desirable behavior. | 452 | * is the most desirable behavior. |
455 | */ | 453 | */ |
456 | if ((val * 2) < SOCK_MIN_RCVBUF) | 454 | if ((val * 2) < SOCK_MIN_RCVBUF) |
457 | sk->sk_rcvbuf = SOCK_MIN_RCVBUF; | 455 | sk->sk_rcvbuf = SOCK_MIN_RCVBUF; |
458 | else | 456 | else |
459 | sk->sk_rcvbuf = val * 2; | 457 | sk->sk_rcvbuf = val * 2; |
458 | break; | ||
459 | |||
460 | case SO_RCVBUFFORCE: | ||
461 | if (!capable(CAP_NET_ADMIN)) { | ||
462 | ret = -EPERM; | ||
460 | break; | 463 | break; |
464 | } | ||
465 | goto set_rcvbuf; | ||
461 | 466 | ||
462 | case SO_RCVBUFFORCE: | 467 | case SO_KEEPALIVE: |
463 | if (!capable(CAP_NET_ADMIN)) { | ||
464 | ret = -EPERM; | ||
465 | break; | ||
466 | } | ||
467 | goto set_rcvbuf; | ||
468 | |||
469 | case SO_KEEPALIVE: | ||
470 | #ifdef CONFIG_INET | 468 | #ifdef CONFIG_INET |
471 | if (sk->sk_protocol == IPPROTO_TCP) | 469 | if (sk->sk_protocol == IPPROTO_TCP) |
472 | tcp_set_keepalive(sk, valbool); | 470 | tcp_set_keepalive(sk, valbool); |
473 | #endif | 471 | #endif |
474 | sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); | 472 | sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); |
475 | break; | 473 | break; |
476 | 474 | ||
477 | case SO_OOBINLINE: | 475 | case SO_OOBINLINE: |
478 | sock_valbool_flag(sk, SOCK_URGINLINE, valbool); | 476 | sock_valbool_flag(sk, SOCK_URGINLINE, valbool); |
477 | break; | ||
478 | |||
479 | case SO_NO_CHECK: | ||
480 | sk->sk_no_check = valbool; | ||
481 | break; | ||
482 | |||
483 | case SO_PRIORITY: | ||
484 | if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN)) | ||
485 | sk->sk_priority = val; | ||
486 | else | ||
487 | ret = -EPERM; | ||
488 | break; | ||
489 | |||
490 | case SO_LINGER: | ||
491 | if (optlen < sizeof(ling)) { | ||
492 | ret = -EINVAL; /* 1003.1g */ | ||
479 | break; | 493 | break; |
480 | 494 | } | |
481 | case SO_NO_CHECK: | 495 | if (copy_from_user(&ling,optval,sizeof(ling))) { |
482 | sk->sk_no_check = valbool; | 496 | ret = -EFAULT; |
483 | break; | ||
484 | |||
485 | case SO_PRIORITY: | ||
486 | if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN)) | ||
487 | sk->sk_priority = val; | ||
488 | else | ||
489 | ret = -EPERM; | ||
490 | break; | 497 | break; |
491 | 498 | } | |
492 | case SO_LINGER: | 499 | if (!ling.l_onoff) |
493 | if(optlen<sizeof(ling)) { | 500 | sock_reset_flag(sk, SOCK_LINGER); |
494 | ret = -EINVAL; /* 1003.1g */ | 501 | else { |
495 | break; | ||
496 | } | ||
497 | if (copy_from_user(&ling,optval,sizeof(ling))) { | ||
498 | ret = -EFAULT; | ||
499 | break; | ||
500 | } | ||
501 | if (!ling.l_onoff) | ||
502 | sock_reset_flag(sk, SOCK_LINGER); | ||
503 | else { | ||
504 | #if (BITS_PER_LONG == 32) | 502 | #if (BITS_PER_LONG == 32) |
505 | if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) | 503 | if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) |
506 | sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT; | 504 | sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT; |
507 | else | ||
508 | #endif | ||
509 | sk->sk_lingertime = (unsigned int)ling.l_linger * HZ; | ||
510 | sock_set_flag(sk, SOCK_LINGER); | ||
511 | } | ||
512 | break; | ||
513 | |||
514 | case SO_BSDCOMPAT: | ||
515 | sock_warn_obsolete_bsdism("setsockopt"); | ||
516 | break; | ||
517 | |||
518 | case SO_PASSCRED: | ||
519 | if (valbool) | ||
520 | set_bit(SOCK_PASSCRED, &sock->flags); | ||
521 | else | 505 | else |
522 | clear_bit(SOCK_PASSCRED, &sock->flags); | 506 | #endif |
523 | break; | 507 | sk->sk_lingertime = (unsigned int)ling.l_linger * HZ; |
524 | 508 | sock_set_flag(sk, SOCK_LINGER); | |
525 | case SO_TIMESTAMP: | 509 | } |
526 | if (valbool) { | 510 | break; |
527 | sock_set_flag(sk, SOCK_RCVTSTAMP); | 511 | |
528 | sock_enable_timestamp(sk); | 512 | case SO_BSDCOMPAT: |
529 | } else | 513 | sock_warn_obsolete_bsdism("setsockopt"); |
530 | sock_reset_flag(sk, SOCK_RCVTSTAMP); | 514 | break; |
531 | break; | 515 | |
532 | 516 | case SO_PASSCRED: | |
533 | case SO_RCVLOWAT: | 517 | if (valbool) |
534 | if (val < 0) | 518 | set_bit(SOCK_PASSCRED, &sock->flags); |
535 | val = INT_MAX; | 519 | else |
536 | sk->sk_rcvlowat = val ? : 1; | 520 | clear_bit(SOCK_PASSCRED, &sock->flags); |
537 | break; | 521 | break; |
522 | |||
523 | case SO_TIMESTAMP: | ||
524 | if (valbool) { | ||
525 | sock_set_flag(sk, SOCK_RCVTSTAMP); | ||
526 | sock_enable_timestamp(sk); | ||
527 | } else | ||
528 | sock_reset_flag(sk, SOCK_RCVTSTAMP); | ||
529 | break; | ||
530 | |||
531 | case SO_RCVLOWAT: | ||
532 | if (val < 0) | ||
533 | val = INT_MAX; | ||
534 | sk->sk_rcvlowat = val ? : 1; | ||
535 | break; | ||
536 | |||
537 | case SO_RCVTIMEO: | ||
538 | ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen); | ||
539 | break; | ||
540 | |||
541 | case SO_SNDTIMEO: | ||
542 | ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen); | ||
543 | break; | ||
538 | 544 | ||
539 | case SO_RCVTIMEO: | 545 | #ifdef CONFIG_NETDEVICES |
540 | ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen); | 546 | case SO_BINDTODEVICE: |
541 | break; | 547 | { |
548 | char devname[IFNAMSIZ]; | ||
542 | 549 | ||
543 | case SO_SNDTIMEO: | 550 | /* Sorry... */ |
544 | ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen); | 551 | if (!capable(CAP_NET_RAW)) { |
552 | ret = -EPERM; | ||
545 | break; | 553 | break; |
554 | } | ||
546 | 555 | ||
547 | #ifdef CONFIG_NETDEVICES | 556 | /* Bind this socket to a particular device like "eth0", |
548 | case SO_BINDTODEVICE: | 557 | * as specified in the passed interface name. If the |
549 | { | 558 | * name is "" or the option length is zero the socket |
550 | char devname[IFNAMSIZ]; | 559 | * is not bound. |
560 | */ | ||
551 | 561 | ||
552 | /* Sorry... */ | 562 | if (!valbool) { |
553 | if (!capable(CAP_NET_RAW)) { | 563 | sk->sk_bound_dev_if = 0; |
554 | ret = -EPERM; | 564 | } else { |
565 | if (optlen > IFNAMSIZ - 1) | ||
566 | optlen = IFNAMSIZ - 1; | ||
567 | memset(devname, 0, sizeof(devname)); | ||
568 | if (copy_from_user(devname, optval, optlen)) { | ||
569 | ret = -EFAULT; | ||
555 | break; | 570 | break; |
556 | } | 571 | } |
557 | 572 | ||
558 | /* Bind this socket to a particular device like "eth0", | 573 | /* Remove any cached route for this socket. */ |
559 | * as specified in the passed interface name. If the | 574 | sk_dst_reset(sk); |
560 | * name is "" or the option length is zero the socket | ||
561 | * is not bound. | ||
562 | */ | ||
563 | 575 | ||
564 | if (!valbool) { | 576 | if (devname[0] == '\0') { |
565 | sk->sk_bound_dev_if = 0; | 577 | sk->sk_bound_dev_if = 0; |
566 | } else { | 578 | } else { |
567 | if (optlen > IFNAMSIZ - 1) | 579 | struct net_device *dev = dev_get_by_name(devname); |
568 | optlen = IFNAMSIZ - 1; | 580 | if (!dev) { |
569 | memset(devname, 0, sizeof(devname)); | 581 | ret = -ENODEV; |
570 | if (copy_from_user(devname, optval, optlen)) { | ||
571 | ret = -EFAULT; | ||
572 | break; | 582 | break; |
573 | } | 583 | } |
574 | 584 | sk->sk_bound_dev_if = dev->ifindex; | |
575 | /* Remove any cached route for this socket. */ | 585 | dev_put(dev); |
576 | sk_dst_reset(sk); | ||
577 | |||
578 | if (devname[0] == '\0') { | ||
579 | sk->sk_bound_dev_if = 0; | ||
580 | } else { | ||
581 | struct net_device *dev = dev_get_by_name(devname); | ||
582 | if (!dev) { | ||
583 | ret = -ENODEV; | ||
584 | break; | ||
585 | } | ||
586 | sk->sk_bound_dev_if = dev->ifindex; | ||
587 | dev_put(dev); | ||
588 | } | ||
589 | } | 586 | } |
590 | break; | ||
591 | } | 587 | } |
588 | break; | ||
589 | } | ||
592 | #endif | 590 | #endif |
593 | 591 | ||
594 | 592 | ||
595 | case SO_ATTACH_FILTER: | 593 | case SO_ATTACH_FILTER: |
596 | ret = -EINVAL; | 594 | ret = -EINVAL; |
597 | if (optlen == sizeof(struct sock_fprog)) { | 595 | if (optlen == sizeof(struct sock_fprog)) { |
598 | struct sock_fprog fprog; | 596 | struct sock_fprog fprog; |
599 | |||
600 | ret = -EFAULT; | ||
601 | if (copy_from_user(&fprog, optval, sizeof(fprog))) | ||
602 | break; | ||
603 | |||
604 | ret = sk_attach_filter(&fprog, sk); | ||
605 | } | ||
606 | break; | ||
607 | 597 | ||
608 | case SO_DETACH_FILTER: | 598 | ret = -EFAULT; |
609 | rcu_read_lock_bh(); | 599 | if (copy_from_user(&fprog, optval, sizeof(fprog))) |
610 | filter = rcu_dereference(sk->sk_filter); | ||
611 | if (filter) { | ||
612 | rcu_assign_pointer(sk->sk_filter, NULL); | ||
613 | sk_filter_release(sk, filter); | ||
614 | rcu_read_unlock_bh(); | ||
615 | break; | 600 | break; |
616 | } | 601 | |
602 | ret = sk_attach_filter(&fprog, sk); | ||
603 | } | ||
604 | break; | ||
605 | |||
606 | case SO_DETACH_FILTER: | ||
607 | rcu_read_lock_bh(); | ||
608 | filter = rcu_dereference(sk->sk_filter); | ||
609 | if (filter) { | ||
610 | rcu_assign_pointer(sk->sk_filter, NULL); | ||
611 | sk_filter_release(sk, filter); | ||
617 | rcu_read_unlock_bh(); | 612 | rcu_read_unlock_bh(); |
618 | ret = -ENONET; | ||
619 | break; | 613 | break; |
614 | } | ||
615 | rcu_read_unlock_bh(); | ||
616 | ret = -ENONET; | ||
617 | break; | ||
620 | 618 | ||
621 | case SO_PASSSEC: | 619 | case SO_PASSSEC: |
622 | if (valbool) | 620 | if (valbool) |
623 | set_bit(SOCK_PASSSEC, &sock->flags); | 621 | set_bit(SOCK_PASSSEC, &sock->flags); |
624 | else | 622 | else |
625 | clear_bit(SOCK_PASSSEC, &sock->flags); | 623 | clear_bit(SOCK_PASSSEC, &sock->flags); |
626 | break; | 624 | break; |
627 | 625 | ||
628 | /* We implement the SO_SNDLOWAT etc to | 626 | /* We implement the SO_SNDLOWAT etc to |
629 | not be settable (1003.1g 5.3) */ | 627 | not be settable (1003.1g 5.3) */ |
630 | default: | 628 | default: |
631 | ret = -ENOPROTOOPT; | 629 | ret = -ENOPROTOOPT; |
632 | break; | 630 | break; |
633 | } | 631 | } |
634 | release_sock(sk); | 632 | release_sock(sk); |
635 | return ret; | 633 | return ret; |
@@ -641,8 +639,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
641 | { | 639 | { |
642 | struct sock *sk = sock->sk; | 640 | struct sock *sk = sock->sk; |
643 | 641 | ||
644 | union | 642 | union { |
645 | { | ||
646 | int val; | 643 | int val; |
647 | struct linger ling; | 644 | struct linger ling; |
648 | struct timeval tm; | 645 | struct timeval tm; |
@@ -651,148 +648,148 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
651 | unsigned int lv = sizeof(int); | 648 | unsigned int lv = sizeof(int); |
652 | int len; | 649 | int len; |
653 | 650 | ||
654 | if(get_user(len,optlen)) | 651 | if (get_user(len, optlen)) |
655 | return -EFAULT; | 652 | return -EFAULT; |
656 | if(len < 0) | 653 | if (len < 0) |
657 | return -EINVAL; | 654 | return -EINVAL; |
658 | 655 | ||
659 | switch(optname) | 656 | switch(optname) { |
660 | { | 657 | case SO_DEBUG: |
661 | case SO_DEBUG: | 658 | v.val = sock_flag(sk, SOCK_DBG); |
662 | v.val = sock_flag(sk, SOCK_DBG); | 659 | break; |
663 | break; | 660 | |
664 | 661 | case SO_DONTROUTE: | |
665 | case SO_DONTROUTE: | 662 | v.val = sock_flag(sk, SOCK_LOCALROUTE); |
666 | v.val = sock_flag(sk, SOCK_LOCALROUTE); | 663 | break; |
667 | break; | 664 | |
668 | 665 | case SO_BROADCAST: | |
669 | case SO_BROADCAST: | 666 | v.val = !!sock_flag(sk, SOCK_BROADCAST); |
670 | v.val = !!sock_flag(sk, SOCK_BROADCAST); | 667 | break; |
671 | break; | 668 | |
672 | 669 | case SO_SNDBUF: | |
673 | case SO_SNDBUF: | 670 | v.val = sk->sk_sndbuf; |
674 | v.val = sk->sk_sndbuf; | 671 | break; |
675 | break; | 672 | |
676 | 673 | case SO_RCVBUF: | |
677 | case SO_RCVBUF: | 674 | v.val = sk->sk_rcvbuf; |
678 | v.val = sk->sk_rcvbuf; | 675 | break; |
679 | break; | 676 | |
680 | 677 | case SO_REUSEADDR: | |
681 | case SO_REUSEADDR: | 678 | v.val = sk->sk_reuse; |
682 | v.val = sk->sk_reuse; | 679 | break; |
683 | break; | 680 | |
684 | 681 | case SO_KEEPALIVE: | |
685 | case SO_KEEPALIVE: | 682 | v.val = !!sock_flag(sk, SOCK_KEEPOPEN); |
686 | v.val = !!sock_flag(sk, SOCK_KEEPOPEN); | 683 | break; |
687 | break; | 684 | |
688 | 685 | case SO_TYPE: | |
689 | case SO_TYPE: | 686 | v.val = sk->sk_type; |
690 | v.val = sk->sk_type; | 687 | break; |
691 | break; | 688 | |
692 | 689 | case SO_ERROR: | |
693 | case SO_ERROR: | 690 | v.val = -sock_error(sk); |
694 | v.val = -sock_error(sk); | 691 | if (v.val==0) |
695 | if(v.val==0) | 692 | v.val = xchg(&sk->sk_err_soft, 0); |
696 | v.val = xchg(&sk->sk_err_soft, 0); | 693 | break; |
697 | break; | 694 | |
698 | 695 | case SO_OOBINLINE: | |
699 | case SO_OOBINLINE: | 696 | v.val = !!sock_flag(sk, SOCK_URGINLINE); |
700 | v.val = !!sock_flag(sk, SOCK_URGINLINE); | 697 | break; |
701 | break; | 698 | |
702 | 699 | case SO_NO_CHECK: | |
703 | case SO_NO_CHECK: | 700 | v.val = sk->sk_no_check; |
704 | v.val = sk->sk_no_check; | 701 | break; |
705 | break; | 702 | |
706 | 703 | case SO_PRIORITY: | |
707 | case SO_PRIORITY: | 704 | v.val = sk->sk_priority; |
708 | v.val = sk->sk_priority; | 705 | break; |
709 | break; | 706 | |
710 | 707 | case SO_LINGER: | |
711 | case SO_LINGER: | 708 | lv = sizeof(v.ling); |
712 | lv = sizeof(v.ling); | 709 | v.ling.l_onoff = !!sock_flag(sk, SOCK_LINGER); |
713 | v.ling.l_onoff = !!sock_flag(sk, SOCK_LINGER); | 710 | v.ling.l_linger = sk->sk_lingertime / HZ; |
714 | v.ling.l_linger = sk->sk_lingertime / HZ; | 711 | break; |
715 | break; | 712 | |
716 | 713 | case SO_BSDCOMPAT: | |
717 | case SO_BSDCOMPAT: | 714 | sock_warn_obsolete_bsdism("getsockopt"); |
718 | sock_warn_obsolete_bsdism("getsockopt"); | 715 | break; |
719 | break; | 716 | |
720 | 717 | case SO_TIMESTAMP: | |
721 | case SO_TIMESTAMP: | 718 | v.val = sock_flag(sk, SOCK_RCVTSTAMP); |
722 | v.val = sock_flag(sk, SOCK_RCVTSTAMP); | 719 | break; |
723 | break; | 720 | |
724 | 721 | case SO_RCVTIMEO: | |
725 | case SO_RCVTIMEO: | 722 | lv=sizeof(struct timeval); |
726 | lv=sizeof(struct timeval); | 723 | if (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) { |
727 | if (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) { | 724 | v.tm.tv_sec = 0; |
728 | v.tm.tv_sec = 0; | 725 | v.tm.tv_usec = 0; |
729 | v.tm.tv_usec = 0; | 726 | } else { |
730 | } else { | 727 | v.tm.tv_sec = sk->sk_rcvtimeo / HZ; |
731 | v.tm.tv_sec = sk->sk_rcvtimeo / HZ; | 728 | v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) / HZ; |
732 | v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) / HZ; | 729 | } |
733 | } | 730 | break; |
734 | break; | 731 | |
732 | case SO_SNDTIMEO: | ||
733 | lv=sizeof(struct timeval); | ||
734 | if (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) { | ||
735 | v.tm.tv_sec = 0; | ||
736 | v.tm.tv_usec = 0; | ||
737 | } else { | ||
738 | v.tm.tv_sec = sk->sk_sndtimeo / HZ; | ||
739 | v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) / HZ; | ||
740 | } | ||
741 | break; | ||
735 | 742 | ||
736 | case SO_SNDTIMEO: | 743 | case SO_RCVLOWAT: |
737 | lv=sizeof(struct timeval); | 744 | v.val = sk->sk_rcvlowat; |
738 | if (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) { | 745 | break; |
739 | v.tm.tv_sec = 0; | ||
740 | v.tm.tv_usec = 0; | ||
741 | } else { | ||
742 | v.tm.tv_sec = sk->sk_sndtimeo / HZ; | ||
743 | v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) / HZ; | ||
744 | } | ||
745 | break; | ||
746 | 746 | ||
747 | case SO_RCVLOWAT: | 747 | case SO_SNDLOWAT: |
748 | v.val = sk->sk_rcvlowat; | 748 | v.val=1; |
749 | break; | 749 | break; |
750 | 750 | ||
751 | case SO_SNDLOWAT: | 751 | case SO_PASSCRED: |
752 | v.val=1; | 752 | v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0; |
753 | break; | 753 | break; |
754 | 754 | ||
755 | case SO_PASSCRED: | 755 | case SO_PEERCRED: |
756 | v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0; | 756 | if (len > sizeof(sk->sk_peercred)) |
757 | break; | 757 | len = sizeof(sk->sk_peercred); |
758 | if (copy_to_user(optval, &sk->sk_peercred, len)) | ||
759 | return -EFAULT; | ||
760 | goto lenout; | ||
758 | 761 | ||
759 | case SO_PEERCRED: | 762 | case SO_PEERNAME: |
760 | if (len > sizeof(sk->sk_peercred)) | 763 | { |
761 | len = sizeof(sk->sk_peercred); | 764 | char address[128]; |
762 | if (copy_to_user(optval, &sk->sk_peercred, len)) | 765 | |
763 | return -EFAULT; | 766 | if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2)) |
764 | goto lenout; | 767 | return -ENOTCONN; |
765 | 768 | if (lv < len) | |
766 | case SO_PEERNAME: | 769 | return -EINVAL; |
767 | { | 770 | if (copy_to_user(optval, address, len)) |
768 | char address[128]; | 771 | return -EFAULT; |
769 | 772 | goto lenout; | |
770 | if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2)) | 773 | } |
771 | return -ENOTCONN; | ||
772 | if (lv < len) | ||
773 | return -EINVAL; | ||
774 | if (copy_to_user(optval, address, len)) | ||
775 | return -EFAULT; | ||
776 | goto lenout; | ||
777 | } | ||
778 | 774 | ||
779 | /* Dubious BSD thing... Probably nobody even uses it, but | 775 | /* Dubious BSD thing... Probably nobody even uses it, but |
780 | * the UNIX standard wants it for whatever reason... -DaveM | 776 | * the UNIX standard wants it for whatever reason... -DaveM |
781 | */ | 777 | */ |
782 | case SO_ACCEPTCONN: | 778 | case SO_ACCEPTCONN: |
783 | v.val = sk->sk_state == TCP_LISTEN; | 779 | v.val = sk->sk_state == TCP_LISTEN; |
784 | break; | 780 | break; |
785 | 781 | ||
786 | case SO_PASSSEC: | 782 | case SO_PASSSEC: |
787 | v.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0; | 783 | v.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0; |
788 | break; | 784 | break; |
789 | 785 | ||
790 | case SO_PEERSEC: | 786 | case SO_PEERSEC: |
791 | return security_socket_getpeersec_stream(sock, optval, optlen, len); | 787 | return security_socket_getpeersec_stream(sock, optval, optlen, len); |
792 | 788 | ||
793 | default: | 789 | default: |
794 | return(-ENOPROTOOPT); | 790 | return -ENOPROTOOPT; |
795 | } | 791 | } |
792 | |||
796 | if (len > lv) | 793 | if (len > lv) |
797 | len = lv; | 794 | len = lv; |
798 | if (copy_to_user(optval, &v, len)) | 795 | if (copy_to_user(optval, &v, len)) |
@@ -1220,13 +1217,13 @@ static void __lock_sock(struct sock *sk) | |||
1220 | { | 1217 | { |
1221 | DEFINE_WAIT(wait); | 1218 | DEFINE_WAIT(wait); |
1222 | 1219 | ||
1223 | for(;;) { | 1220 | for (;;) { |
1224 | prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait, | 1221 | prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait, |
1225 | TASK_UNINTERRUPTIBLE); | 1222 | TASK_UNINTERRUPTIBLE); |
1226 | spin_unlock_bh(&sk->sk_lock.slock); | 1223 | spin_unlock_bh(&sk->sk_lock.slock); |
1227 | schedule(); | 1224 | schedule(); |
1228 | spin_lock_bh(&sk->sk_lock.slock); | 1225 | spin_lock_bh(&sk->sk_lock.slock); |
1229 | if(!sock_owned_by_user(sk)) | 1226 | if (!sock_owned_by_user(sk)) |
1230 | break; | 1227 | break; |
1231 | } | 1228 | } |
1232 | finish_wait(&sk->sk_lock.wq, &wait); | 1229 | finish_wait(&sk->sk_lock.wq, &wait); |
@@ -1258,7 +1255,7 @@ static void __release_sock(struct sock *sk) | |||
1258 | } while (skb != NULL); | 1255 | } while (skb != NULL); |
1259 | 1256 | ||
1260 | bh_lock_sock(sk); | 1257 | bh_lock_sock(sk); |
1261 | } while((skb = sk->sk_backlog.head) != NULL); | 1258 | } while ((skb = sk->sk_backlog.head) != NULL); |
1262 | } | 1259 | } |
1263 | 1260 | ||
1264 | /** | 1261 | /** |
@@ -1420,7 +1417,7 @@ static void sock_def_write_space(struct sock *sk) | |||
1420 | /* Do not wake up a writer until he can make "significant" | 1417 | /* Do not wake up a writer until he can make "significant" |
1421 | * progress. --DaveM | 1418 | * progress. --DaveM |
1422 | */ | 1419 | */ |
1423 | if((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { | 1420 | if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { |
1424 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 1421 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) |
1425 | wake_up_interruptible(sk->sk_sleep); | 1422 | wake_up_interruptible(sk->sk_sleep); |
1426 | 1423 | ||
@@ -1482,8 +1479,7 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1482 | 1479 | ||
1483 | sock_set_flag(sk, SOCK_ZAPPED); | 1480 | sock_set_flag(sk, SOCK_ZAPPED); |
1484 | 1481 | ||
1485 | if(sock) | 1482 | if (sock) { |
1486 | { | ||
1487 | sk->sk_type = sock->type; | 1483 | sk->sk_type = sock->type; |
1488 | sk->sk_sleep = &sock->wait; | 1484 | sk->sk_sleep = &sock->wait; |
1489 | sock->sk = sk; | 1485 | sock->sk = sk; |
diff --git a/net/core/wireless.c b/net/core/wireless.c index b07fe270a508..8f7f3abdb224 100644 --- a/net/core/wireless.c +++ b/net/core/wireless.c | |||
@@ -463,17 +463,17 @@ static inline iw_handler get_handler(struct net_device *dev, | |||
463 | unsigned int index; /* *MUST* be unsigned */ | 463 | unsigned int index; /* *MUST* be unsigned */ |
464 | 464 | ||
465 | /* Check if we have some wireless handlers defined */ | 465 | /* Check if we have some wireless handlers defined */ |
466 | if(dev->wireless_handlers == NULL) | 466 | if (dev->wireless_handlers == NULL) |
467 | return NULL; | 467 | return NULL; |
468 | 468 | ||
469 | /* Try as a standard command */ | 469 | /* Try as a standard command */ |
470 | index = cmd - SIOCIWFIRST; | 470 | index = cmd - SIOCIWFIRST; |
471 | if(index < dev->wireless_handlers->num_standard) | 471 | if (index < dev->wireless_handlers->num_standard) |
472 | return dev->wireless_handlers->standard[index]; | 472 | return dev->wireless_handlers->standard[index]; |
473 | 473 | ||
474 | /* Try as a private command */ | 474 | /* Try as a private command */ |
475 | index = cmd - SIOCIWFIRSTPRIV; | 475 | index = cmd - SIOCIWFIRSTPRIV; |
476 | if(index < dev->wireless_handlers->num_private) | 476 | if (index < dev->wireless_handlers->num_private) |
477 | return dev->wireless_handlers->private[index]; | 477 | return dev->wireless_handlers->private[index]; |
478 | 478 | ||
479 | /* Not found */ | 479 | /* Not found */ |
@@ -487,7 +487,7 @@ static inline iw_handler get_handler(struct net_device *dev, | |||
487 | static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) | 487 | static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) |
488 | { | 488 | { |
489 | /* New location */ | 489 | /* New location */ |
490 | if((dev->wireless_handlers != NULL) && | 490 | if ((dev->wireless_handlers != NULL) && |
491 | (dev->wireless_handlers->get_wireless_stats != NULL)) | 491 | (dev->wireless_handlers->get_wireless_stats != NULL)) |
492 | return dev->wireless_handlers->get_wireless_stats(dev); | 492 | return dev->wireless_handlers->get_wireless_stats(dev); |
493 | 493 | ||
@@ -516,7 +516,7 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) | |||
516 | */ | 516 | */ |
517 | static inline int call_commit_handler(struct net_device * dev) | 517 | static inline int call_commit_handler(struct net_device * dev) |
518 | { | 518 | { |
519 | if((netif_running(dev)) && | 519 | if ((netif_running(dev)) && |
520 | (dev->wireless_handlers->standard[0] != NULL)) { | 520 | (dev->wireless_handlers->standard[0] != NULL)) { |
521 | /* Call the commit handler on the driver */ | 521 | /* Call the commit handler on the driver */ |
522 | return dev->wireless_handlers->standard[0](dev, NULL, | 522 | return dev->wireless_handlers->standard[0](dev, NULL, |
@@ -577,7 +577,7 @@ static int iw_handler_get_iwstats(struct net_device * dev, | |||
577 | wrqu->data.length = sizeof(struct iw_statistics); | 577 | wrqu->data.length = sizeof(struct iw_statistics); |
578 | 578 | ||
579 | /* Check if we need to clear the updated flag */ | 579 | /* Check if we need to clear the updated flag */ |
580 | if(wrqu->data.flags != 0) | 580 | if (wrqu->data.flags != 0) |
581 | stats->qual.updated &= ~IW_QUAL_ALL_UPDATED; | 581 | stats->qual.updated &= ~IW_QUAL_ALL_UPDATED; |
582 | return 0; | 582 | return 0; |
583 | } else | 583 | } else |
@@ -596,12 +596,12 @@ static int iw_handler_get_private(struct net_device * dev, | |||
596 | char * extra) | 596 | char * extra) |
597 | { | 597 | { |
598 | /* Check if the driver has something to export */ | 598 | /* Check if the driver has something to export */ |
599 | if((dev->wireless_handlers->num_private_args == 0) || | 599 | if ((dev->wireless_handlers->num_private_args == 0) || |
600 | (dev->wireless_handlers->private_args == NULL)) | 600 | (dev->wireless_handlers->private_args == NULL)) |
601 | return -EOPNOTSUPP; | 601 | return -EOPNOTSUPP; |
602 | 602 | ||
603 | /* Check if there is enough buffer up there */ | 603 | /* Check if there is enough buffer up there */ |
604 | if(wrqu->data.length < dev->wireless_handlers->num_private_args) { | 604 | if (wrqu->data.length < dev->wireless_handlers->num_private_args) { |
605 | /* User space can't know in advance how large the buffer | 605 | /* User space can't know in advance how large the buffer |
606 | * needs to be. Give it a hint, so that we can support | 606 | * needs to be. Give it a hint, so that we can support |
607 | * any size buffer we want somewhat efficiently... */ | 607 | * any size buffer we want somewhat efficiently... */ |
@@ -735,7 +735,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
735 | int ret = -EINVAL; | 735 | int ret = -EINVAL; |
736 | 736 | ||
737 | /* Get the description of the IOCTL */ | 737 | /* Get the description of the IOCTL */ |
738 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 738 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
739 | return -EOPNOTSUPP; | 739 | return -EOPNOTSUPP; |
740 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 740 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
741 | 741 | ||
@@ -750,14 +750,14 @@ static int ioctl_standard_call(struct net_device * dev, | |||
750 | info.flags = 0; | 750 | info.flags = 0; |
751 | 751 | ||
752 | /* Check if we have a pointer to user space data or not */ | 752 | /* Check if we have a pointer to user space data or not */ |
753 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 753 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
754 | 754 | ||
755 | /* No extra arguments. Trivial to handle */ | 755 | /* No extra arguments. Trivial to handle */ |
756 | ret = handler(dev, &info, &(iwr->u), NULL); | 756 | ret = handler(dev, &info, &(iwr->u), NULL); |
757 | 757 | ||
758 | #ifdef WE_SET_EVENT | 758 | #ifdef WE_SET_EVENT |
759 | /* Generate an event to notify listeners of the change */ | 759 | /* Generate an event to notify listeners of the change */ |
760 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 760 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
761 | ((ret == 0) || (ret == -EIWCOMMIT))) | 761 | ((ret == 0) || (ret == -EIWCOMMIT))) |
762 | wireless_send_event(dev, cmd, &(iwr->u), NULL); | 762 | wireless_send_event(dev, cmd, &(iwr->u), NULL); |
763 | #endif /* WE_SET_EVENT */ | 763 | #endif /* WE_SET_EVENT */ |
@@ -800,19 +800,19 @@ static int ioctl_standard_call(struct net_device * dev, | |||
800 | iwr->u.data.length -= essid_compat; | 800 | iwr->u.data.length -= essid_compat; |
801 | 801 | ||
802 | /* Check what user space is giving us */ | 802 | /* Check what user space is giving us */ |
803 | if(IW_IS_SET(cmd)) { | 803 | if (IW_IS_SET(cmd)) { |
804 | /* Check NULL pointer */ | 804 | /* Check NULL pointer */ |
805 | if((iwr->u.data.pointer == NULL) && | 805 | if ((iwr->u.data.pointer == NULL) && |
806 | (iwr->u.data.length != 0)) | 806 | (iwr->u.data.length != 0)) |
807 | return -EFAULT; | 807 | return -EFAULT; |
808 | /* Check if number of token fits within bounds */ | 808 | /* Check if number of token fits within bounds */ |
809 | if(iwr->u.data.length > descr->max_tokens) | 809 | if (iwr->u.data.length > descr->max_tokens) |
810 | return -E2BIG; | 810 | return -E2BIG; |
811 | if(iwr->u.data.length < descr->min_tokens) | 811 | if (iwr->u.data.length < descr->min_tokens) |
812 | return -EINVAL; | 812 | return -EINVAL; |
813 | } else { | 813 | } else { |
814 | /* Check NULL pointer */ | 814 | /* Check NULL pointer */ |
815 | if(iwr->u.data.pointer == NULL) | 815 | if (iwr->u.data.pointer == NULL) |
816 | return -EFAULT; | 816 | return -EFAULT; |
817 | /* Save user space buffer size for checking */ | 817 | /* Save user space buffer size for checking */ |
818 | user_length = iwr->u.data.length; | 818 | user_length = iwr->u.data.length; |
@@ -822,7 +822,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
822 | * implied by the test at the end. */ | 822 | * implied by the test at the end. */ |
823 | 823 | ||
824 | /* Support for very large requests */ | 824 | /* Support for very large requests */ |
825 | if((descr->flags & IW_DESCR_FLAG_NOMAX) && | 825 | if ((descr->flags & IW_DESCR_FLAG_NOMAX) && |
826 | (user_length > descr->max_tokens)) { | 826 | (user_length > descr->max_tokens)) { |
827 | /* Allow userspace to GET more than max so | 827 | /* Allow userspace to GET more than max so |
828 | * we can support any size GET requests. | 828 | * we can support any size GET requests. |
@@ -848,7 +848,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
848 | } | 848 | } |
849 | 849 | ||
850 | /* If it is a SET, get all the extra data in here */ | 850 | /* If it is a SET, get all the extra data in here */ |
851 | if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { | 851 | if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { |
852 | err = copy_from_user(extra, iwr->u.data.pointer, | 852 | err = copy_from_user(extra, iwr->u.data.pointer, |
853 | iwr->u.data.length * | 853 | iwr->u.data.length * |
854 | descr->token_size); | 854 | descr->token_size); |
@@ -871,7 +871,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
871 | /* If we have something to return to the user */ | 871 | /* If we have something to return to the user */ |
872 | if (!ret && IW_IS_GET(cmd)) { | 872 | if (!ret && IW_IS_GET(cmd)) { |
873 | /* Check if there is enough buffer up there */ | 873 | /* Check if there is enough buffer up there */ |
874 | if(user_length < iwr->u.data.length) { | 874 | if (user_length < iwr->u.data.length) { |
875 | kfree(extra); | 875 | kfree(extra); |
876 | return -E2BIG; | 876 | return -E2BIG; |
877 | } | 877 | } |
@@ -890,9 +890,9 @@ static int ioctl_standard_call(struct net_device * dev, | |||
890 | 890 | ||
891 | #ifdef WE_SET_EVENT | 891 | #ifdef WE_SET_EVENT |
892 | /* Generate an event to notify listeners of the change */ | 892 | /* Generate an event to notify listeners of the change */ |
893 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 893 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
894 | ((ret == 0) || (ret == -EIWCOMMIT))) { | 894 | ((ret == 0) || (ret == -EIWCOMMIT))) { |
895 | if(descr->flags & IW_DESCR_FLAG_RESTRICT) | 895 | if (descr->flags & IW_DESCR_FLAG_RESTRICT) |
896 | /* If the event is restricted, don't | 896 | /* If the event is restricted, don't |
897 | * export the payload */ | 897 | * export the payload */ |
898 | wireless_send_event(dev, cmd, &(iwr->u), NULL); | 898 | wireless_send_event(dev, cmd, &(iwr->u), NULL); |
@@ -907,7 +907,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
907 | } | 907 | } |
908 | 908 | ||
909 | /* Call commit handler if needed and defined */ | 909 | /* Call commit handler if needed and defined */ |
910 | if(ret == -EIWCOMMIT) | 910 | if (ret == -EIWCOMMIT) |
911 | ret = call_commit_handler(dev); | 911 | ret = call_commit_handler(dev); |
912 | 912 | ||
913 | /* Here, we will generate the appropriate event if needed */ | 913 | /* Here, we will generate the appropriate event if needed */ |
@@ -944,8 +944,8 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
944 | int ret = -EINVAL; | 944 | int ret = -EINVAL; |
945 | 945 | ||
946 | /* Get the description of the IOCTL */ | 946 | /* Get the description of the IOCTL */ |
947 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 947 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
948 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 948 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
949 | descr = &(dev->wireless_handlers->private_args[i]); | 949 | descr = &(dev->wireless_handlers->private_args[i]); |
950 | break; | 950 | break; |
951 | } | 951 | } |
@@ -953,7 +953,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
953 | #ifdef WE_IOCTL_DEBUG | 953 | #ifdef WE_IOCTL_DEBUG |
954 | printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n", | 954 | printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n", |
955 | ifr->ifr_name, cmd); | 955 | ifr->ifr_name, cmd); |
956 | if(descr) { | 956 | if (descr) { |
957 | printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n", | 957 | printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n", |
958 | dev->name, descr->name, | 958 | dev->name, descr->name, |
959 | descr->set_args, descr->get_args); | 959 | descr->set_args, descr->get_args); |
@@ -961,11 +961,11 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
961 | #endif /* WE_IOCTL_DEBUG */ | 961 | #endif /* WE_IOCTL_DEBUG */ |
962 | 962 | ||
963 | /* Compute the size of the set/get arguments */ | 963 | /* Compute the size of the set/get arguments */ |
964 | if(descr != NULL) { | 964 | if (descr != NULL) { |
965 | if(IW_IS_SET(cmd)) { | 965 | if (IW_IS_SET(cmd)) { |
966 | int offset = 0; /* For sub-ioctls */ | 966 | int offset = 0; /* For sub-ioctls */ |
967 | /* Check for sub-ioctl handler */ | 967 | /* Check for sub-ioctl handler */ |
968 | if(descr->name[0] == '\0') | 968 | if (descr->name[0] == '\0') |
969 | /* Reserve one int for sub-ioctl index */ | 969 | /* Reserve one int for sub-ioctl index */ |
970 | offset = sizeof(__u32); | 970 | offset = sizeof(__u32); |
971 | 971 | ||
@@ -973,7 +973,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
973 | extra_size = get_priv_size(descr->set_args); | 973 | extra_size = get_priv_size(descr->set_args); |
974 | 974 | ||
975 | /* Does it fits in iwr ? */ | 975 | /* Does it fits in iwr ? */ |
976 | if((descr->set_args & IW_PRIV_SIZE_FIXED) && | 976 | if ((descr->set_args & IW_PRIV_SIZE_FIXED) && |
977 | ((extra_size + offset) <= IFNAMSIZ)) | 977 | ((extra_size + offset) <= IFNAMSIZ)) |
978 | extra_size = 0; | 978 | extra_size = 0; |
979 | } else { | 979 | } else { |
@@ -981,7 +981,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
981 | extra_size = get_priv_size(descr->get_args); | 981 | extra_size = get_priv_size(descr->get_args); |
982 | 982 | ||
983 | /* Does it fits in iwr ? */ | 983 | /* Does it fits in iwr ? */ |
984 | if((descr->get_args & IW_PRIV_SIZE_FIXED) && | 984 | if ((descr->get_args & IW_PRIV_SIZE_FIXED) && |
985 | (extra_size <= IFNAMSIZ)) | 985 | (extra_size <= IFNAMSIZ)) |
986 | extra_size = 0; | 986 | extra_size = 0; |
987 | } | 987 | } |
@@ -992,7 +992,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
992 | info.flags = 0; | 992 | info.flags = 0; |
993 | 993 | ||
994 | /* Check if we have a pointer to user space data or not. */ | 994 | /* Check if we have a pointer to user space data or not. */ |
995 | if(extra_size == 0) { | 995 | if (extra_size == 0) { |
996 | /* No extra arguments. Trivial to handle */ | 996 | /* No extra arguments. Trivial to handle */ |
997 | ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u)); | 997 | ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u)); |
998 | } else { | 998 | } else { |
@@ -1000,19 +1000,19 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1000 | int err; | 1000 | int err; |
1001 | 1001 | ||
1002 | /* Check what user space is giving us */ | 1002 | /* Check what user space is giving us */ |
1003 | if(IW_IS_SET(cmd)) { | 1003 | if (IW_IS_SET(cmd)) { |
1004 | /* Check NULL pointer */ | 1004 | /* Check NULL pointer */ |
1005 | if((iwr->u.data.pointer == NULL) && | 1005 | if ((iwr->u.data.pointer == NULL) && |
1006 | (iwr->u.data.length != 0)) | 1006 | (iwr->u.data.length != 0)) |
1007 | return -EFAULT; | 1007 | return -EFAULT; |
1008 | 1008 | ||
1009 | /* Does it fits within bounds ? */ | 1009 | /* Does it fits within bounds ? */ |
1010 | if(iwr->u.data.length > (descr->set_args & | 1010 | if (iwr->u.data.length > (descr->set_args & |
1011 | IW_PRIV_SIZE_MASK)) | 1011 | IW_PRIV_SIZE_MASK)) |
1012 | return -E2BIG; | 1012 | return -E2BIG; |
1013 | } else { | 1013 | } else { |
1014 | /* Check NULL pointer */ | 1014 | /* Check NULL pointer */ |
1015 | if(iwr->u.data.pointer == NULL) | 1015 | if (iwr->u.data.pointer == NULL) |
1016 | return -EFAULT; | 1016 | return -EFAULT; |
1017 | } | 1017 | } |
1018 | 1018 | ||
@@ -1029,7 +1029,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | /* If it is a SET, get all the extra data in here */ | 1031 | /* If it is a SET, get all the extra data in here */ |
1032 | if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { | 1032 | if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { |
1033 | err = copy_from_user(extra, iwr->u.data.pointer, | 1033 | err = copy_from_user(extra, iwr->u.data.pointer, |
1034 | extra_size); | 1034 | extra_size); |
1035 | if (err) { | 1035 | if (err) { |
@@ -1071,7 +1071,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1071 | 1071 | ||
1072 | 1072 | ||
1073 | /* Call commit handler if needed and defined */ | 1073 | /* Call commit handler if needed and defined */ |
1074 | if(ret == -EIWCOMMIT) | 1074 | if (ret == -EIWCOMMIT) |
1075 | ret = call_commit_handler(dev); | 1075 | ret = call_commit_handler(dev); |
1076 | 1076 | ||
1077 | return ret; | 1077 | return ret; |
@@ -1098,51 +1098,50 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1098 | /* A bunch of special cases, then the generic case... | 1098 | /* A bunch of special cases, then the generic case... |
1099 | * Note that 'cmd' is already filtered in dev_ioctl() with | 1099 | * Note that 'cmd' is already filtered in dev_ioctl() with |
1100 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ | 1100 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ |
1101 | switch(cmd) | 1101 | switch (cmd) { |
1102 | { | 1102 | case SIOCGIWSTATS: |
1103 | case SIOCGIWSTATS: | 1103 | /* Get Wireless Stats */ |
1104 | /* Get Wireless Stats */ | 1104 | return ioctl_standard_call(dev, |
1105 | ifr, | ||
1106 | cmd, | ||
1107 | &iw_handler_get_iwstats); | ||
1108 | |||
1109 | case SIOCGIWPRIV: | ||
1110 | /* Check if we have some wireless handlers defined */ | ||
1111 | if (dev->wireless_handlers != NULL) { | ||
1112 | /* We export to user space the definition of | ||
1113 | * the private handler ourselves */ | ||
1105 | return ioctl_standard_call(dev, | 1114 | return ioctl_standard_call(dev, |
1106 | ifr, | 1115 | ifr, |
1107 | cmd, | 1116 | cmd, |
1108 | &iw_handler_get_iwstats); | 1117 | &iw_handler_get_private); |
1109 | 1118 | } | |
1110 | case SIOCGIWPRIV: | 1119 | // ## Fall-through for old API ## |
1111 | /* Check if we have some wireless handlers defined */ | 1120 | default: |
1112 | if(dev->wireless_handlers != NULL) { | 1121 | /* Generic IOCTL */ |
1113 | /* We export to user space the definition of | 1122 | /* Basic check */ |
1114 | * the private handler ourselves */ | 1123 | if (!netif_device_present(dev)) |
1124 | return -ENODEV; | ||
1125 | /* New driver API : try to find the handler */ | ||
1126 | handler = get_handler(dev, cmd); | ||
1127 | if (handler != NULL) { | ||
1128 | /* Standard and private are not the same */ | ||
1129 | if (cmd < SIOCIWFIRSTPRIV) | ||
1115 | return ioctl_standard_call(dev, | 1130 | return ioctl_standard_call(dev, |
1116 | ifr, | 1131 | ifr, |
1117 | cmd, | 1132 | cmd, |
1118 | &iw_handler_get_private); | 1133 | handler); |
1119 | } | 1134 | else |
1120 | // ## Fall-through for old API ## | 1135 | return ioctl_private_call(dev, |
1121 | default: | 1136 | ifr, |
1122 | /* Generic IOCTL */ | 1137 | cmd, |
1123 | /* Basic check */ | 1138 | handler); |
1124 | if (!netif_device_present(dev)) | 1139 | } |
1125 | return -ENODEV; | 1140 | /* Old driver API : call driver ioctl handler */ |
1126 | /* New driver API : try to find the handler */ | 1141 | if (dev->do_ioctl) { |
1127 | handler = get_handler(dev, cmd); | 1142 | return dev->do_ioctl(dev, ifr, cmd); |
1128 | if(handler != NULL) { | 1143 | } |
1129 | /* Standard and private are not the same */ | 1144 | return -EOPNOTSUPP; |
1130 | if(cmd < SIOCIWFIRSTPRIV) | ||
1131 | return ioctl_standard_call(dev, | ||
1132 | ifr, | ||
1133 | cmd, | ||
1134 | handler); | ||
1135 | else | ||
1136 | return ioctl_private_call(dev, | ||
1137 | ifr, | ||
1138 | cmd, | ||
1139 | handler); | ||
1140 | } | ||
1141 | /* Old driver API : call driver ioctl handler */ | ||
1142 | if (dev->do_ioctl) { | ||
1143 | return dev->do_ioctl(dev, ifr, cmd); | ||
1144 | } | ||
1145 | return -EOPNOTSUPP; | ||
1146 | } | 1145 | } |
1147 | /* Not reached */ | 1146 | /* Not reached */ |
1148 | return -EINVAL; | 1147 | return -EINVAL; |
@@ -1196,7 +1195,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1196 | 1195 | ||
1197 | /* Get the description of the Request */ | 1196 | /* Get the description of the Request */ |
1198 | cmd = request->cmd; | 1197 | cmd = request->cmd; |
1199 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 1198 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
1200 | return -EOPNOTSUPP; | 1199 | return -EOPNOTSUPP; |
1201 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 1200 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
1202 | 1201 | ||
@@ -1208,7 +1207,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1208 | 1207 | ||
1209 | /* Check if wrqu is complete */ | 1208 | /* Check if wrqu is complete */ |
1210 | hdr_len = event_type_size[descr->header_type]; | 1209 | hdr_len = event_type_size[descr->header_type]; |
1211 | if(request_len < hdr_len) { | 1210 | if (request_len < hdr_len) { |
1212 | #ifdef WE_RTNETLINK_DEBUG | 1211 | #ifdef WE_RTNETLINK_DEBUG |
1213 | printk(KERN_DEBUG | 1212 | printk(KERN_DEBUG |
1214 | "%s (WE.r) : Wireless request too short (%d)\n", | 1213 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1222,7 +1221,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1222 | info.flags = 0; | 1221 | info.flags = 0; |
1223 | 1222 | ||
1224 | /* Check if we have extra data in the reply or not */ | 1223 | /* Check if we have extra data in the reply or not */ |
1225 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 1224 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
1226 | 1225 | ||
1227 | /* Create the kernel buffer that we will return. | 1226 | /* Create the kernel buffer that we will return. |
1228 | * It's at an offset to match the TYPE_POINT case... */ | 1227 | * It's at an offset to match the TYPE_POINT case... */ |
@@ -1254,7 +1253,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1254 | * for max space. Easier, and won't last long... */ | 1253 | * for max space. Easier, and won't last long... */ |
1255 | extra_size = descr->max_tokens * descr->token_size; | 1254 | extra_size = descr->max_tokens * descr->token_size; |
1256 | /* Support for very large requests */ | 1255 | /* Support for very large requests */ |
1257 | if((descr->flags & IW_DESCR_FLAG_NOMAX) && | 1256 | if ((descr->flags & IW_DESCR_FLAG_NOMAX) && |
1258 | (wrqu_point.data.length > descr->max_tokens)) | 1257 | (wrqu_point.data.length > descr->max_tokens)) |
1259 | extra_size = (wrqu_point.data.length | 1258 | extra_size = (wrqu_point.data.length |
1260 | * descr->token_size); | 1259 | * descr->token_size); |
@@ -1299,7 +1298,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1299 | #endif /* WE_RTNETLINK_DEBUG */ | 1298 | #endif /* WE_RTNETLINK_DEBUG */ |
1300 | 1299 | ||
1301 | /* Check if there is enough buffer up there */ | 1300 | /* Check if there is enough buffer up there */ |
1302 | if(wrqu_point.data.length < wrqu->data.length) | 1301 | if (wrqu_point.data.length < wrqu->data.length) |
1303 | ret = -E2BIG; | 1302 | ret = -E2BIG; |
1304 | } | 1303 | } |
1305 | 1304 | ||
@@ -1309,7 +1308,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1309 | *p_len = request->len; | 1308 | *p_len = request->len; |
1310 | } else { | 1309 | } else { |
1311 | /* Cleanup */ | 1310 | /* Cleanup */ |
1312 | if(buffer) | 1311 | if (buffer) |
1313 | kfree(buffer); | 1312 | kfree(buffer); |
1314 | } | 1313 | } |
1315 | 1314 | ||
@@ -1338,7 +1337,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1338 | 1337 | ||
1339 | /* Get the description of the Request */ | 1338 | /* Get the description of the Request */ |
1340 | cmd = request->cmd; | 1339 | cmd = request->cmd; |
1341 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 1340 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
1342 | return -EOPNOTSUPP; | 1341 | return -EOPNOTSUPP; |
1343 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 1342 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
1344 | 1343 | ||
@@ -1353,7 +1352,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1353 | 1352 | ||
1354 | /* Check if wrqu is complete */ | 1353 | /* Check if wrqu is complete */ |
1355 | hdr_len = event_type_pk_size[descr->header_type]; | 1354 | hdr_len = event_type_pk_size[descr->header_type]; |
1356 | if(request_len < hdr_len) { | 1355 | if (request_len < hdr_len) { |
1357 | #ifdef WE_RTNETLINK_DEBUG | 1356 | #ifdef WE_RTNETLINK_DEBUG |
1358 | printk(KERN_DEBUG | 1357 | printk(KERN_DEBUG |
1359 | "%s (WE.r) : Wireless request too short (%d)\n", | 1358 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1367,7 +1366,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1367 | info.flags = 0; | 1366 | info.flags = 0; |
1368 | 1367 | ||
1369 | /* Check if we have extra data in the request or not */ | 1368 | /* Check if we have extra data in the request or not */ |
1370 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 1369 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
1371 | 1370 | ||
1372 | /* No extra arguments. Trivial to handle */ | 1371 | /* No extra arguments. Trivial to handle */ |
1373 | ret = handler(dev, &info, wrqu, NULL); | 1372 | ret = handler(dev, &info, wrqu, NULL); |
@@ -1382,16 +1381,16 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1382 | wrqu = &wrqu_point; | 1381 | wrqu = &wrqu_point; |
1383 | 1382 | ||
1384 | /* Check if number of token fits within bounds */ | 1383 | /* Check if number of token fits within bounds */ |
1385 | if(wrqu_point.data.length > descr->max_tokens) | 1384 | if (wrqu_point.data.length > descr->max_tokens) |
1386 | return -E2BIG; | 1385 | return -E2BIG; |
1387 | if(wrqu_point.data.length < descr->min_tokens) | 1386 | if (wrqu_point.data.length < descr->min_tokens) |
1388 | return -EINVAL; | 1387 | return -EINVAL; |
1389 | 1388 | ||
1390 | /* Real length of payload */ | 1389 | /* Real length of payload */ |
1391 | extra_len = wrqu_point.data.length * descr->token_size; | 1390 | extra_len = wrqu_point.data.length * descr->token_size; |
1392 | 1391 | ||
1393 | /* Check if request is self consistent */ | 1392 | /* Check if request is self consistent */ |
1394 | if((request_len - hdr_len) < extra_len) { | 1393 | if ((request_len - hdr_len) < extra_len) { |
1395 | #ifdef WE_RTNETLINK_DEBUG | 1394 | #ifdef WE_RTNETLINK_DEBUG |
1396 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", | 1395 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", |
1397 | dev->name, extra_size); | 1396 | dev->name, extra_size); |
@@ -1420,9 +1419,9 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1420 | 1419 | ||
1421 | #ifdef WE_SET_EVENT | 1420 | #ifdef WE_SET_EVENT |
1422 | /* Generate an event to notify listeners of the change */ | 1421 | /* Generate an event to notify listeners of the change */ |
1423 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 1422 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
1424 | ((ret == 0) || (ret == -EIWCOMMIT))) { | 1423 | ((ret == 0) || (ret == -EIWCOMMIT))) { |
1425 | if(descr->flags & IW_DESCR_FLAG_RESTRICT) | 1424 | if (descr->flags & IW_DESCR_FLAG_RESTRICT) |
1426 | /* If the event is restricted, don't | 1425 | /* If the event is restricted, don't |
1427 | * export the payload */ | 1426 | * export the payload */ |
1428 | wireless_send_event(dev, cmd, wrqu, NULL); | 1427 | wireless_send_event(dev, cmd, wrqu, NULL); |
@@ -1432,11 +1431,11 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1432 | #endif /* WE_SET_EVENT */ | 1431 | #endif /* WE_SET_EVENT */ |
1433 | 1432 | ||
1434 | /* Cleanup - I told you it wasn't that long ;-) */ | 1433 | /* Cleanup - I told you it wasn't that long ;-) */ |
1435 | if(extra) | 1434 | if (extra) |
1436 | kfree(extra); | 1435 | kfree(extra); |
1437 | 1436 | ||
1438 | /* Call commit handler if needed and defined */ | 1437 | /* Call commit handler if needed and defined */ |
1439 | if(ret == -EIWCOMMIT) | 1438 | if (ret == -EIWCOMMIT) |
1440 | ret = call_commit_handler(dev); | 1439 | ret = call_commit_handler(dev); |
1441 | 1440 | ||
1442 | return ret; | 1441 | return ret; |
@@ -1477,12 +1476,12 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1477 | 1476 | ||
1478 | /* Get the description of the Request */ | 1477 | /* Get the description of the Request */ |
1479 | cmd = request->cmd; | 1478 | cmd = request->cmd; |
1480 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 1479 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
1481 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 1480 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
1482 | descr = &(dev->wireless_handlers->private_args[i]); | 1481 | descr = &(dev->wireless_handlers->private_args[i]); |
1483 | break; | 1482 | break; |
1484 | } | 1483 | } |
1485 | if(descr == NULL) | 1484 | if (descr == NULL) |
1486 | return -EOPNOTSUPP; | 1485 | return -EOPNOTSUPP; |
1487 | 1486 | ||
1488 | #ifdef WE_RTNETLINK_DEBUG | 1487 | #ifdef WE_RTNETLINK_DEBUG |
@@ -1496,7 +1495,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1496 | extra_size = get_priv_size(descr->get_args); | 1495 | extra_size = get_priv_size(descr->get_args); |
1497 | 1496 | ||
1498 | /* Does it fits in wrqu ? */ | 1497 | /* Does it fits in wrqu ? */ |
1499 | if((descr->get_args & IW_PRIV_SIZE_FIXED) && | 1498 | if ((descr->get_args & IW_PRIV_SIZE_FIXED) && |
1500 | (extra_size <= IFNAMSIZ)) { | 1499 | (extra_size <= IFNAMSIZ)) { |
1501 | hdr_len = extra_size; | 1500 | hdr_len = extra_size; |
1502 | extra_size = 0; | 1501 | extra_size = 0; |
@@ -1505,7 +1504,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1505 | } | 1504 | } |
1506 | 1505 | ||
1507 | /* Check if wrqu is complete */ | 1506 | /* Check if wrqu is complete */ |
1508 | if(request_len < hdr_len) { | 1507 | if (request_len < hdr_len) { |
1509 | #ifdef WE_RTNETLINK_DEBUG | 1508 | #ifdef WE_RTNETLINK_DEBUG |
1510 | printk(KERN_DEBUG | 1509 | printk(KERN_DEBUG |
1511 | "%s (WE.r) : Wireless request too short (%d)\n", | 1510 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1519,7 +1518,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1519 | info.flags = 0; | 1518 | info.flags = 0; |
1520 | 1519 | ||
1521 | /* Check if we have a pointer to user space data or not. */ | 1520 | /* Check if we have a pointer to user space data or not. */ |
1522 | if(extra_size == 0) { | 1521 | if (extra_size == 0) { |
1523 | 1522 | ||
1524 | /* Create the kernel buffer that we will return. | 1523 | /* Create the kernel buffer that we will return. |
1525 | * It's at an offset to match the TYPE_POINT case... */ | 1524 | * It's at an offset to match the TYPE_POINT case... */ |
@@ -1591,7 +1590,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1591 | *p_len = request->len; | 1590 | *p_len = request->len; |
1592 | } else { | 1591 | } else { |
1593 | /* Cleanup */ | 1592 | /* Cleanup */ |
1594 | if(buffer) | 1593 | if (buffer) |
1595 | kfree(buffer); | 1594 | kfree(buffer); |
1596 | } | 1595 | } |
1597 | 1596 | ||
@@ -1632,12 +1631,12 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1632 | 1631 | ||
1633 | /* Get the description of the Request */ | 1632 | /* Get the description of the Request */ |
1634 | cmd = request->cmd; | 1633 | cmd = request->cmd; |
1635 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 1634 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
1636 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 1635 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
1637 | descr = &(dev->wireless_handlers->private_args[i]); | 1636 | descr = &(dev->wireless_handlers->private_args[i]); |
1638 | break; | 1637 | break; |
1639 | } | 1638 | } |
1640 | if(descr == NULL) | 1639 | if (descr == NULL) |
1641 | return -EOPNOTSUPP; | 1640 | return -EOPNOTSUPP; |
1642 | 1641 | ||
1643 | #ifdef WE_RTNETLINK_DEBUG | 1642 | #ifdef WE_RTNETLINK_DEBUG |
@@ -1649,7 +1648,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1649 | 1648 | ||
1650 | /* Compute the size of the set arguments */ | 1649 | /* Compute the size of the set arguments */ |
1651 | /* Check for sub-ioctl handler */ | 1650 | /* Check for sub-ioctl handler */ |
1652 | if(descr->name[0] == '\0') | 1651 | if (descr->name[0] == '\0') |
1653 | /* Reserve one int for sub-ioctl index */ | 1652 | /* Reserve one int for sub-ioctl index */ |
1654 | offset = sizeof(__u32); | 1653 | offset = sizeof(__u32); |
1655 | 1654 | ||
@@ -1657,7 +1656,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1657 | extra_size = get_priv_size(descr->set_args); | 1656 | extra_size = get_priv_size(descr->set_args); |
1658 | 1657 | ||
1659 | /* Does it fits in wrqu ? */ | 1658 | /* Does it fits in wrqu ? */ |
1660 | if((descr->set_args & IW_PRIV_SIZE_FIXED) && | 1659 | if ((descr->set_args & IW_PRIV_SIZE_FIXED) && |
1661 | (extra_size <= IFNAMSIZ)) { | 1660 | (extra_size <= IFNAMSIZ)) { |
1662 | hdr_len = IW_EV_LCP_PK_LEN + extra_size; | 1661 | hdr_len = IW_EV_LCP_PK_LEN + extra_size; |
1663 | extra_size = 0; | 1662 | extra_size = 0; |
@@ -1669,7 +1668,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1669 | wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN); | 1668 | wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN); |
1670 | 1669 | ||
1671 | /* Check if wrqu is complete */ | 1670 | /* Check if wrqu is complete */ |
1672 | if(request_len < hdr_len) { | 1671 | if (request_len < hdr_len) { |
1673 | #ifdef WE_RTNETLINK_DEBUG | 1672 | #ifdef WE_RTNETLINK_DEBUG |
1674 | printk(KERN_DEBUG | 1673 | printk(KERN_DEBUG |
1675 | "%s (WE.r) : Wireless request too short (%d)\n", | 1674 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1683,7 +1682,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1683 | info.flags = 0; | 1682 | info.flags = 0; |
1684 | 1683 | ||
1685 | /* Check if we have a pointer to user space data or not. */ | 1684 | /* Check if we have a pointer to user space data or not. */ |
1686 | if(extra_size == 0) { | 1685 | if (extra_size == 0) { |
1687 | 1686 | ||
1688 | /* No extra arguments. Trivial to handle */ | 1687 | /* No extra arguments. Trivial to handle */ |
1689 | ret = handler(dev, &info, wrqu, (char *) wrqu); | 1688 | ret = handler(dev, &info, wrqu, (char *) wrqu); |
@@ -1696,7 +1695,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1696 | wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); | 1695 | wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); |
1697 | 1696 | ||
1698 | /* Does it fits within bounds ? */ | 1697 | /* Does it fits within bounds ? */ |
1699 | if(wrqu_point.data.length > (descr->set_args & | 1698 | if (wrqu_point.data.length > (descr->set_args & |
1700 | IW_PRIV_SIZE_MASK)) | 1699 | IW_PRIV_SIZE_MASK)) |
1701 | return -E2BIG; | 1700 | return -E2BIG; |
1702 | 1701 | ||
@@ -1704,7 +1703,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1704 | extra_len = adjust_priv_size(descr->set_args, &wrqu_point); | 1703 | extra_len = adjust_priv_size(descr->set_args, &wrqu_point); |
1705 | 1704 | ||
1706 | /* Check if request is self consistent */ | 1705 | /* Check if request is self consistent */ |
1707 | if((request_len - hdr_len) < extra_len) { | 1706 | if ((request_len - hdr_len) < extra_len) { |
1708 | #ifdef WE_RTNETLINK_DEBUG | 1707 | #ifdef WE_RTNETLINK_DEBUG |
1709 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", | 1708 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", |
1710 | dev->name, extra_size); | 1709 | dev->name, extra_size); |
@@ -1734,7 +1733,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1734 | } | 1733 | } |
1735 | 1734 | ||
1736 | /* Call commit handler if needed and defined */ | 1735 | /* Call commit handler if needed and defined */ |
1737 | if(ret == -EIWCOMMIT) | 1736 | if (ret == -EIWCOMMIT) |
1738 | ret = call_commit_handler(dev); | 1737 | ret = call_commit_handler(dev); |
1739 | 1738 | ||
1740 | return ret; | 1739 | return ret; |
@@ -1756,21 +1755,21 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1756 | iw_handler handler; | 1755 | iw_handler handler; |
1757 | 1756 | ||
1758 | /* Check length */ | 1757 | /* Check length */ |
1759 | if(len < IW_EV_LCP_PK_LEN) { | 1758 | if (len < IW_EV_LCP_PK_LEN) { |
1760 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", | 1759 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", |
1761 | dev->name, len); | 1760 | dev->name, len); |
1762 | return -EINVAL; | 1761 | return -EINVAL; |
1763 | } | 1762 | } |
1764 | 1763 | ||
1765 | /* ReCheck length (len may have padding) */ | 1764 | /* ReCheck length (len may have padding) */ |
1766 | if(request->len > len) { | 1765 | if (request->len > len) { |
1767 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", | 1766 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", |
1768 | dev->name, request->len, len); | 1767 | dev->name, request->len, len); |
1769 | return -EINVAL; | 1768 | return -EINVAL; |
1770 | } | 1769 | } |
1771 | 1770 | ||
1772 | /* Only accept GET requests in here */ | 1771 | /* Only accept GET requests in here */ |
1773 | if(!IW_IS_GET(request->cmd)) | 1772 | if (!IW_IS_GET(request->cmd)) |
1774 | return -EOPNOTSUPP; | 1773 | return -EOPNOTSUPP; |
1775 | 1774 | ||
1776 | /* If command is `get the encoding parameters', check if | 1775 | /* If command is `get the encoding parameters', check if |
@@ -1782,16 +1781,16 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1782 | } | 1781 | } |
1783 | 1782 | ||
1784 | /* Special cases */ | 1783 | /* Special cases */ |
1785 | if(request->cmd == SIOCGIWSTATS) | 1784 | if (request->cmd == SIOCGIWSTATS) |
1786 | /* Get Wireless Stats */ | 1785 | /* Get Wireless Stats */ |
1787 | return rtnetlink_standard_get(dev, | 1786 | return rtnetlink_standard_get(dev, |
1788 | request, | 1787 | request, |
1789 | request->len, | 1788 | request->len, |
1790 | &iw_handler_get_iwstats, | 1789 | &iw_handler_get_iwstats, |
1791 | p_buf, p_len); | 1790 | p_buf, p_len); |
1792 | if(request->cmd == SIOCGIWPRIV) { | 1791 | if (request->cmd == SIOCGIWPRIV) { |
1793 | /* Check if we have some wireless handlers defined */ | 1792 | /* Check if we have some wireless handlers defined */ |
1794 | if(dev->wireless_handlers == NULL) | 1793 | if (dev->wireless_handlers == NULL) |
1795 | return -EOPNOTSUPP; | 1794 | return -EOPNOTSUPP; |
1796 | /* Get Wireless Stats */ | 1795 | /* Get Wireless Stats */ |
1797 | return rtnetlink_standard_get(dev, | 1796 | return rtnetlink_standard_get(dev, |
@@ -1807,9 +1806,9 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1807 | 1806 | ||
1808 | /* Try to find the handler */ | 1807 | /* Try to find the handler */ |
1809 | handler = get_handler(dev, request->cmd); | 1808 | handler = get_handler(dev, request->cmd); |
1810 | if(handler != NULL) { | 1809 | if (handler != NULL) { |
1811 | /* Standard and private are not the same */ | 1810 | /* Standard and private are not the same */ |
1812 | if(request->cmd < SIOCIWFIRSTPRIV) | 1811 | if (request->cmd < SIOCIWFIRSTPRIV) |
1813 | return rtnetlink_standard_get(dev, | 1812 | return rtnetlink_standard_get(dev, |
1814 | request, | 1813 | request, |
1815 | request->len, | 1814 | request->len, |
@@ -1840,21 +1839,21 @@ int wireless_rtnetlink_set(struct net_device * dev, | |||
1840 | iw_handler handler; | 1839 | iw_handler handler; |
1841 | 1840 | ||
1842 | /* Check length */ | 1841 | /* Check length */ |
1843 | if(len < IW_EV_LCP_PK_LEN) { | 1842 | if (len < IW_EV_LCP_PK_LEN) { |
1844 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", | 1843 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", |
1845 | dev->name, len); | 1844 | dev->name, len); |
1846 | return -EINVAL; | 1845 | return -EINVAL; |
1847 | } | 1846 | } |
1848 | 1847 | ||
1849 | /* ReCheck length (len may have padding) */ | 1848 | /* ReCheck length (len may have padding) */ |
1850 | if(request->len > len) { | 1849 | if (request->len > len) { |
1851 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", | 1850 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", |
1852 | dev->name, request->len, len); | 1851 | dev->name, request->len, len); |
1853 | return -EINVAL; | 1852 | return -EINVAL; |
1854 | } | 1853 | } |
1855 | 1854 | ||
1856 | /* Only accept SET requests in here */ | 1855 | /* Only accept SET requests in here */ |
1857 | if(!IW_IS_SET(request->cmd)) | 1856 | if (!IW_IS_SET(request->cmd)) |
1858 | return -EOPNOTSUPP; | 1857 | return -EOPNOTSUPP; |
1859 | 1858 | ||
1860 | /* Basic check */ | 1859 | /* Basic check */ |
@@ -1863,9 +1862,9 @@ int wireless_rtnetlink_set(struct net_device * dev, | |||
1863 | 1862 | ||
1864 | /* New driver API : try to find the handler */ | 1863 | /* New driver API : try to find the handler */ |
1865 | handler = get_handler(dev, request->cmd); | 1864 | handler = get_handler(dev, request->cmd); |
1866 | if(handler != NULL) { | 1865 | if (handler != NULL) { |
1867 | /* Standard and private are not the same */ | 1866 | /* Standard and private are not the same */ |
1868 | if(request->cmd < SIOCIWFIRSTPRIV) | 1867 | if (request->cmd < SIOCIWFIRSTPRIV) |
1869 | return rtnetlink_standard_set(dev, | 1868 | return rtnetlink_standard_set(dev, |
1870 | request, | 1869 | request, |
1871 | request->len, | 1870 | request->len, |
@@ -2015,17 +2014,17 @@ void wireless_send_event(struct net_device * dev, | |||
2015 | unsigned cmd_index; /* *MUST* be unsigned */ | 2014 | unsigned cmd_index; /* *MUST* be unsigned */ |
2016 | 2015 | ||
2017 | /* Get the description of the Event */ | 2016 | /* Get the description of the Event */ |
2018 | if(cmd <= SIOCIWLAST) { | 2017 | if (cmd <= SIOCIWLAST) { |
2019 | cmd_index = cmd - SIOCIWFIRST; | 2018 | cmd_index = cmd - SIOCIWFIRST; |
2020 | if(cmd_index < standard_ioctl_num) | 2019 | if (cmd_index < standard_ioctl_num) |
2021 | descr = &(standard_ioctl[cmd_index]); | 2020 | descr = &(standard_ioctl[cmd_index]); |
2022 | } else { | 2021 | } else { |
2023 | cmd_index = cmd - IWEVFIRST; | 2022 | cmd_index = cmd - IWEVFIRST; |
2024 | if(cmd_index < standard_event_num) | 2023 | if (cmd_index < standard_event_num) |
2025 | descr = &(standard_event[cmd_index]); | 2024 | descr = &(standard_event[cmd_index]); |
2026 | } | 2025 | } |
2027 | /* Don't accept unknown events */ | 2026 | /* Don't accept unknown events */ |
2028 | if(descr == NULL) { | 2027 | if (descr == NULL) { |
2029 | /* Note : we don't return an error to the driver, because | 2028 | /* Note : we don't return an error to the driver, because |
2030 | * the driver would not know what to do about it. It can't | 2029 | * the driver would not know what to do about it. It can't |
2031 | * return an error to the user, because the event is not | 2030 | * return an error to the user, because the event is not |
@@ -2044,18 +2043,18 @@ void wireless_send_event(struct net_device * dev, | |||
2044 | #endif /* WE_EVENT_DEBUG */ | 2043 | #endif /* WE_EVENT_DEBUG */ |
2045 | 2044 | ||
2046 | /* Check extra parameters and set extra_len */ | 2045 | /* Check extra parameters and set extra_len */ |
2047 | if(descr->header_type == IW_HEADER_TYPE_POINT) { | 2046 | if (descr->header_type == IW_HEADER_TYPE_POINT) { |
2048 | /* Check if number of token fits within bounds */ | 2047 | /* Check if number of token fits within bounds */ |
2049 | if(wrqu->data.length > descr->max_tokens) { | 2048 | if (wrqu->data.length > descr->max_tokens) { |
2050 | printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length); | 2049 | printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length); |
2051 | return; | 2050 | return; |
2052 | } | 2051 | } |
2053 | if(wrqu->data.length < descr->min_tokens) { | 2052 | if (wrqu->data.length < descr->min_tokens) { |
2054 | printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length); | 2053 | printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length); |
2055 | return; | 2054 | return; |
2056 | } | 2055 | } |
2057 | /* Calculate extra_len - extra is NULL for restricted events */ | 2056 | /* Calculate extra_len - extra is NULL for restricted events */ |
2058 | if(extra != NULL) | 2057 | if (extra != NULL) |
2059 | extra_len = wrqu->data.length * descr->token_size; | 2058 | extra_len = wrqu->data.length * descr->token_size; |
2060 | /* Always at an offset in wrqu */ | 2059 | /* Always at an offset in wrqu */ |
2061 | wrqu_off = IW_EV_POINT_OFF; | 2060 | wrqu_off = IW_EV_POINT_OFF; |
@@ -2074,14 +2073,14 @@ void wireless_send_event(struct net_device * dev, | |||
2074 | 2073 | ||
2075 | /* Create temporary buffer to hold the event */ | 2074 | /* Create temporary buffer to hold the event */ |
2076 | event = kmalloc(event_len, GFP_ATOMIC); | 2075 | event = kmalloc(event_len, GFP_ATOMIC); |
2077 | if(event == NULL) | 2076 | if (event == NULL) |
2078 | return; | 2077 | return; |
2079 | 2078 | ||
2080 | /* Fill event */ | 2079 | /* Fill event */ |
2081 | event->len = event_len; | 2080 | event->len = event_len; |
2082 | event->cmd = cmd; | 2081 | event->cmd = cmd; |
2083 | memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN); | 2082 | memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN); |
2084 | if(extra != NULL) | 2083 | if (extra != NULL) |
2085 | memcpy(((char *) event) + hdr_len, extra, extra_len); | 2084 | memcpy(((char *) event) + hdr_len, extra, extra_len); |
2086 | 2085 | ||
2087 | #ifdef WE_EVENT_RTNETLINK | 2086 | #ifdef WE_EVENT_RTNETLINK |
@@ -2116,7 +2115,7 @@ void wireless_send_event(struct net_device * dev, | |||
2116 | static inline struct iw_spy_data * get_spydata(struct net_device *dev) | 2115 | static inline struct iw_spy_data * get_spydata(struct net_device *dev) |
2117 | { | 2116 | { |
2118 | /* This is the new way */ | 2117 | /* This is the new way */ |
2119 | if(dev->wireless_data) | 2118 | if (dev->wireless_data) |
2120 | return(dev->wireless_data->spy_data); | 2119 | return(dev->wireless_data->spy_data); |
2121 | return NULL; | 2120 | return NULL; |
2122 | } | 2121 | } |
@@ -2134,7 +2133,7 @@ int iw_handler_set_spy(struct net_device * dev, | |||
2134 | struct sockaddr * address = (struct sockaddr *) extra; | 2133 | struct sockaddr * address = (struct sockaddr *) extra; |
2135 | 2134 | ||
2136 | /* Make sure driver is not buggy or using the old API */ | 2135 | /* Make sure driver is not buggy or using the old API */ |
2137 | if(!spydata) | 2136 | if (!spydata) |
2138 | return -EOPNOTSUPP; | 2137 | return -EOPNOTSUPP; |
2139 | 2138 | ||
2140 | /* Disable spy collection while we copy the addresses. | 2139 | /* Disable spy collection while we copy the addresses. |
@@ -2151,11 +2150,11 @@ int iw_handler_set_spy(struct net_device * dev, | |||
2151 | smp_wmb(); | 2150 | smp_wmb(); |
2152 | 2151 | ||
2153 | /* Are there are addresses to copy? */ | 2152 | /* Are there are addresses to copy? */ |
2154 | if(wrqu->data.length > 0) { | 2153 | if (wrqu->data.length > 0) { |
2155 | int i; | 2154 | int i; |
2156 | 2155 | ||
2157 | /* Copy addresses */ | 2156 | /* Copy addresses */ |
2158 | for(i = 0; i < wrqu->data.length; i++) | 2157 | for (i = 0; i < wrqu->data.length; i++) |
2159 | memcpy(spydata->spy_address[i], address[i].sa_data, | 2158 | memcpy(spydata->spy_address[i], address[i].sa_data, |
2160 | ETH_ALEN); | 2159 | ETH_ALEN); |
2161 | /* Reset stats */ | 2160 | /* Reset stats */ |
@@ -2199,23 +2198,23 @@ int iw_handler_get_spy(struct net_device * dev, | |||
2199 | int i; | 2198 | int i; |
2200 | 2199 | ||
2201 | /* Make sure driver is not buggy or using the old API */ | 2200 | /* Make sure driver is not buggy or using the old API */ |
2202 | if(!spydata) | 2201 | if (!spydata) |
2203 | return -EOPNOTSUPP; | 2202 | return -EOPNOTSUPP; |
2204 | 2203 | ||
2205 | wrqu->data.length = spydata->spy_number; | 2204 | wrqu->data.length = spydata->spy_number; |
2206 | 2205 | ||
2207 | /* Copy addresses. */ | 2206 | /* Copy addresses. */ |
2208 | for(i = 0; i < spydata->spy_number; i++) { | 2207 | for (i = 0; i < spydata->spy_number; i++) { |
2209 | memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN); | 2208 | memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN); |
2210 | address[i].sa_family = AF_UNIX; | 2209 | address[i].sa_family = AF_UNIX; |
2211 | } | 2210 | } |
2212 | /* Copy stats to the user buffer (just after). */ | 2211 | /* Copy stats to the user buffer (just after). */ |
2213 | if(spydata->spy_number > 0) | 2212 | if (spydata->spy_number > 0) |
2214 | memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number), | 2213 | memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number), |
2215 | spydata->spy_stat, | 2214 | spydata->spy_stat, |
2216 | sizeof(struct iw_quality) * spydata->spy_number); | 2215 | sizeof(struct iw_quality) * spydata->spy_number); |
2217 | /* Reset updated flags. */ | 2216 | /* Reset updated flags. */ |
2218 | for(i = 0; i < spydata->spy_number; i++) | 2217 | for (i = 0; i < spydata->spy_number; i++) |
2219 | spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; | 2218 | spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; |
2220 | return 0; | 2219 | return 0; |
2221 | } | 2220 | } |
@@ -2233,7 +2232,7 @@ int iw_handler_set_thrspy(struct net_device * dev, | |||
2233 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; | 2232 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; |
2234 | 2233 | ||
2235 | /* Make sure driver is not buggy or using the old API */ | 2234 | /* Make sure driver is not buggy or using the old API */ |
2236 | if(!spydata) | 2235 | if (!spydata) |
2237 | return -EOPNOTSUPP; | 2236 | return -EOPNOTSUPP; |
2238 | 2237 | ||
2239 | /* Just do it */ | 2238 | /* Just do it */ |
@@ -2263,7 +2262,7 @@ int iw_handler_get_thrspy(struct net_device * dev, | |||
2263 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; | 2262 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; |
2264 | 2263 | ||
2265 | /* Make sure driver is not buggy or using the old API */ | 2264 | /* Make sure driver is not buggy or using the old API */ |
2266 | if(!spydata) | 2265 | if (!spydata) |
2267 | return -EOPNOTSUPP; | 2266 | return -EOPNOTSUPP; |
2268 | 2267 | ||
2269 | /* Just do it */ | 2268 | /* Just do it */ |
@@ -2327,7 +2326,7 @@ void wireless_spy_update(struct net_device * dev, | |||
2327 | int match = -1; | 2326 | int match = -1; |
2328 | 2327 | ||
2329 | /* Make sure driver is not buggy or using the old API */ | 2328 | /* Make sure driver is not buggy or using the old API */ |
2330 | if(!spydata) | 2329 | if (!spydata) |
2331 | return; | 2330 | return; |
2332 | 2331 | ||
2333 | #ifdef WE_SPY_DEBUG | 2332 | #ifdef WE_SPY_DEBUG |
@@ -2335,8 +2334,8 @@ void wireless_spy_update(struct net_device * dev, | |||
2335 | #endif /* WE_SPY_DEBUG */ | 2334 | #endif /* WE_SPY_DEBUG */ |
2336 | 2335 | ||
2337 | /* Update all records that match */ | 2336 | /* Update all records that match */ |
2338 | for(i = 0; i < spydata->spy_number; i++) | 2337 | for (i = 0; i < spydata->spy_number; i++) |
2339 | if(!compare_ether_addr(address, spydata->spy_address[i])) { | 2338 | if (!compare_ether_addr(address, spydata->spy_address[i])) { |
2340 | memcpy(&(spydata->spy_stat[i]), wstats, | 2339 | memcpy(&(spydata->spy_stat[i]), wstats, |
2341 | sizeof(struct iw_quality)); | 2340 | sizeof(struct iw_quality)); |
2342 | match = i; | 2341 | match = i; |
@@ -2346,15 +2345,15 @@ void wireless_spy_update(struct net_device * dev, | |||
2346 | * To avoid event storms, we have a simple hysteresis : we generate | 2345 | * To avoid event storms, we have a simple hysteresis : we generate |
2347 | * event only when we go under the low threshold or above the | 2346 | * event only when we go under the low threshold or above the |
2348 | * high threshold. */ | 2347 | * high threshold. */ |
2349 | if(match >= 0) { | 2348 | if (match >= 0) { |
2350 | if(spydata->spy_thr_under[match]) { | 2349 | if (spydata->spy_thr_under[match]) { |
2351 | if(wstats->level > spydata->spy_thr_high.level) { | 2350 | if (wstats->level > spydata->spy_thr_high.level) { |
2352 | spydata->spy_thr_under[match] = 0; | 2351 | spydata->spy_thr_under[match] = 0; |
2353 | iw_send_thrspy_event(dev, spydata, | 2352 | iw_send_thrspy_event(dev, spydata, |
2354 | address, wstats); | 2353 | address, wstats); |
2355 | } | 2354 | } |
2356 | } else { | 2355 | } else { |
2357 | if(wstats->level < spydata->spy_thr_low.level) { | 2356 | if (wstats->level < spydata->spy_thr_low.level) { |
2358 | spydata->spy_thr_under[match] = 1; | 2357 | spydata->spy_thr_under[match] = 1; |
2359 | iw_send_thrspy_event(dev, spydata, | 2358 | iw_send_thrspy_event(dev, spydata, |
2360 | address, wstats); | 2359 | address, wstats); |
diff --git a/net/socket.c b/net/socket.c index ea8f81abc45c..cf18c5eb592e 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1292,7 +1292,7 @@ asmlinkage long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen) | |||
1292 | int err, fput_needed; | 1292 | int err, fput_needed; |
1293 | 1293 | ||
1294 | sock = sockfd_lookup_light(fd, &err, &fput_needed); | 1294 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
1295 | if(sock) { | 1295 | if (sock) { |
1296 | err = move_addr_to_kernel(umyaddr, addrlen, address); | 1296 | err = move_addr_to_kernel(umyaddr, addrlen, address); |
1297 | if (err >= 0) { | 1297 | if (err >= 0) { |
1298 | err = security_socket_bind(sock, | 1298 | err = security_socket_bind(sock, |