From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE1B8A0C4D; Fri, 20 Aug 2021 14:47:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCAAD41259; Fri, 20 Aug 2021 14:47:16 +0200 (CEST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 232DC41259 for ; Fri, 20 Aug 2021 14:47:15 +0200 (CEST) Received: by mail-wr1-f41.google.com with SMTP id r7so14206459wrs.0 for ; Fri, 20 Aug 2021 05:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=D39BR7Hx+lyER4rwWgSRrD1m+uyYWxmWtMg+yflH6i8=; b=gAoXWheYH4q1IJxGEiWJFLwp6p4DGht2mbrEEkZQx6pLNC+vBYQRlJCO6+Uqw7Zr3a NJRZwEN9V+fj5uDUO7M69P9kgZGjImlx3f7K+hVZ2lWpdPlDfCtM5eCKFZAf0djtZv90 XQHRNjEojsY3jlrwJBGhA/u+Kbp1p6k6jov/H9zIJURRUIMp28KkwHGlS4HeKcjEBIAF pMtEsJ6TEGIHTbmmoYgERJru/f988995l7YuhjTdn2H1vhbL1ogJ12ccADmavWxTE64r 4bKRHFqb80YrVug0DxPhoOreHsedHIEdqIW4wwm3eoYkvmUXchptZJigeiUqH/mDue5Q 5E+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D39BR7Hx+lyER4rwWgSRrD1m+uyYWxmWtMg+yflH6i8=; b=NbcGXm8rmxGNDKExzwDuuHnicyxk+ebGPOWEtyn2xulAB6eo8OEu3WNq8IdJQV+fm3 er1Rx3cdjfYuf/cmclYa63JU9XXqr/Mw21m5HPRNXIow/16ur0KA4yDb7syYMmJRQ6Pg NN6thFsepGjral9uKB1rzREIQtUscVj4DkK/9qjYsXITEKNnXbboP3tegCS6/Wm/U9hk PqFdLuH6ttPyA1L4BTkSCdgDAUFm1R0ngGP11o/VmXbJvzQdSXTknw/LfmZh18z+aCIU plXxk8sg0TaxfJkpP6A3MJhFD60ugm4QYgGBRjhFwmNH03CJ7bLwdDDHa4IwM62JpI9O FUdw== X-Gm-Message-State: AOAM531vw7VYL8LQfubfEbltd8FOJl16OGDuHTUB3Nkbl3rrAg+O2KZ5 hZNvCDMwWtD843OKsAoJ8/qbr3Q+oOQ= X-Google-Smtp-Source: ABdhPJz0EGAfmzTZu2gqlyRUVTjK6MNfZsHs0M4uLcjYugaR/7/IhYxtzqKdzDk3vGBoGaSsgeR4Nw== X-Received: by 2002:a5d:49c5:: with SMTP id t5mr10272892wrs.161.1629463634933; Fri, 20 Aug 2021 05:47:14 -0700 (PDT) Received: from tucornea-dev-machine.localdomain ([193.226.172.42]) by smtp.gmail.com with ESMTPSA id k17sm10856798wmj.0.2021.08.20.05.47.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Aug 2021 05:47:14 -0700 (PDT) From: Tudor Cornea To: linville@tuxdriver.com Cc: thomas@monjalon.net, dev@dpdk.org, Tudor Cornea Date: Fri, 20 Aug 2021 15:46:47 +0300 Message-Id: <1629463607-76292-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] net/af_packet: try to reinsert the stripped vlan tag X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The af_packet pmd driver binds to a raw socket and allows sending and receiving of packets through the kernel. Since commit bcc6d47903 [1], the kernel strips the vlan tags early in __netif_receive_skb_core(), so we receive untagged packets while running with the af_packet pmd. Luckily for us, the skb vlan-related fields are still populated from the stripped vlan tags, so we end up having all the information that we need in the mbuf. We would like to have the the vlan tag inside the mbuf. Let's take a shot at it by trying to reinsert the stripped vlan tag. As a side note, something similar was done for the netvsc pmd. [1] https://github.com/torvalds/linux/commit/bcc6d47903612c3861201cc3a866fb604f26b8b2 Signed-off-by: Tudor Cornea --- drivers/net/af_packet/rte_eth_af_packet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index b73b211..d116583 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -148,6 +148,10 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (ppd->tp_status & TP_STATUS_VLAN_VALID) { mbuf->vlan_tci = ppd->tp_vlan_tci; mbuf->ol_flags |= (PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED); + + /* the kernel always strips the vlan tag, try to reinsert it */ + if (rte_vlan_insert(&mbuf)) + PMD_LOG(ERR, "Failed to reinsert vlan tag"); } /* release incoming frame and advance ring buffer */ -- 2.7.4