}
 #endif
 
+static void addrconf_init_auto_addrs(struct net_device *dev)
+{
+       switch (dev->type) {
+#if IS_ENABLED(CONFIG_IPV6_SIT)
+       case ARPHRD_SIT:
+               addrconf_sit_config(dev);
+               break;
+#endif
+#if IS_ENABLED(CONFIG_NET_IPGRE) || IS_ENABLED(CONFIG_IPV6_GRE)
+       case ARPHRD_IP6GRE:
+       case ARPHRD_IPGRE:
+               addrconf_gre_config(dev);
+               break;
+#endif
+       case ARPHRD_LOOPBACK:
+               init_loopback(dev);
+               break;
+
+       default:
+               addrconf_dev_config(dev);
+               break;
+       }
+}
+
 static int fixup_permanent_addr(struct net *net,
                                struct inet6_dev *idev,
                                struct inet6_ifaddr *ifp)
                        run_pending = 1;
                }
 
-               switch (dev->type) {
-#if IS_ENABLED(CONFIG_IPV6_SIT)
-               case ARPHRD_SIT:
-                       addrconf_sit_config(dev);
-                       break;
-#endif
-#if IS_ENABLED(CONFIG_NET_IPGRE) || IS_ENABLED(CONFIG_IPV6_GRE)
-               case ARPHRD_IP6GRE:
-               case ARPHRD_IPGRE:
-                       addrconf_gre_config(dev);
-                       break;
-#endif
-               case ARPHRD_LOOPBACK:
-                       init_loopback(dev);
-                       break;
-
-               default:
-                       addrconf_dev_config(dev);
-                       break;
-               }
+               addrconf_init_auto_addrs(dev);
 
                if (!IS_ERR_OR_NULL(idev)) {
                        if (run_pending)
 
                        if (idev->cnf.addr_gen_mode != new_val) {
                                idev->cnf.addr_gen_mode = new_val;
-                               addrconf_dev_config(idev->dev);
+                               addrconf_init_auto_addrs(idev->dev);
                        }
                } else if (&net->ipv6.devconf_all->addr_gen_mode == ctl->data) {
                        struct net_device *dev;
                                if (idev &&
                                    idev->cnf.addr_gen_mode != new_val) {
                                        idev->cnf.addr_gen_mode = new_val;
-                                       addrconf_dev_config(idev->dev);
+                                       addrconf_init_auto_addrs(idev->dev);
                                }
                        }
                }