aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2018-11-08 06:19:21 -0500
committerDavid S. Miller <davem@davemloft.net>2018-11-08 20:13:08 -0500
commit32bbd8793f24b0d5beb1cdb33c45c75ad1140e4b (patch)
tree69b7c7f0348e063bd81215058130c1b1800410db /net/ipv6/tcp_ipv6.c
parentce7336610ca950cda131293def57a0178d860121 (diff)
net: Convert protocol error handlers from void to int
We'll need this to handle ICMP errors for tunnels without a sending socket (i.e. FoU and GUE). There, we might have to look up different types of IP tunnels, registered as network protocols, before we get a match, so we want this for the error handlers of IPPROTO_IPIP and IPPROTO_IPV6 in both inet_protos and inet6_protos. These error codes will be used in the next patch. For consistency, return sensible error codes in protocol error handlers whenever handlers can't handle errors because, even if valid, they don't match a protocol or any of its states. This has no effect on existing error handling paths. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 03e6b7a2bc53..a3f559162521 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -349,7 +349,7 @@ static void tcp_v6_mtu_reduced(struct sock *sk)
349 } 349 }
350} 350}
351 351
352static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 352static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
353 u8 type, u8 code, int offset, __be32 info) 353 u8 type, u8 code, int offset, __be32 info)
354{ 354{
355 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data; 355 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
@@ -371,17 +371,19 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
371 if (!sk) { 371 if (!sk) {
372 __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), 372 __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
373 ICMP6_MIB_INERRORS); 373 ICMP6_MIB_INERRORS);
374 return; 374 return -ENOENT;
375 } 375 }
376 376
377 if (sk->sk_state == TCP_TIME_WAIT) { 377 if (sk->sk_state == TCP_TIME_WAIT) {
378 inet_twsk_put(inet_twsk(sk)); 378 inet_twsk_put(inet_twsk(sk));
379 return; 379 return 0;
380 } 380 }
381 seq = ntohl(th->seq); 381 seq = ntohl(th->seq);
382 fatal = icmpv6_err_convert(type, code, &err); 382 fatal = icmpv6_err_convert(type, code, &err);
383 if (sk->sk_state == TCP_NEW_SYN_RECV) 383 if (sk->sk_state == TCP_NEW_SYN_RECV) {
384 return tcp_req_err(sk, seq, fatal); 384 tcp_req_err(sk, seq, fatal);
385 return 0;
386 }
385 387
386 bh_lock_sock(sk); 388 bh_lock_sock(sk);
387 if (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG) 389 if (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG)
@@ -467,6 +469,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
467out: 469out:
468 bh_unlock_sock(sk); 470 bh_unlock_sock(sk);
469 sock_put(sk); 471 sock_put(sk);
472 return 0;
470} 473}
471 474
472 475