@@ -567,17 +567,16 @@ static void otto_l3_fib_event_work_do(struct work_struct *work)
567567/* Called with rcu_read_lock() */
568568static int otto_l3_fib_notifier (struct notifier_block * this , unsigned long event , void * ptr )
569569{
570- struct fib_notifier_info * info = ptr ;
571- struct rtl838x_switch_priv * priv ;
570+ struct otto_l3_ctrl * ctrl = container_of ( this , struct otto_l3_ctrl , fib_nb ) ;
571+ struct rtl838x_switch_priv * priv = ctrl -> priv ;
572572 struct otto_l3_fib_event_work * fib_work ;
573+ struct fib_notifier_info * info = ptr ;
573574
574575 if ((info -> family != AF_INET && info -> family != AF_INET6 &&
575576 info -> family != RTNL_FAMILY_IPMR &&
576577 info -> family != RTNL_FAMILY_IP6MR ))
577578 return NOTIFY_DONE ;
578579
579- priv = container_of (this , struct rtl838x_switch_priv , fib_nb );
580-
581580 /* ignore FIB events for HW with missing L3 offloading implementation */
582581 if (!priv -> r -> l3_setup )
583582 return NOTIFY_DONE ;
@@ -647,13 +646,12 @@ static void otto_l3_net_event_work_do(struct work_struct *work)
647646
648647static int otto_l3_netevent_notifier (struct notifier_block * this , unsigned long event , void * ptr )
649648{
650- struct rtl838x_switch_priv * priv ;
651- struct net_device * dev ;
649+ struct otto_l3_ctrl * ctrl = container_of (this , struct otto_l3_ctrl , ne_nb );
650+ struct rtl838x_switch_priv * priv = ctrl -> priv ;
651+ struct otto_l3_net_event_work * net_work ;
652652 struct neighbour * n = ptr ;
653+ struct net_device * dev ;
653654 int err , port ;
654- struct otto_l3_net_event_work * net_work ;
655-
656- priv = container_of (this , struct rtl838x_switch_priv , ne_nb );
657655
658656 switch (event ) {
659657 case NETEVENT_NEIGH_UPDATE :
@@ -693,13 +691,15 @@ static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long
693691
694692void otto_l3_remove (struct rtl838x_switch_priv * priv )
695693{
696- if (priv -> ne_nb .notifier_call ) {
697- unregister_netevent_notifier (& priv -> ne_nb );
698- priv -> ne_nb .notifier_call = NULL ;
694+ struct otto_l3_ctrl * ctrl = priv -> l3_ctrl ;
695+
696+ if (ctrl -> ne_nb .notifier_call ) {
697+ unregister_netevent_notifier (& ctrl -> ne_nb );
698+ ctrl -> ne_nb .notifier_call = NULL ;
699699 }
700- if (priv -> fib_nb .notifier_call ) {
701- unregister_fib_notifier (& init_net , & priv -> fib_nb );
702- priv -> fib_nb .notifier_call = NULL ;
700+ if (ctrl -> fib_nb .notifier_call ) {
701+ unregister_fib_notifier (& init_net , & ctrl -> fib_nb );
702+ ctrl -> fib_nb .notifier_call = NULL ;
703703 }
704704}
705705
@@ -721,10 +721,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
721721 * Register netevent notifier callback to catch notifications about neighboring changes
722722 * to update nexthop entries for L3 routing.
723723 */
724- priv -> ne_nb .notifier_call = otto_l3_netevent_notifier ;
725- err = register_netevent_notifier (& priv -> ne_nb );
724+ ctrl -> ne_nb .notifier_call = otto_l3_netevent_notifier ;
725+ err = register_netevent_notifier (& ctrl -> ne_nb );
726726 if (err ) {
727- priv -> ne_nb .notifier_call = NULL ;
727+ ctrl -> ne_nb .notifier_call = NULL ;
728728 return dev_err_probe (dev , err , "Failed to register netevent notifier\n" );
729729 }
730730
@@ -733,10 +733,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
733733 * FIBs pointing to our own netdevs are programmed into the device, so no need to pass a
734734 * callback.
735735 */
736- priv -> fib_nb .notifier_call = otto_l3_fib_notifier ;
737- err = register_fib_notifier (& init_net , & priv -> fib_nb , NULL , NULL );
736+ ctrl -> fib_nb .notifier_call = otto_l3_fib_notifier ;
737+ err = register_fib_notifier (& init_net , & ctrl -> fib_nb , NULL , NULL );
738738 if (err ) {
739- priv -> fib_nb .notifier_call = NULL ;
739+ ctrl -> fib_nb .notifier_call = NULL ;
740740 otto_l3_remove (priv );
741741 return dev_err_probe (dev , err , "Failed to register fib event notifier\n" );
742742 }
0 commit comments