0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-07 22:15:19 +00:00

BFD: Show session for ip / ip prefix

This commit is contained in:
Katerina Kubecova 2024-01-18 12:36:48 +01:00 committed by Ondrej Zajicek
parent 37bf207843
commit a48dc5efe0
3 changed files with 21 additions and 6 deletions

View File

@ -1192,7 +1192,7 @@ void bfd_show_details(struct bfd_session *s)
}
void
bfd_show_sessions(struct proto *P, int details)
bfd_show_sessions(struct proto *P, int details, net_addr addr)
{
byte tbuf[TM_DATETIME_BUFFER_SIZE];
struct bfd_proto *p = (struct bfd_proto *) P;
@ -1215,6 +1215,9 @@ bfd_show_sessions(struct proto *P, int details)
HASH_WALK(p->session_hash_id, next_id, s)
{
/* FIXME: this is thread-unsafe, but perhaps harmless */
if (addr.type != 0 && !ipa_in_netX(s->addr, &addr))
continue;
if (!details)
{
state = s->loc_state;

View File

@ -218,7 +218,7 @@ static inline void bfd_unlock_sessions(struct bfd_proto *p) { pthread_spin_unloc
struct bfd_session * bfd_find_session_by_id(struct bfd_proto *p, u32 id);
struct bfd_session * bfd_find_session_by_addr(struct bfd_proto *p, ip_addr addr, uint ifindex);
void bfd_session_process_ctl(struct bfd_session *s, u8 flags, u32 old_tx_int, u32 old_rx_int);
void bfd_show_sessions(struct proto *P, int details);
void bfd_show_sessions(struct proto *P, int details, net_addr addr);
/* packets.c */
void bfd_send_ctl(struct bfd_proto *p, struct bfd_session *s, int final);

View File

@ -29,6 +29,7 @@ CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE,
%type <iface> bfd_neigh_iface
%type <a> bfd_neigh_local
%type <i> bfd_neigh_multihop bfd_auth_type
%type <net> opt_addr
CF_GRAMMAR
@ -181,13 +182,24 @@ bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
cf_error("Multihop neighbor requires specified local address");
};
opt_addr:
/* empty */ {
net_addr addr;
addr.type = 0;
$$ = addr; }
| net_ip4_
| net_ip6_
| IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); }
| IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); }
CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]);
CF_CLI(SHOW BFD SESSIONS, optproto, [<name>], [[Show information about BFD sessions]])
{ PROTO_WALK_CMD($4, &proto_bfd, p) bfd_show_sessions(p, 0); };
CF_CLI(SHOW BFD SESSIONS, optproto opt_addr, [<name>] [<addr>], [[Show information about BFD sessions]])
{ PROTO_WALK_CMD($4, &proto_bfd, p) bfd_show_sessions(p, 0, $5); };
CF_CLI(SHOW BFD SESSIONS ALL, optproto, [<name>], [[Show information about BFD sessions]])
{ PROTO_WALK_CMD($5, &proto_bfd, p) bfd_show_sessions(p, 1); };
CF_CLI(SHOW BFD SESSIONS ALL, optproto opt_addr, [<name>] [<addr>], [[Show information about BFD sessions]])
{ PROTO_WALK_CMD($5, &proto_bfd, p) bfd_show_sessions(p, 1, $6); };
CF_CODE