From patchwork Thu Sep 29 12:21:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 117140 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D73D3A00C4; Thu, 29 Sep 2022 14:22:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFE5840694; Thu, 29 Sep 2022 14:22:09 +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 3B0DA40395 for ; Thu, 29 Sep 2022 14:22:09 +0200 (CEST) Received: by mail-wr1-f41.google.com with SMTP id r6so1911404wru.8 for ; Thu, 29 Sep 2022 05:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=Zbo6clz1xbdTFlfKjs/cp1Gn4EcEmqPYvc2NJOis0kE=; b=XYEqI7ML+VaqGl2zrMqqfpOsBVoexlgb+1bNh+EW0ukmWg/wXgO2gnuTiUGqsWnq5H jGe1CPfzLoiks2E0URl/2Lo+Tqcync6TcsO5Thvj9j0Pz0r/zJ6764+WNDYDf4aW6n2P gnOsi7OUic+OIZ+UoXn8qiefXY6fwVnGiy2s9k6oJhN7HJs2NAP84YKycieo5gsVmSox cJjXkKUBkjYr+g2lDhbEViVIN4+duaRdiunbIiMvdz9rfXSbRNWLiL2joGrH78Z4zuju /nbr+yzOl8/BoFFv3xaFk9xK36RXz0+7Oh0kkPOHaI4efFzhsoAhBxhOLlxPltUjQ7UC cTMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=Zbo6clz1xbdTFlfKjs/cp1Gn4EcEmqPYvc2NJOis0kE=; b=FjC1/aAmnKqhkvMHaNFjxeANCwOsrtiZFQkxzDdGvhceMS7XeTl3nas81guK2e4UNQ 5jOBAsTlYigUAC3C4vWLNwkSxHF7OR0ukwJh3dz3YrX8eNyjyf0VXKf3Pu7xbMa55H1T 1KGt1zbIOsmMtuT2WquitEpKcNPSZlEm06mBV2YzXOasNaeUZcCB0azKqWTqYTU1im7I RX97XrZAmH/xjTmIjnNGIf9b91IXeNQvIwy0gZ0h5UlXFdpqHrZM9ghT6EXzqCGUgTkv jwpoxTMj6X7IfX3O8lMrAio8rW2JgR0jmvYGpNSFd+D5EqsZNq/yGDXw8zlsAwNqNIGQ nM/w== X-Gm-Message-State: ACrzQf0mjwCxsMPH9wuF9rUo1V5aXtIuoMgPNO+t9G2c/3czL1IwruSY 1OkvZ8zI5wThIfv83jx/gI2m6VqqJ79tgX98 X-Google-Smtp-Source: AMsMyM6t8CJ0LUTO+JZi8tF8Uk1wMK8Ou0h/SqHx0wn7DADkwId/Mqfof0+SVKceqMrQZ1WirstkjQ== X-Received: by 2002:adf:d209:0:b0:228:6298:f288 with SMTP id j9-20020adfd209000000b002286298f288mr2041224wrh.386.1664454128898; Thu, 29 Sep 2022 05:22:08 -0700 (PDT) Received: from gojira.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id r9-20020adfda49000000b002258235bda3sm6777219wrl.61.2022.09.29.05.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 05:22:08 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Qiming Yang , Wenjun Wu , Wei Zhao Subject: [PATCH] net/ixgbevf: fix promiscuous and allmulti Date: Thu, 29 Sep 2022 14:21:55 +0200 Message-Id: <20220929122155.816-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 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 The configuration of allmulti and promiscuous modes conflicts together. For instance, if we enable promiscuous mode, then enable and disable allmulti, then the promiscuous mode is wrongly disabled. Fix this behavior by: - doing nothing when we set/unset allmulti if promiscuous mode is on - restorting the proper mode (none or allmulti) when we disable promiscuous mode Fixes: 1f4564ed7696 ("net/ixgbevf: enable promiscuous mode") Signed-off-by: Olivier Matz Acked-by: Wenjun Wu --- Hi, For reference, this was tested with this plan: echo 8 > "/sys/bus/pci/devices/0000:01:00.1/sriov_numvfs" ip link set dev eno2 up ip link set dev eno2 promisc on bridge link set dev eno2 hwmode veb ip link set dev eno2 mtu 9000 ip link set dev eno2 vf 0 mac ac:1f:6b:fe:ba:b0 ip link set dev eno2 vf 0 spoofchk off ip link set dev eno2 vf 0 trust on ip link set dev eno2 vf 1 mac ac:1f:6b:fe:ba:b1 ip link set dev eno2 vf 1 spoofchk off ip link set dev eno2 vf 1 trust on python3 usertools/dpdk-devbind.py -s python3 usertools/dpdk-devbind.py -b vfio-pci 0000:01:10.1 # vf 0 python3 usertools/dpdk-devbind.py -b ixgbevf 0000:01:10.3 # vf 1 # in another terminal scapy while True: sendp(Ether(dst='ac:1f:6b:00:00:00'), iface='eno2v1') # wrong mac sendp(Ether(dst='ac:1f:6b:fe:ba:b0'), iface='eno2v1') # correct mac time.sleep(1) ./build/app/dpdk-testpmd -l 1,2 -a 0000:01:10.1 -- -i --total-num-mbufs=32768 show port info all set fwd rxonly set verbose 1 set promisc all off set allmulti all off start # ok, only packets to dst='ac:1f:6b:fe:ba:b0' are received # ok, both packets are received set promisc all on # nok, only packets to dst='ac:1f:6b:fe:ba:b0' are received set allmulti all on set allmulti all off drivers/net/ixgbe/ixgbe_ethdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 8cec951d94..cc8383c5a9 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -7785,9 +7785,13 @@ static int ixgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + int mode = IXGBEVF_XCAST_MODE_NONE; int ret; - switch (hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_NONE)) { + if (dev->data->all_multicast) + mode = IXGBEVF_XCAST_MODE_ALLMULTI; + + switch (hw->mac.ops.update_xcast_mode(hw, mode)) { case IXGBE_SUCCESS: ret = 0; break; @@ -7809,6 +7813,9 @@ ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev) int ret; int mode = IXGBEVF_XCAST_MODE_ALLMULTI; + if (dev->data->promiscuous) + return 0; + switch (hw->mac.ops.update_xcast_mode(hw, mode)) { case IXGBE_SUCCESS: ret = 0; @@ -7830,6 +7837,9 @@ ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev) struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); int ret; + if (dev->data->promiscuous) + return 0; + switch (hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI)) { case IXGBE_SUCCESS: ret = 0;