aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorMike Rapoport <mike.rapoport@ravellosystems.com>2013-06-25 16:01:52 +0300
committerStephen Hemminger <stephen@networkplumber.org>2013-06-25 09:31:36 -0700
commita5e7c10a7ec244f272703f36f339c967efe1fc0d (patch)
tree43eee04be4e76ae1a8608976bc292e645b18a979 /drivers/net/vxlan.c
parentvxlan: add implicit fdb entry for default destination (diff)
downloadlinux-dev-a5e7c10a7ec244f272703f36f339c967efe1fc0d.tar.xz
linux-dev-a5e7c10a7ec244f272703f36f339c967efe1fc0d.zip
vxlan: introduce vxlan_fdb_find_rdst
which will be reused by vxlan_fdb_delete Signed-off-by: Mike Rapoport <mike.rapoport@ravellosystems.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index bdfe46e50c49..306bd94efa89 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -388,21 +388,34 @@ static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,
return f;
}
-/* Add/update destinations for multicast */
-static int vxlan_fdb_append(struct vxlan_fdb *f,
- __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
+/* caller should hold vxlan->hash_lock */
+static struct vxlan_rdst *vxlan_fdb_find_rdst(struct vxlan_fdb *f,
+ __be32 ip, __be16 port,
+ __u32 vni, __u32 ifindex)
{
struct vxlan_rdst *rd;
- /* protected by vxlan->hash_lock */
list_for_each_entry(rd, &f->remotes, list) {
if (rd->remote_ip == ip &&
rd->remote_port == port &&
rd->remote_vni == vni &&
rd->remote_ifindex == ifindex)
- return 0;
+ return rd;
}
+ return NULL;
+}
+
+/* Add/update destinations for multicast */
+static int vxlan_fdb_append(struct vxlan_fdb *f,
+ __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
+{
+ struct vxlan_rdst *rd;
+
+ rd = vxlan_fdb_find_rdst(f, ip, port, vni, ifindex);
+ if (rd)
+ return 0;
+
rd = kmalloc(sizeof(*rd), GFP_ATOMIC);
if (rd == NULL)
return -ENOBUFS;