bgpd/bmp: convert BMP code into module

This is mostly here for documentation purposes to show how some code is
converted into a module.

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2019-04-24 17:23:09 +02:00
parent d35a6c2895
commit 0ba4eeec22
6 changed files with 19 additions and 14 deletions

View File

@ -33,6 +33,8 @@
#include "filter.h"
#include "lib_errors.h"
#include "stream.h"
#include "libfrr.h"
#include "version.h"
#include "bgpd/bgp_table.h"
#include "bgpd/bgpd.h"
@ -46,6 +48,7 @@
int accept_sock = -1;
struct thread *bmp_serv_thread = NULL;
DEFINE_MTYPE_STATIC(BGPD, BGP_BMP, "BGP Monitoring Protocol Information")
/* BMP access-class command */
static char *bmp_acl_name = NULL;
@ -454,7 +457,7 @@ static int bmp_accept(struct thread *thread)
return 0;
}
void bmp_serv_sock(const char *hostname, unsigned short port)
static void bmp_serv_sock(const char *hostname, unsigned short port)
{
int ret;
struct addrinfo req;
@ -514,11 +517,19 @@ void bmp_serv_sock(const char *hostname, unsigned short port)
freeaddrinfo(ainfo_save);
}
void bgp_bmp_init()
static int bgp_bmp_init(struct thread_master *tm)
{
hook_register(bgp_packet_dump, bmp_mirror_packet);
bmp_serv_sock("localhost", 60000);
return 0;
}
static int bgp_bmp_module_init(void)
{
hook_register(bgp_packet_dump, bmp_mirror_packet);
hook_register(frr_late_init, bgp_bmp_init);
return 0;
}
FRR_MODULE_SETUP(.name = "bgpd_bmp", .version = FRR_VERSION,
.description = "bgpd BMP module",
.init = bgp_bmp_module_init)

View File

@ -64,7 +64,4 @@ struct bmp
&(X)->t_event); \
} while (0)
extern void bmp_serv_sock(const char *hostname, unsigned short port);
extern void bgp_bmp_init(void);
#endif /*_BGP_BMP_H_*/

View File

@ -106,7 +106,6 @@ DEFINE_MTYPE(BGPD, TIP_ADDR, "BGP own tunnel-ip address")
DEFINE_MTYPE(BGPD, BGP_REDIST, "BGP redistribution")
DEFINE_MTYPE(BGPD, BGP_FILTER_NAME, "BGP Filter Information")
DEFINE_MTYPE(BGPD, BGP_DUMP_STR, "BGP Dump String Information")
DEFINE_MTYPE(BGPD, BGP_BMP, "BGP Monitoring Protocol Information")
DEFINE_MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV")
DEFINE_MTYPE(BGPD, BGP_TEA_OPTIONS, "BGP TEA Options")

View File

@ -102,7 +102,6 @@ DECLARE_MTYPE(TIP_ADDR)
DECLARE_MTYPE(BGP_REDIST)
DECLARE_MTYPE(BGP_FILTER_NAME)
DECLARE_MTYPE(BGP_DUMP_STR)
DECLARE_MTYPE(BGP_BMP)
DECLARE_MTYPE(ENCAP_TLV)
DECLARE_MTYPE(BGP_TEA_OPTIONS)

View File

@ -51,7 +51,6 @@
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_dump.h"
#include "bgpd/bgp_bmp.h"
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_errors.h"
#include "bgpd/bgp_community.h"
@ -8010,9 +8009,6 @@ void bgp_init(unsigned short instance)
/* BFD init */
bgp_bfd_init();
/* BMP init */
bgp_bmp_init();
cmd_variable_handler_register(bgp_viewvrf_var_handlers);
}

View File

@ -42,6 +42,7 @@ endif
if RPKI
module_LTLIBRARIES += bgpd/bgpd_rpki.la
endif
module_LTLIBRARIES += bgpd/bgpd_bmp.la
man8 += $(MANBUILD)/bgpd.8
endif
@ -57,7 +58,6 @@ bgpd_libbgp_a_SOURCES = \
bgpd/bgp_damp.c \
bgpd/bgp_debug.c \
bgpd/bgp_dump.c \
bgpd/bgp_bmp.c \
bgpd/bgp_ecommunity.c \
bgpd/bgp_encap_tlv.c \
bgpd/bgp_errors.c \
@ -218,6 +218,9 @@ bgpd_bgpd_rpki_la_CFLAGS = $(WERROR) $(RTRLIB_CFLAGS)
bgpd_bgpd_rpki_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
bgpd_bgpd_rpki_la_LIBADD = $(RTRLIB_LIBS)
bgpd_bgpd_bmp_la_SOURCES = bgpd/bgp_bmp.c
bgpd_bgpd_bmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
bgpd/bgp_evpn_vty_clippy.c: $(CLIPPY_DEPS)
bgpd/bgp_evpn_vty.$(OBJEXT): bgpd/bgp_evpn_vty_clippy.c
bgpd/bgp_vty_clippy.c: $(CLIPPY_DEPS)