pimd: initial infrastructure to maintain VxLAN SG database

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>
This commit is contained in:
Anuradha Karuppiah 2019-03-19 15:54:02 -07:00
parent 4ab3321f29
commit b583b03582
9 changed files with 215 additions and 0 deletions

View 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,

View 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;

View 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")

View 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 */

136
pimd/pim_vxlan.c Normal file
View File

@ -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;
}
}

39
pimd/pim_vxlan.h Normal file
View File

@ -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 */

27
pimd/pim_vxlan_instance.h Normal file
View File

@ -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 */

View File

@ -113,6 +113,7 @@
#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);

View 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 \