]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - net/ipv4/tcp_ipv4.c
net: Add MIB counters for checksum errors
[mirror_ubuntu-hirsute-kernel.git] / net / ipv4 / tcp_ipv4.c
index 2278669b1d85b4577c680679a0f443c99314a962..8ea9751645968d075e3808b22c86c02c016d0094 100644 (file)
@@ -1866,6 +1866,7 @@ discard:
        return 0;
 
 csum_err:
+       TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_CSUMERRORS);
        TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS);
        goto discard;
 }
@@ -1985,7 +1986,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
         * provided case of th->doff==0 is eliminated.
         * So, we defer the checks. */
        if (!skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb))
-               goto bad_packet;
+               goto csum_error;
 
        th = tcp_hdr(skb);
        iph = ip_hdr(skb);
@@ -2051,6 +2052,8 @@ no_tcp_socket:
                goto discard_it;
 
        if (skb->len < (th->doff << 2) || tcp_checksum_complete(skb)) {
+csum_error:
+               TCP_INC_STATS_BH(net, TCP_MIB_CSUMERRORS);
 bad_packet:
                TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
        } else {
@@ -2072,10 +2075,13 @@ do_time_wait:
                goto discard_it;
        }
 
-       if (skb->len < (th->doff << 2) || tcp_checksum_complete(skb)) {
-               TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
+       if (skb->len < (th->doff << 2)) {
                inet_twsk_put(inet_twsk(sk));
-               goto discard_it;
+               goto bad_packet;
+       }
+       if (tcp_checksum_complete(skb)) {
+               inet_twsk_put(inet_twsk(sk));
+               goto csum_error;
        }
        switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {
        case TCP_TW_SYN: {