Fix dumping receive packets 07/50707/1
authorXavier Simonart <xavier.simonart@intel.com>
Mon, 8 Jan 2018 11:32:23 +0000 (12:32 +0100)
committerXavier Simonart <xavier.simonart@intel.com>
Tue, 16 Jan 2018 15:39:40 +0000 (16:39 +0100)
There were two issues identified in dump receive packets
- when the receive packets was going to be dropped (and not transmitted),
  it was also printed as TX[255].
- a potential crash when using the dump function with modes like
  lat which can receive more than MAX_RING_BURST.
Those issues have been fixed.

Change-Id: Ia2297539d64961a211389d68e3c9c6280472243c
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
VNFs/DPPD-PROX/lconf.c
VNFs/DPPD-PROX/rx_pkt.c

index 682c106..935bac5 100644 (file)
@@ -198,6 +198,15 @@ int lconf_do_flags(struct lcore_cfg *lconf)
        struct task_base *t;
        int ret = 0;
 
+       if ((lconf->msg.type == LCONF_MSG_TRACE) && (lconf->tasks_all[lconf->msg.task_id]->tx_pkt == tx_pkt_drop_all)) {
+               /* We are asked to dump packets through command dump.
+                * This usually means map RX and TX packets before printing them.
+                * However we do not transmit the packets in this case => use the DUMP_RX function.
+                * This will prevent seeing the received packets also printed as TX[255] (= dropped)
+                */
+               lconf->msg.type = LCONF_MSG_DUMP_RX;
+       }
+
        switch (lconf->msg.type) {
        case LCONF_MSG_STOP:
                msg_stop(lconf);
index bd06b26..fd0f7e5 100644 (file)
@@ -77,7 +77,7 @@ static void next_port_pow2(struct rx_params_hw *rx_params_hw)
 static inline void dump_l3(struct task_base *tbase, struct rte_mbuf *mbuf)
 {
        if (unlikely(tbase->aux->task_rt_dump.n_print_rx)) {
-               if (tbase->aux->task_rt_dump.input->reply == NULL) {
+               if ((tbase->aux->task_rt_dump.input == NULL) || (tbase->aux->task_rt_dump.input->reply == NULL)) {
                        plogdx_info(mbuf, "RX: ");
                } else {
                        struct input *input = tbase->aux->task_rt_dump.input;
@@ -408,7 +408,7 @@ uint16_t rx_pkt_dump(struct task_base *tbase, struct rte_mbuf ***mbufs)
                uint32_t n_dump = tbase->aux->task_rt_dump.n_print_rx;
                n_dump = ret < n_dump? ret : n_dump;
 
-               if (tbase->aux->task_rt_dump.input->reply == NULL) {
+               if ((tbase->aux->task_rt_dump.input == NULL) || (tbase->aux->task_rt_dump.input->reply == NULL)) {
                        for (uint32_t i = 0; i < n_dump; ++i) {
                                plogdx_info((*mbufs)[i], "RX: ");
                        }
@@ -453,12 +453,13 @@ uint16_t rx_pkt_trace(struct task_base *tbase, struct rte_mbuf ***mbufs)
        if (ret) {
                uint32_t n_trace = tbase->aux->task_rt_dump.n_trace;
                n_trace = ret < n_trace? ret : n_trace;
+               n_trace = n_trace <= MAX_RING_BURST ? n_trace : MAX_RING_BURST;
 
                for (uint32_t i = 0; i < n_trace; ++i) {
                        uint8_t *pkt = rte_pktmbuf_mtod((*mbufs)[i], uint8_t *);
-                       rte_memcpy(tbase->aux->task_rt_dump.pkt_cpy[tbase->aux->task_rt_dump.cur_trace + i], pkt, sizeof(tbase->aux->task_rt_dump.pkt_cpy[i]));
-                       tbase->aux->task_rt_dump.pkt_cpy_len[tbase->aux->task_rt_dump.cur_trace + i] = rte_pktmbuf_pkt_len((*mbufs)[i]);
-                       tbase->aux->task_rt_dump.pkt_mbuf_addr[tbase->aux->task_rt_dump.cur_trace + i] = (*mbufs)[i];
+                       rte_memcpy(tbase->aux->task_rt_dump.pkt_cpy[i], pkt, sizeof(tbase->aux->task_rt_dump.pkt_cpy[i]));
+                       tbase->aux->task_rt_dump.pkt_cpy_len[i] = rte_pktmbuf_pkt_len((*mbufs)[i]);
+                       tbase->aux->task_rt_dump.pkt_mbuf_addr[i] = (*mbufs)[i];
                }
                tbase->aux->task_rt_dump.cur_trace += n_trace;