DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address change
@ 2018-01-03 14:29 Olivier Matz
  2018-01-04  5:39 ` Xing, Beilei
  2018-01-05 12:34 ` Igor Ryzhov
  0 siblings, 2 replies; 8+ messages in thread
From: Olivier Matz @ 2018-01-03 14:29 UTC (permalink / raw)
  To: dev, Jingjing Wu, Beilei Xing; +Cc: stable, Laurent Hardy

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-11 10:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 14:29 [dpdk-dev] [PATCH] net/i40e: fix VSI MAC filter on primary address change Olivier Matz
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

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).