netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program
@ 2024-08-14  9:08 Feng zhou
  2024-08-14 10:03 ` Toke Høiland-Jørgensen
  2024-08-15 11:18 ` Paolo Abeni
  0 siblings, 2 replies; 5+ messages in thread
From: Feng zhou @ 2024-08-14  9:08 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
	jiri, bigeasy, lorenzo
  Cc: netdev, linux-kernel, bpf, yangzhenze, wangdongdong.6,
	zhoufeng.zf

From: Feng Zhou <zhoufeng.zf@bytedance.com>

Cannot attach when an upper device already has a program, This
restriction is only for bond's slave devices, and should not be
accidentally injured for devices like eth0 and vxlan0.

Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
---
 net/core/dev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 6ea1d20676fb..e1f87662376a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9501,10 +9501,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
 	}
 
 	/* don't allow if an upper device already has a program */
-	netdev_for_each_upper_dev_rcu(dev, upper, iter) {
-		if (dev_xdp_prog_count(upper) > 0) {
-			NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
-			return -EEXIST;
+	if (netif_is_bond_slave(dev)) {
+		netdev_for_each_upper_dev_rcu(dev, upper, iter) {
+			if (dev_xdp_prog_count(upper) > 0) {
+				NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
+				return -EEXIST;
+			}
 		}
 	}
 
-- 
2.30.2


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

* Re: [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program
  2024-08-14  9:08 [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program Feng zhou
@ 2024-08-14 10:03 ` Toke Høiland-Jørgensen
  2024-08-15 11:18 ` Paolo Abeni
  1 sibling, 0 replies; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2024-08-14 10:03 UTC (permalink / raw)
  To: Feng zhou, davem, edumazet, kuba, pabeni, ast, daniel, hawk,
	john.fastabend, jiri, bigeasy, lorenzo
  Cc: netdev, linux-kernel, bpf, yangzhenze, wangdongdong.6,
	zhoufeng.zf

Feng zhou <zhoufeng.zf@bytedance.com> writes:

> From: Feng Zhou <zhoufeng.zf@bytedance.com>
>
> Cannot attach when an upper device already has a program, This
> restriction is only for bond's slave devices, and should not be
> accidentally injured for devices like eth0 and vxlan0.
>
> Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>

Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>


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

* Re: [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program
  2024-08-14  9:08 [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program Feng zhou
  2024-08-14 10:03 ` Toke Høiland-Jørgensen
@ 2024-08-15 11:18 ` Paolo Abeni
  2024-08-15 12:36   ` Jiri Pirko
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2024-08-15 11:18 UTC (permalink / raw)
  To: Feng zhou, davem, edumazet, kuba, ast, daniel, hawk,
	john.fastabend, jiri, bigeasy, lorenzo
  Cc: netdev, linux-kernel, bpf, yangzhenze, wangdongdong.6

On 8/14/24 11:08, Feng zhou wrote:
> From: Feng Zhou <zhoufeng.zf@bytedance.com>
> 
> Cannot attach when an upper device already has a program, This
> restriction is only for bond's slave devices, and should not be
> accidentally injured for devices like eth0 and vxlan0.
> 
> Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
> ---
>   net/core/dev.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6ea1d20676fb..e1f87662376a 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -9501,10 +9501,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
>   	}
>   
>   	/* don't allow if an upper device already has a program */
> -	netdev_for_each_upper_dev_rcu(dev, upper, iter) {
> -		if (dev_xdp_prog_count(upper) > 0) {
> -			NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
> -			return -EEXIST;
> +	if (netif_is_bond_slave(dev)) {

I think we want to consider even team port devices.

Thanks,

Paolo


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

* Re: [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program
  2024-08-15 11:18 ` Paolo Abeni
@ 2024-08-15 12:36   ` Jiri Pirko
  2024-08-22  8:25     ` [External] " Feng Zhou
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2024-08-15 12:36 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Feng zhou, davem, edumazet, kuba, ast, daniel, hawk,
	john.fastabend, bigeasy, lorenzo, netdev, linux-kernel, bpf,
	yangzhenze, wangdongdong.6

Thu, Aug 15, 2024 at 01:18:33PM CEST, pabeni@redhat.com wrote:
>On 8/14/24 11:08, Feng zhou wrote:
>> From: Feng Zhou <zhoufeng.zf@bytedance.com>
>> 
>> Cannot attach when an upper device already has a program, This
>> restriction is only for bond's slave devices, and should not be
>> accidentally injured for devices like eth0 and vxlan0.
>> 
>> Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
>> ---
>>   net/core/dev.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>> 
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 6ea1d20676fb..e1f87662376a 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -9501,10 +9501,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
>>   	}
>>   	/* don't allow if an upper device already has a program */
>> -	netdev_for_each_upper_dev_rcu(dev, upper, iter) {
>> -		if (dev_xdp_prog_count(upper) > 0) {
>> -			NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
>> -			return -EEXIST;
>> +	if (netif_is_bond_slave(dev)) {
>
>I think we want to consider even team port devices.

netif_is_lag_port()


>
>Thanks,
>
>Paolo
>

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

* Re: [External] Re: [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program
  2024-08-15 12:36   ` Jiri Pirko
@ 2024-08-22  8:25     ` Feng Zhou
  0 siblings, 0 replies; 5+ messages in thread
From: Feng Zhou @ 2024-08-22  8:25 UTC (permalink / raw)
  To: Jiri Pirko, Paolo Abeni
  Cc: davem, edumazet, kuba, ast, daniel, hawk, john.fastabend, bigeasy,
	lorenzo, netdev, linux-kernel, bpf, yangzhenze, wangdongdong.6

在 2024/8/15 20:36, Jiri Pirko 写道:
> Thu, Aug 15, 2024 at 01:18:33PM CEST, pabeni@redhat.com wrote:
>> On 8/14/24 11:08, Feng zhou wrote:
>>> From: Feng Zhou <zhoufeng.zf@bytedance.com>
>>>
>>> Cannot attach when an upper device already has a program, This
>>> restriction is only for bond's slave devices, and should not be
>>> accidentally injured for devices like eth0 and vxlan0.
>>>
>>> Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
>>> ---
>>>    net/core/dev.c | 10 ++++++----
>>>    1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/net/core/dev.c b/net/core/dev.c
>>> index 6ea1d20676fb..e1f87662376a 100644
>>> --- a/net/core/dev.c
>>> +++ b/net/core/dev.c
>>> @@ -9501,10 +9501,12 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
>>>    	}
>>>    	/* don't allow if an upper device already has a program */
>>> -	netdev_for_each_upper_dev_rcu(dev, upper, iter) {
>>> -		if (dev_xdp_prog_count(upper) > 0) {
>>> -			NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
>>> -			return -EEXIST;
>>> +	if (netif_is_bond_slave(dev)) {
>>
>> I think we want to consider even team port devices.
> 
> netif_is_lag_port()
> 
> 

Will do, thanks.

>>
>> Thanks,
>>
>> Paolo
>>


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

end of thread, other threads:[~2024-08-22  8:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14  9:08 [PATCH] net: Don't allow to attach xdp if bond slave device's upper already has a program Feng zhou
2024-08-14 10:03 ` Toke Høiland-Jørgensen
2024-08-15 11:18 ` Paolo Abeni
2024-08-15 12:36   ` Jiri Pirko
2024-08-22  8:25     ` [External] " Feng Zhou

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