From 5815cd749e9c23422e4d04bf00920e493efa4be8 Mon Sep 17 00:00:00 2001 From: Xavier Simonart Date: Sat, 11 Sep 2021 18:06:43 +0000 Subject: swap: prevent printing continuous warning messages for STP and LLDP 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 Change-Id: I5a8ef7b76c492451aae66fd1533c61927bc6d8f1 --- VNFs/DPPD-PROX/handle_swap.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'VNFs') diff --git a/VNFs/DPPD-PROX/handle_swap.c b/VNFs/DPPD-PROX/handle_swap.c index 094199e4..06bbc6de 100644 --- a/VNFs/DPPD-PROX/handle_swap.c +++ b/VNFs/DPPD-PROX/handle_swap.c @@ -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; -- cgit 1.2.3-korg