]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netconsole: add STATE_DEACTIVATED to track targets disabled by low level
authorBreno Leitao <leitao@debian.org>
Sun, 18 Jan 2026 11:00:23 +0000 (11:00 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 22 Jan 2026 03:09:11 +0000 (19:09 -0800)
When the low level interface brings a netconsole target down, record this
using a new STATE_DEACTIVATED state. This allows netconsole to distinguish
between targets explicitly disabled by users and those deactivated due to
interface state changes.

It also enables automatic recovery and re-enabling of targets if the
underlying low-level interfaces come back online.

From a code perspective, anything that is not STATE_ENABLED is disabled.

Devices (de)enslaving are marked STATE_DISABLED to prevent automatically
resuming as enslaved interfaces cannot have netconsole enabled.

Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Andre Carvalho <asantostc@gmail.com>
Tested-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260118-netcons-retrigger-v11-3-4de36aebcf48@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c

index b21ecea60d522a92773ef206c6daacace8e2b1a1..7a1e5559fc0da9f24b406dff619974b5d0adad11 100644 (file)
@@ -122,6 +122,7 @@ enum sysdata_feature {
 enum target_state {
        STATE_DISABLED,
        STATE_ENABLED,
+       STATE_DEACTIVATED,
 };
 
 /**
@@ -580,6 +581,14 @@ static ssize_t enabled_store(struct config_item *item,
        if (ret)
                goto out_unlock;
 
+       /* When the user explicitly enables or disables a target that is
+        * currently deactivated, reset its state to disabled. The DEACTIVATED
+        * state only tracks interface-driven deactivation and should _not_
+        * persist when the user manually changes the target's enabled state.
+        */
+       if (nt->state == STATE_DEACTIVATED)
+               nt->state = STATE_DISABLED;
+
        ret = -EINVAL;
        current_enabled = nt->state == STATE_ENABLED;
        if (enabled == current_enabled) {
@@ -1445,10 +1454,19 @@ static int netconsole_netdev_event(struct notifier_block *this,
                                break;
                        case NETDEV_RELEASE:
                        case NETDEV_JOIN:
-                       case NETDEV_UNREGISTER:
+                               /* transition target to DISABLED instead of
+                                * DEACTIVATED when (de)enslaving devices as
+                                * their targets should not be automatically
+                                * resumed when the interface is brought up.
+                                */
                                nt->state = STATE_DISABLED;
                                list_move(&nt->list, &target_cleanup_list);
                                stopped = true;
+                               break;
+                       case NETDEV_UNREGISTER:
+                               nt->state = STATE_DEACTIVATED;
+                               list_move(&nt->list, &target_cleanup_list);
+                               stopped = true;
                        }
                }
                netconsole_target_put(nt);