]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
reinit ip_config when service rdma restart.
authorZheng Li <zheng.x.li@oracle.com>
Tue, 4 Jun 2013 03:20:42 +0000 (11:20 +0800)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Wed, 8 Jul 2015 20:37:57 +0000 (13:37 -0700)
Orabug: 16605377

reinit rds ip_config when net_device REGISTER and UNREGISTER event
happen, that will reassign new value to ip_config's member:dev and
rds_ibdev.

Signed-off-by: zheng.x.li@oracle.com
Signed-off-by: bang.nguyen@oracle.com
(cherry picked from commit 864b4ee41637414ae7916f740441cfa6509bc8dc)

net/rds/ib.c

index 38b973072a9fbbeb91b6bed8ddf11a2785664609..b80805b901772c7c198f785a174aaddd7739b379 100644 (file)
@@ -1030,7 +1030,7 @@ static void rds_ib_dump_ip_config(void)
        }
 }
 
-static int rds_ib_ip_config_init(void)
+static int rds_ib_ip_config_init(bool reinit)
 {
        struct net_device       *dev;
        struct in_ifaddr        *ifa;
@@ -1045,17 +1045,21 @@ static int rds_ib_ip_config_init(void)
        if (!rds_ib_haip_enabled)
                return 0;
 
-       rds_ib_check_up_port();
+       if (!reinit)
+               rds_ib_check_up_port();
 
        rcu_read_unlock();
 
-       ip_config = kzalloc(sizeof(struct rds_ib_port) *
-                               (ip_port_max + 1), GFP_KERNEL);
-       if (!ip_config) {
-               printk(KERN_ERR "RDS/IB: failed to allocate IP config\n");
-               return 1;
+       if (reinit)
+               ip_port_cnt = 0;
+       else {
+               ip_config = kzalloc(sizeof(struct rds_ib_port) *
+                                       (ip_port_max + 1), GFP_KERNEL);
+               if (!ip_config) {
+                       printk(KERN_ERR "RDS/IB: failed to allocate IP config\n");
+                       return 1;
+               }
        }
-
        read_lock(&dev_base_lock);
        for_each_netdev(&init_net, dev) {
                in_dev = in_dev_get(dev);
@@ -1299,35 +1303,37 @@ static int rds_ib_netdev_callback(struct notifier_block *self, unsigned long eve
        if (!rds_ib_haip_enabled || !ip_port_cnt)
                return NOTIFY_DONE;
 
-       if (event != NETDEV_UP && event != NETDEV_DOWN)
+       if (event != NETDEV_UP && event != NETDEV_DOWN &&
+               event != NETDEV_REGISTER && event != NETDEV_UNREGISTER)
                return NOTIFY_DONE;
 
-       for (i = 1; i <= ip_port_cnt; i++) {
-               if (!strcmp(ndev->name, ip_config[i].if_name)) {
-                       port = i;
-                       break;
+       if (event == NETDEV_UP || event == NETDEV_DOWN) {
+               for (i = 1; i <= ip_port_cnt; i++) {
+                       if (!strcmp(ndev->name, ip_config[i].if_name)) {
+                               port = i;
+                               break;
+                       }
                }
-       }
 
-       if (!port)
-               return NOTIFY_DONE;
+               if (!port)
+                       return NOTIFY_DONE;
 
+               work = kzalloc(sizeof *work, GFP_ATOMIC);
+               if (!work) {
+                       printk(KERN_ERR "RDS/IB: failed to allocate port work\n");
+                       return NOTIFY_DONE;
+               }
 
-       printk(KERN_NOTICE "RDS/IB: %s/port_%d/%s is %s\n",
-               ip_config[port].rds_ibdev->dev->name,
-               ip_config[port].port_num, ndev->name,
-               (event == NETDEV_UP) ? "UP" : "DOWN");
+               printk(KERN_NOTICE "RDS/IB: %s/port_%d/%s is %s\n",
+                       ip_config[port].rds_ibdev->dev->name,
+                       ip_config[port].port_num, ndev->name,
+                       (event == NETDEV_UP) ? "UP" : "DOWN");
 
-       work = kzalloc(sizeof *work, GFP_ATOMIC);
-       if (!work) {
-               printk(KERN_ERR "RDS/IB: failed to allocate port work\n");
-               return NOTIFY_DONE;
+               work->dev = ndev;
+               work->port = port;
+               work->event_type = RDS_IB_PORT_EVENT_NET;
        }
 
-       work->dev = ndev;
-       work->port = port;
-       work->event_type = RDS_IB_PORT_EVENT_NET;
-
        switch (event) {
        case NETDEV_UP:
                if (rds_ib_haip_fallback) {
@@ -1350,6 +1356,11 @@ static int rds_ib_netdev_callback(struct notifier_block *self, unsigned long eve
                INIT_DELAYED_WORK(&work->work, rds_ib_failover);
                queue_delayed_work(rds_wq, &work->work, 0);
                break;
+       case NETDEV_UNREGISTER:
+       case NETDEV_REGISTER:
+               rds_ib_ip_config_init(1);
+               rds_ib_ip_failover_groups_init();
+               break;
        }
 
        return NOTIFY_DONE;
@@ -1408,7 +1419,7 @@ int rds_ib_init(void)
 
        rds_info_register_func(RDS_INFO_IB_CONNECTIONS, rds_ib_ic_info);
 
-       ret = rds_ib_ip_config_init();
+       ret = rds_ib_ip_config_init(0);
        if (ret) {
                printk(KERN_ERR "RDS/IB: failed to init port\n");
                goto out_srq;