From: Lin Huang <linhu...@ruijie.com.cn>

Now srtcm_policer will free pkts, if packets are exceed rate limit.
This patch change srtcm_policer not to free pkts, just count dropped packets.

Signed-off-by: Lin Huang <linhu...@ruijie.com.cn>
---
 lib/netdev-dpdk.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8cb1a7703..707f622f3 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2340,8 +2340,7 @@ netdev_dpdk_srtcm_policer_pkt_handle(struct 
rte_meter_srtcm *meter,
 static int
 srtcm_policer_run_single_packet(struct rte_meter_srtcm *meter,
                                 struct rte_meter_srtcm_profile *profile,
-                                struct rte_mbuf **pkts, int pkt_cnt,
-                                bool should_steal)
+                                struct rte_mbuf **pkts, int pkt_cnt)
 {
     int i = 0;
     int cnt = 0;
@@ -2351,19 +2350,13 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
     for (i = 0; i < pkt_cnt; i++) {
         pkt = pkts[i];
         /* Handle current packet */
-        if (netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
-                                                 pkt, current_time)) {
-            if (cnt != i) {
-                pkts[cnt] = pkt;
-            }
-            cnt++;
-        } else {
-            if (should_steal) {
-                rte_pktmbuf_free(pkt);
-            }
+        if (!netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
+                                                  pkt, current_time)) {
+             cnt++;
         }
     }
 
+    /* Count dropped packets */
     return cnt;
 }
 
@@ -2376,7 +2369,7 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
     rte_spinlock_lock(&policer->policer_lock);
     cnt = srtcm_policer_run_single_packet(&policer->in_policer,
                                           &policer->in_prof,
-                                          pkts, pkt_cnt, should_steal);
+                                          pkts, pkt_cnt);
     rte_spinlock_unlock(&policer->policer_lock);
 
     return cnt;
@@ -4876,7 +4869,7 @@ egress_policer_run(struct qos_conf *conf, struct rte_mbuf 
**pkts, int pkt_cnt,
 
     cnt = srtcm_policer_run_single_packet(&policer->egress_meter,
                                           &policer->egress_prof, pkts,
-                                          pkt_cnt, should_steal);
+                                          pkt_cnt);
 
     return cnt;
 }
-- 
2.39.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to