diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index 080ce909..61ceea50 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -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; diff --git a/proto/bfd/bfd.h b/proto/bfd/bfd.h index a68a45ad..83c1c884 100644 --- a/proto/bfd/bfd.h +++ b/proto/bfd/bfd.h @@ -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); diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y index 41f8cbdf..da687b5f 100644 --- a/proto/bfd/config.Y +++ b/proto/bfd/config.Y @@ -29,6 +29,7 @@ CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE, %type bfd_neigh_iface %type bfd_neigh_local %type bfd_neigh_multihop bfd_auth_type +%type 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, [], [[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, [] [], [[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, [], [[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, [] [], [[Show information about BFD sessions]]) +{ PROTO_WALK_CMD($5, &proto_bfd, p) bfd_show_sessions(p, 1, $6); }; CF_CODE