swap: prevent printing continuous warning messages for STP and LLDP 13/72913/1
authorXavier Simonart <simonartxavier@gmail.com>
Sat, 11 Sep 2021 18:06:43 +0000 (18:06 +0000)
committerXavier Simonart <simonartxavier@gmail.com>
Sat, 11 Sep 2021 18:07:43 +0000 (18:07 +0000)
Some switches send frequent STP (Spanning Tree) and LLDP (Link Layer
Discovery Protocol) messages. Handle_swap was printing a warning message
for each of them.
Now a warning will only be printed for the first message of each type.

Signed-off-by: Xavier Simonart <simonartxavier@gmail.com>
Change-Id: I5a8ef7b76c492451aae66fd1533c61927bc6d8f1

VNFs/DPPD-PROX/handle_swap.c

index 094199e..06bbc6d 100644 (file)
@@ -196,6 +196,8 @@ static int handle_swap_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, ui
        struct igmpv2_hdr *pigmp;
        prox_rte_icmp_hdr *picmp;
        uint8_t type;
+       static int llc_printed = 0;
+       static int lldp_printed = 0;
 
        for (j = 0; j < n_pkts; ++j) {
                PREFETCH0(mbufs[j]);
@@ -279,9 +281,31 @@ static int handle_swap_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, ui
                        handle_ipv6(task, mbufs[j], ipv6_hdr, &out[j]);
                        continue;
                case ETYPE_LLDP:
+                       if (!lldp_printed) {
+                               plog_info("Discarding LLDP packets (only printed once)\n");
+                               lldp_printed = 1;
+                       }
                        out[j] = OUT_DISCARD;
                        continue;
                default:
+                       if ((rte_bswap16(hdr->ether_type) < 0x600) && (rte_bswap16(hdr->ether_type) >= 16)) {
+                               // 802.3
+                               struct prox_llc {
+                                       uint8_t dsap;
+                                       uint8_t lsap;
+                                       uint8_t control;
+                               };
+                               struct prox_llc *llc = (struct prox_llc *)(hdr + 1);
+                               if ((llc->dsap == 0x42) && (llc->lsap == 0x42)) {
+                                       // STP Protocol
+                                       out[j] = OUT_DISCARD;
+                                       if (!llc_printed) {
+                                               plog_info("Discarding STP packets (only printed once)\n");
+                                               llc_printed = 1;
+                                       }
+                                       continue;
+                               }
+                       }
                        plog_warn("Unsupported ether_type 0x%x\n", hdr->ether_type);
                        out[j] = OUT_DISCARD;
                        continue;