aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /net/ipv4/raw.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index ab996f9c0fe0..cc6f097fbd5f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -60,7 +60,6 @@
60#include <net/net_namespace.h> 60#include <net/net_namespace.h>
61#include <net/dst.h> 61#include <net/dst.h>
62#include <net/sock.h> 62#include <net/sock.h>
63#include <linux/gfp.h>
64#include <linux/ip.h> 63#include <linux/ip.h>
65#include <linux/net.h> 64#include <linux/net.h>
66#include <net/ip.h> 65#include <net/ip.h>
@@ -87,7 +86,7 @@ void raw_hash_sk(struct sock *sk)
87 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; 86 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
88 struct hlist_head *head; 87 struct hlist_head *head;
89 88
90 head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)]; 89 head = &h->ht[inet_sk(sk)->inet_num & (RAW_HTABLE_SIZE - 1)];
91 90
92 write_lock_bh(&h->lock); 91 write_lock_bh(&h->lock);
93 sk_add_node(sk, head); 92 sk_add_node(sk, head);
@@ -115,9 +114,9 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
115 sk_for_each_from(sk, node) { 114 sk_for_each_from(sk, node) {
116 struct inet_sock *inet = inet_sk(sk); 115 struct inet_sock *inet = inet_sk(sk);
117 116
118 if (net_eq(sock_net(sk), net) && inet->num == num && 117 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
119 !(inet->daddr && inet->daddr != raddr) && 118 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
120 !(inet->rcv_saddr && inet->rcv_saddr != laddr) && 119 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
121 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) 120 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
122 goto found; /* gotcha */ 121 goto found; /* gotcha */
123 } 122 }
@@ -292,7 +291,6 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
292 /* Charge it to the socket. */ 291 /* Charge it to the socket. */
293 292
294 if (sock_queue_rcv_skb(sk, skb) < 0) { 293 if (sock_queue_rcv_skb(sk, skb) < 0) {
295 atomic_inc(&sk->sk_drops);
296 kfree_skb(skb); 294 kfree_skb(skb);
297 return NET_RX_DROP; 295 return NET_RX_DROP;
298 } 296 }
@@ -327,7 +325,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
327 int err; 325 int err;
328 326
329 if (length > rt->u.dst.dev->mtu) { 327 if (length > rt->u.dst.dev->mtu) {
330 ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, 328 ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport,
331 rt->u.dst.dev->mtu); 329 rt->u.dst.dev->mtu);
332 return -EMSGSIZE; 330 return -EMSGSIZE;
333 } 331 }
@@ -500,10 +498,10 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
500 err = -EDESTADDRREQ; 498 err = -EDESTADDRREQ;
501 if (sk->sk_state != TCP_ESTABLISHED) 499 if (sk->sk_state != TCP_ESTABLISHED)
502 goto out; 500 goto out;
503 daddr = inet->daddr; 501 daddr = inet->inet_daddr;
504 } 502 }
505 503
506 ipc.addr = inet->saddr; 504 ipc.addr = inet->inet_saddr;
507 ipc.opt = NULL; 505 ipc.opt = NULL;
508 ipc.shtx.flags = 0; 506 ipc.shtx.flags = 0;
509 ipc.oif = sk->sk_bound_dev_if; 507 ipc.oif = sk->sk_bound_dev_if;
@@ -645,9 +643,9 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
645 if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL && 643 if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
646 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) 644 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
647 goto out; 645 goto out;
648 inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr; 646 inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
649 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) 647 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
650 inet->saddr = 0; /* Use device */ 648 inet->inet_saddr = 0; /* Use device */
651 sk_dst_reset(sk); 649 sk_dst_reset(sk);
652 ret = 0; 650 ret = 0;
653out: return ret; 651out: return ret;
@@ -692,7 +690,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
692 if (err) 690 if (err)
693 goto done; 691 goto done;
694 692
695 sock_recv_timestamp(msg, sk, skb); 693 sock_recv_ts_and_drops(msg, sk, skb);
696 694
697 /* Copy the address. */ 695 /* Copy the address. */
698 if (sin) { 696 if (sin) {
@@ -717,7 +715,7 @@ static int raw_init(struct sock *sk)
717{ 715{
718 struct raw_sock *rp = raw_sk(sk); 716 struct raw_sock *rp = raw_sk(sk);
719 717
720 if (inet_sk(sk)->num == IPPROTO_ICMP) 718 if (inet_sk(sk)->inet_num == IPPROTO_ICMP)
721 memset(&rp->filter, 0, sizeof(rp->filter)); 719 memset(&rp->filter, 0, sizeof(rp->filter));
722 return 0; 720 return 0;
723} 721}
@@ -754,7 +752,7 @@ static int do_raw_setsockopt(struct sock *sk, int level, int optname,
754 char __user *optval, unsigned int optlen) 752 char __user *optval, unsigned int optlen)
755{ 753{
756 if (optname == ICMP_FILTER) { 754 if (optname == ICMP_FILTER) {
757 if (inet_sk(sk)->num != IPPROTO_ICMP) 755 if (inet_sk(sk)->inet_num != IPPROTO_ICMP)
758 return -EOPNOTSUPP; 756 return -EOPNOTSUPP;
759 else 757 else
760 return raw_seticmpfilter(sk, optval, optlen); 758 return raw_seticmpfilter(sk, optval, optlen);
@@ -784,7 +782,7 @@ static int do_raw_getsockopt(struct sock *sk, int level, int optname,
784 char __user *optval, int __user *optlen) 782 char __user *optval, int __user *optlen)
785{ 783{
786 if (optname == ICMP_FILTER) { 784 if (optname == ICMP_FILTER) {
787 if (inet_sk(sk)->num != IPPROTO_ICMP) 785 if (inet_sk(sk)->inet_num != IPPROTO_ICMP)
788 return -EOPNOTSUPP; 786 return -EOPNOTSUPP;
789 else 787 else
790 return raw_geticmpfilter(sk, optval, optlen); 788 return raw_geticmpfilter(sk, optval, optlen);
@@ -943,10 +941,10 @@ EXPORT_SYMBOL_GPL(raw_seq_stop);
943static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i) 941static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
944{ 942{
945 struct inet_sock *inet = inet_sk(sp); 943 struct inet_sock *inet = inet_sk(sp);
946 __be32 dest = inet->daddr, 944 __be32 dest = inet->inet_daddr,
947 src = inet->rcv_saddr; 945 src = inet->inet_rcv_saddr;
948 __u16 destp = 0, 946 __u16 destp = 0,
949 srcp = inet->num; 947 srcp = inet->inet_num;
950 948
951 seq_printf(seq, "%4d: %08X:%04X %08X:%04X" 949 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
952 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n", 950 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",