]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: initial infrastructure to maintain VxLAN SG database
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Tue, 19 Mar 2019 22:54:02 +0000 (15:54 -0700)
committerAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Sat, 20 Apr 2019 15:33:21 +0000 (08:33 -0700)
These entries will be used over the subsequent commits for
1. vxlan-tunnel-termination handling - setup MDT to rx VxLAN encapsulated
BUM traffic.
2. vxlan-tunnel-origination handling - register local-vtep-ip as a
multicast source.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
pimd/pim_instance.c
pimd/pim_instance.h
pimd/pim_memory.c
pimd/pim_memory.h
pimd/pim_vxlan.c [new file with mode: 0644]
pimd/pim_vxlan.h [new file with mode: 0644]
pimd/pim_vxlan_instance.h [new file with mode: 0644]
pimd/pimd.h
pimd/subdir.am

index 092a2d76fa08c76821bebcaaba7686ff2511d02f..1416d8de550836801848b3712390bd0f35c01117 100644 (file)
@@ -60,6 +60,7 @@ static void pim_instance_terminate(struct pim_instance *pim)
        pim_oil_terminate(pim);
 
        pim_msdp_exit(pim);
+       pim_vxlan_exit(pim);
 
        XFREE(MTYPE_PIM_PIM_INSTANCE, pim);
 }
@@ -86,6 +87,7 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
        pim->spt.plist = NULL;
 
        pim_msdp_init(pim, router->master);
+       pim_vxlan_init(pim);
 
        snprintf(hash_name, 64, "PIM %s RPF Hash", vrf->name);
        pim->rpf_hash = hash_create_size(256, pim_rpf_hash_key, pim_rpf_equal,
index e651356bfed4796651d955295abc4fa955feb13d..1740bcc7900d2ced781b72f8edd518f00f0f7186 100644 (file)
@@ -26,6 +26,7 @@
 #include "pim_str.h"
 #include "pim_msdp.h"
 #include "pim_assert.h"
+#include "pim_vxlan_instance.h"
 
 #if defined(HAVE_LINUX_MROUTE_H)
 #include <linux/mroute.h>
@@ -110,6 +111,7 @@ struct pim_instance {
        struct hash *channel_oil_hash;
 
        struct pim_msdp msdp;
+       struct pim_vxlan_instance vxlan;
 
        struct list *ssmpingd_list;
        struct in_addr ssmpingd_group_addr;
index dff16c41658511d0598c54e8d61a29c354db2f4f..2bbab67e458a730a85484161b3b842e1577aa431 100644 (file)
@@ -52,3 +52,4 @@ DEFINE_MTYPE(PIMD, PIM_PIM_INSTANCE, "PIM global state")
 DEFINE_MTYPE(PIMD, PIM_NEXTHOP_CACHE, "PIM nexthop cache state")
 DEFINE_MTYPE(PIMD, PIM_SSM_INFO, "PIM SSM configuration")
 DEFINE_MTYPE(PIMD, PIM_SPT_PLIST_NAME, "PIM SPT Prefix List Name")
+DEFINE_MTYPE(PIMD, PIM_VXLAN_SG, "PIM VxLAN mroute cache")
index 01189aca7681674e753c42afb4df11bd45f16d0f..e5ca57a15dc22eb0cbc192578b3e79dc2ea48854 100644 (file)
@@ -51,5 +51,6 @@ DECLARE_MTYPE(PIM_PIM_INSTANCE)
 DECLARE_MTYPE(PIM_NEXTHOP_CACHE)
 DECLARE_MTYPE(PIM_SSM_INFO)
 DECLARE_MTYPE(PIM_SPT_PLIST_NAME);
+DECLARE_MTYPE(PIM_VXLAN_SG)
 
 #endif /* _QUAGGA_PIM_MEMORY_H */
diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c
new file mode 100644 (file)
index 0000000..893f9f0
--- /dev/null
@@ -0,0 +1,136 @@
+/* PIM support for VxLAN BUM flooding
+ *
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ *
+ * This file is part of FRR.
+ *
+ * FRR is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <zebra.h>
+
+#include <hash.h>
+#include <jhash.h>
+#include <log.h>
+#include <prefix.h>
+#include <vrf.h>
+
+#include "pimd.h"
+#include "pim_iface.h"
+#include "pim_memory.h"
+#include "pim_oil.h"
+#include "pim_register.h"
+#include "pim_str.h"
+#include "pim_upstream.h"
+#include "pim_ifchannel.h"
+#include "pim_nht.h"
+#include "pim_zebra.h"
+#include "pim_vxlan.h"
+
+
+/************************** vxlan SG cache management ************************/
+static unsigned int pim_vxlan_sg_hash_key_make(void *p)
+{
+       struct pim_vxlan_sg *vxlan_sg = p;
+
+       return (jhash_2words(vxlan_sg->sg.src.s_addr,
+                               vxlan_sg->sg.grp.s_addr, 0));
+}
+
+static bool pim_vxlan_sg_hash_eq(const void *p1, const void *p2)
+{
+       const struct pim_vxlan_sg *sg1 = p1;
+       const struct pim_vxlan_sg *sg2 = p2;
+
+       return ((sg1->sg.src.s_addr == sg2->sg.src.s_addr)
+                       && (sg1->sg.grp.s_addr == sg2->sg.grp.s_addr));
+}
+
+static struct pim_vxlan_sg *pim_vxlan_sg_new(struct pim_instance *pim,
+               struct prefix_sg *sg)
+{
+       struct pim_vxlan_sg *vxlan_sg;
+
+       vxlan_sg = XCALLOC(MTYPE_PIM_VXLAN_SG, sizeof(*vxlan_sg));
+
+       vxlan_sg->pim = pim;
+       vxlan_sg->sg = *sg;
+       pim_str_sg_set(sg, vxlan_sg->sg_str);
+
+       if (PIM_DEBUG_VXLAN)
+               zlog_debug("vxlan SG %s alloc", vxlan_sg->sg_str);
+
+       vxlan_sg = hash_get(pim->vxlan.sg_hash, vxlan_sg, hash_alloc_intern);
+
+       return vxlan_sg;
+}
+
+struct pim_vxlan_sg *pim_vxlan_sg_find(struct pim_instance *pim,
+               struct prefix_sg *sg)
+{
+       struct pim_vxlan_sg lookup;
+
+       lookup.sg = *sg;
+       return hash_lookup(pim->vxlan.sg_hash, &lookup);
+}
+
+struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim,
+               struct prefix_sg *sg)
+{
+       struct pim_vxlan_sg *vxlan_sg;
+
+       vxlan_sg = pim_vxlan_sg_find(pim, sg);
+       if (vxlan_sg)
+               return vxlan_sg;
+
+       vxlan_sg = pim_vxlan_sg_new(pim, sg);
+
+       return vxlan_sg;
+}
+
+void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg)
+{
+       struct pim_vxlan_sg *vxlan_sg;
+
+       vxlan_sg = pim_vxlan_sg_find(pim, sg);
+       if (!vxlan_sg)
+               return;
+
+       hash_release(vxlan_sg->pim->vxlan.sg_hash, vxlan_sg);
+
+       if (PIM_DEBUG_VXLAN)
+               zlog_debug("vxlan SG %s free", vxlan_sg->sg_str);
+
+       XFREE(MTYPE_PIM_VXLAN_SG, vxlan_sg);
+}
+
+void pim_vxlan_init(struct pim_instance *pim)
+{
+       char hash_name[64];
+
+       snprintf(hash_name, sizeof(hash_name),
+               "PIM %s vxlan SG hash", pim->vrf->name);
+       pim->vxlan.sg_hash = hash_create(pim_vxlan_sg_hash_key_make,
+                       pim_vxlan_sg_hash_eq, hash_name);
+}
+
+void pim_vxlan_exit(struct pim_instance *pim)
+{
+       if (pim->vxlan.sg_hash) {
+               hash_clean(pim->vxlan.sg_hash, NULL);
+               hash_free(pim->vxlan.sg_hash);
+               pim->vxlan.sg_hash = NULL;
+       }
+}
diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h
new file mode 100644 (file)
index 0000000..5ad6c7d
--- /dev/null
@@ -0,0 +1,39 @@
+/* PIM support for VxLAN BUM flooding
+ *
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ *
+ * This file is part of FRR.
+ *
+ * FRR is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef PIM_VXLAN_H
+#define PIM_VXLAN_H
+
+struct pim_vxlan_sg {
+       struct pim_instance *pim;
+
+       /* key */
+       struct prefix_sg sg;
+       char sg_str[PIM_SG_LEN];
+};
+
+extern struct pim_vxlan_sg *pim_vxlan_sg_find(struct pim_instance *pim,
+                                           struct prefix_sg *sg);
+extern struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim,
+                                          struct prefix_sg *sg);
+extern void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg);
+
+#endif /* PIM_VXLAN_H */
diff --git a/pimd/pim_vxlan_instance.h b/pimd/pim_vxlan_instance.h
new file mode 100644 (file)
index 0000000..63ef3a6
--- /dev/null
@@ -0,0 +1,27 @@
+/* PIM support for VxLAN BUM flooding
+ *
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef PIM_VXLAN_INSTANCE_H
+#define PIM_VXLAN_INSTANCE_H
+
+struct pim_vxlan_instance {
+       struct hash *sg_hash;
+};
+
+extern void pim_vxlan_init(struct pim_instance *pim);
+extern void pim_vxlan_exit(struct pim_instance *pim);
+
+#endif /* PIM_VXLAN_INSTANCE_H */
index 50c19658dab044f4cc528d369bb8f87c0209d49e..2f2a870371397bb084b0733e23b64ddbed9c32d5 100644 (file)
 #define PIM_MASK_PIM_NHT_DETAIL      (1 << 23)
 #define PIM_MASK_PIM_NHT_RP          (1 << 24)
 #define PIM_MASK_MTRACE              (1 << 25)
+#define PIM_MASK_VXLAN               (1 << 26)
 /* Remember 32 bits!!! */
 
 /* PIM error codes */
@@ -180,6 +181,7 @@ extern uint8_t qpim_ecmp_rebalance_enable;
 #define PIM_DEBUG_PIM_NHT_DETAIL (router->debugs & PIM_MASK_PIM_NHT_DETAIL)
 #define PIM_DEBUG_PIM_NHT_RP (router->debugs & PIM_MASK_PIM_NHT_RP)
 #define PIM_DEBUG_MTRACE (router->debugs & PIM_MASK_MTRACE)
+#define PIM_DEBUG_VXLAN (router->debugs & PIM_MASK_VXLAN)
 
 #define PIM_DEBUG_EVENTS                                                       \
        (router->debugs                                                        \
@@ -220,6 +222,7 @@ extern uint8_t qpim_ecmp_rebalance_enable;
 #define PIM_DO_DEBUG_PIM_NHT (router->debugs |= PIM_MASK_PIM_NHT)
 #define PIM_DO_DEBUG_PIM_NHT_RP (router->debugs |= PIM_MASK_PIM_NHT_RP)
 #define PIM_DO_DEBUG_MTRACE (router->debugs |= PIM_MASK_MTRACE)
+#define PIM_DO_DEBUG_VXLAN (router->debugs |= PIM_MASK_VXLAN)
 
 #define PIM_DONT_DEBUG_PIM_EVENTS (router->debugs &= ~PIM_MASK_PIM_EVENTS)
 #define PIM_DONT_DEBUG_PIM_PACKETS (router->debugs &= ~PIM_MASK_PIM_PACKETS)
@@ -249,6 +252,7 @@ extern uint8_t qpim_ecmp_rebalance_enable;
 #define PIM_DONT_DEBUG_PIM_NHT (router->debugs &= ~PIM_MASK_PIM_NHT)
 #define PIM_DONT_DEBUG_PIM_NHT_RP (router->debugs &= ~PIM_MASK_PIM_NHT_RP)
 #define PIM_DONT_DEBUG_MTRACE (router->debugs &= ~PIM_MASK_MTRACE)
+#define PIM_DONT_DEBUG_VXLAN (router->debugs &= ~PIM_MASK_VXLAN)
 
 void pim_router_init(void);
 void pim_router_terminate(void);
index 7d8df7d1053b3c84e5d48804e354648e9fc5524f..7f4810722b858267f139c8dc5b2f0a5ae5305aa9 100644 (file)
@@ -60,6 +60,7 @@ pimd_libpim_a_SOURCES = \
        pimd/pim_vty.c \
        pimd/pim_zebra.c \
        pimd/pim_zlookup.c \
+       pimd/pim_vxlan.c \
        pimd/pimd.c \
        # end
 
@@ -110,6 +111,8 @@ noinst_HEADERS += \
        pimd/pim_vty.h \
        pimd/pim_zebra.h \
        pimd/pim_zlookup.h \
+       pimd/pim_vxlan.h \
+       pimd/pim_vxlan_instance.h \
        pimd/pimd.h \
        pimd/mtracebis_netlink.h \
        pimd/mtracebis_routeget.h \