aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_metrics.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_metrics.c')
-rw-r--r--net/ipv4/tcp_metrics.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 52f3c6b971d2..06493736fbc8 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -215,13 +215,15 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
215 addr.family = req->rsk_ops->family; 215 addr.family = req->rsk_ops->family;
216 switch (addr.family) { 216 switch (addr.family) {
217 case AF_INET: 217 case AF_INET:
218 addr.addr.a4 = inet_rsk(req)->rmt_addr; 218 addr.addr.a4 = inet_rsk(req)->ir_rmt_addr;
219 hash = (__force unsigned int) addr.addr.a4; 219 hash = (__force unsigned int) addr.addr.a4;
220 break; 220 break;
221#if IS_ENABLED(CONFIG_IPV6)
221 case AF_INET6: 222 case AF_INET6:
222 *(struct in6_addr *)addr.addr.a6 = inet6_rsk(req)->rmt_addr; 223 *(struct in6_addr *)addr.addr.a6 = inet_rsk(req)->ir_v6_rmt_addr;
223 hash = ipv6_addr_hash(&inet6_rsk(req)->rmt_addr); 224 hash = ipv6_addr_hash(&inet_rsk(req)->ir_v6_rmt_addr);
224 break; 225 break;
226#endif
225 default: 227 default:
226 return NULL; 228 return NULL;
227 } 229 }
@@ -240,7 +242,6 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,
240 242
241static 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)
242{ 244{
243 struct inet6_timewait_sock *tw6;
244 struct tcp_metrics_block *tm; 245 struct tcp_metrics_block *tm;
245 struct inetpeer_addr addr; 246 struct inetpeer_addr addr;
246 unsigned int hash; 247 unsigned int hash;
@@ -252,11 +253,12 @@ static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock
252 addr.addr.a4 = tw->tw_daddr; 253 addr.addr.a4 = tw->tw_daddr;
253 hash = (__force unsigned int) addr.addr.a4; 254 hash = (__force unsigned int) addr.addr.a4;
254 break; 255 break;
256#if IS_ENABLED(CONFIG_IPV6)
255 case AF_INET6: 257 case AF_INET6:
256 tw6 = inet6_twsk((struct sock *)tw); 258 *(struct in6_addr *)addr.addr.a6 = tw->tw_v6_daddr;
257 *(struct in6_addr *)addr.addr.a6 = tw6->tw_v6_daddr; 259 hash = ipv6_addr_hash(&tw->tw_v6_daddr);
258 hash = ipv6_addr_hash(&tw6->tw_v6_daddr);
259 break; 260 break;
261#endif
260 default: 262 default:
261 return NULL; 263 return NULL;
262 } 264 }
@@ -288,10 +290,12 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
288 addr.addr.a4 = inet_sk(sk)->inet_daddr; 290 addr.addr.a4 = inet_sk(sk)->inet_daddr;
289 hash = (__force unsigned int) addr.addr.a4; 291 hash = (__force unsigned int) addr.addr.a4;
290 break; 292 break;
293#if IS_ENABLED(CONFIG_IPV6)
291 case AF_INET6: 294 case AF_INET6:
292 *(struct in6_addr *)addr.addr.a6 = inet6_sk(sk)->daddr; 295 *(struct in6_addr *)addr.addr.a6 = sk->sk_v6_daddr;
293 hash = ipv6_addr_hash(&inet6_sk(sk)->daddr); 296 hash = ipv6_addr_hash(&sk->sk_v6_daddr);
294 break; 297 break;
298#endif
295 default: 299 default:
296 return NULL; 300 return NULL;
297 } 301 }
@@ -659,16 +663,20 @@ void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
659void tcp_fastopen_cache_set(struct sock *sk, u16 mss, 663void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
660 struct tcp_fastopen_cookie *cookie, bool syn_lost) 664 struct tcp_fastopen_cookie *cookie, bool syn_lost)
661{ 665{
666 struct dst_entry *dst = __sk_dst_get(sk);
662 struct tcp_metrics_block *tm; 667 struct tcp_metrics_block *tm;
663 668
669 if (!dst)
670 return;
664 rcu_read_lock(); 671 rcu_read_lock();
665 tm = tcp_get_metrics(sk, __sk_dst_get(sk), true); 672 tm = tcp_get_metrics(sk, dst, true);
666 if (tm) { 673 if (tm) {
667 struct tcp_fastopen_metrics *tfom = &tm->tcpm_fastopen; 674 struct tcp_fastopen_metrics *tfom = &tm->tcpm_fastopen;
668 675
669 write_seqlock_bh(&fastopen_seqlock); 676 write_seqlock_bh(&fastopen_seqlock);
670 tfom->mss = mss; 677 if (mss)
671 if (cookie->len > 0) 678 tfom->mss = mss;
679 if (cookie && cookie->len > 0)
672 tfom->cookie = *cookie; 680 tfom->cookie = *cookie;
673 if (syn_lost) { 681 if (syn_lost) {
674 ++tfom->syn_loss; 682 ++tfom->syn_loss;
@@ -983,7 +991,7 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
983 return 0; 991 return 0;
984} 992}
985 993
986static struct genl_ops tcp_metrics_nl_ops[] = { 994static const struct genl_ops tcp_metrics_nl_ops[] = {
987 { 995 {
988 .cmd = TCP_METRICS_CMD_GET, 996 .cmd = TCP_METRICS_CMD_GET,
989 .doit = tcp_metrics_nl_cmd_get, 997 .doit = tcp_metrics_nl_cmd_get,
@@ -1074,8 +1082,7 @@ void __init tcp_metrics_init(void)
1074 if (ret < 0) 1082 if (ret < 0)
1075 goto cleanup; 1083 goto cleanup;
1076 ret = genl_register_family_with_ops(&tcp_metrics_nl_family, 1084 ret = genl_register_family_with_ops(&tcp_metrics_nl_family,
1077 tcp_metrics_nl_ops, 1085 tcp_metrics_nl_ops);
1078 ARRAY_SIZE(tcp_metrics_nl_ops));
1079 if (ret < 0) 1086 if (ret < 0)
1080 goto cleanup_subsys; 1087 goto cleanup_subsys;
1081 return; 1088 return;