@@ -804,6 +804,14 @@ static struct vxlan_fdb *vxlan_fdb_alloc(struct vxlan_dev *vxlan,
804
804
return f ;
805
805
}
806
806
807
+ static void vxlan_fdb_insert (struct vxlan_dev * vxlan , const u8 * mac ,
808
+ __be32 src_vni , struct vxlan_fdb * f )
809
+ {
810
+ ++ vxlan -> addrcnt ;
811
+ hlist_add_head_rcu (& f -> hlist ,
812
+ vxlan_fdb_head (vxlan , mac , src_vni ));
813
+ }
814
+
807
815
static int vxlan_fdb_create (struct vxlan_dev * vxlan ,
808
816
const u8 * mac , union vxlan_addr * ip ,
809
817
__u16 state , __be16 port , __be32 src_vni ,
@@ -829,18 +837,13 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
829
837
return rc ;
830
838
}
831
839
832
- ++ vxlan -> addrcnt ;
833
- hlist_add_head_rcu (& f -> hlist ,
834
- vxlan_fdb_head (vxlan , mac , src_vni ));
835
-
836
840
* fdb = f ;
837
841
838
842
return 0 ;
839
843
}
840
844
841
- static void vxlan_fdb_free (struct rcu_head * head )
845
+ static void __vxlan_fdb_free (struct vxlan_fdb * f )
842
846
{
843
- struct vxlan_fdb * f = container_of (head , struct vxlan_fdb , rcu );
844
847
struct vxlan_rdst * rd , * nd ;
845
848
846
849
list_for_each_entry_safe (rd , nd , & f -> remotes , list ) {
@@ -850,6 +853,13 @@ static void vxlan_fdb_free(struct rcu_head *head)
850
853
kfree (f );
851
854
}
852
855
856
+ static void vxlan_fdb_free (struct rcu_head * head )
857
+ {
858
+ struct vxlan_fdb * f = container_of (head , struct vxlan_fdb , rcu );
859
+
860
+ __vxlan_fdb_free (f );
861
+ }
862
+
853
863
static void vxlan_fdb_destroy (struct vxlan_dev * vxlan , struct vxlan_fdb * f ,
854
864
bool do_notify , bool swdev_notify )
855
865
{
@@ -977,6 +987,7 @@ static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,
977
987
if (rc < 0 )
978
988
return rc ;
979
989
990
+ vxlan_fdb_insert (vxlan , mac , src_vni , f );
980
991
rc = vxlan_fdb_notify (vxlan , f , first_remote_rtnl (f ), RTM_NEWNEIGH ,
981
992
swdev_notify , extack );
982
993
if (rc )
@@ -3571,12 +3582,17 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3571
3582
if (err )
3572
3583
goto errout ;
3573
3584
3574
- /* notify default fdb entry */
3575
3585
if (f ) {
3586
+ vxlan_fdb_insert (vxlan , all_zeros_mac ,
3587
+ vxlan -> default_dst .remote_vni , f );
3588
+
3589
+ /* notify default fdb entry */
3576
3590
err = vxlan_fdb_notify (vxlan , f , first_remote_rtnl (f ),
3577
3591
RTM_NEWNEIGH , true, extack );
3578
- if (err )
3579
- goto errout ;
3592
+ if (err ) {
3593
+ vxlan_fdb_destroy (vxlan , f , false, false);
3594
+ goto unregister ;
3595
+ }
3580
3596
}
3581
3597
3582
3598
list_add (& vxlan -> next , & vn -> vxlan_list );
@@ -3588,7 +3604,8 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3588
3604
* destroy the entry by hand here.
3589
3605
*/
3590
3606
if (f )
3591
- vxlan_fdb_destroy (vxlan , f , false, false);
3607
+ __vxlan_fdb_free (f );
3608
+ unregister :
3592
3609
if (unregister )
3593
3610
unregister_netdevice (dev );
3594
3611
return err ;
0 commit comments