]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/bfd.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / lib / bfd.c
index 1dfe583caf7743744a35c49362e7c5abe6d1015b..4e192422cdb5ffa49d160db0dc748a7ccefaa31d 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -34,8 +34,8 @@
 
 DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info")
 
-int bfd_debug = 0;
-struct bfd_gbl bfd_gbl;
+static int bfd_debug = 0;
+static struct bfd_gbl bfd_gbl;
 
 /*
  * bfd_gbl_init - Initialize the BFD global structure
@@ -74,10 +74,7 @@ struct bfd_info *bfd_info_create(void)
  */
 void bfd_info_free(struct bfd_info **bfd_info)
 {
-       if (*bfd_info) {
-               XFREE(MTYPE_BFD_INFO, *bfd_info);
-               *bfd_info = NULL;
-       }
+       XFREE(MTYPE_BFD_INFO, *bfd_info);
 }
 
 /*
@@ -127,14 +124,14 @@ void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx, uint32_t min_tx,
  */
 void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,
                      int family, void *dst_ip, void *src_ip, char *if_name,
-                     int ttl, int multihop, int command, int set_flag,
-                     vrf_id_t vrf_id)
+                     int ttl, int multihop, int cbit, int command,
+                     int set_flag, vrf_id_t vrf_id)
 {
        struct stream *s;
        int ret;
        int len;
 
-       /* Individual reg/dereg messages are supressed during shutdown. */
+       /* Individual reg/dereg messages are suppressed during shutdown. */
        if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) {
                if (bfd_debug)
                        zlog_debug(
@@ -208,6 +205,11 @@ void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,
                        stream_putc(s, 0);
                }
        }
+       /* cbit */
+       if (cbit)
+               stream_putc(s, 1);
+       else
+               stream_putc(s, 0);
 
        stream_putw_at(s, 0, stream_get_endp(s));
 
@@ -253,11 +255,13 @@ const char *bfd_get_command_dbg_str(int command)
  */
 struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,
                                    struct prefix *sp, int *status,
+                                   int *remote_cbit,
                                    vrf_id_t vrf_id)
 {
        unsigned int ifindex;
        struct interface *ifp = NULL;
        int plen;
+       int local_remote_cbit;
 
        /* Get interface index. */
        ifindex = stream_getl(s);
@@ -292,6 +296,9 @@ struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,
                stream_get(&sp->u.prefix, s, plen);
                sp->prefixlen = stream_getc(s);
        }
+       local_remote_cbit = stream_getc(s);
+       if (remote_cbit)
+               *remote_cbit = local_remote_cbit;
        return ifp;
 }
 
@@ -305,6 +312,8 @@ const char *bfd_get_status_str(int status)
                return "Down";
        case BFD_STATUS_UP:
                return "Up";
+       case BFD_STATUS_ADMIN_DOWN:
+               return "Admin Down";
        case BFD_STATUS_UNKNOWN:
        default:
                return "Unknown";
@@ -433,7 +442,8 @@ void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop,
  * bfd_client_sendmsg - Format and send a client register
  *                    command to Zebra to be forwarded to BFD
  */
-void bfd_client_sendmsg(struct zclient *zclient, int command)
+void bfd_client_sendmsg(struct zclient *zclient, int command,
+                       vrf_id_t vrf_id)
 {
        struct stream *s;
        int ret;
@@ -450,7 +460,7 @@ void bfd_client_sendmsg(struct zclient *zclient, int command)
 
        s = zclient->obuf;
        stream_reset(s);
-       zclient_create_header(s, command, VRF_DEFAULT);
+       zclient_create_header(s, command, vrf_id);
 
        stream_putl(s, getpid());