if (err)
                goto err_free_entry;
 
+       if (hlist_is_singular_node(&mdb_entry->mdb_node, &vxlan->mdb_list))
+               vxlan->cfg.flags |= VXLAN_F_MDB;
+
        return mdb_entry;
 
 err_free_entry:
        if (!list_empty(&mdb_entry->remotes))
                return;
 
+       if (hlist_is_singular_node(&mdb_entry->mdb_node, &vxlan->mdb_list))
+               vxlan->cfg.flags &= ~VXLAN_F_MDB;
+
        rhashtable_remove_fast(&vxlan->mdb_tbl, &mdb_entry->rhnode,
                               vxlan_mdb_rht_params);
        hlist_del(&mdb_entry->mdb_node);
 void vxlan_mdb_fini(struct vxlan_dev *vxlan)
 {
        vxlan_mdb_entries_flush(vxlan);
+       WARN_ON_ONCE(vxlan->cfg.flags & VXLAN_F_MDB);
        rhashtable_free_and_destroy(&vxlan->mdb_tbl, vxlan_mdb_check_empty,
                                    NULL);
 }
 
 #define VXLAN_F_IPV6_LINKLOCAL         0x8000
 #define VXLAN_F_TTL_INHERIT            0x10000
 #define VXLAN_F_VNIFILTER               0x20000
+#define VXLAN_F_MDB                    0x40000
 
 /* Flags that are used in the receive path. These flags must match in
  * order for a socket to be shareable