Merge remote-tracking branch 'spi/for-5.14' into spi-next
[linux-2.6-microblaze.git] / net / openvswitch / meter.c
index 96b524c..896b8f5 100644 (file)
@@ -611,6 +611,14 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
        spin_lock(&meter->lock);
 
        long_delta_ms = (now_ms - meter->used); /* ms */
+       if (long_delta_ms < 0) {
+               /* This condition means that we have several threads fighting
+                * for a meter lock, and the one who received the packets a
+                * bit later wins. Assuming that all racing threads received
+                * packets at the same time to avoid overflow.
+                */
+               long_delta_ms = 0;
+       }
 
        /* Make sure delta_ms will not be too large, so that bucket will not
         * wrap around below.