aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_metrics.c
diff options
context:
space:
mode:
authorChristoph Paasch <christoph.paasch@uclouvain.be>2014-01-08 10:05:55 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-10 17:38:18 -0500
commit324fd55a19827b7191cc6ab73865e30c0e6e6423 (patch)
tree72fbca045ee4ce77be017ca57422d3d0585ce6f0 /net/ipv4/tcp_metrics.c
parent1a6c1e5bd20793e35364280e7df5abd155ef057f (diff)
tcp: metrics: rename tcpm_addr to tcpm_daddr
As we will add also the source-address, we rename all accesses to the tcp-metrics address to use "daddr". Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_metrics.c')
-rw-r--r--net/ipv4/tcp_metrics.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 06493736fbc8..f9b5f519a4ea 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -31,7 +31,7 @@ struct tcp_fastopen_metrics {
31 31
32struct tcp_metrics_block { 32struct tcp_metrics_block {
33 struct tcp_metrics_block __rcu *tcpm_next; 33 struct tcp_metrics_block __rcu *tcpm_next;
34 struct inetpeer_addr tcpm_addr; 34 struct inetpeer_addr tcpm_daddr;
35 unsigned long tcpm_stamp; 35 unsigned long tcpm_stamp;
36 u32 tcpm_ts; 36 u32 tcpm_ts;
37 u32 tcpm_ts_stamp; 37 u32 tcpm_ts_stamp;
@@ -131,7 +131,7 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst,
131} 131}
132 132
133static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst, 133static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
134 struct inetpeer_addr *addr, 134 struct inetpeer_addr *daddr,
135 unsigned int hash, 135 unsigned int hash,
136 bool reclaim) 136 bool reclaim)
137{ 137{
@@ -155,7 +155,7 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
155 if (!tm) 155 if (!tm)
156 goto out_unlock; 156 goto out_unlock;
157 } 157 }
158 tm->tcpm_addr = *addr; 158 tm->tcpm_daddr = *daddr;
159 159
160 tcpm_suck_dst(tm, dst, true); 160 tcpm_suck_dst(tm, dst, true);
161 161
@@ -189,7 +189,7 @@ static struct tcp_metrics_block *tcp_get_encode(struct tcp_metrics_block *tm, in
189 return NULL; 189 return NULL;
190} 190}
191 191
192static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *addr, 192static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *daddr,
193 struct net *net, unsigned int hash) 193 struct net *net, unsigned int hash)
194{ 194{
195 struct tcp_metrics_block *tm; 195 struct tcp_metrics_block *tm;
@@ -197,7 +197,7 @@ static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *a
197 197
198 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; 198 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
199 tm = rcu_dereference(tm->tcpm_next)) { 199 tm = rcu_dereference(tm->tcpm_next)) {
200 if (addr_same(&tm->tcpm_addr, addr)) 200 if (addr_same(&tm->tcpm_daddr, daddr))
201 break; 201 break;
202 depth++; 202 depth++;
203 } 203 }
@@ -208,19 +208,19 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
208 struct dst_entry *dst) 208 struct dst_entry *dst)
209{ 209{
210 struct tcp_metrics_block *tm; 210 struct tcp_metrics_block *tm;
211 struct inetpeer_addr addr; 211 struct inetpeer_addr daddr;
212 unsigned int hash; 212 unsigned int hash;
213 struct net *net; 213 struct net *net;
214 214
215 addr.family = req->rsk_ops->family; 215 daddr.family = req->rsk_ops->family;
216 switch (addr.family) { 216 switch (daddr.family) {
217 case AF_INET: 217 case AF_INET:
218 addr.addr.a4 = inet_rsk(req)->ir_rmt_addr; 218 daddr.addr.a4 = inet_rsk(req)->ir_rmt_addr;
219 hash = (__force unsigned int) addr.addr.a4; 219 hash = (__force unsigned int) daddr.addr.a4;
220 break; 220 break;
221#if IS_ENABLED(CONFIG_IPV6) 221#if IS_ENABLED(CONFIG_IPV6)
222 case AF_INET6: 222 case AF_INET6:
223 *(struct in6_addr *)addr.addr.a6 = inet_rsk(req)->ir_v6_rmt_addr; 223 *(struct in6_addr *)daddr.addr.a6 = inet_rsk(req)->ir_v6_rmt_addr;
224 hash = ipv6_addr_hash(&inet_rsk(req)->ir_v6_rmt_addr); 224 hash = ipv6_addr_hash(&inet_rsk(req)->ir_v6_rmt_addr);
225 break; 225 break;
226#endif 226#endif
@@ -233,7 +233,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
233 233
234 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; 234 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
235 tm = rcu_dereference(tm->tcpm_next)) { 235 tm = rcu_dereference(tm->tcpm_next)) {
236 if (addr_same(&tm->tcpm_addr, &addr)) 236 if (addr_same(&tm->tcpm_daddr, &daddr))
237 break; 237 break;
238 } 238 }
239 tcpm_check_stamp(tm, dst); 239 tcpm_check_stamp(tm, dst);
@@ -243,19 +243,19 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
243static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock *tw) 243static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock *tw)
244{ 244{
245 struct tcp_metrics_block *tm; 245 struct tcp_metrics_block *tm;
246 struct inetpeer_addr addr; 246 struct inetpeer_addr daddr;
247 unsigned int hash; 247 unsigned int hash;
248 struct net *net; 248 struct net *net;
249 249
250 addr.family = tw->tw_family; 250 daddr.family = tw->tw_family;
251 switch (addr.family) { 251 switch (daddr.family) {
252 case AF_INET: 252 case AF_INET:
253 addr.addr.a4 = tw->tw_daddr; 253 daddr.addr.a4 = tw->tw_daddr;
254 hash = (__force unsigned int) addr.addr.a4; 254 hash = (__force unsigned int) daddr.addr.a4;
255 break; 255 break;
256#if IS_ENABLED(CONFIG_IPV6) 256#if IS_ENABLED(CONFIG_IPV6)
257 case AF_INET6: 257 case AF_INET6:
258 *(struct in6_addr *)addr.addr.a6 = tw->tw_v6_daddr; 258 *(struct in6_addr *)daddr.addr.a6 = tw->tw_v6_daddr;
259 hash = ipv6_addr_hash(&tw->tw_v6_daddr); 259 hash = ipv6_addr_hash(&tw->tw_v6_daddr);
260 break; 260 break;
261#endif 261#endif
@@ -268,7 +268,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock
268 268
269 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; 269 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
270 tm = rcu_dereference(tm->tcpm_next)) { 270 tm = rcu_dereference(tm->tcpm_next)) {
271 if (addr_same(&tm->tcpm_addr, &addr)) 271 if (addr_same(&tm->tcpm_daddr, &daddr))
272 break; 272 break;
273 } 273 }
274 return tm; 274 return tm;
@@ -279,20 +279,20 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
279 bool create) 279 bool create)
280{ 280{
281 struct tcp_metrics_block *tm; 281 struct tcp_metrics_block *tm;
282 struct inetpeer_addr addr; 282 struct inetpeer_addr daddr;
283 unsigned int hash; 283 unsigned int hash;
284 struct net *net; 284 struct net *net;
285 bool reclaim; 285 bool reclaim;
286 286
287 addr.family = sk->sk_family; 287 daddr.family = sk->sk_family;
288 switch (addr.family) { 288 switch (daddr.family) {
289 case AF_INET: 289 case AF_INET:
290 addr.addr.a4 = inet_sk(sk)->inet_daddr; 290 daddr.addr.a4 = inet_sk(sk)->inet_daddr;
291 hash = (__force unsigned int) addr.addr.a4; 291 hash = (__force unsigned int) daddr.addr.a4;
292 break; 292 break;
293#if IS_ENABLED(CONFIG_IPV6) 293#if IS_ENABLED(CONFIG_IPV6)
294 case AF_INET6: 294 case AF_INET6:
295 *(struct in6_addr *)addr.addr.a6 = sk->sk_v6_daddr; 295 *(struct in6_addr *)daddr.addr.a6 = sk->sk_v6_daddr;
296 hash = ipv6_addr_hash(&sk->sk_v6_daddr); 296 hash = ipv6_addr_hash(&sk->sk_v6_daddr);
297 break; 297 break;
298#endif 298#endif
@@ -303,14 +303,14 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
303 net = dev_net(dst->dev); 303 net = dev_net(dst->dev);
304 hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); 304 hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
305 305
306 tm = __tcp_get_metrics(&addr, net, hash); 306 tm = __tcp_get_metrics(&daddr, net, hash);
307 reclaim = false; 307 reclaim = false;
308 if (tm == TCP_METRICS_RECLAIM_PTR) { 308 if (tm == TCP_METRICS_RECLAIM_PTR) {
309 reclaim = true; 309 reclaim = true;
310 tm = NULL; 310 tm = NULL;
311 } 311 }
312 if (!tm && create) 312 if (!tm && create)
313 tm = tcpm_new(dst, &addr, hash, reclaim); 313 tm = tcpm_new(dst, &daddr, hash, reclaim);
314 else 314 else
315 tcpm_check_stamp(tm, dst); 315 tcpm_check_stamp(tm, dst);
316 316
@@ -724,15 +724,15 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
724 struct nlattr *nest; 724 struct nlattr *nest;
725 int i; 725 int i;
726 726
727 switch (tm->tcpm_addr.family) { 727 switch (tm->tcpm_daddr.family) {
728 case AF_INET: 728 case AF_INET:
729 if (nla_put_be32(msg, TCP_METRICS_ATTR_ADDR_IPV4, 729 if (nla_put_be32(msg, TCP_METRICS_ATTR_ADDR_IPV4,
730 tm->tcpm_addr.addr.a4) < 0) 730 tm->tcpm_daddr.addr.a4) < 0)
731 goto nla_put_failure; 731 goto nla_put_failure;
732 break; 732 break;
733 case AF_INET6: 733 case AF_INET6:
734 if (nla_put(msg, TCP_METRICS_ATTR_ADDR_IPV6, 16, 734 if (nla_put(msg, TCP_METRICS_ATTR_ADDR_IPV6, 16,
735 tm->tcpm_addr.addr.a6) < 0) 735 tm->tcpm_daddr.addr.a6) < 0)
736 goto nla_put_failure; 736 goto nla_put_failure;
737 break; 737 break;
738 default: 738 default:
@@ -882,14 +882,14 @@ static int parse_nl_addr(struct genl_info *info, struct inetpeer_addr *addr,
882static int tcp_metrics_nl_cmd_get(struct sk_buff *skb, struct genl_info *info) 882static int tcp_metrics_nl_cmd_get(struct sk_buff *skb, struct genl_info *info)
883{ 883{
884 struct tcp_metrics_block *tm; 884 struct tcp_metrics_block *tm;
885 struct inetpeer_addr addr; 885 struct inetpeer_addr daddr;
886 unsigned int hash; 886 unsigned int hash;
887 struct sk_buff *msg; 887 struct sk_buff *msg;
888 struct net *net = genl_info_net(info); 888 struct net *net = genl_info_net(info);
889 void *reply; 889 void *reply;
890 int ret; 890 int ret;
891 891
892 ret = parse_nl_addr(info, &addr, &hash, 0); 892 ret = parse_nl_addr(info, &daddr, &hash, 0);
893 if (ret < 0) 893 if (ret < 0)
894 return ret; 894 return ret;
895 895
@@ -907,7 +907,7 @@ static int tcp_metrics_nl_cmd_get(struct sk_buff *skb, struct genl_info *info)
907 rcu_read_lock(); 907 rcu_read_lock();
908 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; 908 for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
909 tm = rcu_dereference(tm->tcpm_next)) { 909 tm = rcu_dereference(tm->tcpm_next)) {
910 if (addr_same(&tm->tcpm_addr, &addr)) { 910 if (addr_same(&tm->tcpm_daddr, &daddr)) {
911 ret = tcp_metrics_fill_info(msg, tm); 911 ret = tcp_metrics_fill_info(msg, tm);
912 break; 912 break;
913 } 913 }
@@ -962,12 +962,12 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
962 struct tcpm_hash_bucket *hb; 962 struct tcpm_hash_bucket *hb;
963 struct tcp_metrics_block *tm; 963 struct tcp_metrics_block *tm;
964 struct tcp_metrics_block __rcu **pp; 964 struct tcp_metrics_block __rcu **pp;
965 struct inetpeer_addr addr; 965 struct inetpeer_addr daddr;
966 unsigned int hash; 966 unsigned int hash;
967 struct net *net = genl_info_net(info); 967 struct net *net = genl_info_net(info);
968 int ret; 968 int ret;
969 969
970 ret = parse_nl_addr(info, &addr, &hash, 1); 970 ret = parse_nl_addr(info, &daddr, &hash, 1);
971 if (ret < 0) 971 if (ret < 0)
972 return ret; 972 return ret;
973 if (ret > 0) 973 if (ret > 0)
@@ -979,7 +979,7 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
979 spin_lock_bh(&tcp_metrics_lock); 979 spin_lock_bh(&tcp_metrics_lock);
980 for (tm = deref_locked_genl(*pp); tm; 980 for (tm = deref_locked_genl(*pp); tm;
981 pp = &tm->tcpm_next, tm = deref_locked_genl(*pp)) { 981 pp = &tm->tcpm_next, tm = deref_locked_genl(*pp)) {
982 if (addr_same(&tm->tcpm_addr, &addr)) { 982 if (addr_same(&tm->tcpm_daddr, &daddr)) {
983 *pp = tm->tcpm_next; 983 *pp = tm->tcpm_next;
984 break; 984 break;
985 } 985 }