summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorKaterina Kubecova <katerina.kubecova@nic.cz>2024-01-18 12:36:48 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2024-03-04 23:35:10 +0100
commita48dc5efe05f4e985b648f19679865153d0398bd (patch)
tree66976a310c69e8bb5e0cea46fbee2be536d64373 /proto
parent37bf2078434b5de5662d28345bce788624d50ac7 (diff)
BFD: Show session for ip / ip prefix
Diffstat (limited to 'proto')
-rw-r--r--proto/bfd/bfd.c5
-rw-r--r--proto/bfd/bfd.h2
-rw-r--r--proto/bfd/config.Y20
3 files changed, 21 insertions, 6 deletions
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 <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