summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_dump.c
diff options
context:
space:
mode:
authorMarton Kun-Szabo <martonk@amazon.com>2019-08-09 19:53:01 +0200
committerMarton Kun-Szabo <martonk@amazon.com>2019-08-13 20:59:27 +0200
commit7d8d0eabb4772ac773d60180fb88272a7825ca4a (patch)
treee94c3b1256a223b63aaac18f90464e05285ad5fe /bgpd/bgp_dump.c
parentMerge pull request #4706 from qlyoung/fix-exit-vrf-markfile (diff)
downloadfrr-7d8d0eabb4772ac773d60180fb88272a7825ca4a.tar.xz
frr-7d8d0eabb4772ac773d60180fb88272a7825ca4a.zip
bgpd: hook for bgp peer status change events
Generally available hook for plugging application-specific code in for bgp peer change events. This hook (peer_status_changed) replaces the previous, more specific 'peer_established' hook with a more general-purpose one. Also, 'bgp_dump_state' is now registered under this hook. Signed-off-by: Marton Kun-Szabo <martonk@amazon.com>
Diffstat (limited to 'bgpd/bgp_dump.c')
-rw-r--r--bgpd/bgp_dump.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 535f36ab5..640224e75 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -494,13 +494,13 @@ static void bgp_dump_common(struct stream *obuf, struct peer *peer,
}
/* Dump BGP status change. */
-void bgp_dump_state(struct peer *peer, int status_old, int status_new)
+int bgp_dump_state(struct peer *peer)
{
struct stream *obuf;
/* If dump file pointer is disabled return immediately. */
if (bgp_dump_all.fp == NULL)
- return;
+ return 0;
/* Make dump stream. */
obuf = bgp_dump_obuf;
@@ -510,8 +510,8 @@ void bgp_dump_state(struct peer *peer, int status_old, int status_new)
bgp_dump_all.type);
bgp_dump_common(obuf, peer, 1); /* force this in as4speak*/
- stream_putw(obuf, status_old);
- stream_putw(obuf, status_new);
+ stream_putw(obuf, peer->ostatus);
+ stream_putw(obuf, peer->status);
/* Set length. */
bgp_dump_set_size(obuf, MSG_PROTOCOL_BGP4MP);
@@ -519,6 +519,7 @@ void bgp_dump_state(struct peer *peer, int status_old, int status_new)
/* Write to the stream. */
fwrite(STREAM_DATA(obuf), stream_get_endp(obuf), 1, bgp_dump_all.fp);
fflush(bgp_dump_all.fp);
+ return 0;
}
static void bgp_dump_packet_func(struct bgp_dump *bgp_dump, struct peer *peer,
@@ -867,6 +868,7 @@ void bgp_dump_init(void)
install_element(CONFIG_NODE, &no_dump_bgp_all_cmd);
hook_register(bgp_packet_dump, bgp_dump_packet);
+ hook_register(peer_status_changed, bgp_dump_state);
}
void bgp_dump_finish(void)
@@ -878,4 +880,5 @@ void bgp_dump_finish(void)
stream_free(bgp_dump_obuf);
bgp_dump_obuf = NULL;
hook_unregister(bgp_packet_dump, bgp_dump_packet);
+ hook_unregister(peer_status_changed, bgp_dump_state);
}