Skip to contentSkip to conversation

Bonding: returns detailed error about XDP failures

PATCH Superseded Hangbin Liu 4 participants 15 messages Oct 17, 2024 – Oct 19, 2024

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Bonding: returns detailed error about XDP failures

Based on discussion[1], this patch set returns detailed error about XDP failures. And update bonding document about XDP supports.

v2: update the title in the doc (Nikolay Aleksandrov)

[1] https://lore.kernel.org/netdev/[email protected]/

Hangbin Liu (3):
bonding: return detailed error when loading native XDP fails
bonding: use correct return value
Documentation: bonding: add XDP support explanation

 Documentation/networking/bonding.rst | 12 ++++++++++++
 drivers/net/bonding/bond_main.c      |  7 +++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.46.0
#1 lore raw

PATCH v2 1/3 bonding: return detailed error when loading native XDP fails

Bonding only supports native XDP for specific modes, which can lead to confusion for users regarding why XDP loads successfully at times and fails at others. This patch enhances error handling by returning detailed error messages, providing users with clearer insights into the specific reasons for the failure when loading native XDP.

---
 drivers/net/bonding/bond_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +4 -1
index b1bffd8e9a95..f0f76b6ac8be 100644
@@ -5676,8 +5676,11 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 
 	ASSERT_RTNL();
 
-	if (!bond_xdp_check(bond))
+	if (!bond_xdp_check(bond)) {
+		BOND_NL_ERR(dev, extack,
+			    "No native XDP support for the current bonding mode");
 		return -EOPNOTSUPP;
+	}
 
 	old_prog = bond->xdp_prog;
 	bond->xdp_prog = prog;
Signature · 1 line
2.46.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCHv2 net-next 1/3] bonding: return detailed error when loading native XDP fails

Quoted 8 lines · Hangbin Liu

Bonding only supports native XDP for specific modes, which can lead to confusion for users regarding why XDP loads successfully at times and fails at others. This patch enhances error handling by returning detailed error messages, providing users with clearer insights into the specific reasons for the failure when loading native XDP.

#3 lore raw

PATCH v2 2/3 bonding: use correct return value

In reply to Hangbin Liu

When a slave already has an XDP program loaded, the correct return value should be -EEXIST instead of -EOPNOTSUPP.

Fixes 9e2ee5c7e7c3 ("net, bonding: Add XDP support to the bonding driver")
---
 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;
 			goto err;
 		}
 
Signature · 1 line
2.46.0
#4 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 15 lines · Hangbin Liu

When a slave already has an XDP program loaded, the correct return value should be -EEXIST instead of -EOPNOTSUPP.

Fixes 9e2ee5c7e7c3 ("net, bonding: Add XDP support to the bonding driver")
---
 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

-Toke

#5 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Thanks
Hangbin

reviewer
#6 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 15 lines · Hangbin Liu
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

Quoted 3 lines

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Hi Toke,

Could you add some colour to what extent user's might rely on this error code?

Basically I think that if they do then we shouldn't change this.

#7 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 20 lines · Simon Horman
Quoted 15 lines · Hangbin Liu
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

Quoted 3 lines

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Quoted 5 lines

Hi Toke,

Could you add some colour to what extent user's might rely on this error code?

Basically I think that if they do then we shouldn't change this.

Well, that's the trouble with UAPI, we don't really know. In libxdp and xdp-tools we look at the return code to provide a nicer error message, like:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L615

and as a signal to fall back to loading the programme without a dispatcher:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L1824

Both of these cases would be unaffected (or even improved) by this patch, so in that sense I don't have a concrete objection, just a general "userspace may react to this". In other words, my concern is more of a general "we don't know, so this seems risky". If any of you have more information about how bonding XDP is generally used, that may help get a better idea of this?

-Toke

reviewer
#8 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 36 lines · Toke Høiland-Jørgensen
Quoted 20 lines · Simon Horman
Quoted 15 lines · Hangbin Liu
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

Quoted 3 lines

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Quoted 5 lines

Hi Toke,

Could you add some colour to what extent user's might rely on this error code?

Basically I think that if they do then we shouldn't change this.

Well, that's the trouble with UAPI, we don't really know. In libxdp and xdp-tools we look at the return code to provide a nicer error message, like:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L615

and as a signal to fall back to loading the programme without a dispatcher:

Quoted 8 lines

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L1824

Both of these cases would be unaffected (or even improved) by this patch, so in that sense I don't have a concrete objection, just a general "userspace may react to this". In other words, my concern is more of a general "we don't know, so this seems risky". If any of you have more information about how bonding XDP is generally used, that may help get a better idea of this?

Yes, that is the trouble with the UAPI. I was hoping you might be able to provide the clarity you ask for above. But alas, things are as clear as mud.

In lieu of more information I suggest caution and dropping this change for now.

Signature · 1 line
pw-bot: cr
#9 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 46 lines · Simon Horman
Quoted 36 lines · Toke Høiland-Jørgensen
Quoted 20 lines · Simon Horman
Quoted 15 lines · Hangbin Liu
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

Quoted 3 lines

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Quoted 5 lines

Hi Toke,

Could you add some colour to what extent user's might rely on this error code?

Basically I think that if they do then we shouldn't change this.

Well, that's the trouble with UAPI, we don't really know. In libxdp and xdp-tools we look at the return code to provide a nicer error message, like:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L615

and as a signal to fall back to loading the programme without a dispatcher:

Quoted 8 lines

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L1824

Both of these cases would be unaffected (or even improved) by this patch, so in that sense I don't have a concrete objection, just a general "userspace may react to this". In other words, my concern is more of a general "we don't know, so this seems risky". If any of you have more information about how bonding XDP is generally used, that may help get a better idea of this?

Quoted 6 lines

Yes, that is the trouble with the UAPI. I was hoping you might be able to provide the clarity you ask for above. But alas, things are as clear as mud.

In lieu of more information I suggest caution and dropping this change for now.

OK, I will drop this one.

Thanks
Hangbin

reviewer
#10 lore raw

Re: [PATCHv2 net-next 2/3] bonding: use correct return value

Quoted 47 lines · Hangbin Liu
Quoted 46 lines · Simon Horman
Quoted 44 lines · Toke Høiland-Jørgensen
Quoted 20 lines · Simon Horman
Quoted 15 lines · Hangbin Liu
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 5 lines
drivers/net/bonding/bond_main.c +0 -0
index f0f76b6ac8be..6887a867fe8b 100644
@@ -5699,7 +5699,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
Quoted 8 lines

drivers/net/bonding/bond_main.c static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, · line 5702

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
 		if (dev_xdp_prog_count(slave_dev) > 0) {
 			SLAVE_NL_ERR(dev, slave_dev, extack,
 				     "Slave has XDP program loaded, please unload before enslaving");
-			err = -EOPNOTSUPP;
+			err = -EEXIST;

Hmm, this has been UAPI since kernel 5.15, so can we really change it now? What's the purpose of changing it, anyway?

Quoted 3 lines

I just think it should return EXIST when the error is "Slave has XDP program loaded". No special reason. If all others think we should not change it, I can drop this patch.

Quoted 5 lines

Hi Toke,

Could you add some colour to what extent user's might rely on this error code?

Basically I think that if they do then we shouldn't change this.

Well, that's the trouble with UAPI, we don't really know. In libxdp and xdp-tools we look at the return code to provide a nicer error message, like:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L615

and as a signal to fall back to loading the programme without a dispatcher:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L1824

Both of these cases would be unaffected (or even improved) by this patch, so in that sense I don't have a concrete objection, just a general "userspace may react to this". In other words, my concern is more of a general "we don't know, so this seems risky". If any of you have more information about how bonding XDP is generally used, that may help get a better idea of this?

Quoted 8 lines
Quoted 6 lines

Yes, that is the trouble with the UAPI. I was hoping you might be able to provide the clarity you ask for above. But alas, things are as clear as mud.

In lieu of more information I suggest caution and dropping this change for now.

OK, I will drop this one.

Thanks.

#11 lore raw

PATCH v2 3/3 Documentation: bonding: add XDP support explanation

In reply to Hangbin Liu

Add document about which modes have native XDP support.

---
 Documentation/networking/bonding.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/networking/bonding.rst +12 -0
index e774b48de9f5..5c4a83005025 100644
@@ -2916,6 +2916,18 @@ from the bond (``ifenslave -d bond0 eth0``). The bonding driver will
 then restore the MAC addresses that the slaves had before they were
 enslaved.
 
+9.  What bonding modes support native XDP?
+------------------------------------------
+
+Currently, only the following bonding modes support native XDP:
+  * balance-rr (0)
+  * active-backup (1)
+  * balance-xor (2)
+  * 802.3ad (4)
+
+Note that the vlan+srcmac hash policy does not support native XDP.
+For other bonding modes, the XDP program must be loaded with generic mode.
+
 16. Resources and Links
 =======================
 
Signature · 1 line
2.46.0
Reviewed-by on v2 3/3
#12 lore raw

Re: [PATCHv2 net-next 3/3] Documentation: bonding: add XDP support explanation

Quoted 12 lines · Hangbin Liu

Add document about which modes have native XDP support.

---
 Documentation/networking/bonding.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/networking/bonding.rst +0 -0
index e774b48de9f5..5c4a83005025 100644

Documentation/networking/bonding.rst from the bond (``ifenslave -d bond0 eth0``). The bonding driver will · line 2922

Quoted 7 lines
Documentation/networking/bonding.rst +4 -0
@@ -2916,6 +2916,18 @@ from the bond (``ifenslave -d bond0 eth0``). The bonding driver will
 then restore the MAC addresses that the slaves had before they were
 enslaved.
 
+9.  What bonding modes support native XDP?
+------------------------------------------
+
+Currently, only the following bonding modes support native XDP:

If there's a new version please consider dropping this sentence. It just repeats the title above in a different way.

Documentation/networking/bonding.rst from the bond (``ifenslave -d bond0 eth0``). The bonding driver will · line 2933

Quoted 11 lines
Documentation/networking/bonding.rst +8 -0
+  * balance-rr (0)
+  * active-backup (1)
+  * balance-xor (2)
+  * 802.3ad (4)
+
+Note that the vlan+srcmac hash policy does not support native XDP.
+For other bonding modes, the XDP program must be loaded with generic mode.
+
 16. Resources and Links
 =======================
 
#13 lore raw
In reply to Hangbin Liu
Quoted 7 lines · Hangbin Liu

Based on discussion[1], this patch set returns detailed error about XDP failures. And update bonding document about XDP supports.

v2: update the title in the doc (Nikolay Aleksandrov)

[1] https://lore.kernel.org/netdev/[email protected]/

Quoted 9 lines

Hangbin Liu (3):
bonding: return detailed error when loading native XDP fails
bonding: use correct return value
Documentation: bonding: add XDP support explanation

 Documentation/networking/bonding.rst | 12 ++++++++++++
 drivers/net/bonding/bond_main.c      |  7 +++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

Please CC reviewers when sending new versions. I was CCed on patches 1 and 2 probably due to the tag, but wasn't on patch 3 and had to search for the series.

Thanks,
Nik

#14 lore raw
Quoted 3 lines · Nikolay Aleksandrov

Please CC reviewers when sending new versions. I was CCed on patches 1 and 2 probably due to the tag, but wasn't on patch 3 and had to search for the series.

Oh, sorry for the inconvenient. I thought you are in the cc list. Next time I will do double check.

Hangbin