From: Donald Sharp Date: Thu, 15 Oct 2015 13:19:31 +0000 (-0700) Subject: pimd: Start adding the ability to handle the Bridge Router X-Git-Tag: frr-2.0-rc1~832 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2bd9e1bc6ce62f9405f8b840ee0b0dc2a7967eac;p=matthieu%2Ffrr.git pimd: Start adding the ability to handle the Bridge Router Add code to allow the check and set the PMBR(S,G) if the register.borderbit is set. Signed-off-by: Donald Sharp --- diff --git a/lib/memtypes.c b/lib/memtypes.c index d0db1bc996..7d75f31a3d 100644 --- a/lib/memtypes.c +++ b/lib/memtypes.c @@ -284,6 +284,7 @@ struct memory_list memory_list_pim[] = { MTYPE_PIM_UPSTREAM, "PIM upstream (S,G) state" }, { MTYPE_PIM_SSMPINGD, "PIM sspimgd socket" }, { MTYPE_PIM_STATIC_ROUTE, "PIM Static Route" }, + { MTYPE_PIM_BR, "PIM Bridge Router info" }, { -1, NULL }, }; diff --git a/pimd/Makefile.am b/pimd/Makefile.am index 8e0f5e91dd..3e2d992cdb 100644 --- a/pimd/Makefile.am +++ b/pimd/Makefile.am @@ -53,7 +53,8 @@ libpim_a_SOURCES = \ pim_oil.c pim_zlookup.c pim_pim.c pim_tlv.c pim_neighbor.c \ pim_hello.c pim_ifchannel.c pim_join.c pim_assert.c \ pim_msg.c pim_upstream.c pim_rpf.c pim_macro.c \ - pim_igmp_join.c pim_ssmpingd.c pim_int.c pim_rp.c pim_static.c + pim_igmp_join.c pim_ssmpingd.c pim_int.c pim_rp.c \ + pim_static.c pim_br.c noinst_HEADERS = \ pimd.h pim_version.h pim_cmd.h pim_signals.h pim_iface.h \ @@ -62,7 +63,8 @@ noinst_HEADERS = \ pim_oil.h pim_zlookup.h pim_pim.h pim_tlv.h pim_neighbor.h \ pim_hello.h pim_ifchannel.h pim_join.h pim_assert.h \ pim_msg.h pim_upstream.h pim_rpf.h pim_macro.h \ - pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_rp.h pim_static.h + pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_rp.h \ + pim_static.h pim_br.h pimd_SOURCES = \ pim_main.c $(libpim_a_SOURCES) diff --git a/pimd/pim_br.c b/pimd/pim_br.c new file mode 100644 index 0000000000..db4aa3e864 --- /dev/null +++ b/pimd/pim_br.c @@ -0,0 +1,93 @@ +/* + * PIM for Quagga + * Copyright (C) 2015 Cumulus Networks, Inc. + * Donald Sharp + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +#include + +#include "memory.h" +#include "log.h" + +#include "pimd.h" +#include "pim_str.h" +#include "pim_br.h" +#include "linklist.h" + +struct pim_br { + struct in_addr source; + struct in_addr group; + struct in_addr pmbr; +}; + +struct in_addr pim_br_unknown = { .s_addr = 0 }; + +static struct list *pim_br_list = NULL; + +struct in_addr +pim_br_get_pmbr (struct in_addr source, struct in_addr group) +{ + struct listnode *node; + struct pim_br *pim_br; + + for (ALL_LIST_ELEMENTS_RO (pim_br_list, node, pim_br)) { + if (source.s_addr == pim_br->source.s_addr && + group.s_addr == pim_br->group.s_addr) + return pim_br->pmbr; + } + + return pim_br_unknown; +} + +void +pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr br) +{ + struct listnode *node, *next; + struct pim_br *pim_br; + + for (ALL_LIST_ELEMENTS (pim_br_list, node, next, pim_br)) { + if (source.s_addr == pim_br->source.s_addr && + group.s_addr == pim_br->group.s_addr) + break; + } + + if (!pim_br) { + pim_br = XCALLOC(MTYPE_PIM_BR, sizeof (*pim_br)); + if (!pim_br) { + zlog_err("PIM XCALLOC(%zu) failure", sizeof(*pim_br)); + return; + } + + pim_br->source = source; + pim_br->group = group; + + listnode_add(pim_br_list, pim_br); + } + + pim_br->pmbr = br; +} + + +void pim_br_init (void) +{ + pim_br_list = list_new(); + if (!pim_br_list) { + zlog_err("%s: Failure to create pim_br_list", + __PRETTY_FUNCTION__); + return; + } +} diff --git a/pimd/pim_br.h b/pimd/pim_br.h new file mode 100644 index 0000000000..8986d01622 --- /dev/null +++ b/pimd/pim_br.h @@ -0,0 +1,32 @@ +/* + * PIM for Quagga + * Copyright (C) 2015 Cumulus Networks, Inc. + * Donald Sharp + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +#ifndef PIM_BR_H +#define PIM_BR_H + +struct in_addr pim_br_get_pmbr (struct in_addr source, struct in_addr group); + +void pim_br_set_pmbr (struct in_addr source, struct in_addr group, struct in_addr value); + +void pim_br_init (void); + +extern struct in_addr pim_br_unknown; + +#endif