diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-10-15 02:30:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-18 21:52:53 -0400 |
commit | c720c7e8383aff1cb219bddf474ed89d850336e3 (patch) | |
tree | 4f12337e6690fccced376db9f501eaf98614a65e /net/dccp | |
parent | 988ade6b8e27e79311812f83a87b5cea11fabcd7 (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/dccp')
-rw-r--r-- | net/dccp/ipv4.c | 40 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 27 | ||||
-rw-r--r-- | net/dccp/output.c | 4 | ||||
-rw-r--r-- | net/dccp/probe.c | 13 | ||||
-rw-r--r-- | net/dccp/proto.c | 4 |
5 files changed, 47 insertions, 41 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 7302e1498d46..00028d4b09d9 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -62,10 +62,10 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
62 | nexthop = inet->opt->faddr; | 62 | nexthop = inet->opt->faddr; |
63 | } | 63 | } |
64 | 64 | ||
65 | tmp = ip_route_connect(&rt, nexthop, inet->saddr, | 65 | tmp = ip_route_connect(&rt, nexthop, inet->inet_saddr, |
66 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, | 66 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, |
67 | IPPROTO_DCCP, | 67 | IPPROTO_DCCP, |
68 | inet->sport, usin->sin_port, sk, 1); | 68 | inet->inet_sport, usin->sin_port, sk, 1); |
69 | if (tmp < 0) | 69 | if (tmp < 0) |
70 | return tmp; | 70 | return tmp; |
71 | 71 | ||
@@ -77,12 +77,12 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
77 | if (inet->opt == NULL || !inet->opt->srr) | 77 | if (inet->opt == NULL || !inet->opt->srr) |
78 | daddr = rt->rt_dst; | 78 | daddr = rt->rt_dst; |
79 | 79 | ||
80 | if (inet->saddr == 0) | 80 | if (inet->inet_saddr == 0) |
81 | inet->saddr = rt->rt_src; | 81 | inet->inet_saddr = rt->rt_src; |
82 | inet->rcv_saddr = inet->saddr; | 82 | inet->inet_rcv_saddr = inet->inet_saddr; |
83 | 83 | ||
84 | inet->dport = usin->sin_port; | 84 | inet->inet_dport = usin->sin_port; |
85 | inet->daddr = daddr; | 85 | inet->inet_daddr = daddr; |
86 | 86 | ||
87 | inet_csk(sk)->icsk_ext_hdr_len = 0; | 87 | inet_csk(sk)->icsk_ext_hdr_len = 0; |
88 | if (inet->opt != NULL) | 88 | if (inet->opt != NULL) |
@@ -98,17 +98,19 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
98 | if (err != 0) | 98 | if (err != 0) |
99 | goto failure; | 99 | goto failure; |
100 | 100 | ||
101 | err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport, | 101 | err = ip_route_newports(&rt, IPPROTO_DCCP, inet->inet_sport, |
102 | sk); | 102 | inet->inet_dport, sk); |
103 | if (err != 0) | 103 | if (err != 0) |
104 | goto failure; | 104 | goto failure; |
105 | 105 | ||
106 | /* OK, now commit destination to socket. */ | 106 | /* OK, now commit destination to socket. */ |
107 | sk_setup_caps(sk, &rt->u.dst); | 107 | sk_setup_caps(sk, &rt->u.dst); |
108 | 108 | ||
109 | dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, inet->daddr, | 109 | dp->dccps_iss = secure_dccp_sequence_number(inet->inet_saddr, |
110 | inet->sport, inet->dport); | 110 | inet->inet_daddr, |
111 | inet->id = dp->dccps_iss ^ jiffies; | 111 | inet->inet_sport, |
112 | inet->inet_dport); | ||
113 | inet->inet_id = dp->dccps_iss ^ jiffies; | ||
112 | 114 | ||
113 | err = dccp_connect(sk); | 115 | err = dccp_connect(sk); |
114 | rt = NULL; | 116 | rt = NULL; |
@@ -123,7 +125,7 @@ failure: | |||
123 | dccp_set_state(sk, DCCP_CLOSED); | 125 | dccp_set_state(sk, DCCP_CLOSED); |
124 | ip_rt_put(rt); | 126 | ip_rt_put(rt); |
125 | sk->sk_route_caps = 0; | 127 | sk->sk_route_caps = 0; |
126 | inet->dport = 0; | 128 | inet->inet_dport = 0; |
127 | goto out; | 129 | goto out; |
128 | } | 130 | } |
129 | 131 | ||
@@ -352,7 +354,9 @@ void dccp_v4_send_check(struct sock *sk, int unused, struct sk_buff *skb) | |||
352 | struct dccp_hdr *dh = dccp_hdr(skb); | 354 | struct dccp_hdr *dh = dccp_hdr(skb); |
353 | 355 | ||
354 | dccp_csum_outgoing(skb); | 356 | dccp_csum_outgoing(skb); |
355 | dh->dccph_checksum = dccp_v4_csum_finish(skb, inet->saddr, inet->daddr); | 357 | dh->dccph_checksum = dccp_v4_csum_finish(skb, |
358 | inet->inet_saddr, | ||
359 | inet->inet_daddr); | ||
356 | } | 360 | } |
357 | 361 | ||
358 | EXPORT_SYMBOL_GPL(dccp_v4_send_check); | 362 | EXPORT_SYMBOL_GPL(dccp_v4_send_check); |
@@ -393,14 +397,14 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
393 | 397 | ||
394 | newinet = inet_sk(newsk); | 398 | newinet = inet_sk(newsk); |
395 | ireq = inet_rsk(req); | 399 | ireq = inet_rsk(req); |
396 | newinet->daddr = ireq->rmt_addr; | 400 | newinet->inet_daddr = ireq->rmt_addr; |
397 | newinet->rcv_saddr = ireq->loc_addr; | 401 | newinet->inet_rcv_saddr = ireq->loc_addr; |
398 | newinet->saddr = ireq->loc_addr; | 402 | newinet->inet_saddr = ireq->loc_addr; |
399 | newinet->opt = ireq->opt; | 403 | newinet->opt = ireq->opt; |
400 | ireq->opt = NULL; | 404 | ireq->opt = NULL; |
401 | newinet->mc_index = inet_iif(skb); | 405 | newinet->mc_index = inet_iif(skb); |
402 | newinet->mc_ttl = ip_hdr(skb)->ttl; | 406 | newinet->mc_ttl = ip_hdr(skb)->ttl; |
403 | newinet->id = jiffies; | 407 | newinet->inet_id = jiffies; |
404 | 408 | ||
405 | dccp_sync_mss(newsk, dst_mtu(dst)); | 409 | dccp_sync_mss(newsk, dst_mtu(dst)); |
406 | 410 | ||
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index a2afb553d8b3..6d89f9f7d5d8 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -158,8 +158,8 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
158 | ipv6_addr_copy(&fl.fl6_dst, &np->daddr); | 158 | ipv6_addr_copy(&fl.fl6_dst, &np->daddr); |
159 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); | 159 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); |
160 | fl.oif = sk->sk_bound_dev_if; | 160 | fl.oif = sk->sk_bound_dev_if; |
161 | fl.fl_ip_dport = inet->dport; | 161 | fl.fl_ip_dport = inet->inet_dport; |
162 | fl.fl_ip_sport = inet->sport; | 162 | fl.fl_ip_sport = inet->inet_sport; |
163 | security_sk_classify_flow(sk, &fl); | 163 | security_sk_classify_flow(sk, &fl); |
164 | 164 | ||
165 | err = ip6_dst_lookup(sk, &dst, &fl); | 165 | err = ip6_dst_lookup(sk, &dst, &fl); |
@@ -510,9 +510,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
510 | 510 | ||
511 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); | 511 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); |
512 | 512 | ||
513 | ipv6_addr_set_v4mapped(newinet->daddr, &newnp->daddr); | 513 | ipv6_addr_set_v4mapped(newinet->inet_daddr, &newnp->daddr); |
514 | 514 | ||
515 | ipv6_addr_set_v4mapped(newinet->saddr, &newnp->saddr); | 515 | ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr); |
516 | 516 | ||
517 | ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); | 517 | ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); |
518 | 518 | ||
@@ -640,7 +640,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
640 | 640 | ||
641 | dccp_sync_mss(newsk, dst_mtu(dst)); | 641 | dccp_sync_mss(newsk, dst_mtu(dst)); |
642 | 642 | ||
643 | newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6; | 643 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; |
644 | newinet->inet_rcv_saddr = LOOPBACK4_IPV6; | ||
644 | 645 | ||
645 | __inet6_hash(newsk); | 646 | __inet6_hash(newsk); |
646 | __inet_inherit_port(sk, newsk); | 647 | __inet_inherit_port(sk, newsk); |
@@ -968,10 +969,9 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
968 | icsk->icsk_af_ops = &dccp_ipv6_af_ops; | 969 | icsk->icsk_af_ops = &dccp_ipv6_af_ops; |
969 | sk->sk_backlog_rcv = dccp_v6_do_rcv; | 970 | sk->sk_backlog_rcv = dccp_v6_do_rcv; |
970 | goto failure; | 971 | goto failure; |
971 | } else { | ||
972 | ipv6_addr_set_v4mapped(inet->saddr, &np->saddr); | ||
973 | ipv6_addr_set_v4mapped(inet->rcv_saddr, &np->rcv_saddr); | ||
974 | } | 972 | } |
973 | ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr); | ||
974 | ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &np->rcv_saddr); | ||
975 | 975 | ||
976 | return err; | 976 | return err; |
977 | } | 977 | } |
@@ -984,7 +984,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
984 | ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr); | 984 | ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr); |
985 | fl.oif = sk->sk_bound_dev_if; | 985 | fl.oif = sk->sk_bound_dev_if; |
986 | fl.fl_ip_dport = usin->sin6_port; | 986 | fl.fl_ip_dport = usin->sin6_port; |
987 | fl.fl_ip_sport = inet->sport; | 987 | fl.fl_ip_sport = inet->inet_sport; |
988 | security_sk_classify_flow(sk, &fl); | 988 | security_sk_classify_flow(sk, &fl); |
989 | 989 | ||
990 | if (np->opt != NULL && np->opt->srcrt != NULL) { | 990 | if (np->opt != NULL && np->opt->srcrt != NULL) { |
@@ -1017,7 +1017,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
1017 | 1017 | ||
1018 | /* set the source address */ | 1018 | /* set the source address */ |
1019 | ipv6_addr_copy(&np->saddr, saddr); | 1019 | ipv6_addr_copy(&np->saddr, saddr); |
1020 | inet->rcv_saddr = LOOPBACK4_IPV6; | 1020 | inet->inet_rcv_saddr = LOOPBACK4_IPV6; |
1021 | 1021 | ||
1022 | __ip6_dst_store(sk, dst, NULL, NULL); | 1022 | __ip6_dst_store(sk, dst, NULL, NULL); |
1023 | 1023 | ||
@@ -1026,7 +1026,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
1026 | icsk->icsk_ext_hdr_len = (np->opt->opt_flen + | 1026 | icsk->icsk_ext_hdr_len = (np->opt->opt_flen + |
1027 | np->opt->opt_nflen); | 1027 | np->opt->opt_nflen); |
1028 | 1028 | ||
1029 | inet->dport = usin->sin6_port; | 1029 | inet->inet_dport = usin->sin6_port; |
1030 | 1030 | ||
1031 | dccp_set_state(sk, DCCP_REQUESTING); | 1031 | dccp_set_state(sk, DCCP_REQUESTING); |
1032 | err = inet6_hash_connect(&dccp_death_row, sk); | 1032 | err = inet6_hash_connect(&dccp_death_row, sk); |
@@ -1035,7 +1035,8 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
1035 | 1035 | ||
1036 | dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32, | 1036 | dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32, |
1037 | np->daddr.s6_addr32, | 1037 | np->daddr.s6_addr32, |
1038 | inet->sport, inet->dport); | 1038 | inet->inet_sport, |
1039 | inet->inet_dport); | ||
1039 | err = dccp_connect(sk); | 1040 | err = dccp_connect(sk); |
1040 | if (err) | 1041 | if (err) |
1041 | goto late_failure; | 1042 | goto late_failure; |
@@ -1046,7 +1047,7 @@ late_failure: | |||
1046 | dccp_set_state(sk, DCCP_CLOSED); | 1047 | dccp_set_state(sk, DCCP_CLOSED); |
1047 | __sk_dst_reset(sk); | 1048 | __sk_dst_reset(sk); |
1048 | failure: | 1049 | failure: |
1049 | inet->dport = 0; | 1050 | inet->inet_dport = 0; |
1050 | sk->sk_route_caps = 0; | 1051 | sk->sk_route_caps = 0; |
1051 | return err; | 1052 | return err; |
1052 | } | 1053 | } |
diff --git a/net/dccp/output.c b/net/dccp/output.c index c96119fda688..d6bb753bf6ad 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -99,8 +99,8 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
99 | /* Build DCCP header and checksum it. */ | 99 | /* Build DCCP header and checksum it. */ |
100 | dh = dccp_zeroed_hdr(skb, dccp_header_size); | 100 | dh = dccp_zeroed_hdr(skb, dccp_header_size); |
101 | dh->dccph_type = dcb->dccpd_type; | 101 | dh->dccph_type = dcb->dccpd_type; |
102 | dh->dccph_sport = inet->sport; | 102 | dh->dccph_sport = inet->inet_sport; |
103 | dh->dccph_dport = inet->dport; | 103 | dh->dccph_dport = inet->inet_dport; |
104 | dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4; | 104 | dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4; |
105 | dh->dccph_ccval = dcb->dccpd_ccval; | 105 | dh->dccph_ccval = dcb->dccpd_ccval; |
106 | dh->dccph_cscov = dp->dccps_pcslen; | 106 | dh->dccph_cscov = dp->dccps_pcslen; |
diff --git a/net/dccp/probe.c b/net/dccp/probe.c index 5e6ec8b9b7b6..dc328425fa20 100644 --- a/net/dccp/probe.c +++ b/net/dccp/probe.c | |||
@@ -80,19 +80,20 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
80 | if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3) | 80 | if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3) |
81 | hc = ccid3_hc_tx_sk(sk); | 81 | hc = ccid3_hc_tx_sk(sk); |
82 | 82 | ||
83 | if (port == 0 || ntohs(inet->dport) == port || | 83 | if (port == 0 || ntohs(inet->inet_dport) == port || |
84 | ntohs(inet->sport) == port) { | 84 | ntohs(inet->inet_sport) == port) { |
85 | if (hc) | 85 | if (hc) |
86 | printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n", | 86 | printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n", |
87 | &inet->saddr, ntohs(inet->sport), | 87 | &inet->inet_saddr, ntohs(inet->inet_sport), |
88 | &inet->daddr, ntohs(inet->dport), size, | 88 | &inet->inet_daddr, ntohs(inet->inet_dport), size, |
89 | hc->tx_s, hc->tx_rtt, hc->tx_p, | 89 | hc->tx_s, hc->tx_rtt, hc->tx_p, |
90 | hc->tx_x_calc, hc->tx_x_recv >> 6, | 90 | hc->tx_x_calc, hc->tx_x_recv >> 6, |
91 | hc->tx_x >> 6, hc->tx_t_ipi); | 91 | hc->tx_x >> 6, hc->tx_t_ipi); |
92 | else | 92 | else |
93 | printl("%pI4:%u %pI4:%u %d\n", | 93 | printl("%pI4:%u %pI4:%u %d\n", |
94 | &inet->saddr, ntohs(inet->sport), | 94 | &inet->inet_saddr, ntohs(inet->inet_sport), |
95 | &inet->daddr, ntohs(inet->dport), size); | 95 | &inet->inet_daddr, ntohs(inet->inet_dport), |
96 | size); | ||
96 | } | 97 | } |
97 | 98 | ||
98 | jprobe_return(); | 99 | jprobe_return(); |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index ecb203fff501..671cd1413d59 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -278,7 +278,7 @@ int dccp_disconnect(struct sock *sk, int flags) | |||
278 | sk->sk_send_head = NULL; | 278 | sk->sk_send_head = NULL; |
279 | } | 279 | } |
280 | 280 | ||
281 | inet->dport = 0; | 281 | inet->inet_dport = 0; |
282 | 282 | ||
283 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) | 283 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) |
284 | inet_reset_saddr(sk); | 284 | inet_reset_saddr(sk); |
@@ -290,7 +290,7 @@ int dccp_disconnect(struct sock *sk, int flags) | |||
290 | inet_csk_delack_init(sk); | 290 | inet_csk_delack_init(sk); |
291 | __sk_dst_reset(sk); | 291 | __sk_dst_reset(sk); |
292 | 292 | ||
293 | WARN_ON(inet->num && !icsk->icsk_bind_hash); | 293 | WARN_ON(inet->inet_num && !icsk->icsk_bind_hash); |
294 | 294 | ||
295 | sk->sk_error_report(sk); | 295 | sk->sk_error_report(sk); |
296 | return err; | 296 | return err; |