]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BFD: Show session for ip / ip prefix
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Thu, 18 Jan 2024 11:36:48 +0000 (12:36 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Mon, 4 Mar 2024 22:35:10 +0000 (23:35 +0100)
proto/bfd/bfd.c
proto/bfd/bfd.h
proto/bfd/config.Y

index 080ce909b7784c55de70d853338202a61c238922..61ceea5077ea893693929c06b1b34f670c03d541 100644 (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;
index a68a45adc12aca5f3e00fc2541872b68217fe214..83c1c88460fc0e9fae6624ecf6db9c6e25784595 100644 (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);
index 41f8cbdf3beabcecaf2a6ebbca140b3156169724..da687b5f0761f60750e39a3e3e8ce4cbb0244bbd 100644 (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