diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c index 5ea2471ffc03..9b0c54f0702c 100644 --- a/net/openvswitch/meter.c +++ b/net/openvswitch/meter.c @@ -464,6 +464,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.