similarly to what already exists for L4, add conntrack_l3csum_err
and ipf_l3csum_err for L3.

Received packets with L3 bad checksum will increase respectively
ipf_l3csum_err if they are fragments and conntrack_l3csum_err
otherwise.

Although the patch basically covers IPv4, the names are kept generic.

Signed-off-by: Paolo Valerio <[email protected]>
---
 lib/conntrack.c |    3 +++
 lib/ipf.c       |    3 +++
 2 files changed, 6 insertions(+)

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 99198a601..70cdcc12a 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -45,6 +45,7 @@ VLOG_DEFINE_THIS_MODULE(conntrack);
 
 COVERAGE_DEFINE(conntrack_full);
 COVERAGE_DEFINE(conntrack_long_cleanup);
+COVERAGE_DEFINE(conntrack_l3csum_err);
 COVERAGE_DEFINE(conntrack_l4csum_err);
 
 struct conn_lookup_ctx {
@@ -1613,6 +1614,7 @@ extract_l3_ipv4(struct conn_key *key, const void *data, 
size_t size,
     }
 
     if (validate_checksum && csum(data, ip_len) != 0) {
+        COVERAGE_INC(conntrack_l3csum_err);
         return false;
     }
 
@@ -2051,6 +2053,7 @@ conn_key_extract(struct conntrack *ct, struct dp_packet 
*pkt, ovs_be16 dl_type,
         bool hwol_bad_l3_csum = dp_packet_ip_checksum_bad(pkt);
         if (hwol_bad_l3_csum) {
             ok = false;
+            COVERAGE_INC(conntrack_l3csum_err);
         } else {
             bool hwol_good_l3_csum = dp_packet_ip_checksum_valid(pkt)
                                      || dp_packet_hwol_is_ipv4(pkt);
diff --git a/lib/ipf.c b/lib/ipf.c
index c20bcc0b3..f26e7d492 100644
--- a/lib/ipf.c
+++ b/lib/ipf.c
@@ -36,6 +36,7 @@
 
 VLOG_DEFINE_THIS_MODULE(ipf);
 COVERAGE_DEFINE(ipf_stuck_frag_list_purged);
+COVERAGE_DEFINE(ipf_l3csum_err);
 
 enum {
     IPV4_PACKET_MAX_HDR_SIZE = 60,
@@ -575,6 +576,7 @@ static bool
 ipf_is_valid_v4_frag(struct ipf *ipf, struct dp_packet *pkt)
 {
     if (OVS_UNLIKELY(dp_packet_ip_checksum_bad(pkt))) {
+        COVERAGE_INC(ipf_l3csum_err);
         goto invalid_pkt;
     }
 
@@ -610,6 +612,7 @@ ipf_is_valid_v4_frag(struct ipf *ipf, struct dp_packet *pkt)
     if (OVS_UNLIKELY(!dp_packet_ip_checksum_valid(pkt)
                      && !dp_packet_hwol_is_ipv4(pkt)
                      && csum(l3, ip_hdr_len) != 0)) {
+        COVERAGE_INC(ipf_l3csum_err);
         goto invalid_pkt;
     }
 

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to