aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/af_inet.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/af_inet.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/af_inet.c')
-rw-r--r--net/ipv4/af_inet.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1deff48b122e..04a14b1600ac 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -174,12 +174,12 @@ static int inet_autobind(struct sock *sk)
174 /* We may need to bind the socket. */ 174 /* We may need to bind the socket. */
175 lock_sock(sk); 175 lock_sock(sk);
176 inet = inet_sk(sk); 176 inet = inet_sk(sk);
177 if (!inet->num) { 177 if (!inet->inet_num) {
178 if (sk->sk_prot->get_port(sk, 0)) { 178 if (sk->sk_prot->get_port(sk, 0)) {
179 release_sock(sk); 179 release_sock(sk);
180 return -EAGAIN; 180 return -EAGAIN;
181 } 181 }
182 inet->sport = htons(inet->num); 182 inet->inet_sport = htons(inet->inet_num);
183 } 183 }
184 release_sock(sk); 184 release_sock(sk);
185 return 0; 185 return 0;
@@ -354,7 +354,7 @@ lookup_protocol:
354 inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; 354 inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
355 355
356 if (SOCK_RAW == sock->type) { 356 if (SOCK_RAW == sock->type) {
357 inet->num = protocol; 357 inet->inet_num = protocol;
358 if (IPPROTO_RAW == protocol) 358 if (IPPROTO_RAW == protocol)
359 inet->hdrincl = 1; 359 inet->hdrincl = 1;
360 } 360 }
@@ -364,7 +364,7 @@ lookup_protocol:
364 else 364 else
365 inet->pmtudisc = IP_PMTUDISC_WANT; 365 inet->pmtudisc = IP_PMTUDISC_WANT;
366 366
367 inet->id = 0; 367 inet->inet_id = 0;
368 368
369 sock_init_data(sock, sk); 369 sock_init_data(sock, sk);
370 370
@@ -381,13 +381,13 @@ lookup_protocol:
381 381
382 sk_refcnt_debug_inc(sk); 382 sk_refcnt_debug_inc(sk);
383 383
384 if (inet->num) { 384 if (inet->inet_num) {
385 /* It assumes that any protocol which allows 385 /* It assumes that any protocol which allows
386 * the user to assign a number at socket 386 * the user to assign a number at socket
387 * creation time automatically 387 * creation time automatically
388 * shares. 388 * shares.
389 */ 389 */
390 inet->sport = htons(inet->num); 390 inet->inet_sport = htons(inet->inet_num);
391 /* Add to protocol hash chains. */ 391 /* Add to protocol hash chains. */
392 sk->sk_prot->hash(sk); 392 sk->sk_prot->hash(sk);
393 } 393 }
@@ -494,27 +494,27 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
494 494
495 /* Check these errors (active socket, double bind). */ 495 /* Check these errors (active socket, double bind). */
496 err = -EINVAL; 496 err = -EINVAL;
497 if (sk->sk_state != TCP_CLOSE || inet->num) 497 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
498 goto out_release_sock; 498 goto out_release_sock;
499 499
500 inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr; 500 inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
501 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) 501 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
502 inet->saddr = 0; /* Use device */ 502 inet->inet_saddr = 0; /* Use device */
503 503
504 /* Make sure we are allowed to bind here. */ 504 /* Make sure we are allowed to bind here. */
505 if (sk->sk_prot->get_port(sk, snum)) { 505 if (sk->sk_prot->get_port(sk, snum)) {
506 inet->saddr = inet->rcv_saddr = 0; 506 inet->inet_saddr = inet->inet_rcv_saddr = 0;
507 err = -EADDRINUSE; 507 err = -EADDRINUSE;
508 goto out_release_sock; 508 goto out_release_sock;
509 } 509 }
510 510
511 if (inet->rcv_saddr) 511 if (inet->inet_rcv_saddr)
512 sk->sk_userlocks |= SOCK_BINDADDR_LOCK; 512 sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
513 if (snum) 513 if (snum)
514 sk->sk_userlocks |= SOCK_BINDPORT_LOCK; 514 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
515 inet->sport = htons(inet->num); 515 inet->inet_sport = htons(inet->inet_num);
516 inet->daddr = 0; 516 inet->inet_daddr = 0;
517 inet->dport = 0; 517 inet->inet_dport = 0;
518 sk_dst_reset(sk); 518 sk_dst_reset(sk);
519 err = 0; 519 err = 0;
520out_release_sock: 520out_release_sock:
@@ -532,7 +532,7 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr * uaddr,
532 if (uaddr->sa_family == AF_UNSPEC) 532 if (uaddr->sa_family == AF_UNSPEC)
533 return sk->sk_prot->disconnect(sk, flags); 533 return sk->sk_prot->disconnect(sk, flags);
534 534
535 if (!inet_sk(sk)->num && inet_autobind(sk)) 535 if (!inet_sk(sk)->inet_num && inet_autobind(sk))
536 return -EAGAIN; 536 return -EAGAIN;
537 return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len); 537 return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len);
538} 538}
@@ -689,17 +689,17 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
689 689
690 sin->sin_family = AF_INET; 690 sin->sin_family = AF_INET;
691 if (peer) { 691 if (peer) {
692 if (!inet->dport || 692 if (!inet->inet_dport ||
693 (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) && 693 (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
694 peer == 1)) 694 peer == 1))
695 return -ENOTCONN; 695 return -ENOTCONN;
696 sin->sin_port = inet->dport; 696 sin->sin_port = inet->inet_dport;
697 sin->sin_addr.s_addr = inet->daddr; 697 sin->sin_addr.s_addr = inet->inet_daddr;
698 } else { 698 } else {
699 __be32 addr = inet->rcv_saddr; 699 __be32 addr = inet->inet_rcv_saddr;
700 if (!addr) 700 if (!addr)
701 addr = inet->saddr; 701 addr = inet->inet_saddr;
702 sin->sin_port = inet->sport; 702 sin->sin_port = inet->inet_sport;
703 sin->sin_addr.s_addr = addr; 703 sin->sin_addr.s_addr = addr;
704 } 704 }
705 memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); 705 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
@@ -714,7 +714,7 @@ int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
714 struct sock *sk = sock->sk; 714 struct sock *sk = sock->sk;
715 715
716 /* We may need to bind the socket. */ 716 /* We may need to bind the socket. */
717 if (!inet_sk(sk)->num && inet_autobind(sk)) 717 if (!inet_sk(sk)->inet_num && inet_autobind(sk))
718 return -EAGAIN; 718 return -EAGAIN;
719 719
720 return sk->sk_prot->sendmsg(iocb, sk, msg, size); 720 return sk->sk_prot->sendmsg(iocb, sk, msg, size);
@@ -728,7 +728,7 @@ static ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset,
728 struct sock *sk = sock->sk; 728 struct sock *sk = sock->sk;
729 729
730 /* We may need to bind the socket. */ 730 /* We may need to bind the socket. */
731 if (!inet_sk(sk)->num && inet_autobind(sk)) 731 if (!inet_sk(sk)->inet_num && inet_autobind(sk))
732 return -EAGAIN; 732 return -EAGAIN;
733 733
734 if (sk->sk_prot->sendpage) 734 if (sk->sk_prot->sendpage)
@@ -1059,9 +1059,9 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1059 struct inet_sock *inet = inet_sk(sk); 1059 struct inet_sock *inet = inet_sk(sk);
1060 int err; 1060 int err;
1061 struct rtable *rt; 1061 struct rtable *rt;
1062 __be32 old_saddr = inet->saddr; 1062 __be32 old_saddr = inet->inet_saddr;
1063 __be32 new_saddr; 1063 __be32 new_saddr;
1064 __be32 daddr = inet->daddr; 1064 __be32 daddr = inet->inet_daddr;
1065 1065
1066 if (inet->opt && inet->opt->srr) 1066 if (inet->opt && inet->opt->srr)
1067 daddr = inet->opt->faddr; 1067 daddr = inet->opt->faddr;
@@ -1071,7 +1071,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1071 RT_CONN_FLAGS(sk), 1071 RT_CONN_FLAGS(sk),
1072 sk->sk_bound_dev_if, 1072 sk->sk_bound_dev_if,
1073 sk->sk_protocol, 1073 sk->sk_protocol,
1074 inet->sport, inet->dport, sk, 0); 1074 inet->inet_sport, inet->inet_dport, sk, 0);
1075 if (err) 1075 if (err)
1076 return err; 1076 return err;
1077 1077
@@ -1087,7 +1087,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1087 __func__, &old_saddr, &new_saddr); 1087 __func__, &old_saddr, &new_saddr);
1088 } 1088 }
1089 1089
1090 inet->saddr = inet->rcv_saddr = new_saddr; 1090 inet->inet_saddr = inet->inet_rcv_saddr = new_saddr;
1091 1091
1092 /* 1092 /*
1093 * XXX The only one ugly spot where we need to 1093 * XXX The only one ugly spot where we need to
@@ -1113,7 +1113,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1113 return 0; 1113 return 0;
1114 1114
1115 /* Reroute. */ 1115 /* Reroute. */
1116 daddr = inet->daddr; 1116 daddr = inet->inet_daddr;
1117 if (inet->opt && inet->opt->srr) 1117 if (inet->opt && inet->opt->srr)
1118 daddr = inet->opt->faddr; 1118 daddr = inet->opt->faddr;
1119{ 1119{
@@ -1123,7 +1123,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1123 .nl_u = { 1123 .nl_u = {
1124 .ip4_u = { 1124 .ip4_u = {
1125 .daddr = daddr, 1125 .daddr = daddr,
1126 .saddr = inet->saddr, 1126 .saddr = inet->inet_saddr,
1127 .tos = RT_CONN_FLAGS(sk), 1127 .tos = RT_CONN_FLAGS(sk),
1128 }, 1128 },
1129 }, 1129 },
@@ -1131,8 +1131,8 @@ int inet_sk_rebuild_header(struct sock *sk)
1131 .flags = inet_sk_flowi_flags(sk), 1131 .flags = inet_sk_flowi_flags(sk),
1132 .uli_u = { 1132 .uli_u = {
1133 .ports = { 1133 .ports = {
1134 .sport = inet->sport, 1134 .sport = inet->inet_sport,
1135 .dport = inet->dport, 1135 .dport = inet->inet_dport,
1136 }, 1136 },
1137 }, 1137 },
1138 }; 1138 };