DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org, Jingjing Wu <jingjing.wu@intel.com>,
	Beilei Xing <beilei.xing@intel.com>
Cc: stable@dpdk.org, Laurent Hardy <laurent.hardy@6wind.com>
Subject: [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address change
Date: Wed,  3 Jan 2018 15:29:23 +0100	[thread overview]
Message-ID: <20180103142923.3528-1-olivier.matz@6wind.com> (raw)

When primary address mac is changed, the mac filters were not updated in
the VSI with the new mac addr and incoming packets with this destination
address are dropped by the hardware filters.

This patch removes the VSI mac filter for the previous mac address and
adds a new one for new mac address.

Fixes: e18e01e92c29 ("i40e: support default MAC address setting")
Cc: stable@dpdk.org

Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

Please, review the patch carefully since I'm not an i40e expert ;)

To reproduce the issue:

make config T=x86_64-native-linuxapp-gcc
make -j4
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
echo 256 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 256 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
modprobe uio_pci_generic
insmod ./build/kmod/igb_uio.ko
python usertools/dpdk-devbind.py -b igb_uio 0000:02:00.0
./build/app/testpmd -l 0,1 --log-level 8 -- --total-num-mbufs=65536 -i --port-topology=chained
# note: the MAC address of port is 68:05:CA:38:6D:C0

set promisc all off
show port info 0
set fwd rxonly
set verbose 1
start

# on a tester node, send a packet with scapy
# it is properly received by the PMD
sendp(Ether(dst='68:05:CA:38:6D:C0')/IP()/UDP()/Raw("x"*10), iface='ens3f2')

# back on DUT, change primary mac addr on port 0
stop
mac_addr set 0 00:00:01:02:03:04
start

# Without the patch, this packet is not received
sendp(Ether(dst='00:00:01:02:03:04')/IP()/UDP()/Raw("x"*10), iface='ens3f2')
# Without the patch, this packet with the old addr is received
sendp(Ether(dst='68:05:CA:38:6D:C0')/IP()/UDP()/Raw("x"*10), iface='ens3f2')


 drivers/net/i40e/i40e_ethdev.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 811cc9ffe..e7d070879 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10818,12 +10818,41 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 				      struct ether_addr *mac_addr)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_vsi *vsi = pf->main_vsi;
+	struct i40e_mac_filter_info mac_filter;
+	struct i40e_mac_filter *f;
+	int ret;
 
 	if (!is_valid_assigned_ether_addr(mac_addr)) {
 		PMD_DRV_LOG(ERR, "Tried to set invalid MAC address.");
 		return;
 	}
 
+	TAILQ_FOREACH(f, &vsi->mac_list, next) {
+		if (is_same_ether_addr(&pf->dev_addr, &f->mac_info.mac_addr))
+			break;
+	}
+
+	if (f == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to find filter for default mac");
+		return;
+	}
+
+	mac_filter = f->mac_info;
+	ret = i40e_vsi_delete_mac(vsi, &mac_filter.mac_addr);
+	if (ret != I40E_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Failed to delete mac filter");
+		return;
+	}
+	memcpy(&mac_filter.mac_addr, mac_addr, ETH_ADDR_LEN);
+	ret = i40e_vsi_add_mac(vsi, &mac_filter);
+	if (ret != I40E_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Failed to add mac filter");
+		return;
+	}
+	memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
+
 	/* Flags: 0x3 updates port address */
 	i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
 }
-- 
2.11.0

             reply	other threads:[~2018-01-03 14:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 14:29 Olivier Matz [this message]
2018-01-04  5:39 ` Xing, Beilei
2018-01-10 13:57   ` Zhang, Helin
2018-01-10 22:46     ` Igor Ryzhov
2018-01-11  8:21       ` Xing, Beilei
2018-01-11 10:08         ` Igor Ryzhov
2018-01-05 12:34 ` Igor Ryzhov
2018-01-08  6:36   ` Zhang, Helin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180103142923.3528-1-olivier.matz@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=laurent.hardy@6wind.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).