The callers are only interested whether there is a CoS or not. It is not
an error if there isn't, so it has a positive return value. Any other case
needs to release the packet, which is not handled after calling
queue_enq().

Signed-off-by: Zoltan Kiss <zoltan.k...@linaro.org>
---
 platform/linux-generic/odp_classification.c | 9 +++++++--
 platform/linux-generic/pktio/loop.c         | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index f5e4673..4f2974b 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -743,7 +743,7 @@ int _odp_packet_classifier(pktio_entry_t *entry, 
odp_packet_t pkt)
        /* Matching PMR and selecting the CoS for the packet*/
        cos = pktio_select_cos(entry, pkt_addr, pkt_hdr);
        if (cos == NULL)
-               return -1;
+               return 1;
 
        if (cos->s.pool == NULL) {
                odp_packet_free(pkt);
@@ -766,7 +766,12 @@ int _odp_packet_classifier(pktio_entry_t *entry, 
odp_packet_t pkt)
 
        /* Enqueuing the Packet based on the CoS */
        queue = cos->s.queue;
-       return queue_enq(queue, odp_buf_to_hdr((odp_buffer_t)new_pkt), 0);
+       if (queue_enq(queue, odp_buf_to_hdr((odp_buffer_t)new_pkt), 0)) {
+               odp_packet_free(new_pkt);
+               return -1;
+       } else {
+               return 0;
+       }
 }
 
 int packet_classifier(odp_pktio_t pktio, odp_packet_t pkt)
diff --git a/platform/linux-generic/pktio/loop.c 
b/platform/linux-generic/pktio/loop.c
index 0ea6d0e..5ed4ca9 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -70,7 +70,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, 
odp_packet_t pkts[],
                        pkt_hdr = odp_packet_hdr(pkt);
                        packet_parse_reset(pkt_hdr);
                        packet_parse_l2(pkt_hdr);
-                       if (0 > _odp_packet_classifier(pktio_entry, pkt)) {
+                       if (_odp_packet_classifier(pktio_entry, pkt) == 1) {
                                pkts[j++] = pkt;
                                pktio_entry->s.stats.in_octets +=
                                        odp_packet_len(pkts[i]);
-- 
1.9.1

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to