diff mbox series

net: retain NOCARRIER on protodown interfaces

Message ID 20240927073331.80425-1-boyko.cxx@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series net: retain NOCARRIER on protodown interfaces | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 13 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 79 this patch: 79
netdev/source_inline success Was 0 now: 0

Commit Message

Volodymyr Boyko Sept. 27, 2024, 7:33 a.m. UTC
Make interface with enabled protodown to retain NOCARRIER state during
transfer of operstate from its lower device.

Signed-off-by: Volodymyr Boyko <boyko.cxx@gmail.com>
---
Currently bringing up lower device enables carrier on upper devices
ignoring the protodown flag.

Steps to reproduce:
```
ip l a test0 up type dummy
ip l a test0.mv0 up link test0 type macvlan mode bridge
ip l s test0.mv0 protodown on
sleep 1
printf 'before flap:\n'
ip -o l show | grep test0
ip l set down test0 && ip l set up test0
printf 'after flap:\n'
ip -o l show | grep test0
ip l del test0
```

output without this change:
```
before flap:
28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
	 state LOWERLAYERDOWN protodown on
after flap:
28: test0.mv0@test0: <BROADCAST,MULTICAST,UP,LOWER_UP>
	 state UP protodown on
```

output with this change:
```
before flap:
28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
	state DOWN protodown on
after flap:
28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
	state DOWN protodown on
```
---
 net/core/dev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Paolo Abeni Oct. 3, 2024, 8:55 a.m. UTC | #1
On 9/27/24 09:33, Volodymyr Boyko wrote:
> Make interface with enabled protodown to retain NOCARRIER state during
> transfer of operstate from its lower device.
> 
> Signed-off-by: Volodymyr Boyko <boyko.cxx@gmail.com>
> ---
> Currently bringing up lower device enables carrier on upper devices
> ignoring the protodown flag.
> 
> Steps to reproduce:
> ```
> ip l a test0 up type dummy
> ip l a test0.mv0 up link test0 type macvlan mode bridge
> ip l s test0.mv0 protodown on
> sleep 1
> printf 'before flap:\n'
> ip -o l show | grep test0
> ip l set down test0 && ip l set up test0
> printf 'after flap:\n'
> ip -o l show | grep test0
> ip l del test0
> ```
> 
> output without this change:
> ```
> before flap:
> 28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
> 	 state LOWERLAYERDOWN protodown on
> after flap:
> 28: test0.mv0@test0: <BROADCAST,MULTICAST,UP,LOWER_UP>
> 	 state UP protodown on
> ```
> 
> output with this change:
> ```
> before flap:
> 28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
> 	state DOWN protodown on
> after flap:
> 28: test0.mv0@test0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
> 	state DOWN protodown on
> ```

I'm unsure we can accept this change of behavior: existing user-space 
application may rely on the existing one. I tend to stay on the safe side.

Paolo
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 1e740faf9e78..10b0ae0ca5a8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10198,10 +10198,12 @@  void netif_stacked_transfer_operstate(const struct net_device *rootdev,
 	else
 		netif_testing_off(dev);
 
-	if (netif_carrier_ok(rootdev))
-		netif_carrier_on(dev);
-	else
-		netif_carrier_off(dev);
+	if (!dev->proto_down) {
+		if (netif_carrier_ok(rootdev))
+			netif_carrier_on(dev);
+		else
+			netif_carrier_off(dev);
+	}
 }
 EXPORT_SYMBOL(netif_stacked_transfer_operstate);