]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
bgpd: Replace bgp_flag_* to [UN]SET/CHECK_FLAG macros
[mirror_frr.git] / bgpd / bgp_vty.c
index eff5b3b7bca6635c5429b407e75281261fceb410..e55548f713bcf240e22976245dfd8c71076dcf78 100644 (file)
@@ -105,8 +105,10 @@ DEFINE_HOOK(bgp_inst_config_write,
                (struct bgp *bgp, struct vty *vty),
                (bgp, vty))
 
-#define GR_NO_OPER "The Graceful Restart No Operation was executed as cmd same as previous one."
-#define GR_INVALID "The Graceful Restart command used is not valid at this moment."
+#define GR_NO_OPER                                                             \
+       "The Graceful Restart No Operation was executed as cmd same as previous one."
+#define GR_INVALID                                                             \
+       "The Graceful Restart command used is not valid at this moment."
 static struct peer_group *listen_range_exists(struct bgp *bgp,
                                              struct prefix *range, int exact);
 
@@ -120,23 +122,18 @@ enum show_type {
        show_ipv6_peer
 };
 
-static struct peer_group *listen_range_exists(
-                                               struct bgp *bgp,
-                                               struct prefix *range,
-                                               int exact);
+static struct peer_group *listen_range_exists(struct bgp *bgp,
+                                             struct prefix *range, int exact);
 
-static void bgp_show_global_graceful_restart_mode_vty(
-                                       struct vty *vty,
-                                       struct bgp *bgp,
-                                       bool use_json,
-                                       json_object *json);
+static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty,
+                                                     struct bgp *bgp,
+                                                     bool use_json,
+                                                     json_object *json);
 
-static int bgp_show_neighbor_graceful_restart_afi_all(
-                               struct vty *vty,
-                               enum show_type type,
-                               const char *ip_str,
-                               afi_t afi,
-                               bool use_json);
+static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty,
+                                                     enum show_type type,
+                                                     const char *ip_str,
+                                                     afi_t afi, bool use_json);
 
 static enum node_type bgp_node_type(afi_t afi, safi_t safi)
 {
@@ -425,13 +422,13 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
                               DFLT_BGP_CONNECT_RETRY);
 
                if (DFLT_BGP_IMPORT_CHECK)
-                       bgp_flag_set(*bgp, BGP_FLAG_IMPORT_CHECK);
+                       SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK);
                if (DFLT_BGP_SHOW_HOSTNAME)
-                       bgp_flag_set(*bgp, BGP_FLAG_SHOW_HOSTNAME);
+                       SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME);
                if (DFLT_BGP_LOG_NEIGHBOR_CHANGES)
-                       bgp_flag_set(*bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+                       SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
                if (DFLT_BGP_DETERMINISTIC_MED)
-                       bgp_flag_set(*bgp, BGP_FLAG_DETERMINISTIC_MED);
+                       SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED);
 
                ret = BGP_SUCCESS;
        }
@@ -838,8 +835,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        bgp_peer_gr_flags_update(peer);
 
-                       if (CHECK_FLAG(peer->flags,
-                                       PEER_FLAG_GRACEFUL_RESTART))
+                       if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
                                gr_router_detected = true;
 
                        ret = bgp_peer_clear(peer, afi, safi, nnode,
@@ -847,14 +843,13 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        if (ret < 0)
                                bgp_clear_vty_error(vty, peer, afi, safi, ret);
-
                }
 
-               if (gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
+               if (gr_router_detected
+                   && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
                        bgp_zebra_send_capabilities(bgp, false);
-               } else if (!gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
+               } else if (!gr_router_detected
+                          && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
                        bgp_zebra_send_capabilities(bgp, true);
                }
 
@@ -942,8 +937,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        bgp_peer_gr_flags_update(peer);
 
-                       if (CHECK_FLAG(peer->flags,
-                               PEER_FLAG_GRACEFUL_RESTART))
+                       if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
                                gr_router_detected = true;
 
                        ret = bgp_peer_clear(peer, afi, safi, nnode, stype);
@@ -954,11 +948,11 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                                found = true;
                }
 
-               if (gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
+               if (gr_router_detected
+                   && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
                        bgp_zebra_send_capabilities(bgp, false);
-               } else if (!gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
+               } else if (!gr_router_detected
+                          && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
                        bgp_zebra_send_capabilities(bgp, true);
                }
 
@@ -980,8 +974,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 
                        bgp_peer_gr_flags_update(peer);
 
-                       if (CHECK_FLAG(peer->flags,
-                               PEER_FLAG_GRACEFUL_RESTART))
+                       if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
                                gr_router_detected = true;
 
                        ret = bgp_peer_clear(peer, afi, safi, nnode, stype);
@@ -992,11 +985,11 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                                found = true;
                }
 
-               if (gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
+               if (gr_router_detected
+                   && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) {
                        bgp_zebra_send_capabilities(bgp, false);
-               } else if (!gr_router_detected &&
-                       bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
+               } else if (!gr_router_detected
+                          && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) {
                        bgp_zebra_send_capabilities(bgp, true);
                }
 
@@ -1999,7 +1992,7 @@ DEFUN (bgp_client_to_client_reflection,
        "reflection of routes allowed\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
        bgp_clear_star_soft_out(vty, bgp->name);
 
        return CMD_SUCCESS;
@@ -2014,7 +2007,7 @@ DEFUN (no_bgp_client_to_client_reflection,
        "reflection of routes allowed\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+       SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
        bgp_clear_star_soft_out(vty, bgp->name);
 
        return CMD_SUCCESS;
@@ -2028,7 +2021,7 @@ DEFUN (bgp_always_compare_med,
        "Allow comparing MED from different neighbors\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
+       SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2042,7 +2035,7 @@ DEFUN (no_bgp_always_compare_med,
        "Allow comparing MED from different neighbors\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2130,8 +2123,8 @@ DEFUN (bgp_deterministic_med,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
-               bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED);
+       if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
+               SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
                bgp_recalculate_all_bestpaths(bgp);
        }
 
@@ -2152,7 +2145,7 @@ DEFUN (no_bgp_deterministic_med,
        struct peer *peer;
        struct listnode *node, *nnode;
 
-       if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
                bestpath_per_as_used = 0;
 
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
@@ -2172,7 +2165,7 @@ DEFUN (no_bgp_deterministic_med,
                                "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
                        return CMD_WARNING_CONFIG_FAILED;
                } else {
-                       bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED);
+                       UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
                        bgp_recalculate_all_bestpaths(bgp);
                }
        }
@@ -2197,8 +2190,8 @@ DEFUN (bgp_graceful_restart,
 
        ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD);
 
-       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp,
-                               bgp->peer, ret);
+       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer,
+                                                             ret);
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
@@ -2224,8 +2217,8 @@ DEFUN (no_bgp_graceful_restart,
 
        ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD);
 
-       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp,
-                       bgp->peer, ret);
+       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer,
+                                                             ret);
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
@@ -2284,9 +2277,9 @@ DEFUN (bgp_graceful_restart_select_defer_time,
        defer_time = strtoul(argv[idx_number]->arg, NULL, 10);
        bgp->select_defer_time = defer_time;
        if (defer_time == 0)
-               bgp_flag_set(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+               SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
        else
-               bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+               UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
 
        return CMD_SUCCESS;
 }
@@ -2333,7 +2326,7 @@ DEFUN (no_bgp_graceful_restart_select_defer_time,
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
        bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME;
-       bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
 
        return CMD_SUCCESS;
 }
@@ -2346,7 +2339,7 @@ DEFUN (bgp_graceful_restart_preserve_fw,
        "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD);
+       SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD);
        return CMD_SUCCESS;
 }
 
@@ -2359,7 +2352,7 @@ DEFUN (no_bgp_graceful_restart_preserve_fw,
        "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD);
        return CMD_SUCCESS;
 }
 
@@ -2409,8 +2402,8 @@ DEFUN (no_bgp_graceful_restart_disable,
 
        ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD);
 
-       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp,
-                               bgp->peer, ret);
+       VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer,
+                                                             ret);
 
        if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
                zlog_debug(
@@ -2555,8 +2548,7 @@ DEFUN (no_bgp_neighbor_graceful_restart_helper,
                zlog_debug(
                        "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
 
-       ret = bgp_neighbor_graceful_restart(peer,
-                       NO_PEER_HELPER_CMD);
+       ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD);
 
        VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer);
        VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret);
@@ -2592,8 +2584,7 @@ DEFUN (bgp_neighbor_graceful_restart_disable_set,
        if (!peer)
                return CMD_WARNING_CONFIG_FAILED;
 
-       ret = bgp_neighbor_graceful_restart(peer,
-                               PEER_DISABLE_CMD);
+       ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD);
 
        if (peer->bgp->t_startup)
                bgp_peer_gr_flags_update(peer);
@@ -2655,7 +2646,7 @@ DEFUN_HIDDEN (bgp_graceful_restart_disable_eor,
               "Disable EOR Check\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_GR_DISABLE_EOR);
+       SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR);
 
        return CMD_SUCCESS;
 }
@@ -2669,7 +2660,7 @@ DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor,
               "Disable EOR Check\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_GR_DISABLE_EOR);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR);
 
        return CMD_SUCCESS;
 }
@@ -2723,8 +2714,8 @@ DEFUN (bgp_graceful_shutdown,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
-               bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN);
+       if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+               SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
                bgp_static_redo_import_check(bgp);
                bgp_redistribute_redo(bgp);
                bgp_clear_star_soft_out(vty, bgp->name);
@@ -2743,8 +2734,8 @@ DEFUN (no_bgp_graceful_shutdown,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
-               bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN);
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+               UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
                bgp_static_redo_import_check(bgp);
                bgp_redistribute_redo(bgp);
                bgp_clear_star_soft_out(vty, bgp->name);
@@ -2762,7 +2753,7 @@ DEFUN (bgp_fast_external_failover,
        "Immediately reset session if a link to a directly connected external peer goes down\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
        return CMD_SUCCESS;
 }
 
@@ -2774,7 +2765,7 @@ DEFUN (no_bgp_fast_external_failover,
        "Immediately reset session if a link to a directly connected external peer goes down\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+       SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
        return CMD_SUCCESS;
 }
 
@@ -2787,7 +2778,7 @@ DEFUN (bgp_bestpath_compare_router_id,
        "Compare router-id for identical EBGP paths\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID);
+       SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2802,7 +2793,7 @@ DEFUN (no_bgp_bestpath_compare_router_id,
        "Compare router-id for identical EBGP paths\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2818,7 +2809,7 @@ DEFUN (bgp_bestpath_aspath_ignore,
        "Ignore as-path length in selecting a route\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE);
+       SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2834,7 +2825,7 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
        "Ignore as-path length in selecting a route\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2850,7 +2841,7 @@ DEFUN (bgp_bestpath_aspath_confed,
        "Compare path lengths including confederation sets & sequences in selecting a route\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED);
+       SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2866,7 +2857,7 @@ DEFUN (no_bgp_bestpath_aspath_confed,
        "Compare path lengths including confederation sets & sequences in selecting a route\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2885,14 +2876,14 @@ DEFUN (bgp_bestpath_aspath_multipath_relax,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
        int idx = 0;
-       bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
+       SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
 
        /* no-as-set is now the default behavior so we can silently
         * ignore it */
        if (argv_find(argv, argc, "as-set", &idx))
-               bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+               SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
        else
-               bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+               UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
 
        bgp_recalculate_all_bestpaths(bgp);
 
@@ -2911,8 +2902,8 @@ DEFUN (no_bgp_bestpath_aspath_multipath_relax,
        "Do not generate an AS_SET\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
-       bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
        bgp_recalculate_all_bestpaths(bgp);
 
        return CMD_SUCCESS;
@@ -2926,7 +2917,7 @@ DEFUN (bgp_log_neighbor_changes,
        "Log neighbor up/down and reset reason\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+       SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
        return CMD_SUCCESS;
 }
 
@@ -2938,7 +2929,7 @@ DEFUN (no_bgp_log_neighbor_changes,
        "Log neighbor up/down and reset reason\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
        return CMD_SUCCESS;
 }
 
@@ -2958,10 +2949,10 @@ DEFUN (bgp_bestpath_med,
 
        int idx = 0;
        if (argv_find(argv, argc, "confed", &idx))
-               bgp_flag_set(bgp, BGP_FLAG_MED_CONFED);
+               SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
        idx = 0;
        if (argv_find(argv, argc, "missing-as-worst", &idx))
-               bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST);
+               SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
 
        bgp_recalculate_all_bestpaths(bgp);
 
@@ -2984,10 +2975,10 @@ DEFUN (no_bgp_bestpath_med,
 
        int idx = 0;
        if (argv_find(argv, argc, "confed", &idx))
-               bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED);
+               UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
        idx = 0;
        if (argv_find(argv, argc, "missing-as-worst", &idx))
-               bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST);
+               UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
 
        bgp_recalculate_all_bestpaths(bgp);
 
@@ -3004,7 +2995,7 @@ DEFUN (no_bgp_default_ipv4_unicast,
        "Activate ipv4-unicast for a peer by default\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4);
+       SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4);
        return CMD_SUCCESS;
 }
 
@@ -3016,7 +3007,7 @@ DEFUN (bgp_default_ipv4_unicast,
        "Activate ipv4-unicast for a peer by default\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4);
        return CMD_SUCCESS;
 }
 
@@ -3029,7 +3020,7 @@ DEFUN (bgp_default_show_hostname,
        "Show hostname in certain command outputs\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME);
+       SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
        return CMD_SUCCESS;
 }
 
@@ -3042,7 +3033,7 @@ DEFUN (no_bgp_default_show_hostname,
        "Show hostname in certain command outputs\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
        return CMD_SUCCESS;
 }
 
@@ -3055,8 +3046,8 @@ DEFUN (bgp_network_import_check,
        "Check BGP network route exists in IGP\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) {
-               bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK);
+       if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+               SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
                bgp_static_redo_import_check(bgp);
        }
 
@@ -3079,8 +3070,8 @@ DEFUN (no_bgp_network_import_check,
        "Check BGP network route exists in IGP\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) {
-               bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK);
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+               UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
                bgp_static_redo_import_check(bgp);
        }
 
@@ -3167,8 +3158,8 @@ DEFUN (bgp_rr_allow_outbound_policy,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
-               bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+       if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+               SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
                update_group_announce_rrclients(bgp);
                bgp_clear_star_soft_out(vty, bgp->name);
        }
@@ -3186,8 +3177,8 @@ DEFUN (no_bgp_rr_allow_outbound_policy,
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
 
-       if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
-               bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+               UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
                update_group_announce_rrclients(bgp);
                bgp_clear_star_soft_out(vty, bgp->name);
        }
@@ -3414,7 +3405,7 @@ DEFUN (bgp_disable_connected_route_check,
        "Disable checking if nexthop is connected on ebgp sessions\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+       SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
        bgp_clear_star_soft_in(vty, bgp->name);
 
        return CMD_SUCCESS;
@@ -3428,7 +3419,7 @@ DEFUN (no_bgp_disable_connected_route_check,
        "Disable checking if nexthop is connected on ebgp sessions\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+       UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
        bgp_clear_star_soft_in(vty, bgp->name);
 
        return CMD_SUCCESS;
@@ -3567,7 +3558,7 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
                        ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type,
                                             afi, safi);
        } else {
-               if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)
                    && afi == AFI_IP && safi == SAFI_UNICAST)
                        peer = peer_create(NULL, conf_if, bgp, bgp->as, as,
                                           as_type, 0, 0, NULL);
@@ -8522,14 +8513,14 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
 {
        json_object *bestpath = json_object_new_object();
 
-       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE))
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE))
                json_object_string_add(bestpath, "asPath", "ignore");
 
-       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED))
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED))
                json_object_string_add(bestpath, "asPath", "confed");
 
-       if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
-               if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET))
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET))
                        json_object_string_add(bestpath, "multiPathRelax",
                                               "as-set");
                else
@@ -8538,13 +8529,13 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
        } else
                json_object_string_add(bestpath, "multiPathRelax", "false");
 
-       if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID))
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID))
                json_object_string_add(bestpath, "compareRouterId", "true");
-       if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)
-           || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) {
-               if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED))
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)
+           || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) {
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED))
                        json_object_string_add(bestpath, "med", "confed");
-               if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST))
                        json_object_string_add(bestpath, "med",
                                               "missing-as-worst");
                else
@@ -8667,7 +8658,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,
                dn_flag[1] = '\0';
                dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0';
                if (peer->hostname
-                   && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
+                   && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME))
                        len = vty_out(vty, "%s%s(%s)", dn_flag,
                                      peer->hostname, peer->host);
                else
@@ -8750,8 +8741,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                        dn_flag[0] = '*';
 
                                if (peer->hostname
-                                   && bgp_flag_check(bgp,
-                                                     BGP_FLAG_SHOW_HOSTNAME))
+                                   && CHECK_FLAG(bgp->flags,
+                                                 BGP_FLAG_SHOW_HOSTNAME))
                                        sprintf(neighbor_buf, "%s%s(%s) ",
                                                dn_flag, peer->hostname,
                                                peer->host);
@@ -9112,9 +9103,11 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
                                }
 
                                if (peer->hostname
-                                   && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
+                                   && CHECK_FLAG(bgp->flags,
+                                                 BGP_FLAG_SHOW_HOSTNAME))
                                        len = vty_out(vty, "%s%s(%s)", dn_flag,
-                                                     peer->hostname, peer->host);
+                                                     peer->hostname,
+                                                     peer->host);
                                else
                                        len = vty_out(vty, "%s%s", dn_flag, peer->host);
 
@@ -9454,20 +9447,19 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p,
        }
 }
 
-static void bgp_show_neighnor_graceful_restart_rbit(
-                                               struct vty *vty,
-                                               struct peer *p,
-                                               bool use_json,
-                                               json_object *json)
+static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
+                                                   struct peer *p,
+                                                   bool use_json,
+                                                   json_object *json)
 {
        bool rbit_status = 0;
 
        if (!use_json)
                vty_out(vty, "\n    R bit          : ");
 
-       if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) &&
-               (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) &&
-               (p->status == Established)) {
+       if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)
+           && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV))
+           && (p->status == Established)) {
 
                if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV))
                        rbit_status = 1;
@@ -9477,62 +9469,57 @@ static void bgp_show_neighnor_graceful_restart_rbit(
 
        if (rbit_status) {
                if (use_json)
-                       json_object_boolean_true_add(
-                                       json, "rBit");
+                       json_object_boolean_true_add(json, "rBit");
                else
                        vty_out(vty, "True\n");
        } else {
                if (use_json)
-                       json_object_boolean_false_add(
-                                       json, "rBit");
+                       json_object_boolean_false_add(json, "rBit");
                else
                        vty_out(vty, "False\n");
        }
 }
 
-static void bgp_show_neighbor_graceful_restart_remote_mode(
-                                               struct vty *vty,
-                                               struct peer *peer,
-                                               bool use_json,
-                                               json_object *json)
+static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,
+                                                          struct peer *peer,
+                                                          bool use_json,
+                                                          json_object *json)
 {
        const char *mode = "NotApplicable";
 
        if (!use_json)
                vty_out(vty, "\n    Remote GR Mode : ");
 
-       if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) &&
-               (peer->status == Established)) {
+       if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)
+           && (peer->status == Established)) {
 
-               if ((peer->nsf_af_count == 0) &&
-                       !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
+               if ((peer->nsf_af_count == 0)
+                   && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
 
                        mode = "Disable";
 
-               } else if (peer->nsf_af_count == 0 &&
-                       CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
+               } else if (peer->nsf_af_count == 0
+                          && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
 
                        mode = "Helper";
 
-               } else if (peer->nsf_af_count != 0 &&
-                       CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
+               } else if (peer->nsf_af_count != 0
+                          && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
 
                        mode = "Restart";
-
                }
        }
 
        if (use_json) {
-               json_object_string_add(json,
-                               "remoteGrMode", mode);
+               json_object_string_add(json, "remoteGrMode", mode);
        } else
                vty_out(vty, mode, "\n");
 }
 
-static void  bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty,
-                                               struct peer *p,
-                                               bool use_json,
-                                               json_object *json)
+static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty,
+                                                         struct peer *p,
+                                                         bool use_json,
+                                                         json_object *json)
 {
        const char *mode = "Invalid";
 
@@ -9557,16 +9544,14 @@ static void  bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty,
        }
 
        if (use_json) {
-               json_object_string_add(json,
-                               "localGrMode", mode);
+               json_object_string_add(json, "localGrMode", mode);
        } else {
                vty_out(vty, mode, "\n");
        }
 }
 
-static void  bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
-                                       struct vty *vty, struct peer *peer,
-                                       bool use_json, json_object *json)
+static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
+       struct vty *vty, struct peer *peer, bool use_json, json_object *json)
 {
        afi_t afi;
        safi_t safi;
@@ -9577,268 +9562,241 @@ static void  bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
 
        for (afi = AFI_IP; afi < AFI_MAX; afi++) {
                for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) {
-                       if (peer->afc[afi][safi]
-                               && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)
-                               && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)
-                               ) {
-                               if (use_json) {
-                                       json_afi_safi =
-                                               json_object_new_object();
-                                       json_endofrib_status =
-                                               json_object_new_object();
-                                       json_timer =
-                                               json_object_new_object();
-                               }
+                       if (!peer->afc[afi][safi])
+                               continue;
 
-                               if (peer->eor_stime[afi][safi] >=
-                                   peer->pkt_stime[afi][safi])
-                                       eor_flag = true;
-                               else
-                                       eor_flag = false;
+                       if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)
+                           || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV))
+                               continue;
 
-                               if (!use_json) {
-                                       vty_out(vty, "    %s :\n",
-                                       get_afi_safi_str(afi, safi, false));
+                       if (use_json) {
+                               json_afi_safi = json_object_new_object();
+                               json_endofrib_status = json_object_new_object();
+                               json_timer = json_object_new_object();
+                       }
 
-                                       vty_out(vty,
-                                       "     F bit                 : ");
-                               } else
-                                       get_afi_safi_str(afi, safi, true);
+                       if (peer->eor_stime[afi][safi]
+                           >= peer->pkt_stime[afi][safi])
+                               eor_flag = true;
+                       else
+                               eor_flag = false;
 
-                               if (peer->nsf[afi][safi]
-                                       && CHECK_FLAG(
-                                       peer->af_cap[afi][safi],
-                                       PEER_CAP_RESTART_AF_PRESERVE_RCV)) {
+                       if (!use_json) {
+                               vty_out(vty, "    %s :\n",
+                                       get_afi_safi_str(afi, safi, false));
 
-                                       if (use_json) {
-                                               json_object_boolean_true_add(
-                                               json_afi_safi, "fBit");
-                                       } else {
-                                               vty_out(vty,
-                                                       "True\n");
-                                       }
+                               vty_out(vty, "     F bit                 : ");
+                       }
 
-                               } else {
+                       if (peer->nsf[afi][safi]
+                           && CHECK_FLAG(peer->af_cap[afi][safi],
+                                         PEER_CAP_RESTART_AF_PRESERVE_RCV)) {
 
-                                       if (use_json) {
-                                               json_object_boolean_false_add(
+                               if (use_json) {
+                                       json_object_boolean_true_add(
                                                json_afi_safi, "fBit");
-                                       } else {
-                                               vty_out(vty,
-                                                       "False\n");
-                                       }
-
-                               }
-
-                               if (!use_json)
-                                       vty_out(vty,
-                                       "     End-of-RIB Received   : ");
+                               } else
+                                       vty_out(vty, "True\n");
+                       } else {
+                               if (use_json)
+                                       json_object_boolean_false_add(
+                                               json_afi_safi, "fBit");
+                               else
+                                       vty_out(vty, "False\n");
+                       }
 
-                               if (CHECK_FLAG(peer->af_sflags[afi][safi],
-                                               PEER_STATUS_EOR_RECEIVED)) {
+                       if (!use_json)
+                               vty_out(vty, "     End-of-RIB Received   : ");
 
-                                       if (use_json) {
-                                               json_object_boolean_true_add(
+                       if (CHECK_FLAG(peer->af_sflags[afi][safi],
+                                      PEER_STATUS_EOR_RECEIVED)) {
+                               if (use_json)
+                                       json_object_boolean_true_add(
                                                json_endofrib_status,
-                                                       "endOfRibRecv");
-                                       } else {
-                                               vty_out(vty, "Yes\n");
-                                       }
-
-                               } else {
-                                       if (use_json) {
-                                               json_object_boolean_false_add(
+                                               "endOfRibRecv");
+                               else
+                                       vty_out(vty, "Yes\n");
+                       } else {
+                               if (use_json)
+                                       json_object_boolean_false_add(
                                                json_endofrib_status,
-                                                       "endOfRibRecv");
-                                       } else {
-                                               vty_out(vty, "No\n");
-                                       }
-                               }
+                                               "endOfRibRecv");
+                               else
+                                       vty_out(vty, "No\n");
+                       }
 
-                               if (!use_json)
-                                       vty_out(vty,
-                                       "     End-of-RIB Send       : ");
+                       if (!use_json)
+                               vty_out(vty, "     End-of-RIB Send       : ");
 
-                               if (CHECK_FLAG(peer->af_sflags[afi][safi],
-                                               PEER_STATUS_EOR_SEND)) {
-                                       if (use_json) {
-                                               json_object_boolean_true_add(
+                       if (CHECK_FLAG(peer->af_sflags[afi][safi],
+                                      PEER_STATUS_EOR_SEND)) {
+                               if (use_json) {
+                                       json_object_boolean_true_add(
                                                json_endofrib_status,
-                                                        "endOfRibSend");
+                                               "endOfRibSend");
 
-                                               PRINT_EOR_JSON(eor_flag);
-                                       } else {
-                                               vty_out(vty, "Yes\n");
-                                               vty_out(vty,
+                                       PRINT_EOR_JSON(eor_flag);
+                               } else {
+                                       vty_out(vty, "Yes\n");
+                                       vty_out(vty,
                                                "     EoRSentAfterUpdate   : ");
 
-                                               PRINT_EOR(eor_flag);
-                                       }
-                               } else {
-                                       if (use_json) {
-                                               json_object_boolean_false_add(
+                                       PRINT_EOR(eor_flag);
+                               }
+                       } else {
+                               if (use_json) {
+                                       json_object_boolean_false_add(
                                                json_endofrib_status,
-                                                       "endOfRibSend");
-                                               json_object_boolean_false_add(
+                                               "endOfRibSend");
+                                       json_object_boolean_false_add(
                                                json_endofrib_status,
-                                                "endOfRibSentAfterUpdate");
-                                       } else {
-                                               vty_out(vty, "No\n");
-                                               vty_out(vty,
+                                               "endOfRibSentAfterUpdate");
+                               } else {
+                                       vty_out(vty, "No\n");
+                                       vty_out(vty,
                                                "     EoRSentAfterUpdate   : ");
-                                               vty_out(vty, "No\n");
-                                       }
+                                       vty_out(vty, "No\n");
                                }
+                       }
 
-                               if (use_json) {
-
-                                       json_object_int_add(json_timer,
-                                               "stalePathTimer",
-                                               peer->bgp->stalepath_time);
-
-                                       if (peer->t_gr_stale != NULL) {
+                       if (use_json) {
+                               json_object_int_add(json_timer,
+                                                   "stalePathTimer",
+                                                   peer->bgp->stalepath_time);
 
-                                               json_object_int_add(
+                               if (peer->t_gr_stale != NULL) {
+                                       json_object_int_add(
                                                json_timer,
                                                "stalePathTimerRemaining",
                                                thread_timer_remain_second(
-                                               peer->t_gr_stale));
-                                       }
-
-                                       /* Display Configured Selection
-                                        * Deferral only when when
-                                        * Gr mode is enabled.
-                                        */
-                                       if (CHECK_FLAG(peer->flags,
-                                               PEER_FLAG_GRACEFUL_RESTART)) {
+                                                       peer->t_gr_stale));
+                               }
 
-                                               json_object_int_add(
+                               /* Display Configured Selection
+                                * Deferral only when when
+                                * Gr mode is enabled.
+                                */
+                               if (CHECK_FLAG(peer->flags,
+                                              PEER_FLAG_GRACEFUL_RESTART)) {
+                                       json_object_int_add(
                                                json_timer,
                                                "selectionDeferralTimer",
                                                peer->bgp->stalepath_time);
-                                       }
+                               }
 
-                                       if (peer->bgp->gr_info[afi][safi]
-                                               .t_select_deferral != NULL) {
+                               if (peer->bgp->gr_info[afi][safi]
+                                           .t_select_deferral
+                                   != NULL) {
 
-                                               json_object_int_add(
+                                       json_object_int_add(
                                                json_timer,
                                                "selectionDeferralTimerRemaining",
                                                thread_timer_remain_second(
-                                               peer->bgp
-                                               ->gr_info[afi][safi]
-                                               .t_select_deferral));
-                                       }
-
-                               } else {
+                                                       peer->bgp
+                                                               ->gr_info[afi]
+                                                                        [safi]
+                                                               .t_select_deferral));
+                               }
+                       } else {
+                               vty_out(vty, "     Timers:\n");
 
-                                       vty_out(vty, "     Timers:\n");
+                               vty_out(vty, "%*s", 6, "");
+                               vty_out(vty,
+                                       "Configured Stale Path Time(sec)%*s: %u\n",
+                                       8, "", peer->bgp->stalepath_time);
 
+                               if (peer->t_gr_stale != NULL) {
                                        vty_out(vty, "%*s", 6, "");
                                        vty_out(vty,
-                                       "Configured Stale Path Time(sec)%*s: %u\n",
-                                               8, "",
-                                       peer->bgp->stalepath_time);
-
-                                       if (peer->t_gr_stale != NULL) {
-                                               vty_out(vty, "%*s", 6, "");
-                                               vty_out(vty,
                                                "Stale Path Remaining(sec)%*s: %ld\n",
                                                14, "",
                                                thread_timer_remain_second(
-                                               peer->t_gr_stale));
-                                       }
-                                       /* Display Configured Selection
-                                        * Deferral only when when
-                                        * Gr mode is enabled.
-                                        */
-                                       if (CHECK_FLAG(peer->flags,
-                                               PEER_FLAG_GRACEFUL_RESTART)) {
-                                               vty_out(vty, "%*s", 6, "");
-                                               vty_out(vty,
+                                                       peer->t_gr_stale));
+                               }
+                               /* Display Configured Selection
+                                * Deferral only when when
+                                * Gr mode is enabled.
+                                */
+                               if (CHECK_FLAG(peer->flags,
+                                              PEER_FLAG_GRACEFUL_RESTART)) {
+                                       vty_out(vty, "%*s", 6, "");
+                                       vty_out(vty,
                                                "Configured Selection Deferral Time(sec): %u\n",
                                                peer->bgp->select_defer_time);
-                                       }
+                               }
 
-                                       if (peer->bgp
-                                               ->gr_info[afi][safi]
-                                               .t_select_deferral != NULL) {
+                               if (peer->bgp->gr_info[afi][safi]
+                                           .t_select_deferral
+                                   != NULL) {
 
-                                               vty_out(vty, "%*s", 6, "");
-                                               vty_out(vty,
+                                       vty_out(vty, "%*s", 6, "");
+                                       vty_out(vty,
                                                "Selection Deferral Time Remaining(sec) : %ld\n",
                                                thread_timer_remain_second(
-                                               peer->bgp
-                                               ->gr_info[afi][safi]
-                                               .t_select_deferral));
-                                       }
-
-                               }
-                               if (use_json) {
-                                       json_object_object_add(json_afi_safi,
-                                                       "endOfRibStatus",
-                                                        json_endofrib_status);
-                                       json_object_object_add(json_afi_safi,
-                                                       "timers",
-                                                        json_timer);
-                                       json_object_object_add(json,
-                                               get_afi_safi_str(afi, safi, true),
-                                                        json_afi_safi);
+                                                       peer->bgp
+                                                               ->gr_info[afi]
+                                                                        [safi]
+                                                               .t_select_deferral));
                                }
                        }
+                       if (use_json) {
+                               json_object_object_add(json_afi_safi,
+                                                      "endOfRibStatus",
+                                                      json_endofrib_status);
+                               json_object_object_add(json_afi_safi, "timers",
+                                                      json_timer);
+                               json_object_object_add(
+                                       json, get_afi_safi_str(afi, safi, true),
+                                       json_afi_safi);
+                       }
                }
        }
 }
 
-static void  bgp_show_neighbor_graceful_restart_time(struct vty *vty,
-                                                       struct peer *p,
-                                                       bool use_json,
-                                                       json_object *json)
+static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,
+                                                   struct peer *p,
+                                                   bool use_json,
+                                                   json_object *json)
 {
        if (use_json) {
                json_object *json_timer = NULL;
 
                json_timer = json_object_new_object();
 
-               json_object_int_add(json_timer,
-                                       "configuredRestartTimer",
-                                       p->bgp->restart_time);
+               json_object_int_add(json_timer, "configuredRestartTimer",
+                                   p->bgp->restart_time);
 
-               json_object_int_add(json_timer,
-                                       "receivedRestartTimer",
-                                       p->v_gr_restart);
+               json_object_int_add(json_timer, "receivedRestartTimer",
+                                   p->v_gr_restart);
 
-               if (p->t_gr_restart != NULL) {
-                       json_object_int_add(json_timer,
-                                       "restartTimerRemaining",
-                                       thread_timer_remain_second(
-                                       p->t_gr_restart)
-                                       );
-               }
+               if (p->t_gr_restart != NULL)
+                       json_object_int_add(
+                               json_timer, "restartTimerRemaining",
+                               thread_timer_remain_second(p->t_gr_restart));
 
                json_object_object_add(json, "timers", json_timer);
        } else {
 
                vty_out(vty, "    Timers :\n");
-               vty_out(vty,
-                       "     Configured Restart Time(sec)  : %u\n",
-                               p->bgp->restart_time);
+               vty_out(vty, "     Configured Restart Time(sec)  : %u\n",
+                       p->bgp->restart_time);
 
-               vty_out(vty,
-                       "     Received Restart Time(sec)    : %u\n",
-                                       p->v_gr_restart);
+               vty_out(vty, "     Received Restart Time(sec)    : %u\n",
+                       p->v_gr_restart);
+               if (p->t_gr_restart != NULL)
+                       vty_out(vty,
+                               "     Restart Time Remaining(sec)   : %ld\n",
+                               thread_timer_remain_second(p->t_gr_restart));
                if (p->t_gr_restart != NULL) {
                        vty_out(vty,
-                       "     Restart Time Remaining(sec)   : %ld\n",
-                               thread_timer_remain_second(
-                                       p->t_gr_restart));
+                               "     Restart Time Remaining(sec)   : %ld\n",
+                               thread_timer_remain_second(p->t_gr_restart));
                }
        }
 }
 
 static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
-                                       bool use_json,
-                                       json_object *json)
+                                   bool use_json, json_object *json)
 {
        char buf[SU_ADDRSTRLEN] = {0};
        char dn_flag[2] = {0};
@@ -9849,14 +9807,14 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
 
        if (p->conf_if) {
                if (use_json)
-                       json_object_string_add(json, "neighborAddr",
+                       json_object_string_add(
+                               json, "neighborAddr",
                                BGP_PEER_SU_UNSPEC(p)
-                               ? "none"
-                               : sockunion2str(&p->su, buf,
-                                       SU_ADDRSTRLEN));
+                                       ? "none"
+                                       : sockunion2str(&p->su, buf,
+                                                       SU_ADDRSTRLEN));
                else
-                       vty_out(vty, "BGP neighbor on %s: %s\n",
-                               p->conf_if,
+                       vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if,
                                BGP_PEER_SU_UNSPEC(p)
                                        ? "none"
                                        : sockunion2str(&p->su, buf,
@@ -9865,12 +9823,10 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
                sprintf(neighborAddr, "%s%s", dn_flag, p->host);
 
                if (use_json)
-                       json_object_string_add(
-                               json, "neighborAddr",
-                               neighborAddr);
+                       json_object_string_add(json, "neighborAddr",
+                                              neighborAddr);
                else
-                       vty_out(vty, "BGP neighbor is %s\n",
-                               neighborAddr);
+                       vty_out(vty, "BGP neighbor is %s\n", neighborAddr);
        }
 
        /* more gr info in new format */
@@ -10192,8 +10148,7 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
                                        p->pmax_restart[afi][safi] * 60000);
                }
                json_object_object_add(json_neigh,
-                                       get_afi_safi_str(afi,
-                                               safi, true),
+                                      get_afi_safi_str(afi, safi, true),
                                       json_addr);
 
        } else {
@@ -11649,11 +11604,11 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                        json_grace_send = json_object_new_object();
                        json_grace_recv = json_object_new_object();
 
-                       if ((p->status == Established) &&
-                                       CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
+                       if ((p->status == Established)
+                           && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
                                FOREACH_AFI_SAFI (afi, safi) {
                                        if (CHECK_FLAG(p->af_sflags[afi][safi],
-                                               PEER_STATUS_EOR_SEND)) {
+                                                      PEER_STATUS_EOR_SEND)) {
                                                json_object_boolean_true_add(
                                                        json_grace_send,
                                                        get_afi_safi_str(afi,
@@ -11664,8 +11619,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                }
                                FOREACH_AFI_SAFI (afi, safi) {
                                        if (CHECK_FLAG(
-                                               p->af_sflags[afi][safi],
-                                               PEER_STATUS_EOR_RECEIVED)) {
+                                                   p->af_sflags[afi][safi],
+                                                   PEER_STATUS_EOR_RECEIVED)) {
                                                json_object_boolean_true_add(
                                                        json_grace_recv,
                                                        get_afi_safi_str(afi,
@@ -11675,12 +11630,10 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                        }
                                }
                        }
-                       json_object_object_add(json_grace,
-                                               "endOfRibSend",
-                                                       json_grace_send);
-                       json_object_object_add(json_grace,
-                                               "endOfRibRecv",
-                                               json_grace_recv);
+                       json_object_object_add(json_grace, "endOfRibSend",
+                                              json_grace_send);
+                       json_object_object_add(json_grace, "endOfRibRecv",
+                                              json_grace_recv);
 
 
                        if (p->t_gr_restart)
@@ -11699,13 +11652,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                                * 1000);
                        /* more gr info in new format */
                        BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json,
-                                                       json_grace);
+                                                   json_grace);
                        json_object_object_add(
                                json_neigh, "gracefulRestartInfo", json_grace);
                } else {
                        vty_out(vty, "  Graceful restart informations:\n");
-                       if ((p->status == Established) &&
-                               CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
+                       if ((p->status == Established)
+                           && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
 
                                vty_out(vty, "    End-of-RIB send: ");
                                FOREACH_AFI_SAFI (afi, safi) {
@@ -11714,9 +11667,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                                vty_out(vty, "%s%s",
                                                        eor_send_af_count ? ", "
                                                                          : "",
-                                                       get_afi_safi_str(afi,
-                                                                       safi,
-                                                                       false));
+                                                       get_afi_safi_str(
+                                                               afi, safi,
+                                                               false));
                                                eor_send_af_count++;
                                        }
                                }
@@ -12168,12 +12121,11 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
        }
 }
 
-static int bgp_show_neighbor_graceful_restart(struct vty *vty,
-                                       struct bgp *bgp,
-                                       enum show_type type,
-                                       union sockunion *su,
-                                       const char *conf_if, afi_t afi,
-                                       bool use_json, json_object *json)
+static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
+                                             enum show_type type,
+                                             union sockunion *su,
+                                             const char *conf_if, afi_t afi,
+                                             bool use_json, json_object *json)
 {
        struct listnode *node, *nnode;
        struct peer *peer;
@@ -12194,35 +12146,34 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty,
 
                if (type == show_all) {
                        bgp_show_peer_gr_status(vty, peer, use_json,
-                                                       json_neighbor);
+                                               json_neighbor);
 
                        if (use_json)
-                               json_object_object_add(json,
-                                               peer->host, json_neighbor);
+                               json_object_object_add(json, peer->host,
+                                                      json_neighbor);
 
                } else if (type == show_peer) {
                        if (conf_if) {
                                if ((peer->conf_if
-                                       && !strcmp(peer->conf_if, conf_if))
-                                       || (peer->hostname
+                                    && !strcmp(peer->conf_if, conf_if))
+                                   || (peer->hostname
                                        && !strcmp(peer->hostname, conf_if))) {
                                        find = 1;
-                                       bgp_show_peer_gr_status(vty,
-                                               peer, use_json,
-                                               json_neighbor);
+                                       bgp_show_peer_gr_status(vty, peer,
+                                                               use_json,
+                                                               json_neighbor);
                                }
                        } else {
                                if (sockunion_same(&peer->su, su)) {
                                        find = 1;
-                                       bgp_show_peer_gr_status(vty,
-                                               peer, use_json,
-                                               json_neighbor);
+                                       bgp_show_peer_gr_status(vty, peer,
+                                                               use_json,
+                                                               json_neighbor);
                                }
                        }
-                       if (use_json && find) {
-                               json_object_object_add(json,
-                                               peer->host, json_neighbor);
-                       }
+                       if (use_json && find)
+                               json_object_object_add(json, peer->host,
+                                                      json_neighbor);
                }
 
                if (find)
@@ -12231,14 +12182,14 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty,
 
        if (type == show_peer && !find) {
                if (use_json)
-                       json_object_boolean_true_add(json,
-                                                       "bgpNoSuchNeighbor");
+                       json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
                else
                        vty_out(vty, "%% No such neighbor\n");
        }
        if (use_json) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                                            json, JSON_C_TO_STRING_PRETTY));
+               vty_out(vty, "%s\n",
+                       json_object_to_json_string_ext(
+                               json, JSON_C_TO_STRING_PRETTY));
        } else {
                vty_out(vty, "\n");
        }
@@ -12351,9 +12302,10 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
        return CMD_SUCCESS;
 }
 
-static void  bgp_show_neighbor_graceful_restart_vty(struct vty *vty,
-                                enum show_type type, const char *ip_str,
-                                afi_t afi, bool use_json)
+static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty,
+                                                  enum show_type type,
+                                                  const char *ip_str,
+                                                  afi_t afi, bool use_json)
 {
 
        int ret;
@@ -12363,32 +12315,27 @@ static void  bgp_show_neighbor_graceful_restart_vty(struct vty *vty,
 
        bgp = bgp_get_default();
 
-       if (bgp) {
-
-               if (!use_json) {
-                       bgp_show_global_graceful_restart_mode_vty(vty, bgp,
-                                               use_json, NULL);
-               }
+       if (!bgp)
+               return;
 
-               json = json_object_new_object();
-               if (ip_str) {
-                       ret = str2sockunion(ip_str, &su);
-                       if (ret < 0)
-                               bgp_show_neighbor_graceful_restart(vty,
-                                       bgp, type, NULL, ip_str,
-                                       afi, use_json, json);
-                       else
-                               bgp_show_neighbor_graceful_restart(vty,
-                                       bgp, type, &su, NULL,
-                                       afi, use_json, json);
-               } else {
-                       bgp_show_neighbor_graceful_restart(vty, bgp,
-                                       type, NULL, NULL, afi,
-                                       use_json, json);
-               }
-               json_object_free(json);
-       }
+       if (!use_json)
+               bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json,
+                                                         NULL);
 
+       json = json_object_new_object();
+       if (ip_str) {
+               ret = str2sockunion(ip_str, &su);
+               if (ret < 0)
+                       bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL,
+                                                          ip_str, afi,
+                                                          use_json, json);
+               else
+                       bgp_show_neighbor_graceful_restart(
+                               vty, bgp, type, &su, NULL, afi, use_json, json);
+       } else
+               bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL,
+                                                  afi, use_json, json);
+       json_object_free(json);
 }
 
 static void bgp_show_all_instances_neighbors_vty(struct vty *vty,
@@ -12551,7 +12498,7 @@ DEFUN (show_ip_bgp_neighbors_gracrful_restart,
        afi_t afi = AFI_MAX;
        bool uj = use_json(argc, argv);
 
-       if      (!argv_find_and_parse_afi(argv, argc, &idx, &afi))
+       if (!argv_find_and_parse_afi(argv, argc, &idx, &afi))
                afi = AFI_MAX;
 
        idx++;
@@ -12568,9 +12515,8 @@ DEFUN (show_ip_bgp_neighbors_gracrful_restart,
                return CMD_SUCCESS;
 
 
-       return bgp_show_neighbor_graceful_restart_afi_all(vty,
-                                               sh_type, sh_arg,
-                                               afi, uj);
+       return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg,
+                                                         afi, uj);
 }
 
 /* "show [ip] bgp neighbors" commands.  */
@@ -12714,35 +12660,31 @@ DEFUN (show_ip_bgp_lcommunity_info,
 /* Graceful Restart */
 
 static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty,
-                                       struct bgp *bgp,
-                                       bool use_json,
-                                       json_object *json)
+                                                     struct bgp *bgp,
+                                                     bool use_json,
+                                                     json_object *json)
 {
 
 
        vty_out(vty, "\n%s", SHOW_GR_HEADER);
 
-       int bgp_global_gr_mode = bgp_global_gr_mode_get(bgp);
+       enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp);
 
        switch (bgp_global_gr_mode) {
 
        case GLOBAL_HELPER:
-               vty_out(vty,
-                               "Global BGP GR Mode :  Helper\n");
+               vty_out(vty, "Global BGP GR Mode :  Helper\n");
                break;
 
        case GLOBAL_GR:
-               vty_out(vty,
-                       "Global BGP GR Mode :  Restart\n");
+               vty_out(vty, "Global BGP GR Mode :  Restart\n");
                break;
 
        case GLOBAL_DISABLE:
-               vty_out(vty,
-                               "Global BGP GR Mode :  Disable\n");
+               vty_out(vty, "Global BGP GR Mode :  Disable\n");
                break;
 
        case GLOBAL_INVALID:
-       default:
                vty_out(vty,
                        "Global BGP GR Mode  Invalid\n");
                break;
@@ -12750,26 +12692,23 @@ static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty,
        vty_out(vty, "\n");
 }
 
-static int  bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty,
-                                               enum show_type type,
-                                               const char *ip_str,
-                                               afi_t afi,
-                                               bool use_json)
+static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty,
+                                                     enum show_type type,
+                                                     const char *ip_str,
+                                                     afi_t afi, bool use_json)
 {
        if ((afi == AFI_MAX) && (ip_str == NULL)) {
                afi = AFI_IP;
 
                while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) {
 
-                       bgp_show_neighbor_graceful_restart_vty(vty,
-                                                       type, ip_str,
-                                                       afi, use_json);
+                       bgp_show_neighbor_graceful_restart_vty(
+                               vty, type, ip_str, afi, use_json);
                        afi++;
                }
        } else if (afi != AFI_MAX) {
-               bgp_show_neighbor_graceful_restart_vty(vty,
-                                                       type, ip_str,
-                                                       afi, use_json);
+               bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi,
+                                                      use_json);
        } else {
                return CMD_ERR_INCOMPLETE;
        }
@@ -14606,23 +14545,25 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
                        addr);
 
        if (!CHECK_FLAG(peer->peer_gr_new_status_flag,
-               PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) {
+                       PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) {
 
                if (CHECK_FLAG(peer->peer_gr_new_status_flag,
-                               PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) {
+                              PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) {
                        vty_out(vty,
                                " neighbor %s graceful-restart-helper\n", addr);
-               } else if (CHECK_FLAG(peer->peer_gr_new_status_flag,
-                               PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) {
+               } else if (CHECK_FLAG(
+                                  peer->peer_gr_new_status_flag,
+                                  PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) {
                        vty_out(vty,
                                " neighbor %s graceful-restart\n", addr);
-               } else if ((!(CHECK_FLAG(peer->peer_gr_new_status_flag,
-                               PEER_GRACEFUL_RESTART_NEW_STATE_HELPER))
-                               && !(CHECK_FLAG(peer->peer_gr_new_status_flag,
-                               PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) {
-                       vty_out(vty,
-                               " neighbor %s graceful-restart-disable\n",
-                                       addr);
+               } else if (
+                       (!(CHECK_FLAG(peer->peer_gr_new_status_flag,
+                                     PEER_GRACEFUL_RESTART_NEW_STATE_HELPER))
+                        && !(CHECK_FLAG(
+                                peer->peer_gr_new_status_flag,
+                                PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) {
+                       vty_out(vty, " neighbor %s graceful-restart-disable\n",
+                               addr);
                }
        }
 }
@@ -14664,8 +14605,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
        } else {
                if (peer->afc[afi][safi]) {
                        if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
-                               if (bgp_flag_check(bgp,
-                                                  BGP_FLAG_NO_DEFAULT_IPV4)) {
+                               if (CHECK_FLAG(bgp->flags,
+                                              BGP_FLAG_NO_DEFAULT_IPV4)) {
                                        vty_out(vty, "  neighbor %s activate\n",
                                                addr);
                                }
@@ -14673,8 +14614,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
                                vty_out(vty, "  neighbor %s activate\n", addr);
                } else {
                        if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
-                               if (!bgp_flag_check(bgp,
-                                                   BGP_FLAG_NO_DEFAULT_IPV4)) {
+                               if (!CHECK_FLAG(bgp->flags,
+                                               BGP_FLAG_NO_DEFAULT_IPV4)) {
                                        vty_out(vty,
                                                "  no neighbor %s activate\n",
                                                addr);
@@ -15035,16 +14976,16 @@ int bgp_config_write(struct vty *vty)
                                inet_ntoa(bgp->router_id_static));
 
                /* BGP log-neighbor-changes. */
-               if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
+               if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
                    != SAVE_BGP_LOG_NEIGHBOR_CHANGES)
                        vty_out(vty, " %sbgp log-neighbor-changes\n",
-                               bgp_flag_check(bgp,
-                                              BGP_FLAG_LOG_NEIGHBOR_CHANGES)
+                               CHECK_FLAG(bgp->flags,
+                                          BGP_FLAG_LOG_NEIGHBOR_CHANGES)
                                        ? ""
                                        : "no ");
 
                /* BGP configuration. */
-               if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED))
                        vty_out(vty, " bgp always-compare-med\n");
 
                /* RFC8212 default eBGP policy. */
@@ -15057,7 +14998,7 @@ int bgp_config_write(struct vty *vty)
                        vty_out(vty, " bgp reject-as-sets\n");
 
                /* BGP default ipv4-unicast. */
-               if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4))
                        vty_out(vty, " no bgp default ipv4-unicast\n");
 
                /* BGP default local-preference. */
@@ -15066,10 +15007,10 @@ int bgp_config_write(struct vty *vty)
                                bgp->default_local_pref);
 
                /* BGP default show-hostname */
-               if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)
+               if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
                    != SAVE_BGP_SHOW_HOSTNAME)
                        vty_out(vty, " %sbgp default show-hostname\n",
-                               bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)
+                               CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
                                        ? ""
                                        : "no ");
 
@@ -15080,7 +15021,7 @@ int bgp_config_write(struct vty *vty)
                                bgp->default_subgroup_pkt_queue_max);
 
                /* BGP client-to-client reflection. */
-               if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT))
                        vty_out(vty, " no bgp client-to-client reflection\n");
 
                /* BGP cluster ID. */
@@ -15089,7 +15030,7 @@ int bgp_config_write(struct vty *vty)
                                inet_ntoa(bgp->cluster_id));
 
                /* Disable ebgp connected nexthop check */
-               if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
                        vty_out(vty,
                                " bgp disable-ebgp-connected-route-check\n");
 
@@ -15111,10 +15052,11 @@ int bgp_config_write(struct vty *vty)
                }
 
                /* BGP deterministic-med. */
-               if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)
+               if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)
                    != SAVE_BGP_DETERMINISTIC_MED)
                        vty_out(vty, " %sbgp deterministic-med\n",
-                               bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)
+                               CHECK_FLAG(bgp->flags,
+                                          BGP_FLAG_DETERMINISTIC_MED)
                                        ? ""
                                        : "no ");
 
@@ -15168,11 +15110,11 @@ int bgp_config_write(struct vty *vty)
                        vty_out(vty, " bgp graceful-restart-disable\n");
 
                /* BGP graceful-shutdown */
-               if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
                        vty_out(vty, " bgp graceful-shutdown\n");
 
                /* BGP graceful-restart Preserve State F bit. */
-               if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD))
                        vty_out(vty,
                                " bgp graceful-restart preserve-fw-state\n");
 
@@ -15183,14 +15125,14 @@ int bgp_config_write(struct vty *vty)
                                bgp->rib_stale_time);
 
                /* BGP bestpath method. */
-               if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE))
                        vty_out(vty, " bgp bestpath as-path ignore\n");
-               if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED))
                        vty_out(vty, " bgp bestpath as-path confed\n");
 
-               if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
-                       if (bgp_flag_check(bgp,
-                                          BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+                       if (CHECK_FLAG(bgp->flags,
+                                      BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
                                vty_out(vty,
                                        " bgp bestpath as-path multipath-relax as-set\n");
                        } else {
@@ -15199,27 +15141,28 @@ int bgp_config_write(struct vty *vty)
                        }
                }
 
-               if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
                        vty_out(vty,
                                " bgp route-reflector allow-outbound-policy\n");
                }
-               if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID))
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID))
                        vty_out(vty, " bgp bestpath compare-routerid\n");
-               if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)
-                   || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) {
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)
+                   || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) {
                        vty_out(vty, " bgp bestpath med");
-                       if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED))
+                       if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED))
                                vty_out(vty, " confed");
-                       if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+                       if (CHECK_FLAG(bgp->flags,
+                                      BGP_FLAG_MED_MISSING_AS_WORST))
                                vty_out(vty, " missing-as-worst");
                        vty_out(vty, "\n");
                }
 
                /* BGP network import check. */
-               if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+               if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
                    != SAVE_BGP_IMPORT_CHECK)
                        vty_out(vty, " %sbgp network import-check\n",
-                               bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+                               CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
                                        ? ""
                                        : "no ");
 
@@ -15551,22 +15494,16 @@ void bgp_vty_init(void)
        install_element(BGP_NODE, &no_bgp_deterministic_med_cmd);
 
        /* "bgp graceful-restart" command */
-       install_element(BGP_NODE,
-                       &bgp_graceful_restart_cmd);
-       install_element(BGP_NODE,
-                       &no_bgp_graceful_restart_cmd);
+       install_element(BGP_NODE, &bgp_graceful_restart_cmd);
+       install_element(BGP_NODE, &no_bgp_graceful_restart_cmd);
 
        /* "bgp graceful-restart-disable" command */
-       install_element(BGP_NODE,
-                       &bgp_graceful_restart_disable_cmd);
-       install_element(BGP_NODE,
-                       &no_bgp_graceful_restart_disable_cmd);
+       install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd);
+       install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd);
 
        /* "neighbor a:b:c:d graceful-restart" command */
-       install_element(BGP_NODE,
-                       &bgp_neighbor_graceful_restart_set_cmd);
-       install_element(BGP_NODE,
-                       &no_bgp_neighbor_graceful_restart_set_cmd);
+       install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd);
+       install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd);
 
        /* "neighbor a:b:c:d graceful-restart-disable" command */
        install_element(BGP_NODE,
@@ -16589,8 +16526,7 @@ void bgp_vty_init(void)
        /* "show [ip] bgp neighbors" commands. */
        install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd);
 
-       install_element(VIEW_NODE,
-                       &show_ip_bgp_neighbors_graceful_restart_cmd);
+       install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd);
 
        /* "show [ip] bgp peer-group" commands. */
        install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
@@ -16753,21 +16689,29 @@ static void community_list_perror(struct vty *vty, int ret)
 /*community-list standard */
 DEFUN (community_list_standard,
        bgp_community_list_standard_cmd,
-       "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
+       "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        BGP_STR
        COMMUNITY_LIST_STR
        "Community list number (standard)\n"
        "Add an standard community-list entry\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
 {
        char *cl_name_or_number = NULL;
+       char *seq = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_STANDARD;
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
        argv_find(argv, argc, "(1-99)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
@@ -16776,8 +16720,8 @@ DEFUN (community_list_standard,
        argv_find(argv, argc, "AA:NN", &idx);
        char *str = argv_concat(argv, argc, idx);
 
-       int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct,
-                                    style);
+       int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq,
+                                    direct, style);
 
        XFREE(MTYPE_TMP, str);
 
@@ -16792,13 +16736,15 @@ DEFUN (community_list_standard,
 
 DEFUN (no_community_list_standard_all,
        no_bgp_community_list_standard_all_cmd,
-       "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
+       "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        NO_STR
        BGP_STR
        COMMUNITY_LIST_STR
        "Community list number (standard)\n"
        "Add an standard community-list entry\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
@@ -16807,9 +16753,14 @@ DEFUN (no_community_list_standard_all,
        char *str = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_STANDARD;
-
+       char *seq = NULL;
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
        argv_find(argv, argc, "permit", &idx);
        argv_find(argv, argc, "deny", &idx);
 
@@ -16828,7 +16779,7 @@ DEFUN (no_community_list_standard_all,
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
 
-       int ret = community_list_unset(bgp_clist, cl_name_or_number, str,
+       int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq,
                                       direct, style);
 
        XFREE(MTYPE_TMP, str);
@@ -16851,22 +16802,30 @@ ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cm
 /*community-list expanded */
 DEFUN (community_list_expanded_all,
        bgp_community_list_expanded_all_cmd,
-       "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
+       "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        BGP_STR
        COMMUNITY_LIST_STR
        "Community list number (expanded)\n"
        "Add an expanded community-list entry\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
 {
        char *cl_name_or_number = NULL;
+       char *seq = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_EXPANDED;
-
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
+
        argv_find(argv, argc, "(100-500)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
@@ -16875,8 +16834,8 @@ DEFUN (community_list_expanded_all,
        argv_find(argv, argc, "AA:NN", &idx);
        char *str = argv_concat(argv, argc, idx);
 
-       int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct,
-                                    style);
+       int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq,
+                                    direct, style);
 
        XFREE(MTYPE_TMP, str);
 
@@ -16891,24 +16850,31 @@ DEFUN (community_list_expanded_all,
 
 DEFUN (no_community_list_expanded_all,
        no_bgp_community_list_expanded_all_cmd,
-       "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
+       "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        NO_STR
        BGP_STR
        COMMUNITY_LIST_STR
        "Community list number (expanded)\n"
        "Add an expanded community-list entry\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        COMMUNITY_VAL_STR)
 {
        char *cl_name_or_number = NULL;
+       char *seq = NULL;
        char *str = NULL;
        int direct = 0;
        int style = COMMUNITY_LIST_EXPANDED;
-
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
        argv_find(argv, argc, "permit", &idx);
        argv_find(argv, argc, "deny", &idx);
 
@@ -16927,7 +16893,7 @@ DEFUN (no_community_list_expanded_all,
        argv_find(argv, argc, "WORD", &idx);
        cl_name_or_number = argv[idx]->arg;
 
-       int ret = community_list_unset(bgp_clist, cl_name_or_number, str,
+       int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq,
                                       direct, style);
 
        XFREE(MTYPE_TMP, str);
@@ -17054,7 +17020,13 @@ static int lcommunity_list_set_vty(struct vty *vty, int argc,
        char *str;
        int idx = 0;
        char *cl_name;
+       char *seq = NULL;
+
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
 
+       idx = 0;
        direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
                                                       : COMMUNITY_DENY;
 
@@ -17078,7 +17050,7 @@ static int lcommunity_list_set_vty(struct vty *vty, int argc,
        else
                str = NULL;
 
-       ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style);
+       ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style);
 
        /* Free temporary community list string allocated by
           argv_concat().  */
@@ -17098,7 +17070,13 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc,
        int direct = 0;
        char *str = NULL;
        int idx = 0;
+       char *seq = NULL;
+
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
 
+       idx = 0;
        argv_find(argv, argc, "permit", &idx);
        argv_find(argv, argc, "deny", &idx);
 
@@ -17122,7 +17100,7 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc,
        argv_find(argv, argc, "WORD", &idx);
 
        /* Unset community list.  */
-       ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct,
+       ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct,
                                    style);
 
        /* Free temporary community list string allocated by
@@ -17143,10 +17121,12 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc,
 
 DEFUN (lcommunity_list_standard,
        bgp_lcommunity_list_standard_cmd,
-       "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
+       "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Large Community list number (standard)\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        LCOMMUNITY_VAL_STR)
@@ -17157,10 +17137,12 @@ DEFUN (lcommunity_list_standard,
 
 DEFUN (lcommunity_list_expanded,
        bgp_lcommunity_list_expanded_cmd,
-       "bgp large-community-list (100-500) <deny|permit> LINE...",
+       "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Large Community list number (expanded)\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17171,11 +17153,13 @@ DEFUN (lcommunity_list_expanded,
 
 DEFUN (lcommunity_list_name_standard,
        bgp_lcommunity_list_name_standard_cmd,
-       "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
+       "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Specify standard large-community-list\n"
        "Large Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        LCOMMUNITY_VAL_STR)
@@ -17186,11 +17170,13 @@ DEFUN (lcommunity_list_name_standard,
 
 DEFUN (lcommunity_list_name_expanded,
        bgp_lcommunity_list_name_expanded_cmd,
-       "bgp large-community-list expanded WORD <deny|permit> LINE...",
+       "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Specify expanded large-community-list\n"
        "Large Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17199,8 +17185,8 @@ DEFUN (lcommunity_list_name_expanded,
                                       LARGE_COMMUNITY_LIST_EXPANDED, 1);
 }
 
-DEFUN (no_lcommunity_list_standard_all,
-       no_bgp_lcommunity_list_standard_all_cmd,
+DEFUN (no_lcommunity_list_all,
+       no_bgp_lcommunity_list_all_cmd,
        "no bgp large-community-list <(1-99)|(100-500)|WORD>",
        NO_STR
        BGP_STR
@@ -17213,6 +17199,19 @@ DEFUN (no_lcommunity_list_standard_all,
                                         LARGE_COMMUNITY_LIST_STANDARD);
 }
 
+DEFUN (no_lcommunity_list_name_standard_all,
+       no_bgp_lcommunity_list_name_standard_all_cmd,
+       "no bgp large-community-list standard WORD",
+       NO_STR
+       BGP_STR
+       LCOMMUNITY_LIST_STR
+       "Specify standard large-community-list\n"
+       "Large Community list name\n")
+{
+       return lcommunity_list_unset_vty(vty, argc, argv,
+                                        LARGE_COMMUNITY_LIST_STANDARD);
+}
+
 DEFUN (no_lcommunity_list_name_expanded_all,
        no_bgp_lcommunity_list_name_expanded_all_cmd,
        "no bgp large-community-list expanded WORD",
@@ -17228,11 +17227,13 @@ DEFUN (no_lcommunity_list_name_expanded_all,
 
 DEFUN (no_lcommunity_list_standard,
        no_bgp_lcommunity_list_standard_cmd,
-       "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
+       "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
        NO_STR
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Large Community list number (standard)\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        LCOMMUNITY_VAL_STR)
@@ -17243,11 +17244,13 @@ DEFUN (no_lcommunity_list_standard,
 
 DEFUN (no_lcommunity_list_expanded,
        no_bgp_lcommunity_list_expanded_cmd,
-       "no bgp large-community-list (100-500) <deny|permit> LINE...",
+       "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
        NO_STR
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Large Community list number (expanded)\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17258,12 +17261,14 @@ DEFUN (no_lcommunity_list_expanded,
 
 DEFUN (no_lcommunity_list_name_standard,
        no_bgp_lcommunity_list_name_standard_cmd,
-       "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
+       "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
        NO_STR
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Specify standard large-community-list\n"
        "Large Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        LCOMMUNITY_VAL_STR)
@@ -17274,12 +17279,14 @@ DEFUN (no_lcommunity_list_name_standard,
 
 DEFUN (no_lcommunity_list_name_expanded,
        no_bgp_lcommunity_list_name_expanded_cmd,
-       "no bgp large-community-list expanded WORD <deny|permit> LINE...",
+       "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
        NO_STR
        BGP_STR
        LCOMMUNITY_LIST_STR
        "Specify expanded large-community-list\n"
        "Large community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify large community to reject\n"
        "Specify large community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17374,12 +17381,14 @@ DEFUN (show_lcommunity_list_arg,
 
 DEFUN (extcommunity_list_standard,
        bgp_extcommunity_list_standard_cmd,
-       "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
+       "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        BGP_STR
        EXTCOMMUNITY_LIST_STR
        "Extended Community list number (standard)\n"
        "Specify standard extcommunity-list\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        EXTCOMMUNITY_VAL_STR)
@@ -17387,18 +17396,24 @@ DEFUN (extcommunity_list_standard,
        int style = EXTCOMMUNITY_LIST_STANDARD;
        int direct = 0;
        char *cl_number_or_name = NULL;
+       char *seq = NULL;
 
        int idx = 0;
 
        argv_find(argv, argc, "(1-99)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_number_or_name = argv[idx]->arg;
+
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
        direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
                                                       : COMMUNITY_DENY;
        argv_find(argv, argc, "AA:NN", &idx);
        char *str = argv_concat(argv, argc, idx);
 
-       int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str,
+       int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq,
                                        direct, style);
 
        XFREE(MTYPE_TMP, str);
@@ -17413,12 +17428,14 @@ DEFUN (extcommunity_list_standard,
 
 DEFUN (extcommunity_list_name_expanded,
        bgp_extcommunity_list_name_expanded_cmd,
-       "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
+       "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
        BGP_STR
        EXTCOMMUNITY_LIST_STR
        "Extended Community list number (expanded)\n"
        "Specify expanded extcommunity-list\n"
        "Extended Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17426,17 +17443,23 @@ DEFUN (extcommunity_list_name_expanded,
        int style = EXTCOMMUNITY_LIST_EXPANDED;
        int direct = 0;
        char *cl_number_or_name = NULL;
+       char *seq = NULL;
        int idx = 0;
 
        argv_find(argv, argc, "(100-500)", &idx);
        argv_find(argv, argc, "WORD", &idx);
        cl_number_or_name = argv[idx]->arg;
+
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
        direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT
                                                       : COMMUNITY_DENY;
        argv_find(argv, argc, "LINE", &idx);
        char *str = argv_concat(argv, argc, idx);
 
-       int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str,
+       int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq,
                                        direct, style);
 
        XFREE(MTYPE_TMP, str);
@@ -17451,13 +17474,15 @@ DEFUN (extcommunity_list_name_expanded,
 
 DEFUN (no_extcommunity_list_standard_all,
        no_bgp_extcommunity_list_standard_all_cmd,
-       "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
+       "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
        NO_STR
        BGP_STR
        EXTCOMMUNITY_LIST_STR
        "Extended Community list number (standard)\n"
        "Specify standard extcommunity-list\n"
        "Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        EXTCOMMUNITY_VAL_STR)
@@ -17466,11 +17491,16 @@ DEFUN (no_extcommunity_list_standard_all,
        int direct = 0;
        char *cl_number_or_name = NULL;
        char *str = NULL;
+       char *seq = NULL;
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
        argv_find(argv, argc, "permit", &idx);
        argv_find(argv, argc, "deny", &idx);
-
        if (idx) {
                direct = argv_find(argv, argc, "permit", &idx)
                                 ? COMMUNITY_PERMIT
@@ -17487,7 +17517,7 @@ DEFUN (no_extcommunity_list_standard_all,
        cl_number_or_name = argv[idx]->arg;
 
        int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str,
-                                         direct, style);
+                                         seq, direct, style);
 
        XFREE(MTYPE_TMP, str);
 
@@ -17509,13 +17539,15 @@ ALIAS(no_extcommunity_list_standard_all,
 
 DEFUN (no_extcommunity_list_expanded_all,
        no_bgp_extcommunity_list_expanded_all_cmd,
-       "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
+       "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
        NO_STR
        BGP_STR
        EXTCOMMUNITY_LIST_STR
        "Extended Community list number (expanded)\n"
        "Specify expanded extcommunity-list\n"
        "Extended Community list name\n"
+       "Sequence number of an entry\n"
+       "Sequence number\n"
        "Specify community to reject\n"
        "Specify community to accept\n"
        "An ordered list as a regular-expression\n")
@@ -17524,8 +17556,14 @@ DEFUN (no_extcommunity_list_expanded_all,
        int direct = 0;
        char *cl_number_or_name = NULL;
        char *str = NULL;
+       char *seq = NULL;
        int idx = 0;
 
+       argv_find(argv, argc, "(1-4294967295)", &idx);
+       if (idx)
+               seq = argv[idx]->arg;
+
+       idx = 0;
        argv_find(argv, argc, "permit", &idx);
        argv_find(argv, argc, "deny", &idx);
 
@@ -17545,7 +17583,7 @@ DEFUN (no_extcommunity_list_expanded_all,
        cl_number_or_name = argv[idx]->arg;
 
        int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str,
-                                         direct, style);
+                                         seq, direct, style);
 
        XFREE(MTYPE_TMP, str);
 
@@ -17656,18 +17694,22 @@ static int community_list_config_write(struct vty *vty)
 
        for (list = cm->num.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp community-list %s %s %s\n", list->name,
+                       vty_out(vty,
+                               "bgp community-list %s seq %" PRId64 " %s %s\n",
+                               list->name, entry->seq,
                                community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
        for (list = cm->str.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp community-list %s %s %s %s\n",
+                       vty_out(vty,
+                               "bgp community-list %s %s seq %" PRId64 " %s %s\n",
                                entry->style == COMMUNITY_LIST_STANDARD
                                        ? "standard"
                                        : "expanded",
-                               list->name, community_direct_str(entry->direct),
+                               list->name, entry->seq,
+                               community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
@@ -17677,18 +17719,23 @@ static int community_list_config_write(struct vty *vty)
 
        for (list = cm->num.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp extcommunity-list %s %s %s\n",
-                               list->name, community_direct_str(entry->direct),
+                       vty_out(vty,
+                               "bgp extcommunity-list %s seq %" PRId64 " %s %s\n",
+                               list->name, entry->seq,
+                               community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
        for (list = cm->str.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp extcommunity-list %s %s %s %s\n",
+                       vty_out(vty,
+                               "bgp extcommunity-list %s %s seq %" PRId64
+                               " %s %s\n",
                                entry->style == EXTCOMMUNITY_LIST_STANDARD
                                        ? "standard"
                                        : "expanded",
-                               list->name, community_direct_str(entry->direct),
+                               list->name, entry->seq,
+                               community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
@@ -17700,18 +17747,24 @@ static int community_list_config_write(struct vty *vty)
 
        for (list = cm->num.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp large-community-list %s %s %s\n",
-                               list->name, community_direct_str(entry->direct),
+                       vty_out(vty,
+                               "bgp large-community-list %s seq %" PRId64
+                               " %s %s\n",
+                               list->name, entry->seq,
+                               community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
        for (list = cm->str.head; list; list = list->next)
                for (entry = list->head; entry; entry = entry->next) {
-                       vty_out(vty, "bgp large-community-list %s %s %s %s\n",
+                       vty_out(vty,
+                               "bgp large-community-list %s %s seq %" PRId64
+                               " %s %s\n",
+
                                entry->style == LARGE_COMMUNITY_LIST_STANDARD
                                        ? "standard"
                                        : "expanded",
-                               list->name, community_direct_str(entry->direct),
+                               list->name, entry->seq, community_direct_str(entry->direct),
                                community_list_config_str(entry));
                        write++;
                }
@@ -17754,7 +17807,9 @@ static void community_list_vty(void)
        install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd);
        install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd);
        install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd);
-       install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd);
+       install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd);
+       install_element(CONFIG_NODE,
+                       &no_bgp_lcommunity_list_name_standard_all_cmd);
        install_element(CONFIG_NODE,
                        &no_bgp_lcommunity_list_name_expanded_all_cmd);
        install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd);