mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-02 12:22:47 +00:00
bgpd: Add 'show bgp listeners' command for diagnostics
Add a command to display listen sockets and the vrf that they are associated with. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
2bdced5ab3
commit
2a0e69ae3c
@ -57,8 +57,26 @@ struct bgp_listener {
|
||||
union sockunion su;
|
||||
struct thread *thread;
|
||||
struct bgp *bgp;
|
||||
char *name;
|
||||
};
|
||||
|
||||
void bgp_dump_listener_info(struct vty *vty)
|
||||
{
|
||||
struct listnode *node;
|
||||
struct bgp_listener *listener;
|
||||
|
||||
vty_out(vty, "Name fd Address\n");
|
||||
vty_out(vty, "---------------------------\n");
|
||||
for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) {
|
||||
char buf[SU_ADDRSTRLEN];
|
||||
|
||||
vty_out(vty, "%-16s %d %s\n",
|
||||
listener->name ? listener->name : VRF_DEFAULT_NAME,
|
||||
listener->fd,
|
||||
sockunion2str(&listener->su, buf, sizeof(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set MD5 key for the socket, for the given IPv4 peer address.
|
||||
* If the password is NULL or zero-length, the option will be disabled.
|
||||
@ -762,6 +780,7 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
|
||||
|
||||
listener = XCALLOC(MTYPE_BGP_LISTENER, sizeof(*listener));
|
||||
listener->fd = sock;
|
||||
listener->name = XSTRDUP(MTYPE_BGP_LISTENER, bgp->name);
|
||||
|
||||
/* this socket needs a change of ns. record bgp back pointer */
|
||||
if (bgp->vrf_id != VRF_DEFAULT && vrf_is_backend_netns())
|
||||
@ -871,6 +890,7 @@ void bgp_close_vrf_socket(struct bgp *bgp)
|
||||
thread_cancel(listener->thread);
|
||||
close(listener->fd);
|
||||
listnode_delete(bm->listen_sockets, listener);
|
||||
XFREE(MTYPE_BGP_LISTENER, listener->name);
|
||||
XFREE(MTYPE_BGP_LISTENER, listener);
|
||||
}
|
||||
}
|
||||
@ -892,6 +912,7 @@ void bgp_close(void)
|
||||
thread_cancel(listener->thread);
|
||||
close(listener->fd);
|
||||
listnode_delete(bm->listen_sockets, listener);
|
||||
XFREE(MTYPE_BGP_LISTENER, listener->name);
|
||||
XFREE(MTYPE_BGP_LISTENER, listener);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#define BGP_SOCKET_SNDBUF_SIZE 65536
|
||||
|
||||
extern void bgp_dump_listener_info(struct vty *vty);
|
||||
extern int bgp_socket(struct bgp *bgp, unsigned short port,
|
||||
const char *address);
|
||||
extern void bgp_close_vrf_socket(struct bgp *bgp);
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "bgpd/bgp_label.h"
|
||||
#include "bgpd/bgp_addpath.h"
|
||||
#include "bgpd/bgp_mac.h"
|
||||
#include "bgpd/bgp_network.h"
|
||||
|
||||
#if ENABLE_BGP_VNC
|
||||
#include "bgpd/rfapi/rfapi_backend.h"
|
||||
@ -12766,6 +12767,18 @@ static void show_bgp_peerhash_entry(struct hash_bucket *bucket, void *arg)
|
||||
sockunion2str(&peer->su, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
DEFUN (show_bgp_listeners,
|
||||
show_bgp_listeners_cmd,
|
||||
"show bgp listeners",
|
||||
SHOW_STR
|
||||
BGP_STR
|
||||
"Display Listen Sockets and who created them\n")
|
||||
{
|
||||
bgp_dump_listener_info(vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (show_bgp_peerhash,
|
||||
show_bgp_peerhash_cmd,
|
||||
"show bgp peerhash",
|
||||
@ -13155,6 +13168,7 @@ void bgp_route_init(void)
|
||||
/* show bgp ipv4 flowspec detailed */
|
||||
install_element(VIEW_NODE, &show_ip_bgp_flowspec_routes_detailed_cmd);
|
||||
|
||||
install_element(VIEW_NODE, &show_bgp_listeners_cmd);
|
||||
install_element(VIEW_NODE, &show_bgp_peerhash_cmd);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user