Whamcloud - gitweb
LU-16378 lnet: handles unregister/register events
authorCyril Bordage <cbordage@whamcloud.com>
Mon, 12 Dec 2022 10:49:11 +0000 (11:49 +0100)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 17 Dec 2022 02:23:38 +0000 (02:23 +0000)
When network is restarted, devices are unregistered and then
registered again. When a device registers using an index that is
different from the previous one (before network was restarted), LNet
ignores it. Consequently, this device stays with link in fatal state.

To fix that, we catch unregistering events to clear the saved index
value, and when a registering event comes, we save the new value.

Lustre-change: https://review.whamcloud.com/49375/
Lustre-commit: TBD (from 7442710a56a8f38453441c62253c0ad891fe9b8c)

Signed-off-by: Cyril Bordage <cbordage@whamcloud.com>
Change-Id: I17e93a1103d588f3e630a9c7446b345f4d472b97
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49376
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lnet/klnds/socklnd/socklnd.c

index c9abe79..61c46ac 100644 (file)
@@ -1902,10 +1902,28 @@ ksocknal_handle_link_state_change(struct net_device *dev,
                ksi = &net->ksnn_interface;
                found_ip = false;
 
-               if (ksi->ksni_index != ifindex ||
-                   strcmp(ksi->ksni_name, dev->name))
+               if (strcmp(ksi->ksni_name, dev->name))
+                       continue;
+
+               if (ksi->ksni_index == -1) {
+                       if (dev->reg_state != NETREG_REGISTERED)
+                               continue;
+                       /* A registration just happened: save the new index for
+                        * the device */
+                       ksi->ksni_index = ifindex;
+                       goto out;
+               }
+
+               if (ksi->ksni_index != ifindex)
                        continue;
 
+               if (dev->reg_state == NETREG_UNREGISTERING) {
+                       /* Device is being unregitering, we need to clear the
+                        * index, it can change when device will be back */
+                       ksi->ksni_index = -1;
+                       goto out;
+               }
+
                ni = net->ksnn_ni;
 
                in_dev = __in_dev_get_rtnl(dev);
@@ -1999,6 +2017,8 @@ static int ksocknal_device_event(struct notifier_block *unused,
        case NETDEV_UP:
        case NETDEV_DOWN:
        case NETDEV_CHANGE:
+       case NETDEV_REGISTER:
+       case NETDEV_UNREGISTER:
                ksocknal_handle_link_state_change(dev, operstate);
                break;
        }