aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.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/ipv4/tcp_ipv4.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/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index de47038afdf0..a336787d75e5 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -423,7 +423,7 @@ EXPORT_SYMBOL(tcp_req_err);
423 * 423 *
424 */ 424 */
425 425
426void tcp_v4_err(struct sk_buff *icmp_skb, u32 info) 426int tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
427{ 427{
428 const struct iphdr *iph = (const struct iphdr *)icmp_skb->data; 428 const struct iphdr *iph = (const struct iphdr *)icmp_skb->data;
429 struct tcphdr *th = (struct tcphdr *)(icmp_skb->data + (iph->ihl << 2)); 429 struct tcphdr *th = (struct tcphdr *)(icmp_skb->data + (iph->ihl << 2));
@@ -446,20 +446,21 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
446 inet_iif(icmp_skb), 0); 446 inet_iif(icmp_skb), 0);
447 if (!sk) { 447 if (!sk) {
448 __ICMP_INC_STATS(net, ICMP_MIB_INERRORS); 448 __ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
449 return; 449 return -ENOENT;
450 } 450 }
451 if (sk->sk_state == TCP_TIME_WAIT) { 451 if (sk->sk_state == TCP_TIME_WAIT) {
452 inet_twsk_put(inet_twsk(sk)); 452 inet_twsk_put(inet_twsk(sk));
453 return; 453 return 0;
454 } 454 }
455 seq = ntohl(th->seq); 455 seq = ntohl(th->seq);
456 if (sk->sk_state == TCP_NEW_SYN_RECV) 456 if (sk->sk_state == TCP_NEW_SYN_RECV) {
457 return tcp_req_err(sk, seq, 457 tcp_req_err(sk, seq, type == ICMP_PARAMETERPROB ||
458 type == ICMP_PARAMETERPROB || 458 type == ICMP_TIME_EXCEEDED ||
459 type == ICMP_TIME_EXCEEDED || 459 (type == ICMP_DEST_UNREACH &&
460 (type == ICMP_DEST_UNREACH && 460 (code == ICMP_NET_UNREACH ||
461 (code == ICMP_NET_UNREACH || 461 code == ICMP_HOST_UNREACH)));
462 code == ICMP_HOST_UNREACH))); 462 return 0;
463 }
463 464
464 bh_lock_sock(sk); 465 bh_lock_sock(sk);
465 /* If too many ICMPs get dropped on busy 466 /* If too many ICMPs get dropped on busy
@@ -613,6 +614,7 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
613out: 614out:
614 bh_unlock_sock(sk); 615 bh_unlock_sock(sk);
615 sock_put(sk); 616 sock_put(sk);
617 return 0;
616} 618}
617 619
618void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr) 620void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr)