net/iavf: fix adding multicast MAC address
PATCH 1/1 net/iavf: fix adding multicast MAC address
When the multicast address is added, it will flush previous addresses first, and then add new ones. So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes the issue.
--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_ethdev.c +22 -8
@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, temp_err; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , +"can't add more than a limited number (%u) of addresses." , + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
@@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err =iavf_add_del_mc_addr_list (adapter, mc_addrs, mc_addrs_num, true); -if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ + temp_err =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true); +if (temp_err) +return temp_err; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static int
drivers/net/iavf/iavf_vchnl.c +0 -3
@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,if (mc_addrs ==NULL || mc_addrs_num ==0 )return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num;
Signature · 1 line
2.13.6
Test-by Peng, Yuan <[email protected]>
-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Thursday, October 15, 2020 10:02 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC address
When the multicast address is added, it will flush previous addresses first, and then add new ones.
So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes the issue.
--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_ethdev.c +8 -1
@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, temp_err; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , +"can't add more than a limited number (%u) of addresses." , + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,
if (err)
return err;
- vf->mc_addrs_num = 0;
-
/* add new ones */
err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num, true);
- if (err)
- return err;
- vf->mc_addrs_num = mc_addrs_num;
- memcpy(vf->mc_addrs, mc_addrs, mc_addrs_num * sizeof(*mc_addrs));
+ if (err) {
+ /* When adding new addresses fail, need to add the
+ * previous addresses back.
+ */
+ temp_err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs,
+ vf->mc_addrs_num, true);
+ if (temp_err)
+ return temp_err;
+ } else {
+ vf->mc_addrs_num = mc_addrs_num;
+ memcpy(vf->mc_addrs,
+ mc_addrs, mc_addrs_num * sizeof(*mc_addrs));
+ }
- return 0;
+ return err;
}
static int
drivers/net/iavf/iavf_vchnl.c +0 -3
@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,if (mc_addrs ==NULL || mc_addrs_num ==0 )return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num;
--
2.13.6
Quoted 72 lines
-----Original Message-----
From: Peng, Yuan <[email protected]>
Sent: Thursday, October 15, 2020 1:14 PM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressTest-by Peng, Yuan <[email protected]>
-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Thursday, October 15, 2020 10:02 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressWhen the multicast address is added, it will flush previous addresses first, and then add new ones.
So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes the issue.Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)drivers/net/iavf/iavf_ethdev.c +8
-1@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data- >dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, temp_err; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , + "can't add more than a limited number (%u) of addresses.", + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }drivers/net/iavf/iavf_ethdev.c +0
-0/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf-Quoted 1 line
mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct
rte_eth_dev*dev,drivers/net/iavf/iavf_ethdev.c +0
-2if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num,true);
drivers/net/iavf/iavf_ethdev.c +0
-4-if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; - memcpy(vf->mc_addrs, mc_addrs, mc_addrs_num *
sizeof(*mc_addrs));
drivers/net/iavf/iavf_ethdev.c
Quoted 6 lines
drivers/net/iavf/iavf_ethdev.c +6
-0+if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ + temp_err =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true);
Can we reuse err here?
Quoted 30 lines
drivers/net/iavf/iavf_ethdev.c +8
-1+if (temp_err) +return temp_err; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static intdrivers/net/iavf/iavf_vchnl.c index renamed from drivers/net/iavf/iavf_vchnl.c +0
-0
db0b76876..a2295f879100644drivers/net/iavf/iavf_vchnl.c +0
-3@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, if (mc_addrs == NULL || mc_addrs_num == 0)return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id;
list->num_elements=mc_addrs_num;
--
2.13.6
Hi beilei
Quoted 79 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, October 15, 2020 1:37 PM
To: Peng, Yuan <[email protected]>; Sun, GuinanX <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 22 lines
-----Original Message-----
From: Peng, Yuan <[email protected]>
Sent: Thursday, October 15, 2020 1:14 PM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressTest-by Peng, Yuan <[email protected]>
-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Thursday, October 15, 2020 10:02 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 4 lines
When the multicast address is added, it will flush previous addresses first, and then add new ones.
So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes theissue.
Quoted 41 lines
Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/net/iavf/iavf_ethdev.cindexe68e3bc71..042edadd9100644drivers/net/iavf/iavf_ethdev.c +0
-0@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct
iavf_info*vf = IAVF_DEV_PRIVATE_TO_VF(dev->data-Quoted 1 line
dev_private);struct
iavf_adapter*adapter =IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);drivers/net/iavf/iavf_ethdev.c +4
-1-int err; +int err, temp_err; + +if (mc_addrs_num > IAVF_NUM_MACADDR_MAX) { PMD_DRV_LOG(ERR, + "can't add more than a limited number (%u) ofaddresses.",
drivers/net/iavf/iavf_ethdev.c +3
-0+ (uint32_t)IAVF_NUM_MACADDR_MAX); +return -EINVAL ; +}/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf-Quoted 1 line
mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct
rte_eth_dev*dev,
if (err)
return err;drivers/net/iavf/iavf_ethdev.c +0
-2-vf->mc_addrs_num =0 ; -/* add new ones */ err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num,true); -if (err) -return err;
Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c
Quoted 8 lines
drivers/net/iavf/iavf_ethdev.c +6
-2-vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ +temp_err =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true);Can we reuse err here?
This err cannot be reused.
When performing mac address addition, the testpmd side will first add the mac address to mac_pool.
When the driver layer returns that it failed to add an address, the tespmd layer will delete the failed address from mac_pool.
If err is reused, the successful result of executing the add back address will overwrite the previous err, causing problems with the address stored in mac_pool on the testpmd side.
Quoted 28 lines
Quoted 27 lines
drivers/net/iavf/iavf_ethdev.c +7
-1+if (temp_err) +return temp_err; +}else { +vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); } -return 0 ; +return err; } static int(quoted diff) +0
-0
b/drivers/net/iavf/iavf_vchnl.cindexdb0b76876..a2295f879100644drivers/net/iavf/iavf_vchnl.c +0
-3@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, if (mc_addrs == NULL || mc_addrs_num == 0) return 0; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num; --2.13.6
Quoted 105 lines
-----Original Message-----
From: Sun, GuinanX <[email protected]>
Sent: Thursday, October 15, 2020 1:57 PM
To: Xing, Beilei <[email protected]>; Peng, Yuan <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressHi beilei
Quoted 80 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, October 15, 2020 1:37 PM
To: Peng, Yuan <[email protected]>; Sun, GuinanX <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 23 lines
-----Original Message-----
From: Peng, Yuan <[email protected]>
Sent: Thursday, October 15, 2020 1:14 PM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressTest-by Peng, Yuan <[email protected]>
-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Thursday, October 15, 2020 10:02 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 5 lines
When the multicast address is added, it will flush previous addresses first, and then add new ones.
So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes theissue.
Quoted 39 lines
Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/net/iavf/iavf_ethdev.cindexe68e3bc71..042edadd9100644drivers/net/iavf/iavf_ethdev.c +0
-0@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct
iavf_info*vf = IAVF_DEV_PRIVATE_TO_VF(dev->data-Quoted 1 line
dev_private);struct
iavf_adapter*adapter =IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);drivers/net/iavf/iavf_ethdev.c +4
-1-int err; +int err, temp_err; + +if (mc_addrs_num > IAVF_NUM_MACADDR_MAX) { PMD_DRV_LOG(ERR, + "can't add more than a limited number (%u) ofaddresses.",
+ (uint32_t)IAVF_NUM_MACADDR_MAX); return-EINVAL; }/* flush previous addresses */
err = iavf_add_del_mc_addr_list(adapter,vf->mc_addrs, vf-Quoted 1 line
mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct
rte_eth_dev*dev,
if (err)
return err;drivers/net/iavf/iavf_ethdev.c +0
-2-vf->mc_addrs_num =0 ; -/* add new ones */ err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num,true); -if (err) -return err;
Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c
Quoted 8 lines
drivers/net/iavf/iavf_ethdev.c +6
-2-vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ +temp_err =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true);Can we reuse err here?
This err cannot be reused.
Quoted 9 lines
When performing mac address addition, the testpmd side will first add the mac address to
mac_pool.
When the driver layer returns that it failed to add an address, the tespmd layer will delete the failed address frommac_pool.If err is reused, the successful result of executing the add back address will overwrite the previous err, causing problems with the address stored in
mac_poolon the testpmd side.
Yes, I missed return err in the end of the function.
Little comments, can we use 'ret' which is more common to indicate return value?
Quoted 30 lines
Quoted 29 lines
Quoted 28 lines
drivers/net/iavf/iavf_ethdev.c +7
-1+if (temp_err) +return temp_err; +}else { +vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); } -return 0 ; +return err; } static int(quoted diff) +0
-0
b/drivers/net/iavf/iavf_vchnl.cindexdb0b76876..a2295f879100644drivers/net/iavf/iavf_vchnl.c +0
-2@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, if (mc_addrs == NULL || mc_addrs_num == 0) return 0; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id=
vf->vsi_res->vsi_id;list->num_elements=mc_addrs_num; --
2.13.6
Hi Beilei
Quoted 121 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, October 15, 2020 2:44 PM
To: Sun, GuinanX <[email protected]>; Peng, Yuan <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 111 lines
-----Original Message-----
From: Sun, GuinanX <[email protected]>
Sent: Thursday, October 15, 2020 1:57 PM
To: Xing, Beilei <[email protected]>; Peng, Yuan <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressHi beilei
Quoted 81 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, October 15, 2020 1:37 PM
To: Peng, Yuan <[email protected]>; Sun, GuinanX <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 23 lines
-----Original Message-----
From: Peng, Yuan <[email protected]>
Sent: Thursday, October 15, 2020 1:14 PM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressTest-by Peng, Yuan <[email protected]>
-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Thursday, October 15, 2020 10:02 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>; Zhang, Qi Z <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH] net/iavf: fix adding multicast MAC addressQuoted 5 lines
When the multicast address is added, it will flush previous addresses first, and then add new ones.
So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes theissue.
Quoted 40 lines
Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)(quoted diff) +0
-0
b/drivers/net/iavf/iavf_ethdev.cindexe68e3bc71..042edadd9100644drivers/net/iavf/iavf_ethdev.c +5
-1@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data- >dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, temp_err; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) {PMD_DRV_LOG (ERR , + "can't add more than a limited number (%u) of addresses.", + (uint32_t )IAVF_NUM_MACADDR_MAX );return -EINVAL ; }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf-Quoted 1 line
mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct
rte_eth_dev*dev,
if (err)
return err;drivers/net/iavf/iavf_ethdev.c +0
-2-vf->mc_addrs_num =0 ; -/* add new ones */ err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num,true); -if (err) -return err;
Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c
Quoted 8 lines
drivers/net/iavf/iavf_ethdev.c +6
-2-vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ +temp_err =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true);Can we reuse err here?
This err cannot be reused.
When performing mac address addition, the testpmd side will first add the mac address to
mac_pool.
When the driver layer returns that it failed to add an address, the tespmd layer will delete the failed address frommac_pool.
Quoted 8 lines
Quoted 4 lines
If err is reused, the successful result of executing the add back address will overwrite the previous err, causing problems with the address stored in
mac_poolon the testpmd side.Yes, I missed return err in the end of the function.
Little comments, can we use 'ret' which is more common to indicate return value?
OK, patch V2 will fix it.
Quoted 33 lines
Quoted 32 lines
Quoted 31 lines
Quoted 30 lines
drivers/net/iavf/iavf_ethdev.c +7
-1+if (temp_err) +return temp_err; +}else { +vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); } -return 0 ; +return err; } static int(quoted diff) +0
-0
b/drivers/net/iavf/iavf_vchnl.cindexdb0b76876..a2295f879100644drivers/net/iavf/iavf_vchnl.c +0
-2@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, if (mc_addrs == NULL || mc_addrs_num == 0)return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer;
list->vsi_id=vf->vsi_res->vsi_id;list->num_elements=mc_addrs_num; --
2.13.6
PATCH v2 1/1 net/iavf: fix adding multicast MAC address
In reply to Guinan SunWhen the multicast address is added, it will flush previous addresses first, and then add new ones. So when adding an address that exceeds the upper limit causes a failure, you need to add the previous address list back. This patch fixes the issue.
---
v2:
* modify the variable name
--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_ethdev.c +22 -8
@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, ret; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , +"can't add more than a limited number (%u) of addresses." , + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
@@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err =iavf_add_del_mc_addr_list (adapter, mc_addrs, mc_addrs_num, true); -if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* When adding new addresses fail, need to add the +* previous addresses back. +*/ + ret =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true); +if (ret) +return ret; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static int
drivers/net/iavf/iavf_vchnl.c +0 -3
@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,if (mc_addrs ==NULL || mc_addrs_num ==0 )return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num;
Signature · 1 line
2.17.1
PATCH v3 1/1 net/iavf: fix adding multicast MAC address
In reply to Guinan SunWhen the multicast address list is added, it will flush previous addresses first, and then add new ones. So when the number of multicast addresses added to the list exceeds the upper limit causes a failure, should add the previous addresses back. This patch fixes the issue.
---
v3:
* modify commit message
v2:
* modify the variable name
--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_ethdev.c +22 -8
@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, ret; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , +"can't add more than a limited number (%u) of addresses." , + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
@@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err =iavf_add_del_mc_addr_list (adapter, mc_addrs, mc_addrs_num, true); -if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* if adding mac address list fails, should add the previous +* addresses back. +*/ + ret =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true); +if (ret) +return ret; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static int
drivers/net/iavf/iavf_vchnl.c +0 -3
@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,if (mc_addrs ==NULL || mc_addrs_num ==0 )return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num;
Signature · 1 line
2.17.1
Quoted 10 lines
-----Original Message-----
From: Guinan Sun <[email protected]>
Sent: Thursday, October 15, 2020 4:14 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [PATCH v3] net/iavf: fix adding multicast MAC address
Quoted 5 lines
When the multicast address list is added, it will flush previous addresses first, and then add new ones.
So when the number of multicast addresses added to the list exceeds the upper limit causes a failure, should add the previous addresses back. This patch fixes the issue.
If the number of multicast address list exceeds the upper limit, it will cause failure, then need to roll back previous addresses.
Except this,
Quoted 89 lines
Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>Tested-by Peng Yuan <[email protected]>---
v3:
* modify commit message
v2:
* modify the variable name--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)drivers/net/iavf/iavf_ethdev.c +8
-1@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data- >dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, ret; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , + "can't add more than a limited number (%u) of addresses.", + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }drivers/net/iavf/iavf_ethdev.c +0
-0/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf-Quoted 1 line
mc_addrs_num, @@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct
rte_eth_dev*dev,drivers/net/iavf/iavf_ethdev.c +0
-2if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err = iavf_add_del_mc_addr_list(adapter, mc_addrs, mc_addrs_num,true);
drivers/net/iavf/iavf_ethdev.c +0
-4-if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; - memcpy(vf->mc_addrs, mc_addrs, mc_addrs_num *
sizeof(*mc_addrs));drivers/net/iavf/iavf_ethdev.c +14
-1+if (err) { +/* if adding mac address list fails, should add the previous +* addresses back. +*/ + ret =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true); +if (ret) +return ret; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static intdrivers/net/iavf/iavf_vchnl.c index renamed from drivers/net/iavf/iavf_vchnl.c +0
-0
db0b76876..a2295f879100644drivers/net/iavf/iavf_vchnl.c +0
-3@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, if (mc_addrs == NULL || mc_addrs_num == 0)return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id;
list->num_elements=mc_addrs_num;
--
2.17.1
PATCH v4 1/1 net/iavf: fix adding multicast MAC address
In reply to Guinan SunWhen the multicast address list is added, it will flush previous addresses first, and then add new ones. If the number of multicast address in the list exceeds the upper limit, it will cause failure, then need to roll back previous addresses. This patch fixes the issue.
---
v4:
* modify commit message
* add Acked-by
v3:
* modify commit message
v2:
* modify the variable name
--- drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++++-------- drivers/net/iavf/iavf_vchnl.c | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_ethdev.c +22 -8
@@ -164,7 +164,14 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); -int err; +int err, ret; + +if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) { +PMD_DRV_LOG (ERR , +"can't add more than a limited number (%u) of addresses." , + (uint32_t )IAVF_NUM_MACADDR_MAX ); +return -EINVAL ; + }/* flush previous addresses */ err = iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
@@ -172,17 +179,24 @@ iavf_set_mc_addr_list(struct rte_eth_dev *dev,if (err)return err; - vf->mc_addrs_num =0 ; -/* add new ones */ err =iavf_add_del_mc_addr_list (adapter, mc_addrs, mc_addrs_num, true); -if (err) -return err; - vf->mc_addrs_num = mc_addrs_num; -memcpy (vf->mc_addrs, mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); +if (err) { +/* if adding mac address list fails, should add the previous +* addresses back. +*/ + ret =iavf_add_del_mc_addr_list (adapter, vf->mc_addrs, + vf->mc_addrs_num, true); +if (ret) +return ret; + }else { + vf->mc_addrs_num = mc_addrs_num; +memcpy (vf->mc_addrs, + mc_addrs, mc_addrs_num *sizeof (*mc_addrs)); + } -return 0 ; +return err; } static int
drivers/net/iavf/iavf_vchnl.c +0 -3
@@ -1107,9 +1107,6 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,if (mc_addrs ==NULL || mc_addrs_num ==0 )return 0 ; -if (mc_addrs_num >IAVF_NUM_MACADDR_MAX ) -return -EINVAL ; - list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements = mc_addrs_num;
Signature · 1 line
2.17.1
Zhang, Qi Z
AppliedQuoted 16 lines
-----Original Message-----
From: Guinan Sun <[email protected]>
Sent: Thursday, October 15, 2020 4:43 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [PATCH v4] net/iavf: fix adding multicast MAC addressWhen the multicast address list is added, it will flush previous addresses first, and then add new ones.
If the number of multicast address in the list exceeds the upper limit, it will cause failure, then need to roll back previous addresses. This patch fixes the issue.
Quoted 5 lines
Fixes 05e4c3aff35f ("net/iavf: support multicast configuration")Signed-off-by Guinan Sun <[email protected]>Tested-by Peng Yuan <[email protected]>Acked-by Beilei Xing <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi