@@ -1955,10 +1955,66 @@ int ionic_lifs_init(struct ionic *ionic)
19551955 return 0 ;
19561956}
19571957
1958+ static void ionic_lif_notify_work (struct work_struct * ws )
1959+ {
1960+ }
1961+
1962+ static void ionic_lif_set_netdev_info (struct ionic_lif * lif )
1963+ {
1964+ struct ionic_admin_ctx ctx = {
1965+ .work = COMPLETION_INITIALIZER_ONSTACK (ctx .work ),
1966+ .cmd .lif_setattr = {
1967+ .opcode = IONIC_CMD_LIF_SETATTR ,
1968+ .index = cpu_to_le16 (lif -> index ),
1969+ .attr = IONIC_LIF_ATTR_NAME ,
1970+ },
1971+ };
1972+
1973+ strlcpy (ctx .cmd .lif_setattr .name , lif -> netdev -> name ,
1974+ sizeof (ctx .cmd .lif_setattr .name ));
1975+
1976+ ionic_adminq_post_wait (lif , & ctx );
1977+ }
1978+
1979+ static struct ionic_lif * ionic_netdev_lif (struct net_device * netdev )
1980+ {
1981+ if (!netdev || netdev -> netdev_ops -> ndo_start_xmit != ionic_start_xmit )
1982+ return NULL ;
1983+
1984+ return netdev_priv (netdev );
1985+ }
1986+
1987+ static int ionic_lif_notify (struct notifier_block * nb ,
1988+ unsigned long event , void * info )
1989+ {
1990+ struct net_device * ndev = netdev_notifier_info_to_dev (info );
1991+ struct ionic * ionic = container_of (nb , struct ionic , nb );
1992+ struct ionic_lif * lif = ionic_netdev_lif (ndev );
1993+
1994+ if (!lif || lif -> ionic != ionic )
1995+ return NOTIFY_DONE ;
1996+
1997+ switch (event ) {
1998+ case NETDEV_CHANGENAME :
1999+ ionic_lif_set_netdev_info (lif );
2000+ break ;
2001+ }
2002+
2003+ return NOTIFY_DONE ;
2004+ }
2005+
19582006int ionic_lifs_register (struct ionic * ionic )
19592007{
19602008 int err ;
19612009
2010+ INIT_WORK (& ionic -> nb_work , ionic_lif_notify_work );
2011+
2012+ ionic -> nb .notifier_call = ionic_lif_notify ;
2013+
2014+ err = register_netdevice_notifier (& ionic -> nb );
2015+ if (err )
2016+ ionic -> nb .notifier_call = NULL ;
2017+
19622018 /* only register LIF0 for now */
19632019 err = register_netdev (ionic -> master_lif -> netdev );
19642020 if (err ) {
@@ -1974,6 +2030,12 @@ int ionic_lifs_register(struct ionic *ionic)
19742030
19752031void ionic_lifs_unregister (struct ionic * ionic )
19762032{
2033+ if (ionic -> nb .notifier_call ) {
2034+ unregister_netdevice_notifier (& ionic -> nb );
2035+ cancel_work_sync (& ionic -> nb_work );
2036+ ionic -> nb .notifier_call = NULL ;
2037+ }
2038+
19772039 /* There is only one lif ever registered in the
19782040 * current model, so don't bother searching the
19792041 * ionic->lif for candidates to unregister
0 commit comments