aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-15 02:30:45 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-18 21:52:53 -0400
commitc720c7e8383aff1cb219bddf474ed89d850336e3 (patch)
tree4f12337e6690fccced376db9f501eaf98614a65e /net/ipv4/raw.c
parent988ade6b8e27e79311812f83a87b5cea11fabcd7 (diff)
inet: rename some inet_sock fields
In order to have better cache layouts of struct sock (separate zones for rx/tx paths), we need this preliminary patch. Goal is to transfert fields used at lookup time in the first read-mostly cache line (inside struct sock_common) and move sk_refcnt to a separate cache line (only written by rx path) This patch adds inet_ prefix to daddr, rcv_saddr, dport, num, saddr, sport and id fields. This allows a future patch to define these fields as macros, like sk_refcnt, without name clashes. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 39e2a6b8752c..9ef8c0829a77 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -87,7 +87,7 @@ void raw_hash_sk(struct sock *sk)
87 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; 87 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
88 struct hlist_head *head; 88 struct hlist_head *head;
89 89
90 head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)]; 90 head = &h->ht[inet_sk(sk)->inet_num & (RAW_HTABLE_SIZE - 1)];
91 91
92 write_lock_bh(&h->lock); 92 write_lock_bh(&h->lock);
93 sk_add_node(sk, head); 93 sk_add_node(sk, head);
@@ -115,9 +115,9 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
115 sk_for_each_from(sk, node) { 115 sk_for_each_from(sk, node) {
116 struct inet_sock *inet = inet_sk(sk); 116 struct inet_sock *inet = inet_sk(sk);
117 117
118 if (net_eq(sock_net(sk), net) && inet->num == num && 118 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
119 !(inet->daddr && inet->daddr != raddr) && 119 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
120 !(inet->rcv_saddr && inet->rcv_saddr != laddr) && 120 !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
121 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)) 121 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
122 goto found; /* gotcha */ 122 goto found; /* gotcha */
123 } 123 }
@@ -326,7 +326,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
326 int err; 326 int err;
327 327
328 if (length > rt->u.dst.dev->mtu) { 328 if (length > rt->u.dst.dev->mtu) {
329 ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, 329 ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport,
330 rt->u.dst.dev->mtu); 330 rt->u.dst.dev->mtu);
331 return -EMSGSIZE; 331 return -EMSGSIZE;
332 } 332 }
@@ -489,10 +489,10 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
489 err = -EDESTADDRREQ; 489 err = -EDESTADDRREQ;
490 if (sk->sk_state != TCP_ESTABLISHED) 490 if (sk->sk_state != TCP_ESTABLISHED)
491 goto out; 491 goto out;
492 daddr = inet->daddr; 492 daddr = inet->inet_daddr;
493 } 493 }
494 494
495 ipc.addr = inet->saddr; 495 ipc.addr = inet->inet_saddr;
496 ipc.opt = NULL; 496 ipc.opt = NULL;
497 ipc.shtx.flags = 0; 497 ipc.shtx.flags = 0;
498 ipc.oif = sk->sk_bound_dev_if; 498 ipc.oif = sk->sk_bound_dev_if;
@@ -634,9 +634,9 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
634 if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL && 634 if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
635 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) 635 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
636 goto out; 636 goto out;
637 inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr; 637 inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
638 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) 638 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
639 inet->saddr = 0; /* Use device */ 639 inet->inet_saddr = 0; /* Use device */
640 sk_dst_reset(sk); 640 sk_dst_reset(sk);
641 ret = 0; 641 ret = 0;
642out: return ret; 642out: return ret;
@@ -706,7 +706,7 @@ static int raw_init(struct sock *sk)
706{ 706{
707 struct raw_sock *rp = raw_sk(sk); 707 struct raw_sock *rp = raw_sk(sk);
708 708
709 if (inet_sk(sk)->num == IPPROTO_ICMP) 709 if (inet_sk(sk)->inet_num == IPPROTO_ICMP)
710 memset(&rp->filter, 0, sizeof(rp->filter)); 710 memset(&rp->filter, 0, sizeof(rp->filter));
711 return 0; 711 return 0;
712} 712}
@@ -743,7 +743,7 @@ static int do_raw_setsockopt(struct sock *sk, int level, int optname,
743 char __user *optval, unsigned int optlen) 743 char __user *optval, unsigned int optlen)
744{ 744{
745 if (optname == ICMP_FILTER) { 745 if (optname == ICMP_FILTER) {
746 if (inet_sk(sk)->num != IPPROTO_ICMP) 746 if (inet_sk(sk)->inet_num != IPPROTO_ICMP)
747 return -EOPNOTSUPP; 747 return -EOPNOTSUPP;
748 else 748 else
749 return raw_seticmpfilter(sk, optval, optlen); 749 return raw_seticmpfilter(sk, optval, optlen);
@@ -773,7 +773,7 @@ static int do_raw_getsockopt(struct sock *sk, int level, int optname,
773 char __user *optval, int __user *optlen) 773 char __user *optval, int __user *optlen)
774{ 774{
775 if (optname == ICMP_FILTER) { 775 if (optname == ICMP_FILTER) {
776 if (inet_sk(sk)->num != IPPROTO_ICMP) 776 if (inet_sk(sk)->inet_num != IPPROTO_ICMP)
777 return -EOPNOTSUPP; 777 return -EOPNOTSUPP;
778 else 778 else
779 return raw_geticmpfilter(sk, optval, optlen); 779 return raw_geticmpfilter(sk, optval, optlen);
@@ -932,10 +932,10 @@ EXPORT_SYMBOL_GPL(raw_seq_stop);
932static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i) 932static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
933{ 933{
934 struct inet_sock *inet = inet_sk(sp); 934 struct inet_sock *inet = inet_sk(sp);
935 __be32 dest = inet->daddr, 935 __be32 dest = inet->inet_daddr,
936 src = inet->rcv_saddr; 936 src = inet->inet_rcv_saddr;
937 __u16 destp = 0, 937 __u16 destp = 0,
938 srcp = inet->num; 938 srcp = inet->inet_num;
939 939
940 seq_printf(seq, "%4d: %08X:%04X %08X:%04X" 940 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
941 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n", 941 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",