diff options
author | David Lamparter <equinox@diac24.net> | 2019-04-24 17:23:09 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2019-08-30 19:00:45 +0200 |
commit | 0ba4eeec2208d9290d090ae6a086f74cd24a6865 (patch) | |
tree | 72c2ba00b86dc99ad6d5ec8eb059b2544fb38850 /bgpd | |
parent | bgpd/bmp: use bgp packet dump hook (diff) | |
download | frr-0ba4eeec2208d9290d090ae6a086f74cd24a6865.tar.xz frr-0ba4eeec2208d9290d090ae6a086f74cd24a6865.zip |
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_bmp.c | 19 | ||||
-rw-r--r-- | bgpd/bgp_bmp.h | 3 | ||||
-rw-r--r-- | bgpd/bgp_memory.c | 1 | ||||
-rw-r--r-- | bgpd/bgp_memory.h | 1 | ||||
-rw-r--r-- | bgpd/bgpd.c | 4 | ||||
-rw-r--r-- | bgpd/subdir.am | 5 |
6 files changed, 19 insertions, 14 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index bdc599ab0..71372517d 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -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) diff --git a/bgpd/bgp_bmp.h b/bgpd/bgp_bmp.h index 54365c0f0..7afe1f3cd 100644 --- a/bgpd/bgp_bmp.h +++ b/bgpd/bgp_bmp.h @@ -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_*/ diff --git a/bgpd/bgp_memory.c b/bgpd/bgp_memory.c index cd1277440..3e4dfb11a 100644 --- a/bgpd/bgp_memory.c +++ b/bgpd/bgp_memory.c @@ -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") diff --git a/bgpd/bgp_memory.h b/bgpd/bgp_memory.h index c48548806..03715f562 100644 --- a/bgpd/bgp_memory.h +++ b/bgpd/bgp_memory.h @@ -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) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index c6196be53..fed8cd4d8 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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); } diff --git a/bgpd/subdir.am b/bgpd/subdir.am index 88cf57947..7cd0dc9ac 100644 --- a/bgpd/subdir.am +++ b/bgpd/subdir.am @@ -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) |