datapath/linux/compat/vxlan.c
/* See if multicast group is already in use by other ID */
See if multicast group is already in use by other ID
See if multicast group is already in use by other ID
static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
{
	struct vxlan_dev *vxlan;
	struct vxlan_sock *sock4;
	struct vxlan_sock *sock6 = NULL;
	unsigned short family = dev->default_dst.remote_ip.sa.sa_family;
	sock4 = rtnl_dereference(dev->vn4_sock);
	if (family == AF_INET && sock4 && atomic_read(&sock4->refcnt) == 1)
		return false;
#if IS_ENABLED(CONFIG_IPV6)
	sock6 = rtnl_dereference(dev->vn6_sock);
	if (family == AF_INET6 && sock6 && atomic_read(&sock6->refcnt) == 1)
		return false;
#endif
	list_for_each_entry(vxlan, &vn->vxlan_list, next) {
		if (!netif_running(vxlan->dev) || vxlan == dev)
			continue;
		if (family == AF_INET &&
		    rtnl_dereference(vxlan->vn4_sock) != sock4)
			continue;
#if IS_ENABLED(CONFIG_IPV6)
		if (family == AF_INET6 &&
		    rtnl_dereference(vxlan->vn6_sock) != sock6)
			continue;
#endif
		if (!vxlan_addr_equal(&vxlan->default_dst.remote_ip,
				      &dev->default_dst.remote_ip))
			continue;
		if (vxlan->default_dst.remote_ifindex !=
		    dev->default_dst.remote_ifindex)
			continue;
		return true;
	}
	return false;
}
static bool vxlan_group_used ( struct vxlan_net * vn , struct vxlan_dev * dev ) { struct vxlan_dev * vxlan ; struct vxlan_sock * sock4 ; struct vxlan_sock * sock6 = NULL ; unsigned short family = dev -> default_dst . remote_ip . sa . sa_family ; sock4 = rtnl_dereference ( dev -> vn4_sock ) ; if ( family == AF_INET && sock4 && atomic_read ( & sock4 -> refcnt ) == 1 ) return false ; #if IS_ENABLED ( CONFIG_IPV6 ) sock6 = rtnl_dereference ( dev -> vn6_sock ) ; if ( family == AF_INET6 && sock6 && atomic_read ( & sock6 -> refcnt ) == 1 ) return false ; #endif list_for_each_entry ( vxlan , & vn -> vxlan_list , next ) { if ( ! netif_running ( vxlan -> dev ) || vxlan == dev ) continue ; if ( family == AF_INET && rtnl_dereference ( vxlan -> vn4_sock ) != sock4 ) continue ; #if IS_ENABLED ( CONFIG_IPV6 ) if ( family == AF_INET6 && rtnl_dereference ( vxlan -> vn6_sock ) != sock6 ) continue ; #endif if ( ! vxlan_addr_equal ( & vxlan -> default_dst . remote_ip , & dev -> default_dst . remote_ip ) ) continue ; if ( vxlan -> default_dst . remote_ifindex != dev -> default_dst . remote_ifindex ) continue ; return true ; } return false ; }
See if multicast group is already in use by other ID
See if multicast group is already in use by other ID
/* The vxlan_sock is only used by dev, leaving group has
	 * no effect on other vxlan devices.
	 */