]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Add a couple functions to nexthop_group.c (#4323)
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 3 Jul 2019 12:42:35 +0000 (14:42 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Jul 2019 12:42:35 +0000 (14:42 +0200)
lib: Add a couple functions to nexthop_group.c

Co-authored-by: Donald Sharp <sharpd@cumulusnetworks.com>
58 files changed:
bgpd/bgp_mplsvpn.c
bgpd/bgp_mplsvpn.h
bgpd/bgp_nht.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_updgrp.c
bgpd/bgp_vty.c
bgpd/bgpd.c
doc/user/basic.rst
eigrpd/eigrp_const.h
fpm/fpm.h
lib/command.h
lib/libfrr.c
lib/linklist.h
lib/log.c
lib/log.h
lib/log_vty.c [new file with mode: 0644]
lib/log_vty.h [new file with mode: 0644]
lib/memory_vty.c
lib/northbound.c
lib/subdir.am
lib/table.h
ospfd/ospf_spf.c
ospfd/ospf_vty.c
ospfd/ospfd.c
pimd/pim_assert.c
pimd/pim_bsm.c
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pim_ifchannel.c
pimd/pim_igmp.c
pimd/pim_macro.c
pimd/pim_register.c
pimd/pim_rpf.c
pimd/pim_upstream.c
pimd/pim_vxlan.c
ripd/rip_cli.c
staticd/static_nht.c
tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py
tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py
tests/topotests/bgp_multiview_topo1/README.md
tests/topotests/lib/lutil.py
tests/topotests/lib/topotest.py
tests/topotests/ospf6-topo1/README.md
vtysh/vtysh.c
vtysh/vtysh_user.c
zebra/interface.h
zebra/irdp.h
zebra/irdp_interface.c
zebra/redistribute.c
zebra/redistribute.h
zebra/rib.h
zebra/rt_netlink.c
zebra/zebra_fpm.c
zebra/zebra_fpm_netlink.c
zebra/zebra_rib.c
zebra/zebra_rnh.c
zebra/zebra_vty.c

index 355bc93320f1e110f1f2df0695f0f729151306ba..1156810510d3c744ba416bd3702032b22412df6a 100644 (file)
@@ -1614,11 +1614,13 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
 {
        const char *export_name;
        vpn_policy_direction_t idir, edir;
-       char *vname;
-       char buf[1000];
+       char *vname, *tmp_name;
+       char buf[RD_ADDRSTRLEN];
        struct ecommunity *ecom;
        bool first_export = false;
        int debug;
+       struct listnode *node;
+       bool is_inst_match = false;
 
        export_name = to_bgp->name ? to_bgp->name : VRF_DEFAULT_NAME;
        idir = BGP_VPN_POLICY_DIR_FROMVPN;
@@ -1634,13 +1636,41 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
        vname = (from_bgp->name ? XSTRDUP(MTYPE_TMP, from_bgp->name)
                               : XSTRDUP(MTYPE_TMP, VRF_DEFAULT_NAME));
 
-       listnode_add(to_bgp->vpn_policy[afi].import_vrf, vname);
+       /* Check the import_vrf list of destination vrf for the source vrf name,
+        * insert otherwise.
+        */
+       for (ALL_LIST_ELEMENTS_RO(to_bgp->vpn_policy[afi].import_vrf,
+                                 node, tmp_name)) {
+               if (strcmp(vname, tmp_name) == 0) {
+                       is_inst_match = true;
+                       break;
+               }
+       }
+       if (!is_inst_match)
+               listnode_add(to_bgp->vpn_policy[afi].import_vrf,
+                                    vname);
 
-       if (!listcount(from_bgp->vpn_policy[afi].export_vrf))
-               first_export = true;
+       /* Check if the source vrf already exports to any vrf,
+        * first time export requires to setup auto derived RD/RT values.
+        * Add the destination vrf name to export vrf list if it is
+        * not present.
+        */
+       is_inst_match = false;
        vname = XSTRDUP(MTYPE_TMP, export_name);
-       listnode_add(from_bgp->vpn_policy[afi].export_vrf, vname);
-
+       if (!listcount(from_bgp->vpn_policy[afi].export_vrf)) {
+               first_export = true;
+       } else {
+               for (ALL_LIST_ELEMENTS_RO(from_bgp->vpn_policy[afi].export_vrf,
+                                         node, tmp_name)) {
+                       if (strcmp(vname, tmp_name) == 0) {
+                               is_inst_match = true;
+                               break;
+                       }
+               }
+       }
+       if (!is_inst_match)
+               listnode_add(from_bgp->vpn_policy[afi].export_vrf,
+                            vname);
        /* Update import RT for current VRF using export RT of the VRF we're
         * importing from. First though, make sure "import_vrf" has that
         * set.
@@ -1702,7 +1732,7 @@ void vrf_unimport_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
        const char *export_name, *tmp_name;
        vpn_policy_direction_t idir, edir;
        char *vname;
-       struct ecommunity *ecom;
+       struct ecommunity *ecom = NULL;
        struct listnode *node;
        int debug;
 
@@ -1747,10 +1777,12 @@ void vrf_unimport_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
        if (to_bgp->vpn_policy[afi].import_vrf->count == 0) {
                UNSET_FLAG(to_bgp->af_flags[afi][safi],
                           BGP_CONFIG_VRF_TO_VRF_IMPORT);
-               ecommunity_free(&to_bgp->vpn_policy[afi].rtlist[idir]);
+               if (to_bgp->vpn_policy[afi].rtlist[idir])
+                       ecommunity_free(&to_bgp->vpn_policy[afi].rtlist[idir]);
        } else {
                ecom = from_bgp->vpn_policy[afi].rtlist[edir];
-               ecommunity_del_val(to_bgp->vpn_policy[afi].rtlist[idir],
+               if (ecom)
+                       ecommunity_del_val(to_bgp->vpn_policy[afi].rtlist[idir],
                                   (struct ecommunity_val *)ecom->val);
                vpn_leak_postchange(idir, afi, bgp_get_default(), to_bgp);
        }
@@ -1783,8 +1815,11 @@ void vrf_unimport_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
         *
         * import_vrf and export_vrf must match in having
         * the in/out names as appropriate.
+        * export_vrf list could have been cleaned up
+        * as part of no router bgp source instnace.
         */
-       assert(vname);
+       if (!vname)
+               return;
 
        listnode_delete(from_bgp->vpn_policy[afi].export_vrf, vname);
        XFREE(MTYPE_TMP, vname);
@@ -2471,3 +2506,167 @@ void vpn_leak_postchange_all(void)
                        bgp);
        }
 }
+
+/* When a bgp vrf instance is unconfigured, remove its routes
+ * from the VPN table and this vrf could be importing routes from other
+ * bgp vrf instnaces, unimport them.
+ * VRF X and VRF Y are exporting routes to each other.
+ * When VRF X is deleted, unimport its routes from all target vrfs,
+ * also VRF Y should unimport its routes from VRF X table.
+ * This will ensure VPN table is cleaned up appropriately.
+ */
+int bgp_vpn_leak_unimport(struct bgp *from_bgp, struct vty *vty)
+{
+       struct bgp *to_bgp;
+       const char *tmp_name;
+       char *vname;
+       struct listnode *node, *next;
+       safi_t safi = SAFI_UNICAST;
+       afi_t afi;
+       bool is_vrf_leak_bind;
+       int debug;
+
+       if (from_bgp->inst_type != BGP_INSTANCE_TYPE_VRF)
+               return 0;
+
+       debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) |
+                    BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF));
+
+       tmp_name = from_bgp->name ? from_bgp->name : VRF_DEFAULT_NAME;
+
+       for (afi = 0; afi < AFI_MAX; ++afi) {
+               /* vrf leak is for IPv4 and IPv6 Unicast only */
+               if (afi != AFI_IP && afi != AFI_IP6)
+                       continue;
+
+               for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, to_bgp)) {
+                       if (from_bgp == to_bgp)
+                               continue;
+
+                       /* Unimport and remove source vrf from the
+                        * other vrfs import list.
+                        */
+                       struct vpn_policy *to_vpolicy;
+
+                       is_vrf_leak_bind = false;
+                       to_vpolicy = &(to_bgp->vpn_policy[afi]);
+                       for (ALL_LIST_ELEMENTS_RO(to_vpolicy->import_vrf, node,
+                                                 vname)) {
+                               if (strcmp(vname, tmp_name) == 0) {
+                                       is_vrf_leak_bind = true;
+                                       break;
+                               }
+                       }
+                       /* skip this bgp instance as there is no leak to this
+                        * vrf instance.
+                        */
+                       if (!is_vrf_leak_bind)
+                               continue;
+
+                       if (debug)
+                               zlog_debug("%s: unimport routes from %s to_bgp %s afi %s import vrfs count %u",
+                                          __func__, from_bgp->name_pretty,
+                                          to_bgp->name_pretty, afi2str(afi),
+                                          to_vpolicy->import_vrf->count);
+
+                       vrf_unimport_from_vrf(to_bgp, from_bgp, afi, safi);
+
+                       /* readd vrf name as unimport removes import vrf name
+                        * from the destination vrf's import list where the
+                        * `import vrf` configuration still exist.
+                        */
+                       vname = XSTRDUP(MTYPE_TMP, tmp_name);
+                       listnode_add(to_bgp->vpn_policy[afi].import_vrf,
+                                    vname);
+                       SET_FLAG(to_bgp->af_flags[afi][safi],
+                                BGP_CONFIG_VRF_TO_VRF_IMPORT);
+
+                       /* If to_bgp exports its routes to the bgp vrf
+                        * which is being deleted, un-import the
+                        * to_bgp routes from VPN.
+                        */
+                       for (ALL_LIST_ELEMENTS_RO(to_bgp->vpn_policy[afi]
+                                                 .export_vrf, node,
+                                                 vname)) {
+                               if (strcmp(vname, tmp_name) == 0) {
+                                       vrf_unimport_from_vrf(from_bgp, to_bgp,
+                                                     afi, safi);
+                                       break;
+                               }
+                       }
+               }
+       }
+       return 0;
+}
+
+/* When a router bgp is configured, there could be a bgp vrf
+ * instance importing routes from this newly configured
+ * bgp vrf instance. Export routes from configured
+ * bgp vrf to VPN.
+ * VRF Y has import from bgp vrf x,
+ * when a bgp vrf x instance is created, export its routes
+ * to VRF Y instance.
+ */
+void bgp_vpn_leak_export(struct bgp *from_bgp)
+{
+       afi_t afi;
+       const char *export_name;
+       char *vname;
+       struct listnode *node, *next;
+       struct ecommunity *ecom;
+       vpn_policy_direction_t idir, edir;
+       safi_t safi = SAFI_UNICAST;
+       struct bgp *to_bgp;
+       int debug;
+
+       debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) |
+                    BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF));
+
+       idir = BGP_VPN_POLICY_DIR_FROMVPN;
+       edir = BGP_VPN_POLICY_DIR_TOVPN;
+
+       export_name = (from_bgp->name ? XSTRDUP(MTYPE_TMP, from_bgp->name)
+                              : XSTRDUP(MTYPE_TMP, VRF_DEFAULT_NAME));
+
+       for (afi = 0; afi < AFI_MAX; ++afi) {
+               /* vrf leak is for IPv4 and IPv6 Unicast only */
+               if (afi != AFI_IP && afi != AFI_IP6)
+                       continue;
+
+               for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, to_bgp)) {
+                       if (from_bgp == to_bgp)
+                               continue;
+
+                       /* bgp instance has import list, check to see if newly
+                        * configured bgp instance is the list.
+                        */
+                       struct vpn_policy *to_vpolicy;
+
+                       to_vpolicy = &(to_bgp->vpn_policy[afi]);
+                       for (ALL_LIST_ELEMENTS_RO(to_vpolicy->import_vrf,
+                                                 node, vname)) {
+                               if (strcmp(vname, export_name) != 0)
+                                       continue;
+
+                               if (debug)
+                                       zlog_debug("%s: found from_bgp %s in to_bgp %s import list, import routes.",
+                                          __func__,
+                                          export_name, to_bgp->name_pretty);
+
+                               ecom = from_bgp->vpn_policy[afi].rtlist[edir];
+                               /* remove import rt, it will be readded
+                                * as part of import from vrf.
+                                */
+                               if (ecom)
+                                       ecommunity_del_val(
+                                               to_vpolicy->rtlist[idir],
+                                               (struct ecommunity_val *)
+                                                       ecom->val);
+                               vrf_import_from_vrf(to_bgp, from_bgp,
+                                                   afi, safi);
+                               break;
+
+                       }
+               }
+       }
+}
index 2a6c0e17088419d3a276024ce62ad530a991a6b7..3234f7fc9db284559016a480c4a6a430200eea86 100644 (file)
@@ -266,5 +266,7 @@ extern vrf_id_t get_first_vrf_for_redirect_with_rt(struct ecommunity *eckey);
 extern void vpn_leak_postchange_all(void);
 extern void vpn_handle_router_id_update(struct bgp *bgp, bool withdraw,
                                        bool is_config);
+extern int bgp_vpn_leak_unimport(struct bgp *from_bgp, struct vty *vty);
+extern void bgp_vpn_leak_export(struct bgp *from_bgp);
 
 #endif /* _QUAGGA_BGP_MPLSVPN_H */
index fdfa15b445f76995d2f5989baf6e90663e114acc..74c45ed447686f3c01570b38dbbf3e1f32c36370 100644 (file)
@@ -163,7 +163,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
                        afi = BGP_ATTR_NEXTHOP_AFI_IP6(pi->attr) ? AFI_IP6
                                                                 : AFI_IP;
 
-               /* This will return TRUE if the global IPv6 NH is a link local
+               /* This will return true if the global IPv6 NH is a link local
                 * addr */
                if (make_prefix(afi, pi, &p) < 0)
                        return 1;
index a3aba447b5e5d2c78cccab57a9e6411ba66e8212..9e3ad4e8f298686486681e4c5f5b049cabe04922 100644 (file)
@@ -10992,7 +10992,7 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts,
        if (!peer)
                return CMD_WARNING;
 
-       return bgp_peer_counts(vty, peer, AFI_IP, SAFI_UNICAST, uj);
+       return bgp_peer_counts(vty, peer, afi, safi, uj);
 }
 
 #ifdef KEEP_OLD_VPN_COMMANDS
index a212523b194b552ac29c9e115665605472680d94..e43f9486f636de9bf0aa783ec2e1292972ef4006 100644 (file)
@@ -2695,11 +2695,11 @@ route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
                    && peer->su_remote
                    && sockunion_family(peer->su_remote) == AF_INET6) {
                        /* Set next hop preference to global */
-                       path->attr->mp_nexthop_prefer_global = TRUE;
+                       path->attr->mp_nexthop_prefer_global = true;
                        SET_FLAG(path->attr->rmap_change_flags,
                                 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
                } else {
-                       path->attr->mp_nexthop_prefer_global = FALSE;
+                       path->attr->mp_nexthop_prefer_global = false;
                        SET_FLAG(path->attr->rmap_change_flags,
                                 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
                }
index 82df1905ba5c7615f598c6a3b6f54ffb54d2204b..de7b05bdd932da4118c1660d2070d5a580124678 100644 (file)
@@ -829,7 +829,7 @@ void update_subgroup_inherit_info(struct update_subgroup *to,
  *
  * Delete a subgroup if it is ready to be deleted.
  *
- * Returns TRUE if the subgroup was deleted.
+ * Returns true if the subgroup was deleted.
  */
 static int update_subgroup_check_delete(struct update_subgroup *subgrp)
 {
@@ -979,7 +979,7 @@ static struct update_subgroup *update_subgroup_find(struct update_group *updgrp,
 /*
  * update_subgroup_ready_for_merge
  *
- * Returns TRUE if this subgroup is in a state that allows it to be
+ * Returns true if this subgroup is in a state that allows it to be
  * merged into another subgroup.
  */
 static int update_subgroup_ready_for_merge(struct update_subgroup *subgrp)
@@ -1012,7 +1012,7 @@ static int update_subgroup_ready_for_merge(struct update_subgroup *subgrp)
 /*
  * update_subgrp_can_merge_into
  *
- * Returns TRUE if the first subgroup can merge into the second
+ * Returns true if the first subgroup can merge into the second
  * subgroup.
  */
 static int update_subgroup_can_merge_into(struct update_subgroup *subgrp,
@@ -1092,7 +1092,7 @@ static void update_subgroup_merge(struct update_subgroup *subgrp,
  *
  * Merge this subgroup into another subgroup if possible.
  *
- * Returns TRUE if the subgroup has been merged. The subgroup pointer
+ * Returns true if the subgroup has been merged. The subgroup pointer
  * should not be accessed in this case.
  */
 int update_subgroup_check_merge(struct update_subgroup *subgrp,
@@ -1141,7 +1141,7 @@ static int update_subgroup_merge_check_thread_cb(struct thread *thread)
  * @param force If true, the merge check will be triggered even if the
  *              subgroup doesn't currently look ready for a merge.
  *
- * Returns TRUE if a merge check will be performed shortly.
+ * Returns true if a merge check will be performed shortly.
  */
 int update_subgroup_trigger_merge_check(struct update_subgroup *subgrp,
                                        int force)
@@ -1788,7 +1788,7 @@ int update_group_refresh_default_originate_route_map(struct thread *thread)
  *
  * Refreshes routes out to a peer_af immediately.
  *
- * If the combine parameter is TRUE, then this function will try to
+ * If the combine parameter is true, then this function will try to
  * gather other peers in the subgroup for which a route announcement
  * is pending and efficently announce routes to all of them.
  *
index 9c3bf842134bc1b8d046d7bdabb55ca479e50b45..6e0e079cd8a31ffaeeed0362c565b1c95bef0ade 100644 (file)
@@ -999,6 +999,8 @@ DEFUN_NOSH (router_bgp,
                if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
                        vpn_leak_postchange_all();
 
+               if (inst_type == BGP_INSTANCE_TYPE_VRF)
+                       bgp_vpn_leak_export(bgp);
                /* Pending: handle when user tries to change a view to vrf n vv.
                 */
        }
@@ -1081,6 +1083,9 @@ DEFUN (no_router_bgp,
                }
        }
 
+       if (bgp_vpn_leak_unimport(bgp, vty))
+               return CMD_WARNING_CONFIG_FAILED;
+
        bgp_delete(bgp);
 
        return CMD_SUCCESS;
@@ -11313,15 +11318,19 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                json_object_array_add(json_import_vrfs,
                                                json_object_new_string(vname));
 
+                       json_object_object_add(json, "importFromVrfs",
+                                                      json_import_vrfs);
                        dir = BGP_VPN_POLICY_DIR_FROMVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                        bgp->vpn_policy[afi].rtlist[dir],
                                        ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       json_object_object_add(json, "importFromVrfs",
-                                              json_import_vrfs);
-                       json_object_string_add(json, "importRts", ecom_str);
-
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               json_object_string_add(json, "importRts",
+                                                      ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               json_object_string_add(json, "importRts",
+                                                      "none");
                }
 
                if (!CHECK_FLAG(bgp->af_flags[afi][safi],
@@ -11345,12 +11354,16 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                                 buf1, RD_ADDRSTRLEN));
 
                        dir = BGP_VPN_POLICY_DIR_TOVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                               bgp->vpn_policy[afi].rtlist[dir],
                                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       json_object_string_add(json, "exportRts", ecom_str);
-
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               json_object_string_add(json, "exportRts",
+                                                      ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               json_object_string_add(json, "exportRts",
+                                                      "none");
                }
 
                if (use_json) {
@@ -11383,12 +11396,16 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                vty_out(vty, "  %s\n", vname);
 
                        dir = BGP_VPN_POLICY_DIR_FROMVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       ecom_str = NULL;
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                               bgp->vpn_policy[afi].rtlist[dir],
                                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "Import RT(s): %s\n", ecom_str);
+                               vty_out(vty, "Import RT(s): %s\n", ecom_str);
 
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               vty_out(vty, "Import RT(s):\n");
                }
 
                if (!CHECK_FLAG(bgp->af_flags[afi][safi],
@@ -11411,11 +11428,14 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
                                              buf1, RD_ADDRSTRLEN));
 
                        dir = BGP_VPN_POLICY_DIR_TOVPN;
-                       ecom_str = ecommunity_ecom2str(
+                       if (bgp->vpn_policy[afi].rtlist[dir]) {
+                               ecom_str = ecommunity_ecom2str(
                                        bgp->vpn_policy[afi].rtlist[dir],
                                        ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "Export RT: %s\n", ecom_str);
-                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                               vty_out(vty, "Export RT: %s\n", ecom_str);
+                               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+                       } else
+                               vty_out(vty, "Import RT(s):\n");
                }
        }
 
index 3ca209676f276e170e2513801dd0d45f97ec6e39..6f794928f80e3aec5e7dc9e9c38f4d97f5755e0a 100644 (file)
@@ -248,9 +248,9 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,
 
        /* EVPN uses router id in RD, withdraw them */
        if (is_evpn_enabled())
-               bgp_evpn_handle_router_id_update(bgp, TRUE);
+               bgp_evpn_handle_router_id_update(bgp, true);
 
-       vpn_handle_router_id_update(bgp, TRUE, is_config);
+       vpn_handle_router_id_update(bgp, true, is_config);
 
        IPV4_ADDR_COPY(&bgp->router_id, id);
 
@@ -267,9 +267,9 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,
 
        /* EVPN uses router id in RD, update them */
        if (is_evpn_enabled())
-               bgp_evpn_handle_router_id_update(bgp, FALSE);
+               bgp_evpn_handle_router_id_update(bgp, false);
 
-       vpn_handle_router_id_update(bgp, FALSE, is_config);
+       vpn_handle_router_id_update(bgp, false, is_config);
 
        return 0;
 }
@@ -303,7 +303,7 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
                                        if (BGP_DEBUG(zebra, ZEBRA))
                                                zlog_debug("RID change : vrf %u, RTR ID %s",
                                        bgp->vrf_id, inet_ntoa(*addr));
-                                       bgp_router_id_set(bgp, addr, FALSE);
+                                       bgp_router_id_set(bgp, addr, false);
                                }
                        }
                }
@@ -323,7 +323,7 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
                                        if (BGP_DEBUG(zebra, ZEBRA))
                                                zlog_debug("RID change : vrf %u, RTR ID %s",
                                        bgp->vrf_id, inet_ntoa(*addr));
-                                       bgp_router_id_set(bgp, addr, FALSE);
+                                       bgp_router_id_set(bgp, addr, false);
                                }
                        }
 
@@ -335,7 +335,7 @@ int bgp_router_id_static_set(struct bgp *bgp, struct in_addr id)
 {
        bgp->router_id_static = id;
        bgp_router_id_set(bgp, id.s_addr ? &id : &bgp->router_id_zebra,
-                         TRUE /* is config */);
+                         true /* is config */);
        return 0;
 }
 
@@ -3133,7 +3133,7 @@ int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id,
                /*
                 * suppress vrf socket
                 */
-               if (create == FALSE) {
+               if (create == false) {
                        bgp_close_vrf_socket(bgp);
                        return 0;
                }
@@ -3189,7 +3189,7 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name,
        bgp = bgp_create(as, name, inst_type);
        if (bgp_option_check(BGP_OPT_NO_ZEBRA) && name)
                bgp->vrf_id = vrf_generate_id();
-       bgp_router_id_set(bgp, &bgp->router_id_zebra, TRUE);
+       bgp_router_id_set(bgp, &bgp->router_id_zebra, true);
        bgp_address_init(bgp);
        bgp_tip_hash_init(bgp);
        bgp_scan_init(bgp);
@@ -6922,8 +6922,8 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
        struct peer *g_peer = NULL;
        char buf[SU_ADDRSTRLEN];
        char *addr;
-       int if_pg_printed = FALSE;
-       int if_ras_printed = FALSE;
+       int if_pg_printed = false;
+       int if_ras_printed = false;
 
        /* Skip dynamic neighbors. */
        if (peer_dynamic_neighbor(peer))
@@ -6945,16 +6945,16 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
 
                if (peer_group_active(peer)) {
                        vty_out(vty, " peer-group %s", peer->group->name);
-                       if_pg_printed = TRUE;
+                       if_pg_printed = true;
                } else if (peer->as_type == AS_SPECIFIED) {
                        vty_out(vty, " remote-as %u", peer->as);
-                       if_ras_printed = TRUE;
+                       if_ras_printed = true;
                } else if (peer->as_type == AS_INTERNAL) {
                        vty_out(vty, " remote-as internal");
-                       if_ras_printed = TRUE;
+                       if_ras_printed = true;
                } else if (peer->as_type == AS_EXTERNAL) {
                        vty_out(vty, " remote-as external");
-                       if_ras_printed = TRUE;
+                       if_ras_printed = true;
                }
 
                vty_out(vty, "\n");
index 3d3a75d4b1b420744bd9fe4dc0498b682c8631d8..5509fd5f0d448a323645b113841e5ec78f7a9efd 100644 (file)
@@ -189,6 +189,29 @@ Basic Config Commands
    is used to start the daemon then this command is turned on by default
    and cannot be turned off and the [no] form of the command is dissallowed.
 
+.. index::
+   single: no log-filter WORD [DAEMON]
+   single: log-filter WORD [DAEMON]
+
+.. clicmd:: [no] log-filter WORD [DAEMON]
+
+   This command forces logs to be filtered on a specific string. A log message
+   will only be printed if it matches on one of the filters in the log-filter
+   table. Can be daemon independent.
+
+   .. note::
+
+      Log filters help when you need to turn on debugs that cause significant
+      load on the system (enabling certain debugs can bring FRR to a halt).
+      Log filters prevent this but you should still expect a small performance
+      hit due to filtering each of all those logs.
+
+.. index:: log-filter clear [DAEMON]
+.. clicmd:: log-filter clear [DAEMON]
+
+   This command clears all current filters in the log-filter table. Can be
+   daemon independent.
+
 .. index:: service password-encryption
 .. clicmd:: service password-encryption
 
@@ -321,6 +344,11 @@ Terminal Mode Commands
    Shows the current configuration of the logging system. This includes the
    status of all logging destinations.
 
+.. index:: show log-filter
+.. clicmd:: show log-filter
+
+   Shows the current log filters applied to each daemon.
+
 .. index:: show memory
 .. clicmd:: show memory
 
index 895a141e4a146c140b3fc5b45e6d047222bfccdf..3a103fb9f2e5d2559ba67c4cb0b13541fac02239 100644 (file)
@@ -32,8 +32,6 @@
 #ifndef _ZEBRA_EIGRP_CONST_H_
 #define _ZEBRA_EIGRP_CONST_H_
 
-#define FALSE 0
-
 #define EIGRP_NEIGHBOR_DOWN           0
 #define EIGRP_NEIGHBOR_PENDING        1
 #define EIGRP_NEIGHBOR_UP             2
index ec1da6657c5b1362e86b501a5ebe5b13dd717fb0..f73ab7c66f2d5749455e221d74cf0888a2ebc92d 100644 (file)
--- a/fpm/fpm.h
+++ b/fpm/fpm.h
@@ -245,7 +245,7 @@ static inline fpm_msg_hdr_t *fpm_msg_next(fpm_msg_hdr_t *hdr, size_t *len)
 /*
  * fpm_msg_hdr_ok
  *
- * Returns TRUE if a message header looks well-formed.
+ * Returns true if a message header looks well-formed.
  */
 static inline int fpm_msg_hdr_ok(const fpm_msg_hdr_t *hdr)
 {
@@ -272,7 +272,7 @@ static inline int fpm_msg_hdr_ok(const fpm_msg_hdr_t *hdr)
 /*
  * fpm_msg_ok
  *
- * Returns TRUE if a message looks well-formed.
+ * Returns true if a message looks well-formed.
  *
  * @param len The length in bytes from 'hdr' to the end of the buffer.
  */
index fd8b56d62e9e8a8911ac5d752853b23fbc730779..de38563f96ecf13223a510c6922bb6bfc6df0b3c 100644 (file)
@@ -396,6 +396,7 @@ struct cmd_node {
 #define SR_STR "Segment-Routing specific commands\n"
 #define WATCHFRR_STR "watchfrr information\n"
 #define ZEBRA_STR "Zebra information\n"
+#define FILTER_LOG_STR "Filter Logs\n"
 
 #define CMD_VNI_RANGE "(1-16777215)"
 #define CONF_BACKUP_EXT ".sav"
@@ -410,6 +411,12 @@ struct cmd_node {
 #define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nInterface name or neighbor tag\n"
 #define NEIGHBOR_ADDR_STR3 "Neighbor address\nIPv6 address\nInterface name\n"
 
+/* Dameons lists */
+#define DAEMONS_STR                                                            \
+       "For the zebra daemon\nFor the rip daemon\nFor the ripng daemon\nFor the ospf daemon\nFor the ospfv6 daemon\nFor the bgp daemon\nFor the isis daemon\nFor the pbr daemon\nFor the fabricd daemon\nFor the pim daemon\nFor the static daemon\nFor the sharpd daemon\nFor the vrrpd daemon\n"
+#define DAEMONS_LIST                                                           \
+       "<zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd|fabricd|pimd|staticd|sharpd|vrrpd>"
+
 /* Prototypes. */
 extern void install_node(struct cmd_node *, int (*)(struct vty *));
 extern void install_default(enum node_type);
index ed784fc73a18a0c52575a2d0724475d2754d5471..3294a612952f2971b567e4708080c95cad0a876c 100644 (file)
@@ -31,6 +31,7 @@
 #include "command.h"
 #include "version.h"
 #include "memory_vty.h"
+#include "log_vty.h"
 #include "zclient.h"
 #include "log_int.h"
 #include "module.h"
@@ -677,6 +678,7 @@ struct thread_master *frr_init(void)
 
        vty_init(master, di->log_always);
        memory_init();
+       log_filter_cmd_init();
 
        log_ref_init();
        lib_error_init();
index d23d425d627fee83ac5e61cf036417c811f2dd90..ef914b965f038a8bb75140b8c6920b0f4faf9655 100644 (file)
@@ -316,7 +316,7 @@ extern void list_add_list(struct list *list, struct list *add);
  * list
  *    list to operate on
  * cond
- *    function pointer which takes node data as input and return TRUE or FALSE
+ *    function pointer which takes node data as input and return true or false
  */
 
 extern void list_filter_out_nodes(struct list *list, bool (*cond)(void *data));
index 5ce3bd7020b4738cd73b2d56786466b9ed8ae787..732b238b1ee753c446d1e1b0131918c52c3eb82f 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -65,6 +65,110 @@ const char *zlog_priority[] = {
        "notifications", "informational", "debugging", NULL,
 };
 
+static char zlog_filters[ZLOG_FILTERS_MAX][ZLOG_FILTER_LENGTH_MAX + 1];
+static uint8_t zlog_filter_count;
+
+/*
+ * look for a match on the filter in the current filters, loglock must be held
+ */
+static int zlog_filter_lookup(const char *lookup)
+{
+       for (int i = 0; i < zlog_filter_count; i++) {
+               if (strncmp(lookup, zlog_filters[i], sizeof(zlog_filters[0]))
+                   == 0)
+                       return i;
+       }
+       return -1;
+}
+
+void zlog_filter_clear(void)
+{
+       pthread_mutex_lock(&loglock);
+       zlog_filter_count = 0;
+       pthread_mutex_unlock(&loglock);
+}
+
+int zlog_filter_add(const char *filter)
+{
+       pthread_mutex_lock(&loglock);
+
+       int ret = 0;
+
+       if (zlog_filter_count >= ZLOG_FILTERS_MAX) {
+               ret = 1;
+               goto done;
+       }
+
+       if (zlog_filter_lookup(filter) != -1) {
+               /* Filter already present */
+               ret = -1;
+               goto done;
+       }
+
+       strlcpy(zlog_filters[zlog_filter_count], filter,
+               sizeof(zlog_filters[0]));
+
+       if (zlog_filters[zlog_filter_count][0] == '\0') {
+               /* Filter was either empty or didn't get copied correctly */
+               ret = -1;
+               goto done;
+       }
+
+       zlog_filter_count++;
+
+done:
+       pthread_mutex_unlock(&loglock);
+       return ret;
+}
+
+int zlog_filter_del(const char *filter)
+{
+       pthread_mutex_lock(&loglock);
+
+       int found_idx = zlog_filter_lookup(filter);
+       int last_idx = zlog_filter_count - 1;
+       int ret = 0;
+
+       if (found_idx == -1) {
+               /* Didn't find the filter to delete */
+               ret = -1;
+               goto done;
+       }
+
+       /* Adjust the filter array */
+       memmove(zlog_filters[found_idx], zlog_filters[found_idx + 1],
+               (last_idx - found_idx) * sizeof(zlog_filters[0]));
+
+       zlog_filter_count--;
+
+done:
+       pthread_mutex_unlock(&loglock);
+       return ret;
+}
+
+/* Dump all filters to buffer, delimited by new line */
+int zlog_filter_dump(char *buf, size_t max_size)
+{
+       pthread_mutex_lock(&loglock);
+
+       int ret = 0;
+       int len = 0;
+
+       for (int i = 0; i < zlog_filter_count; i++) {
+               ret = snprintf(buf + len, max_size - len, " %s\n",
+                              zlog_filters[i]);
+               len += ret;
+               if ((ret < 0) || ((size_t)len >= max_size)) {
+                       len = -1;
+                       goto done;
+               }
+       }
+
+done:
+       pthread_mutex_unlock(&loglock);
+       return len;
+}
+
 /*
  * write_wrapper
  *
@@ -178,17 +282,32 @@ size_t quagga_timestamp(int timestamp_precision, char *buf, size_t buflen)
        return 0;
 }
 
-/* Utility routine for current time printing. */
-static void time_print(FILE *fp, struct timestamp_control *ctl)
+static inline void timestamp_control_render(struct timestamp_control *ctl)
 {
        if (!ctl->already_rendered) {
                ctl->len = quagga_timestamp(ctl->precision, ctl->buf,
                                            sizeof(ctl->buf));
                ctl->already_rendered = 1;
        }
+}
+
+/* Utility routine for current time printing. */
+static void time_print(FILE *fp, struct timestamp_control *ctl)
+{
+       timestamp_control_render(ctl);
        fprintf(fp, "%s ", ctl->buf);
 }
 
+static int time_print_buf(char *buf, int len, int max_size,
+                         struct timestamp_control *ctl)
+{
+       timestamp_control_render(ctl);
+
+       if (ctl->len + 1 >= (unsigned long)max_size)
+               return -1;
+
+       return snprintf(buf + len, max_size - len, "%s ", ctl->buf);
+}
 
 static void vzlog_file(struct zlog *zl, struct timestamp_control *tsctl,
                       const char *proto_str, int record_priority, int priority,
@@ -202,42 +321,92 @@ static void vzlog_file(struct zlog *zl, struct timestamp_control *tsctl,
        fflush(fp);
 }
 
+/* Search a buf for the filter strings, loglock must be held */
+static int search_buf(const char *buf)
+{
+       char *found = NULL;
+
+       for (int i = 0; i < zlog_filter_count; i++) {
+               found = strstr(buf, zlog_filters[i]);
+               if (found != NULL)
+                       return 0;
+       }
+
+       return -1;
+}
+
+/* Filter out a log */
+static int vzlog_filter(struct zlog *zl, struct timestamp_control *tsctl,
+                       const char *proto_str, int priority, const char *msg)
+{
+       int len = 0;
+       int ret = 0;
+       char buf[1024] = "";
+
+       ret = time_print_buf(buf, len, sizeof(buf), tsctl);
+
+       len += ret;
+       if ((ret < 0) || ((size_t)len >= sizeof(buf)))
+               goto search;
+
+       if (zl && zl->record_priority)
+               snprintf(buf + len, sizeof(buf) - len, "%s: %s: %s",
+                        zlog_priority[priority], proto_str, msg);
+       else
+               snprintf(buf + len, sizeof(buf) - len, "%s: %s", proto_str,
+                        msg);
+
+search:
+       return search_buf(buf);
+}
+
 /* va_list version of zlog. */
 void vzlog(int priority, const char *format, va_list args)
 {
        pthread_mutex_lock(&loglock);
 
-       char proto_str[32];
+       char proto_str[32] = "";
        int original_errno = errno;
-       struct timestamp_control tsctl;
+       struct timestamp_control tsctl = {};
        tsctl.already_rendered = 0;
        struct zlog *zl = zlog_default;
        char buf[256], *msg;
 
-       /* call external hook */
-       hook_call(zebra_ext_log, priority, format, args);
+       if (zl == NULL) {
+               tsctl.precision = 0;
+       } else {
+               tsctl.precision = zl->timestamp_precision;
+               if (zl->instance)
+                       sprintf(proto_str, "%s[%d]: ", zl->protoname,
+                               zl->instance);
+               else
+                       sprintf(proto_str, "%s: ", zl->protoname);
+       }
 
        msg = vasnprintfrr(MTYPE_TMP, buf, sizeof(buf), format, args);
 
+       /* If it doesn't match on a filter, do nothing with the debug log */
+       if ((priority == LOG_DEBUG) && zlog_filter_count
+           && vzlog_filter(zl, &tsctl, proto_str, priority, msg)) {
+               pthread_mutex_unlock(&loglock);
+               goto out;
+       }
+
+       /* call external hook */
+       hook_call(zebra_ext_log, priority, format, args);
+
        /* When zlog_default is also NULL, use stderr for logging. */
        if (zl == NULL) {
-               tsctl.precision = 0;
                time_print(stderr, &tsctl);
                fprintf(stderr, "%s: %s\n", "unknown", msg);
                fflush(stderr);
                goto out;
        }
-       tsctl.precision = zl->timestamp_precision;
 
        /* Syslog output */
        if (priority <= zl->maxlvl[ZLOG_DEST_SYSLOG])
                syslog(priority | zlog_default->facility, "%s", msg);
 
-       if (zl->instance)
-               sprintf(proto_str, "%s[%d]: ", zl->protoname, zl->instance);
-       else
-               sprintf(proto_str, "%s: ", zl->protoname);
-
        /* File output. */
        if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
                vzlog_file(zl, &tsctl, proto_str, zl->record_priority, priority,
index c5ae6fe32f295cb52cccd7f3db1f062bb60cfff1..501da88a54c36bae272419602396dccc21f8ec5f 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -115,6 +115,15 @@ extern int zlog_reset_file(void);
 /* Rotate log. */
 extern int zlog_rotate(void);
 
+#define ZLOG_FILTERS_MAX 100      /* Max # of filters at once */
+#define ZLOG_FILTER_LENGTH_MAX 80 /* 80 character filter limit */
+
+/* Add/Del/Dump log filters */
+extern void zlog_filter_clear(void);
+extern int zlog_filter_add(const char *filter);
+extern int zlog_filter_del(const char *filter);
+extern int zlog_filter_dump(char *buf, size_t max_size);
+
 const char *lookup_msg(const struct message *mz, int kz, const char *nf);
 
 /* Safe version of strerror -- never returns NULL. */
diff --git a/lib/log_vty.c b/lib/log_vty.c
new file mode 100644 (file)
index 0000000..68d598f
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Logging - VTY code
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ *                    Stephen Worley
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <zebra.h>
+
+#include "lib/log_vty.h"
+#include "command.h"
+#include "lib/vty.h"
+#include "lib/log.h"
+#ifndef VTYSH_EXTRACT_PL
+#include "lib/log_vty_clippy.c"
+#endif
+
+DEFPY (log_filter,
+       log_filter_cmd,
+       "[no] log-filter WORD$filter",
+       NO_STR
+       FILTER_LOG_STR
+       "String to filter by\n")
+{
+       int ret = 0;
+
+       if (no)
+               ret = zlog_filter_del(filter);
+       else
+               ret = zlog_filter_add(filter);
+
+       if (ret == 1) {
+               vty_out(vty, "%% filter table full\n");
+               return CMD_WARNING;
+       } else if (ret != 0) {
+               vty_out(vty, "%% failed to %s log filter\n",
+                       (no ? "remove" : "apply"));
+               return CMD_WARNING;
+       }
+
+       vty_out(vty, " %s\n", filter);
+       return CMD_SUCCESS;
+}
+
+/* Clear all log filters */
+DEFPY (log_filter_clear,
+       log_filter_clear_cmd,
+       "clear log-filter",
+       CLEAR_STR
+       FILTER_LOG_STR)
+{
+       zlog_filter_clear();
+       return CMD_SUCCESS;
+}
+
+/* Show log filter */
+DEFPY (show_log_filter,
+       show_log_filter_cmd,
+       "show log-filter",
+       SHOW_STR
+       FILTER_LOG_STR)
+{
+       char log_filters[ZLOG_FILTERS_MAX * (ZLOG_FILTER_LENGTH_MAX + 3)] = "";
+       int len = 0;
+
+       len = zlog_filter_dump(log_filters, sizeof(log_filters));
+
+       if (len == -1) {
+               vty_out(vty, "%% failed to get filters\n");
+               return CMD_WARNING;
+       }
+
+       if (len != 0)
+               vty_out(vty, "%s", log_filters);
+
+       return CMD_SUCCESS;
+}
+
+void log_filter_cmd_init(void)
+{
+       install_element(VIEW_NODE, &show_log_filter_cmd);
+       install_element(CONFIG_NODE, &log_filter_cmd);
+       install_element(CONFIG_NODE, &log_filter_clear_cmd);
+}
diff --git a/lib/log_vty.h b/lib/log_vty.h
new file mode 100644 (file)
index 0000000..fa5627e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Logging - VTY library
+ * Copyright (C) 2019 Cumulus Networks, Inc.
+ *                    Stephen Worley
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __LOG_VTY_H__
+#define __LOG_VTY_H__
+extern void log_filter_cmd_init(void);
+#endif /* __LOG_VTY_H__ */
index 5fd9c3b900437c13a5feb6c2f792d7aa96a08c33..1adc0d7b748f3c64772af9e115f5dab1e12f6e28 100644 (file)
@@ -171,6 +171,9 @@ DEFUN (show_modules,
                }
                plug = plug->next;
        }
+
+       vty_out(vty, "pid: %u\n", (uint32_t)(getpid()));
+
        return CMD_SUCCESS;
 }
 
index 8a5cd0ef14db39012978d2f21720d6330ec3a235..b2ae1f66cb45a28c6be0570ba89aee4dd3162eed 100644 (file)
@@ -504,7 +504,9 @@ int nb_candidate_edit(struct nb_config *candidate,
                 */
                if (dnode) {
                        lyd_schema_sort(dnode, 0);
-                       lyd_validate(&dnode, LYD_OPT_CONFIG, ly_native_ctx);
+                       lyd_validate(&dnode,
+                                    LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL,
+                                    ly_native_ctx);
                }
                break;
        case NB_OP_DESTROY:
@@ -570,7 +572,8 @@ int nb_candidate_update(struct nb_config *candidate)
  */
 static int nb_candidate_validate_yang(struct nb_config *candidate)
 {
-       if (lyd_validate(&candidate->dnode, LYD_OPT_STRICT | LYD_OPT_CONFIG,
+       if (lyd_validate(&candidate->dnode,
+                        LYD_OPT_STRICT | LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL,
                         ly_native_ctx)
            != 0)
                return NB_ERR_VALIDATION;
index 8223bd547c88e69b231487c4044a0d7062831379..b0cf77ee92fbfe73b757d1ba2646e93e8d66010a 100644 (file)
@@ -42,6 +42,7 @@ lib_libfrr_la_SOURCES = \
        lib/libfrr.c \
        lib/linklist.c \
        lib/log.c \
+       lib/log_vty.c \
        lib/md5.c \
        lib/memory.c \
        lib/memory_vty.c \
@@ -137,6 +138,8 @@ lib/northbound_cli_clippy.c: $(CLIPPY_DEPS)
 lib/northbound_cli.lo: lib/northbound_cli_clippy.c
 lib/vty_clippy.c: $(CLIPPY_DEPS)
 lib/vty.lo: lib/vty_clippy.c
+lib/log_vty_clippy.c: $(CLIPPY_DEPS)
+lib/log_vty.lo: lib/log_vty_clippy.c
 
 pkginclude_HEADERS += \
        lib/agg_table.h \
@@ -179,6 +182,7 @@ pkginclude_HEADERS += \
        lib/libospf.h \
        lib/linklist.h \
        lib/log.h \
+       lib/log_vty.h \
        lib/md5.h \
        lib/memory.h \
        lib/memory_vty.h \
index 57b65ac4ba90cb3f93d8c596a0e4172cb894cbc3..7a69c1664f4a24319151f1e0f3a77ff5100a4006 100644 (file)
@@ -314,7 +314,7 @@ static inline struct route_node *route_table_iter_next(route_table_iter_t *iter)
 /*
  * route_table_iter_is_done
  *
- * Returns TRUE if the iteration is complete.
+ * Returns true if the iteration is complete.
  */
 static inline int route_table_iter_is_done(route_table_iter_t *iter)
 {
@@ -324,7 +324,7 @@ static inline int route_table_iter_is_done(route_table_iter_t *iter)
 /*
  * route_table_iter_started
  *
- * Returns TRUE if this iterator has started iterating over the tree.
+ * Returns true if this iterator has started iterating over the tree.
  */
 static inline int route_table_iter_started(route_table_iter_t *iter)
 {
index f5fe51d54704d88f6d0543dd12265fd29c7ebd2f..620691a98de246d50c7db9eb1445c3444970d1a9 100644 (file)
@@ -804,7 +804,7 @@ static void ospf_spf_next(struct vertex *v, struct ospf *ospf,
        int type = 0, lsa_pos = -1, lsa_pos_next = 0;
 
        /* If this is a router-LSA, and bit V of the router-LSA (see Section
-          A.4.2:RFC2328) is set, set Area A's TransitCapability to TRUE.  */
+          A.4.2:RFC2328) is set, set Area A's TransitCapability to true.  */
        if (v->type == OSPF_VERTEX_ROUTER) {
                if (IS_ROUTER_LSA_VIRTUAL((struct router_lsa *)v->lsa))
                        area->transit = OSPF_TRANSIT_TRUE;
@@ -1207,7 +1207,7 @@ static void ospf_spf_calculate(struct ospf *ospf, struct ospf_area *area,
         * spanning tree. */
        v->lsa_p->stat = LSA_SPF_IN_SPFTREE;
 
-       /* Set Area A's TransitCapability to FALSE. */
+       /* Set Area A's TransitCapability to false. */
        area->transit = OSPF_TRANSIT_FALSE;
        area->shortcut_capability = 1;
 
index 631465fb2067f9c522d65235580c853b49d007dd..dfa34f15efa47d25a789eaf3ed94bfd8a9580197 100644 (file)
@@ -3252,7 +3252,7 @@ DEFUN (show_ip_ospf,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -3269,7 +3269,7 @@ DEFUN (show_ip_ospf,
 
        /* vrf input is provided could be all or specific vrf*/
        if (vrf_name) {
-               bool ospf_output = FALSE;
+               bool ospf_output = false;
 
                use_vrf = 1;
 
@@ -3277,7 +3277,7 @@ DEFUN (show_ip_ospf,
                        for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                                if (!ospf->oi_running)
                                        continue;
-                               ospf_output = TRUE;
+                               ospf_output = true;
                                ret = show_ip_ospf_common(vty, ospf, json,
                                                          use_vrf);
                        }
@@ -3942,7 +3942,7 @@ DEFUN (show_ip_ospf_interface,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL, *intf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0, idx_intf = 0;
@@ -4082,7 +4082,7 @@ DEFUN (show_ip_ospf_interface_traffic,
        struct ospf *ospf = NULL;
        struct listnode *node = NULL;
        char *vrf_name = NULL, *intf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int inst = 0;
        int idx_vrf = 0, idx_intf = 0;
        bool uj = use_json(argc, argv);
@@ -4337,7 +4337,7 @@ DEFUN (show_ip_ospf_neighbor,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -4563,7 +4563,7 @@ DEFUN (show_ip_ospf_neighbor_all,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -5257,7 +5257,7 @@ DEFUN (show_ip_ospf_neighbor_detail,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -5446,7 +5446,7 @@ DEFUN (show_ip_ospf_neighbor_detail_all,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -5626,12 +5626,12 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
        bool uj = use_json(argc, argv);
        struct listnode *node = NULL;
        int ret = CMD_SUCCESS;
-       bool ospf_output = FALSE;
+       bool ospf_output = false;
 
        for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                if (!ospf->oi_running)
                        continue;
-               ospf_output = TRUE;
+               ospf_output = true;
                ret = show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0,
                                                              argv, uj);
        }
@@ -6334,7 +6334,7 @@ DEFUN (show_ip_ospf_database_max,
        struct ospf *ospf = NULL;
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -6343,7 +6343,7 @@ DEFUN (show_ip_ospf_database_max,
        OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
 
        if (vrf_name) {
-               bool ospf_output = FALSE;
+               bool ospf_output = false;
 
                use_vrf = 1;
 
@@ -6351,7 +6351,7 @@ DEFUN (show_ip_ospf_database_max,
                        for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                                if (!ospf->oi_running)
                                        continue;
-                               ospf_output = TRUE;
+                               ospf_output = true;
                                ret = show_ip_ospf_database_common(
                                        vty, ospf, idx_vrf ? 2 : 0, argc, argv,
                                        use_vrf);
@@ -6403,7 +6403,7 @@ DEFUN (show_ip_ospf_instance_database,
        unsigned short instance = 0;
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx = 0;
@@ -6561,7 +6561,7 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,
        unsigned short instance = 0;
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx = 0, idx_vrf = 0;
@@ -6584,7 +6584,7 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,
        OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
 
        if (vrf_name) {
-               bool ospf_output = FALSE;
+               bool ospf_output = false;
 
                use_vrf = 1;
 
@@ -6592,7 +6592,7 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,
                        for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                                if (!ospf->oi_running)
                                        continue;
-                               ospf_output = TRUE;
+                               ospf_output = true;
                                ret = show_ip_ospf_database_type_adv_router_common(
                                        vty, ospf, idx ? 1 : 0, argc, argv,
                                        use_vrf);
@@ -9372,7 +9372,7 @@ DEFUN (show_ip_ospf_border_routers,
        struct ospf *ospf = NULL;
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -9381,7 +9381,7 @@ DEFUN (show_ip_ospf_border_routers,
        OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
 
        if (vrf_name) {
-               bool ospf_output = FALSE;
+               bool ospf_output = false;
 
                use_vrf = 1;
 
@@ -9390,7 +9390,7 @@ DEFUN (show_ip_ospf_border_routers,
                                if (!ospf->oi_running)
                                        continue;
 
-                               ospf_output = TRUE;
+                               ospf_output = true;
                                ret = show_ip_ospf_border_routers_common(
                                        vty, ospf, use_vrf);
                        }
@@ -9510,7 +9510,7 @@ DEFUN (show_ip_ospf_route,
        struct ospf *ospf = NULL;
        struct listnode *node = NULL;
        char *vrf_name = NULL;
-       bool all_vrf = FALSE;
+       bool all_vrf = false;
        int ret = CMD_SUCCESS;
        int inst = 0;
        int idx_vrf = 0;
@@ -9525,7 +9525,7 @@ DEFUN (show_ip_ospf_route,
 
        /* vrf input is provided could be all or specific vrf*/
        if (vrf_name) {
-               bool ospf_output = FALSE;
+               bool ospf_output = false;
 
                use_vrf = 1;
 
@@ -9533,7 +9533,7 @@ DEFUN (show_ip_ospf_route,
                        for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
                                if (!ospf->oi_running)
                                        continue;
-                               ospf_output = TRUE;
+                               ospf_output = true;
                                ret = show_ip_ospf_route_common(vty, ospf, json,
                                                                use_vrf);
                        }
index 073a51561b34e8fb75912de8331be964a528718d..35c313e55543d3fa8aeeced8e73f665ffd5a1cb9 100644 (file)
@@ -628,8 +628,10 @@ static void ospf_finish_final(struct ospf *ospf)
                if (!red_list)
                        continue;
 
-               for (ALL_LIST_ELEMENTS(red_list, node, nnode, red))
+               for (ALL_LIST_ELEMENTS(red_list, node, nnode, red)) {
                        ospf_redistribute_unset(ospf, i, red->instance);
+                       ospf_redist_del(ospf, i, red->instance);
+               }
        }
        ospf_redistribute_default_unset(ospf);
 
@@ -776,6 +778,8 @@ static void ospf_finish_final(struct ospf *ospf)
                                        rn->info = NULL;
                                        route_unlock_node(rn);
                                }
+
+                       ospf_external_del(ospf, i, ext->instance);
                }
        }
 
index 228218e3a31879dfd29e332bc9f74c617d944e0c..3aa2a9224176be698aa5d4c8cd4e6a43ea6a508a 100644 (file)
@@ -728,7 +728,7 @@ void assert_action_a5(struct pim_ifchannel *ch)
          winner metric as AssertWinnerMetric(S,G,I).
          Set Assert Timer to Assert_Time.
          If (I is RPF_interface(S)) AND (UpstreamJPState(S,G) == true)
-         set SPTbit(S,G) to TRUE.
+         set SPTbit(S,G) to true.
 */
 static void assert_action_a6(struct pim_ifchannel *ch,
                             struct pim_assert_metric winner_metric)
@@ -737,7 +737,7 @@ static void assert_action_a6(struct pim_ifchannel *ch,
 
        /*
          If (I is RPF_interface(S)) AND (UpstreamJPState(S,G) == true) set
-         SPTbit(S,G) to TRUE.
+         SPTbit(S,G) to true.
        */
        if (ch->upstream->rpf.source_nexthop.interface == ch->interface)
                if (ch->upstream->join_state == PIM_UPSTREAM_JOINED)
index 9995b5e31f0afae70f28ac9e820d6b46a2bfd259..62f13b5b534199ee90ee20f7ebd4be714594ddb6 100644 (file)
@@ -865,8 +865,8 @@ static void pim_bsm_fwd_whole_sz(struct pim_instance *pim, uint8_t *buf,
        struct pim_interface *pim_ifp;
        struct in_addr dst_addr;
        uint32_t pim_mtu;
-       bool no_fwd = FALSE;
-       bool ret = FALSE;
+       bool no_fwd = false;
+       bool ret = false;
 
        /* For now only global scope zone is supported, so send on all
         * pim interfaces in the vrf
@@ -891,7 +891,7 @@ static void pim_bsm_fwd_whole_sz(struct pim_instance *pim, uint8_t *buf,
                        if (!pim_bsm_send_intf(buf, len, ifp, dst_addr)) {
                                if (PIM_DEBUG_BSM)
                                        zlog_debug(
-                                               "%s: pim_bsm_send_intf returned FALSE",
+                                               "%s: pim_bsm_send_intf returned false",
                                                __PRETTY_FUNCTION__);
                        }
                }
@@ -1216,7 +1216,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,
        struct pim_instance *pim;
        char bsr_str[INET_ADDRSTRLEN];
        uint16_t frag_tag;
-       bool empty_bsm = FALSE;
+       bool empty_bsm = false;
 
        /* BSM Packet acceptance validation */
        pim_ifp = ifp->info;
index 72d7916b20ee416e3a8adf69ef0dfb86f81d2039..6420574e95bdeb09d3469ac4180c38d4b389c4f8 100644 (file)
@@ -9843,7 +9843,7 @@ static void pim_show_vxlan_sg_entry(struct pim_vxlan_sg *vxlan_sg,
        char src_str[INET_ADDRSTRLEN];
        char grp_str[INET_ADDRSTRLEN];
        json_object *json_row;
-       bool installed = (vxlan_sg->up)?TRUE:FALSE;
+       bool installed = (vxlan_sg->up) ? true : false;
        const char *iif_name = vxlan_sg->iif?vxlan_sg->iif->name:"-";
        const char *oif_name;
 
@@ -9941,7 +9941,7 @@ static void pim_show_vxlan_sg_match_addr(struct pim_instance *pim,
 
        cwd.vty = vty;
        cwd.json = json;
-       cwd.addr_match = TRUE;
+       cwd.addr_match = true;
        hash_iterate(pim->vxlan.sg_hash, pim_show_vxlan_sg_hash_entry, &cwd);
 
        if (uj) {
@@ -9982,7 +9982,7 @@ static void pim_show_vxlan_sg_one(struct pim_instance *pim,
 
        vxlan_sg = pim_vxlan_sg_find(pim, &sg);
        if (vxlan_sg) {
-               installed = (vxlan_sg->up)?TRUE:FALSE;
+               installed = (vxlan_sg->up) ? true : false;
                iif_name = vxlan_sg->iif?vxlan_sg->iif->name:"-";
 
                if (pim_vxlan_is_orig_mroute(vxlan_sg))
@@ -10118,8 +10118,8 @@ DEFUN_HIDDEN (no_ip_pim_mlag,
        struct in_addr addr;
 
        addr.s_addr = 0;
-       pim_vxlan_mlag_update(TRUE /*mlag_enable*/,
-               FALSE /*peer_state*/, PIM_VXLAN_MLAG_ROLE_SECONDARY,
+       pim_vxlan_mlag_update(true/*mlag_enable*/,
+               false/*peer_state*/, PIM_VXLAN_MLAG_ROLE_SECONDARY,
                NULL/*peerlink*/, &addr);
 
        return CMD_SUCCESS;
@@ -10169,9 +10169,9 @@ DEFUN_HIDDEN (ip_pim_mlag,
 
        idx += 2;
        if (!strcmp(argv[idx]->arg, "up")) {
-               peer_state = TRUE;
+               peer_state = true;
        } else if (strcmp(argv[idx]->arg, "down")) {
-               peer_state = FALSE;
+               peer_state = false;
        } else {
                vty_out(vty, "unknown MLAG state %s\n", argv[idx]->arg);
                return CMD_WARNING;
@@ -10185,7 +10185,7 @@ DEFUN_HIDDEN (ip_pim_mlag,
                        errno, safe_strerror(errno));
                return CMD_WARNING_CONFIG_FAILED;
        }
-       pim_vxlan_mlag_update(TRUE, peer_state, role, ifp, &reg_addr);
+       pim_vxlan_mlag_update(true, peer_state, role, ifp, &reg_addr);
 
        return CMD_SUCCESS;
 }
index 0511a1a157cb539d9f7f08d548ba2223d61b5c6d..bdeda2d76b717d5f07a5658517a7542313e3f3e4 100644 (file)
@@ -134,7 +134,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
        pim_ifp->igmp_last_member_query_count =
                IGMP_DEFAULT_ROBUSTNESS_VARIABLE;
 
-       /* BSM config on interface: TRUE by default */
+       /* BSM config on interface: true by default */
        pim_ifp->bsm_enable = true;
        pim_ifp->ucast_bsm_accept = true;
 
index 96c7e8052ceda38c08f16a24ad0038bf697e328b..66e64cefa0bfce83ecf94bb2a1a11300100cc78c 100644 (file)
@@ -1218,10 +1218,10 @@ void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch)
        }
 
        if (new_couldassert) {
-               /* CouldAssert(S,G,I) switched from FALSE to TRUE */
+               /* CouldAssert(S,G,I) switched from false to true */
                PIM_IF_FLAG_SET_COULD_ASSERT(ch->flags);
        } else {
-               /* CouldAssert(S,G,I) switched from TRUE to FALSE */
+               /* CouldAssert(S,G,I) switched from true to false */
                PIM_IF_FLAG_UNSET_COULD_ASSERT(ch->flags);
 
                if (ch->ifassert_state == PIM_IFASSERT_I_AM_WINNER) {
@@ -1301,10 +1301,10 @@ void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch)
        }
 
        if (new_atd) {
-               /* AssertTrackingDesired(S,G,I) switched from FALSE to TRUE */
+               /* AssertTrackingDesired(S,G,I) switched from false to true */
                PIM_IF_FLAG_SET_ASSERT_TRACKING_DESIRED(ch->flags);
        } else {
-               /* AssertTrackingDesired(S,G,I) switched from TRUE to FALSE */
+               /* AssertTrackingDesired(S,G,I) switched from true to false */
                PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(ch->flags);
 
                if (ch->ifassert_state == PIM_IFASSERT_I_AM_LOSER) {
index ed965555d9ec1bffb0155e226c8c65fb9138894c..7dfd26ea655d9c67662c5510ebf0313c15876223 100644 (file)
@@ -305,6 +305,13 @@ static int igmp_recv_query(struct igmp_sock *igmp, int query_version,
                return -1;
        }
 
+       if (!pim_if_connected_to_source(ifp, from)) {
+               if (PIM_DEBUG_IGMP_PACKETS)
+                       zlog_debug("Recv IGMP query on interface: %s from a non-connected source: %s",
+                                  ifp->name, from_str);
+               return 0;
+       }
+
        /* Collecting IGMP Rx stats */
        switch (query_version) {
        case 1:
index 908026ab1419b2d7f27a2a77937a499d9c546ade..bdef83925adf6ae0ff33797397209a4b5184af98 100644 (file)
@@ -91,11 +91,11 @@ int pim_macro_chisin_joins(const struct pim_ifchannel *ch)
 
    lost_assert(S,G) =
        { all interfaces I such that
-        lost_assert(S,G,I) == TRUE }
+        lost_assert(S,G,I) == true }
 
      bool lost_assert(S,G,I) {
        if ( RPF_interface(S) == I ) {
-         return FALSE
+         return false
        } else {
          return ( AssertWinner(S,G,I) != NULL AND
                   AssertWinner(S,G,I) != me  AND
@@ -150,7 +150,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch)
 
    pim_include(S,G) =
        { all interfaces I such that:
-        ( (I_am_DR( I ) AND lost_assert(S,G,I) == FALSE )
+        ( (I_am_DR( I ) AND lost_assert(S,G,I) == false )
           OR AssertWinner(S,G,I) == me )
          AND  local_receiver_include(S,G,I) }
 
@@ -178,7 +178,7 @@ int pim_macro_chisin_pim_include(const struct pim_ifchannel *ch)
        return (
                /* I_am_DR( I ) ? */
                PIM_I_am_DR(pim_ifp) &&
-               /* lost_assert(S,G,I) == FALSE ? */
+               /* lost_assert(S,G,I) == false ? */
                (!pim_macro_ch_lost_assert(ch)));
 }
 
@@ -228,7 +228,7 @@ int pim_macro_ch_could_assert_eval(const struct pim_ifchannel *ch)
                return 0; /* false */
        }
 
-       /* SPTbit(S,G) == TRUE */
+       /* SPTbit(S,G) == true */
        if (ch->upstream->sptbit == PIM_UPSTREAM_SPTBIT_FALSE)
                return 0; /* false */
 
@@ -272,9 +272,9 @@ struct pim_assert_metric pim_macro_spt_assert_metric(const struct pim_rpf *rpf,
    following pseudocode:
 
   assert_metric  my_assert_metric(S,G,I) {
-    if( CouldAssert(S,G,I) == TRUE ) {
+    if( CouldAssert(S,G,I) == true ) {
       return spt_assert_metric(S,I)
-    } else if( CouldAssert(*,G,I) == TRUE ) {
+    } else if( CouldAssert(*,G,I) == true ) {
       return rpt_assert_metric(G,I)
     } else {
       return infinite_assert_metric()
@@ -365,11 +365,11 @@ int pim_macro_chisin_oiflist(const struct pim_ifchannel *ch)
        (+) ( pim_include(*,G) (-) pim_exclude(S,G) )
        (-) lost_assert(*,G)
        (+) joins(S,G) ) )
-     OR (local_receiver_include(S,G,I) == TRUE
+     OR (local_receiver_include(S,G,I) == true
         AND (I_am_DR(I) OR (AssertWinner(S,G,I) == me)))
-     OR ((RPF_interface(S) == I) AND (JoinDesired(S,G) == TRUE))
-     OR ((RPF_interface(RP(G)) == I) AND (JoinDesired(*,G) == TRUE)
-        AND (SPTbit(S,G) == FALSE))
+     OR ((RPF_interface(S) == I) AND (JoinDesired(S,G) == true))
+     OR ((RPF_interface(RP(G)) == I) AND (JoinDesired(*,G) == true)
+        AND (SPTbit(S,G) == false))
 
   AssertTrackingDesired(S,G,I) is true on any interface in which an
   (S,G) assert might affect our behavior.
index 3fe7e8bf640e788573a05529dffe6bcfeb359289..4b6661649019c381ed26a30e9485b0fa683c7a75 100644 (file)
@@ -61,7 +61,7 @@ void pim_register_join(struct pim_upstream *up)
        pim_channel_add_oif(up->channel_oil, pim->regiface,
                            PIM_OIF_FLAG_PROTO_PIM);
        up->reg_state = PIM_REG_JOIN;
-       pim_vxlan_update_sg_reg_state(pim, up, TRUE /*reg_join*/);
+       pim_vxlan_update_sg_reg_state(pim, up, true /*reg_join*/);
 }
 
 void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg,
@@ -148,7 +148,7 @@ int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)
                                    PIM_OIF_FLAG_PROTO_PIM);
                pim_upstream_start_register_stop_timer(upstream, 0);
                pim_vxlan_update_sg_reg_state(pim, upstream,
-                       FALSE /*reg_join*/);
+                       false/*reg_join*/);
                break;
        case PIM_REG_JOIN_PENDING:
                upstream->reg_state = PIM_REG_PRUNE;
@@ -283,8 +283,8 @@ void pim_null_register_send(struct pim_upstream *up)
  *          # Note: this may be a spoofing attempt
  *      }
  *      if( I_am_RP(G) AND outer.dst == RP(G) ) {
- *            sentRegisterStop = FALSE;
- *            if ( register.borderbit == TRUE ) {
+ *            sentRegisterStop = false;
+ *            if ( register.borderbit == true ) {
  *                 if ( PMBR(S,G) == unknown ) {
  *                      PMBR(S,G) = outer.src
  *                 } else if ( outer.src != PMBR(S,G) ) {
@@ -296,10 +296,10 @@ void pim_null_register_send(struct pim_upstream *up)
  *             ( SwitchToSptDesired(S,G) AND
  *               ( inherited_olist(S,G) == NULL ))) {
  *              send Register-Stop(S,G) to outer.src
- *              sentRegisterStop = TRUE;
+ *              sentRegisterStop = true;
  *            }
  *            if ( SPTbit(S,G) OR SwitchToSptDesired(S,G) ) {
- *                 if ( sentRegisterStop == TRUE ) {
+ *                 if ( sentRegisterStop == true ) {
  *                      set KeepaliveTimer(S,G) to RP_Keepalive_Period;
  *                 } else {
  *                      set KeepaliveTimer(S,G) to Keepalive_Period;
index b1a2e717d6ab852c40e1de88bcc15f8c25ee9f9a..7d263e99e38cfd173b16d05e2a041f275ef869ae 100644 (file)
@@ -228,7 +228,7 @@ enum pim_rpf_result pim_rpf_update(struct pim_instance *pim,
 
        if ((up->sg.src.s_addr == INADDR_ANY && I_am_RP(pim, up->sg.grp)) ||
            PIM_UPSTREAM_FLAG_TEST_FHR(up->flags))
-               neigh_needed = FALSE;
+               neigh_needed = false;
        pim_find_or_track_nexthop(pim, &nht_p, up, NULL, false, NULL);
        if (!pim_ecmp_nexthop_lookup(pim, &rpf->source_nexthop, &src, &grp,
                                     neigh_needed))
index 194fb2cffdd02af5dc053d73b09b14784726e177..50df2fdbf91707d0d2c4c2453397eee0972d6536 100644 (file)
@@ -1318,14 +1318,14 @@ int pim_upstream_is_sg_rpt(struct pim_upstream *up)
  *   void
  *   Update_SPTbit(S,G,iif) {
  *     if ( iif == RPF_interface(S)
- *           AND JoinDesired(S,G) == TRUE
- *           AND ( DirectlyConnected(S) == TRUE
+ *           AND JoinDesired(S,G) == true
+ *           AND ( DirectlyConnected(S) == true
  *                 OR RPF_interface(S) != RPF_interface(RP(G))
  *                 OR inherited_olist(S,G,rpt) == NULL
  *                 OR ( ( RPF'(S,G) == RPF'(*,G) ) AND
  *                      ( RPF'(S,G) != NULL ) )
  *                 OR ( I_Am_Assert_Loser(S,G,iif) ) {
- *        Set SPTbit(S,G) to TRUE
+ *        Set SPTbit(S,G) to true
  *     }
  *   }
  */
@@ -1344,7 +1344,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,
                return;
        }
 
-       // AND JoinDesired(S,G) == TRUE
+       // AND JoinDesired(S,G) == true
        if (!pim_upstream_evaluate_join_desired(up->channel_oil->pim, up)) {
                if (PIM_DEBUG_TRACE)
                        zlog_debug("%s: %s Join is not Desired",
@@ -1352,7 +1352,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,
                return;
        }
 
-       // DirectlyConnected(S) == TRUE
+       // DirectlyConnected(S) == true
        if (pim_if_connected_to_source(up->rpf.source_nexthop.interface,
                                       up->sg.src)) {
                if (PIM_DEBUG_TRACE)
@@ -1456,7 +1456,7 @@ static int pim_upstream_register_stop_timer(struct thread *t)
                up->reg_state = PIM_REG_JOIN;
                pim_channel_add_oif(up->channel_oil, pim->regiface,
                                    PIM_OIF_FLAG_PROTO_PIM);
-               pim_vxlan_update_sg_reg_state(pim, up, TRUE /*reg_join*/);
+               pim_vxlan_update_sg_reg_state(pim, up, true /*reg_join*/);
                break;
        case PIM_REG_JOIN:
                break;
@@ -1690,7 +1690,7 @@ bool pim_upstream_equal(const void *arg1, const void *arg2)
 /* rfc4601:section-4.2:"Data Packet Forwarding Rules" defines
  * the cases where kat has to be restarted on rxing traffic -
  *
- * if( DirectlyConnected(S) == TRUE AND iif == RPF_interface(S) ) {
+ * if( DirectlyConnected(S) == true AND iif == RPF_interface(S) ) {
  * set KeepaliveTimer(S,G) to Keepalive_Period
  * # Note: a register state transition or UpstreamJPState(S,G)
  * # transition may happen as a result of restarting
index d2648fad50a1da69118d1e8e8b2b95327c263e13..33e3b2340c2ec0253c2cd72aa756f6f0cd2fb259 100644 (file)
@@ -115,7 +115,7 @@ static void pim_vxlan_init_work(void)
        vxlan_info.max_work_cnt = PIM_VXLAN_WORK_MAX;
        vxlan_info.flags |= PIM_VXLANF_WORK_INITED;
        vxlan_info.work_list = list_new();
-       pim_vxlan_work_timer_setup(TRUE /* start */);
+       pim_vxlan_work_timer_setup(true/* start */);
 }
 
 static void pim_vxlan_add_work(struct pim_vxlan_sg *vxlan_sg)
index 346e93b8effecf8b0b7b56ebc1d42fd91c2a29b4..627d3d1993655dadeef931a47eaafca6f83a0f3c 100644 (file)
@@ -829,8 +829,10 @@ DEFPY (ip_rip_authentication_mode,
 
        nb_cli_enqueue_change(vty, "./authentication-scheme/mode", NB_OP_MODIFY,
                              strmatch(mode, "md5") ? "md5" : "plain-text");
-       nb_cli_enqueue_change(vty, "./authentication-scheme/md5-auth-length",
-                             NB_OP_MODIFY, value);
+       if (strmatch(mode, "md5"))
+               nb_cli_enqueue_change(vty,
+                                     "./authentication-scheme/md5-auth-length",
+                                     NB_OP_MODIFY, value);
 
        return nb_cli_apply_changes(vty, "./frr-ripd:rip");
 }
@@ -852,7 +854,7 @@ DEFPY (no_ip_rip_authentication_mode,
        nb_cli_enqueue_change(vty, "./authentication-scheme/mode", NB_OP_MODIFY,
                              NULL);
        nb_cli_enqueue_change(vty, "./authentication-scheme/md5-auth-length",
-                             NB_OP_MODIFY, NULL);
+                             NB_OP_DESTROY, NULL);
 
        return nb_cli_apply_changes(vty, "./frr-ripd:rip");
 }
index 9af30a587a4a17b4d63baeec80cd6cb89c83dd65..2aa0db59f11c4a7d201758ea9396733374609f13 100644 (file)
@@ -37,8 +37,6 @@ static void static_nht_update_safi(struct prefix *p, uint32_t nh_num,
        struct static_route *si;
        struct static_vrf *svrf;
        struct route_node *rn;
-       bool orig;
-       bool reinstall;
 
        svrf = vrf->info;
        if (!svrf)
@@ -49,7 +47,6 @@ static void static_nht_update_safi(struct prefix *p, uint32_t nh_num,
                return;
 
        for (rn = route_top(stable); rn; rn = route_next(rn)) {
-               reinstall = false;
                for (si = rn->info; si; si = si->next) {
                        if (si->nh_vrf_id != nh_vrf_id)
                                continue;
@@ -60,7 +57,6 @@ static void static_nht_update_safi(struct prefix *p, uint32_t nh_num,
                            && si->type != STATIC_IPV6_GATEWAY_IFNAME)
                                continue;
 
-                       orig = si->nh_valid;
                        if (p->family == AF_INET
                            && p->u.prefix4.s_addr == si->addr.ipv4.s_addr)
                                si->nh_valid = !!nh_num;
@@ -69,14 +65,7 @@ static void static_nht_update_safi(struct prefix *p, uint32_t nh_num,
                            && memcmp(&p->u.prefix6, &si->addr.ipv6, 16) == 0)
                                si->nh_valid = !!nh_num;
 
-                       if (orig != si->nh_valid)
-                               reinstall = true;
-
-                       if (reinstall) {
-                               static_zebra_route_add(rn, si, vrf->vrf_id,
-                                                      safi, true);
-                               reinstall = false;
-                       }
+                       static_zebra_route_add(rn, si, vrf->vrf_id, safi, true);
                }
        }
 }
index c17bf1168c763430b23d2b983626e5c235f4b3e6..db53c1aacde84a06b873b36fe90c14ad2db1b290 100644 (file)
@@ -6,14 +6,19 @@ if ret != False and found != None:
     luCommand('ce3', 'vtysh -c "show bgp sum"',
              '.', 'pass', 'See %s sharp routes' % num)
     if num > 0:
+        rtrs = ['ce1', 'ce2', 'ce3']
+        for rtr in rtrs:
+            luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display','.', 'none', 'BGP routes pre remove')
+            luCommand(rtr, 'ip route show | cat -n | tail','.', 'none', 'Linux routes pre remove')
         wait = 2*num/500
         luCommand('ce1', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num))
         luCommand('ce2', 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),'.','none','Removing {} routes'.format(num))
-        rtrs = ['ce1', 'ce2', 'ce3']
         for rtr in rtrs:
-            luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep -c 10\\.\\*/32','^0$', 'wait', 'BGP routes removed', wait)
+            luCommand(rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display',' 10 route', 'wait', 'BGP routes removed', wait)
+            luCommand(rtr, 'vtysh -c "show bgp ipv4 uni"','.', 'none', 'BGP routes post remove')
         for rtr in rtrs:
             luCommand(rtr, 'ip route show | grep -c \\^10\\.','^0$', 'wait', 'Linux routes removed', wait)
+            luCommand(rtr, 'ip route show','.', 'none', 'Linux routes post remove')
         rtrs = ['r1', 'r3', 'r4']
         for rtr in rtrs:
             luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr),'^0$','wait','VRF route removed',wait)
index 7f114d10df78ebd0d91ba2ee323caa7b3963ef2b..3619cdf84fe7422f03c7369afd80ca822dc46090 100644 (file)
@@ -11,14 +11,17 @@ if c > 0:
 else:
     d = r
 wait = 2*num/1000
-mem = {}
+mem_z = {}
+mem_b = {}
 rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4']
 for rtr in rtrs:
-    mem[rtr] = {'value': 0, 'units': 'unknown'}
-    ret = luCommand(rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
+    mem_z[rtr] = {'value': 0, 'units': 'unknown'}
+    mem_b[rtr] = {'value': 0, 'units': 'unknown'}
+    ret = luCommand(rtr, 'vtysh -c "show memory"', 'zebra: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
     found = luLast()
     if ret != False and found != None:
-        mem[rtr] = {'value': int(found.group(1)), 'units': found.group(2)}
+        mem_z[rtr] = {'value': int(found.group(1)), 'units': found.group(2)}
+        mem_b[rtr] = {'value': int(found.group(3)), 'units': found.group(4)}
 
 luCommand('ce1', 'vtysh -c "sharp data nexthop"', 'sharpd is not running', 'none','check if sharpd running')
 doSharp = True
@@ -54,13 +57,20 @@ if doSharp == True:
         luCommand(rtr, 'ip route show vrf {}-cust1 | grep -c \\^10\\.'.format(rtr), str(num), 'wait','See {} linux routes'.format(num), wait)
     rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4']
     for rtr in rtrs:
-        ret = luCommand(rtr, 'vtysh -c "show memory"', 'bgpd: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
+        ret = luCommand(rtr, 'vtysh -c "show memory"', 'zebra: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics:   Total heap allocated: *(\d*) ([A-Za-z]*)', 'none', 'collect bgpd memory stats')
         found = luLast()
         if ret != False and found != None:
-            val = int(found.group(1))
-            if mem[rtr]['units'] != found.group(2):
-                val *= 1000
-            delta = val - int(mem[rtr]['value'])
-            ave = float(delta)/float(num)
-            luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'BGPd heap: {0} {1} --> {2} {3} ({4} {1}/route)'.format(mem[rtr]['value'], mem[rtr]['units'], found.group(1), found.group(2), round(ave,4)))
+            val_z = int(found.group(1))
+            if mem_z[rtr]['units'] != found.group(2):
+                val_z *= 1000
+            delta_z = val_z - int(mem_z[rtr]['value'])
+            ave_z = float(delta_z)/float(num)
+
+            val_b = int(found.group(3))
+            if mem_b[rtr]['units'] != found.group(4):
+                val_b *= 1000
+            delta_b = val_b - int(mem_b[rtr]['value'])
+            ave_b = float(delta_b)/float(num)
+            luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'BGPd heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)'.format(mem_b[rtr]['value'], mem_b[rtr]['units'], found.group(3), found.group(4), round(ave_b,4)))
+            luCommand(rtr, 'vtysh -c "show thread cpu"', '.', 'pass', 'Zebra heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)'.format(mem_z[rtr]['value'], mem_z[rtr]['units'], found.group(1), found.group(2), round(ave_z,4)))
 #done
index c5e615d25210230e4995ec644f15cb9aaf2311a7..2a2747344a32c9e2c0c83347b5d2b179d37c11cd 100644 (file)
@@ -94,7 +94,7 @@ Simplified `R1` config:
 
 Test is executed by running 
 
-       vtysh -c "show log" | grep "Logging configuration for"
+       vtysh -c "show logging" | grep "Logging configuration for"
        
 on router `R1`. This should return the logging information for all daemons registered
 to Zebra and the list of running daemons is compared to the daemons started for this
index 3ae18018bfdd84a10ff54ce82334ddc367458306..e58b4725eb6756b3425ee4570bdfd3ae037848cc 100755 (executable)
@@ -37,7 +37,7 @@ class lUtil:
     base_log_dir = '.'
     fout_name = 'output.log'
     fsum_name = 'summary.txt'
-    l_level = 9
+    l_level = 6
     CallOnFail = False
 
     l_total = 0
@@ -53,12 +53,12 @@ class lUtil:
     fsum = ''
     net  = ''
 
-    def log(self, str):
+    def log(self, str, level=6):
         if self.l_level > 0:
             if self.fout == '':
                 self.fout = open(self.fout_name, 'w', 0)
             self.fout.write(str+'\n')
-        if self.l_level > 5:
+        if level <= self.l_level:
             print(str)
 
     def summary(self, str):
@@ -226,14 +226,16 @@ Total %-4d                                                           %-4d %d\n\
             ret = success
         else:
             ret = search.group()
-            self.log('found:%s:' % ret)
             if op != 'fail':
                 success = True
+                level = 7
             else:
                 success = False
+                level = 5
+            self.log('found:%s:' % ret, level)
            # Experiment: compare matched strings obtained each way
            if self.l_dotall_experiment and (group_nl_converted != ret):
-               self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret))
+               self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
         if op == 'pass' or op == 'fail':
             self.result(target, success, result)
         if js != None:
@@ -265,7 +267,7 @@ LUtil=None
 
 #entry calls
 def luStart(baseScriptDir='.', baseLogDir='.', net='',
-            fout='output.log', fsum='summary.txt', level=9):
+            fout='output.log', fsum='summary.txt', level=None):
     global LUtil
     #init class
     LUtil=lUtil()
@@ -276,7 +278,8 @@ def luStart(baseScriptDir='.', baseLogDir='.', net='',
         LUtil.fout_name = baseLogDir + '/' + fout
     if fsum != None:
         LUtil.fsum_name = baseLogDir + '/' + fsum
-    LUtil.l_level = level
+    if level != None:
+        LUtil.l_level = level
     LUtil.l_dotall_experiment = False
     LUtil.l_dotall_experiment = True
 
@@ -289,11 +292,11 @@ def luCommand(target, command, regexp='.', op='none', result='', time=10, return
 def luLast(usenl=False):
     if usenl:
        if LUtil.l_last_nl != None:
-           LUtil.log('luLast:%s:' %  LUtil.l_last_nl.group())
+           LUtil.log('luLast:%s:' %  LUtil.l_last_nl.group(), 7)
        return LUtil.l_last_nl
     else:
        if LUtil.l_last != None:
-           LUtil.log('luLast:%s:' %  LUtil.l_last.group())
+           LUtil.log('luLast:%s:' %  LUtil.l_last.group(), 7)
        return LUtil.l_last
 
 def luInclude(filename, CallOnFail=None):
index 86993665ceadcd2fc69f7663a6badaee19584b02..867f9f2f0344fa501a6faaf5ace313f3a2e37870 100644 (file)
@@ -959,7 +959,7 @@ class Router(Node):
 
         global fatal_error
 
-        daemonsRunning = self.cmd('vtysh -c "show log" | grep "Logging configuration for"')
+        daemonsRunning = self.cmd('vtysh -c "show logging" | grep "Logging configuration for"')
         # Look for AddressSanitizer Errors in vtysh output and append to /tmp/AddressSanitzer.txt if found
         if checkAddressSanitizerError(daemonsRunning, self.name, "vtysh"):
             return "%s: vtysh killed by AddressSanitizer" % (self.name)
index 28f68e8fa57664188ab5bc424ba1841e550692db..526c019c6acb8c410ed9ace94b3195e366b03eab 100644 (file)
@@ -102,7 +102,7 @@ Simplified `R3` config
 
 Test is executed by running 
 
-       vtysh -c "show log" | grep "Logging configuration for"
+       vtysh -c "show logging" | grep "Logging configuration for"
        
 on each FRR router. This should return the logging information for all daemons registered
 to Zebra and the list of running daemons is compared to the daemons started for this test (`zebra` and `ospf6d`)
index c3aeb27eb950018a66214a7e6080ae02b38747aa..053848bfc31d1c056b3d145c8fa0b08fecc3b199 100644 (file)
@@ -140,6 +140,21 @@ struct vtysh_client vtysh_client[] = {
        {.fd = -1, .name = "vrrpd", .flag = VTYSH_VRRPD, .next = NULL},
 };
 
+/* Searches for client by name, returns index */
+static int vtysh_client_lookup(const char *name)
+{
+       int idx = -1;
+
+       for (unsigned int i = 0; i < array_size(vtysh_client); i++) {
+               if (strmatch(vtysh_client[i].name, name)) {
+                       idx = i;
+                       break;
+               }
+       }
+
+       return idx;
+}
+
 enum vtysh_write_integrated vtysh_write_integrated =
        WRITE_INTEGRATED_UNSPECIFIED;
 
@@ -394,6 +409,23 @@ static int vtysh_client_execute(struct vtysh_client *head_client,
        return vtysh_client_run_all(head_client, line, 0, NULL, NULL);
 }
 
+/* Execute by name */
+static int vtysh_client_execute_name(const char *name, const char *line)
+{
+       int ret = CMD_SUCCESS;
+       int idx_client = -1;
+
+       idx_client = vtysh_client_lookup(name);
+       if (idx_client != -1)
+               ret = vtysh_client_execute(&vtysh_client[idx_client], line);
+       else {
+               vty_out(vty, "Client not found\n");
+               ret = CMD_WARNING;
+       }
+
+       return ret;
+}
+
 /*
  * Retrieve all running config from daemons and parse it with the vtysh config
  * parser. Returned output is not displayed to the user.
@@ -2269,33 +2301,15 @@ DEFUN (vtysh_show_work_queues,
 
 DEFUN (vtysh_show_work_queues_daemon,
        vtysh_show_work_queues_daemon_cmd,
-       "show work-queues <zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pbrd|fabricd|pimd|staticd>",
+       "show work-queues " DAEMONS_LIST,
        SHOW_STR
        "Work Queue information\n"
-       "For the zebra daemon\n"
-       "For the rip daemon\n"
-       "For the ripng daemon\n"
-       "For the ospf daemon\n"
-       "For the ospfv6 daemon\n"
-       "For the bgp daemon\n"
-       "For the isis daemon\n"
-       "For the pbr daemon\n"
-       "For the fabricd daemon\n"
-       "For the pim daemon\n"
-       "For the static daemon\n")
+       DAEMONS_STR)
 {
        int idx_protocol = 2;
-       unsigned int i;
-       int ret = CMD_SUCCESS;
-
-       for (i = 0; i < array_size(vtysh_client); i++) {
-               if (strmatch(vtysh_client[i].name, argv[idx_protocol]->text))
-                       break;
-       }
 
-       ret = vtysh_client_execute(&vtysh_client[i], "show work-queues\n");
-
-       return ret;
+       return vtysh_client_execute_name(argv[idx_protocol]->text,
+                                        "show work-queues\n");
 }
 
 DEFUNSH(VTYSH_ZEBRA, vtysh_link_params, vtysh_link_params_cmd, "link-params",
@@ -2627,22 +2641,109 @@ DEFUNSH(VTYSH_ALL, no_vtysh_config_enable_password,
        return CMD_SUCCESS;
 }
 
+/* Log filter */
+DEFUN (vtysh_log_filter,
+       vtysh_log_filter_cmd,
+       "[no] log-filter WORD ["DAEMONS_LIST"]",
+       NO_STR
+       FILTER_LOG_STR
+       "String to filter by\n"
+       DAEMONS_STR)
+{
+       char *filter = NULL;
+       char *daemon = NULL;
+       int found = 0;
+       int idx = 0;
+       int daemon_idx = 2;
+       int total_len = 0;
+       int len = 0;
+
+       char line[ZLOG_FILTER_LENGTH_MAX + 20];
+
+       found = argv_find(argv, argc, "no", &idx);
+       if (found == 1) {
+               len = snprintf(line, sizeof(line), "no log-filter");
+               daemon_idx += 1;
+       } else
+               len = snprintf(line, sizeof(line), "log-filter");
+
+       total_len += len;
+
+       idx = 1;
+       found = argv_find(argv, argc, "WORD", &idx);
+       if (found != 1) {
+               vty_out(vty, "%% No filter string given\n");
+               return CMD_WARNING;
+       }
+       filter = argv[idx]->arg;
+
+       if (strnlen(filter, ZLOG_FILTER_LENGTH_MAX + 1)
+           > ZLOG_FILTER_LENGTH_MAX) {
+               vty_out(vty, "%% Filter is too long\n");
+               return CMD_WARNING;
+       }
+
+       len = snprintf(line + total_len, sizeof(line) - total_len, " %s\n",
+                      filter);
+
+       if ((len < 0) || (size_t)(total_len + len) > sizeof(line)) {
+               vty_out(vty, "%% Error buffering filter to daemons\n");
+               return CMD_ERR_INCOMPLETE;
+       }
+
+       if (argc >= (daemon_idx + 1))
+               daemon = argv[daemon_idx]->text;
+
+       if (daemon != NULL) {
+               vty_out(vty, "Applying log filter change to %s:\n", daemon);
+               return vtysh_client_execute_name(daemon, line);
+       } else
+               return show_per_daemon(line,
+                                      "Applying log filter change to %s:\n");
+}
+
+/* Clear log filters */
+DEFUN (vtysh_log_filter_clear,
+       vtysh_log_filter_clear_cmd,
+       "log-filter clear ["DAEMONS_LIST"]",
+       FILTER_LOG_STR
+       CLEAR_STR
+       DAEMONS_STR)
+{
+       char *daemon = NULL;
+       int daemon_idx = 2;
+
+       char line[] = "clear log-filter\n";
+
+       if (argc >= (daemon_idx + 1))
+               daemon = argv[daemon_idx]->text;
+
+       if (daemon != NULL) {
+               vty_out(vty, "Clearing all filters applied to %s:\n", daemon);
+               return vtysh_client_execute_name(daemon, line);
+       } else
+               return show_per_daemon(line,
+                                      "Clearing all filters applied to %s:\n");
+}
+
+/* Show log filter */
+DEFUN (vtysh_show_log_filter,
+       vtysh_show_log_filter_cmd,
+       "show log-filter",
+       SHOW_STR
+       FILTER_LOG_STR)
+{
+       char line[] = "do show log-filter\n";
+
+       return show_per_daemon(line, "Log filters applied to %s:\n");
+}
+
 DEFUN (vtysh_write_terminal,
        vtysh_write_terminal_cmd,
-       "write terminal [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|fabricd|pimd|staticd>]",
+       "write terminal ["DAEMONS_LIST"]",
        "Write running configuration to memory, network, or terminal\n"
        "Write to terminal\n"
-       "For the zebra daemon\n"
-       "For the rip daemon\n"
-       "For the ripng daemon\n"
-       "For the ospf daemon\n"
-       "For the ospfv6 daemon\n"
-       "For the ldpd daemon\n"
-       "For the bgp daemon\n"
-       "For the isis daemon\n"
-       "For the fabricd daemon\n"
-       "For the pim daemon\n"
-       "For the static daemon\n")
+       DAEMONS_STR)
 {
        unsigned int i;
        char line[] = "do write terminal\n";
@@ -2668,20 +2769,10 @@ DEFUN (vtysh_write_terminal,
 
 DEFUN (vtysh_show_running_config,
        vtysh_show_running_config_cmd,
-       "show running-config [<zebra|ripd|ripngd|ospfd|ospf6d|ldpd|bgpd|isisd|fabricd|pimd|staticd>]",
+       "show running-config ["DAEMONS_LIST"]",
        SHOW_STR
        "Current operating configuration\n"
-       "For the zebra daemon\n"
-       "For the rip daemon\n"
-       "For the ripng daemon\n"
-       "For the ospf daemon\n"
-       "For the ospfv6 daemon\n"
-       "For the ldp daemon\n"
-       "For the bgp daemon\n"
-       "For the isis daemon\n"
-       "For the fabricd daemon\n"
-       "For the pim daemon\n"
-       "For the static daemon\n")
+       DAEMONS_STR)
 {
        return vtysh_write_terminal(self, vty, argc, argv);
 }
@@ -3871,6 +3962,9 @@ void vtysh_init_vty(void)
 
        /* Logging */
        install_element(VIEW_NODE, &vtysh_show_logging_cmd);
+       install_element(VIEW_NODE, &vtysh_show_log_filter_cmd);
+       install_element(CONFIG_NODE, &vtysh_log_filter_cmd);
+       install_element(CONFIG_NODE, &vtysh_log_filter_clear_cmd);
        install_element(CONFIG_NODE, &vtysh_log_stdout_cmd);
        install_element(CONFIG_NODE, &vtysh_log_stdout_level_cmd);
        install_element(CONFIG_NODE, &no_vtysh_log_stdout_cmd);
index aaf70ab08b1d9917854b5cfb5c0da197979cbb97..17e5a7331c26c71fe4a85db1d645790d13f5154d 100644 (file)
@@ -62,35 +62,20 @@ static int vtysh_pam(const char *user)
 
        /* Start PAM. */
        ret = pam_start(FRR_PAM_NAME, user, &conv, &pamh);
-       /* printf ("ret %d\n", ret); */
 
        /* Is user really user? */
        if (ret == PAM_SUCCESS)
                ret = pam_authenticate(pamh, 0);
-/* printf ("ret %d\n", ret); */
 
-#if 0
-  /* Permitted access? */
-  if (ret == PAM_SUCCESS)
-    ret = pam_acct_mgmt (pamh, 0);
-  printf ("ret %d\n", ret);
-
-  if (ret == PAM_AUTHINFO_UNAVAIL)
-    ret = PAM_SUCCESS;
-#endif /* 0 */
-
-/* This is where we have been authorized or not. */
-#ifdef DEBUG
-       if (ret == PAM_SUCCESS)
-               printf("Authenticated\n");
-       else
-               printf("Not Authenticated\n");
-#endif /* DEBUG */
+       if (ret != PAM_SUCCESS)
+               fprintf(stderr, "vtysh_pam: Failure to initialize pam: %s(%d)",
+                       pam_strerror(pamh, ret), ret);
 
        /* close Linux-PAM */
        if (pam_end(pamh, ret) != PAM_SUCCESS) {
                pamh = NULL;
-               fprintf(stderr, "vtysh_pam: failed to release authenticator\n");
+               fprintf(stderr, "vtysh_pam: failed to release authenticator: %s(%d)\n",
+                       pam_strerror(pamh, ret), ret);
                exit(1);
        }
 
index 6a3914451aa71d522a000be7a9eccb9986ffbb53..e134b9b4236d95ac10c9076a354cea406609ea3a 100644 (file)
@@ -46,7 +46,7 @@ extern "C" {
 struct rtadvconf {
        /* A flag indicating whether or not the router sends periodic Router
           Advertisements and responds to Router Solicitations.
-          Default: FALSE */
+          Default: false */
        int AdvSendAdvertisements;
 
        /* The maximum time allowed between sending unsolicited multicast
@@ -70,19 +70,19 @@ struct rtadvconf {
        /* Unsolicited Router Advertisements' interval timer. */
        int AdvIntervalTimer;
 
-       /* The TRUE/FALSE value to be placed in the "Managed address
+       /* The true/false value to be placed in the "Managed address
           configuration" flag field in the Router Advertisement.  See
           [ADDRCONF].
 
-          Default: FALSE */
+          Default: false */
        int AdvManagedFlag;
 
 
-       /* The TRUE/FALSE value to be placed in the "Other stateful
+       /* The true/false value to be placed in the "Other stateful
           configuration" flag field in the Router Advertisement.  See
           [ADDRCONF].
 
-          Default: FALSE */
+          Default: false */
        int AdvOtherConfigFlag;
 
        /* The value to be placed in MTU options sent by the router.  A
@@ -136,10 +136,10 @@ struct rtadvconf {
           included in the list of advertised prefixes. */
        struct list *AdvPrefixList;
 
-       /* The TRUE/FALSE value to be placed in the "Home agent"
+       /* The true/false value to be placed in the "Home agent"
           flag field in the Router Advertisement.  See [RFC6275 7.1].
 
-          Default: FALSE */
+          Default: false */
        int AdvHomeAgentFlag;
 #ifndef ND_RA_FLAG_HOME_AGENT
 #define ND_RA_FLAG_HOME_AGENT  0x20
@@ -159,10 +159,10 @@ struct rtadvconf {
        int HomeAgentLifetime;
 #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
 
-       /* The TRUE/FALSE value to insert or not an Advertisement Interval
+       /* The true/false value to insert or not an Advertisement Interval
           option. See [RFC 6275 7.3]
 
-          Default: FALSE */
+          Default: false */
        int AdvIntervalOption;
 
        /* The value to be placed in the Default Router Preference field of
index 3f4fa93460ac5f9ba743450d868f0748927a7501..ff4ab8dfbd2ac9068147cc51359a53296b4c10bf 100644 (file)
@@ -32,9 +32,6 @@
 extern "C" {
 #endif
 
-#define TRUE 1
-#define FALSE 0
-
 /* ICMP Messages */
 #ifndef ICMP_ROUTERADVERT
 #define ICMP_ROUTERADVERT 9
index c0b772cd014d49626cc6197f88eb709b544eb876..8e1ca122d391975cf471ed577f17e0e5b7249b3e 100644 (file)
@@ -352,7 +352,7 @@ static void irdp_if_no_shutdown(struct interface *ifp)
 
        irdp->flags &= ~IF_SHUTDOWN;
 
-       irdp_if_start(ifp, irdp->flags & IF_BROADCAST ? FALSE : TRUE, FALSE);
+       irdp_if_start(ifp, irdp->flags & IF_BROADCAST ? false : true, false);
 }
 
 
@@ -407,7 +407,7 @@ DEFUN (ip_irdp_multicast,
        VTY_DECLVAR_CONTEXT(interface, ifp);
        irdp_if_get(ifp);
 
-       irdp_if_start(ifp, TRUE, TRUE);
+       irdp_if_start(ifp, true, true);
        return CMD_SUCCESS;
 }
 
@@ -421,7 +421,7 @@ DEFUN (ip_irdp_broadcast,
        VTY_DECLVAR_CONTEXT(interface, ifp);
        irdp_if_get(ifp);
 
-       irdp_if_start(ifp, FALSE, TRUE);
+       irdp_if_start(ifp, false, true);
        return CMD_SUCCESS;
 }
 
index b13f1170cd5defa3dc53c1d32b0b3d327b81961b..d56579ff4f7e4a62612e31f5c4e1d374ecca4108 100644 (file)
@@ -52,7 +52,7 @@
 static int zebra_import_table_used[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
 static uint32_t zebra_import_table_distance[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
 
-int is_zebra_import_table_enabled(afi_t afi, uint32_t table_id)
+int is_zebra_import_table_enabled(afi_t afi, vrf_id_t vrf_id, uint32_t table_id)
 {
        /*
         * Make sure that what we are called with actualy makes sense
@@ -568,8 +568,8 @@ void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
        }
 }
 
-int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
-                                const char *rmap_name)
+int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
+                                struct route_entry *re, const char *rmap_name)
 {
        struct route_entry *newre;
        struct route_entry *same;
@@ -581,11 +581,11 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
        if (rmap_name)
                ret = zebra_import_table_route_map_check(
                        afi, re->type, re->instance, &rn->p, re->ng.nexthop,
-                       re->vrf_id, re->tag, rmap_name);
+                       zvrf->vrf->vrf_id, re->tag, rmap_name);
 
        if (ret != RMAP_MATCH) {
                UNSET_FLAG(re->flags, ZEBRA_FLAG_SELECTED);
-               zebra_del_import_table_entry(rn, re);
+               zebra_del_import_table_entry(zvrf, rn, re);
                return 0;
        }
 
@@ -603,7 +603,7 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
 
        if (same) {
                UNSET_FLAG(same->flags, ZEBRA_FLAG_SELECTED);
-               zebra_del_import_table_entry(rn, same);
+               zebra_del_import_table_entry(zvrf, rn, same);
        }
 
        newre = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
@@ -612,7 +612,7 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
        newre->flags = re->flags;
        newre->metric = re->metric;
        newre->mtu = re->mtu;
-       newre->table = 0;
+       newre->table = zvrf->table_id;
        newre->nexthop_num = 0;
        newre->uptime = monotime(NULL);
        newre->instance = re->table;
@@ -623,7 +623,8 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
        return 0;
 }
 
-int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)
+int zebra_del_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
+                                struct route_entry *re)
 {
        struct prefix p;
        afi_t afi;
@@ -631,20 +632,21 @@ int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)
        afi = family2afi(rn->p.family);
        prefix_copy(&p, &rn->p);
 
-       rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, re->table,
-                  re->flags, &p, NULL, re->ng.nexthop, 0, re->metric,
-                  re->distance, false);
+       rib_delete(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_TABLE,
+                  re->table, re->flags, &p, NULL, re->ng.nexthop,
+                  zvrf->table_id, re->metric, re->distance, false);
 
        return 0;
 }
 
 /* Assuming no one calls this with the main routing table */
-int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
-                      const char *rmap_name, int add)
+int zebra_import_table(afi_t afi, vrf_id_t vrf_id, uint32_t table_id,
+                      uint32_t distance, const char *rmap_name, int add)
 {
        struct route_table *table;
        struct route_entry *re;
        struct route_node *rn;
+       struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(vrf_id);
 
        if (!is_zebra_valid_kernel_table(table_id)
            || (table_id == RT_TABLE_MAIN))
@@ -653,8 +655,8 @@ int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
        if (afi >= AFI_MAX)
                return (-1);
 
-       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
-                                             table_id, VRF_DEFAULT);
+       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST, vrf_id,
+                                             table_id);
        if (table == NULL) {
                return 0;
        } else if (IS_ZEBRA_DEBUG_RIB) {
@@ -708,15 +710,16 @@ int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
                if (((afi == AFI_IP) && (rn->p.family == AF_INET))
                    || ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) {
                        if (add)
-                               zebra_add_import_table_entry(rn, re, rmap_name);
+                               zebra_add_import_table_entry(zvrf, rn, re,
+                                                            rmap_name);
                        else
-                               zebra_del_import_table_entry(rn, re);
+                               zebra_del_import_table_entry(zvrf, rn, re);
                }
        }
        return 0;
 }
 
-int zebra_import_table_config(struct vty *vty)
+int zebra_import_table_config(struct vty *vty, vrf_id_t vrf_id)
 {
        int i;
        afi_t afi;
@@ -726,7 +729,7 @@ int zebra_import_table_config(struct vty *vty)
 
        for (afi = AFI_IP; afi < AFI_MAX; afi++) {
                for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
-                       if (!is_zebra_import_table_enabled(afi, i))
+                       if (!is_zebra_import_table_enabled(afi, vrf_id, i))
                                continue;
 
                        if (zebra_import_table_distance[afi][i]
@@ -751,61 +754,84 @@ int zebra_import_table_config(struct vty *vty)
        return write;
 }
 
-void zebra_import_table_rm_update(const char *rmap)
+static void zebra_import_table_rm_update_vrf_afi(struct zebra_vrf *zvrf,
+                                                afi_t afi, int table_id,
+                                                const char *rmap)
 {
-       afi_t afi;
-       int i;
        struct route_table *table;
        struct route_entry *re;
        struct route_node *rn;
        const char *rmap_name;
 
-       for (afi = AFI_IP; afi < AFI_MAX; afi++) {
-               for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
-                       if (!is_zebra_import_table_enabled(afi, i))
-                               continue;
+       rmap_name = zebra_get_import_table_route_map(afi, table_id);
+       if ((!rmap_name) || (strcmp(rmap_name, rmap) != 0))
+               return;
 
-                       rmap_name = zebra_get_import_table_route_map(afi, i);
-                       if ((!rmap_name) || (strcmp(rmap_name, rmap) != 0))
+       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
+                                             zvrf->vrf->vrf_id, table_id);
+       if (!table) {
+               if (IS_ZEBRA_DEBUG_RIB_DETAILED)
+                       zlog_debug("%s: Table id=%d not found", __func__,
+                                  table_id);
+               return;
+       }
+
+       for (rn = route_top(table); rn; rn = route_next(rn)) {
+               /*
+                * For each entry in the non-default routing table,
+                * add the entry in the main table
+                */
+               if (!rn->info)
+                       continue;
+
+               RNODE_FOREACH_RE (rn, re) {
+                       if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
                                continue;
-                       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
-                                                             i, VRF_DEFAULT);
-                       if (!table) {
-                               if (IS_ZEBRA_DEBUG_RIB_DETAILED)
-                                       zlog_debug("%s: Table id=%d not found",
-                                                  __func__, i);
+                       break;
+               }
+
+               if (!re)
+                       continue;
+
+               if (((afi == AFI_IP) && (rn->p.family == AF_INET))
+                   || ((afi == AFI_IP6) && (rn->p.family == AF_INET6)))
+                       zebra_add_import_table_entry(zvrf, rn, re, rmap_name);
+       }
+
+       return;
+}
+
+static void zebra_import_table_rm_update_vrf(struct zebra_vrf *zvrf,
+                                            const char *rmap)
+{
+       afi_t afi;
+       int i;
+
+       for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+               for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
+                       if (!is_zebra_import_table_enabled(
+                                   afi, zvrf->vrf->vrf_id, i))
                                continue;
-                       }
 
-                       for (rn = route_top(table); rn; rn = route_next(rn)) {
-                               /* For each entry in the non-default
-                                * routing table,
-                                * add the entry in the main table
-                                */
-                               if (!rn->info)
-                                       continue;
-
-                               RNODE_FOREACH_RE (rn, re) {
-                                       if (CHECK_FLAG(re->status,
-                                                      ROUTE_ENTRY_REMOVED))
-                                               continue;
-                                       break;
-                               }
-
-                               if (!re)
-                                       continue;
-
-                               if (((afi == AFI_IP)
-                                    && (rn->p.family == AF_INET))
-                                   || ((afi == AFI_IP6)
-                                       && (rn->p.family == AF_INET6)))
-                                       zebra_add_import_table_entry(rn, re,
-                                                                    rmap_name);
-                       }
+                       zebra_import_table_rm_update_vrf_afi(zvrf, afi, i,
+                                                            rmap);
                }
        }
+}
 
-       return;
+void zebra_import_table_rm_update(const char *rmap)
+{
+       struct vrf *vrf;
+       struct zebra_vrf *zvrf;
+
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+               zvrf = vrf->info;
+
+               if (!zvrf)
+                       continue;
+
+               zebra_import_table_rm_update_vrf(zvrf, rmap);
+       }
 }
 
 /* Interface parameters update */
index 74a593b2409a3aa4b4945b2170d87f09903147e1..30ff6bcd094c0a69bbbce6c3937158c195740520 100644 (file)
@@ -64,17 +64,21 @@ extern void zebra_interface_vrf_update_del(struct interface *,
 extern void zebra_interface_vrf_update_add(struct interface *,
                                           vrf_id_t old_vrf_id);
 
-extern int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
+extern int zebra_import_table(afi_t afi, vrf_id_t vrf_id,
+                             uint32_t table_id, uint32_t distance,
                              const char *rmap_name, int add);
 
-extern int zebra_add_import_table_entry(struct route_node *rn,
+extern int zebra_add_import_table_entry(struct zebra_vrf *zvrf,
+                                       struct route_node *rn,
                                        struct route_entry *re,
                                        const char *rmap_name);
-extern int zebra_del_import_table_entry(struct route_node *rn,
+extern int zebra_del_import_table_entry(struct zebra_vrf *zvrf,
+                                       struct route_node *rn,
                                        struct route_entry *re);
-extern int is_zebra_import_table_enabled(afi_t, uint32_t table_id);
+extern int is_zebra_import_table_enabled(afi_t, vrf_id_t vrf_id,
+                                        uint32_t table_id);
 
-extern int zebra_import_table_config(struct vty *);
+extern int zebra_import_table_config(struct vty *, vrf_id_t vrf_id);
 
 extern void zebra_import_table_rm_update(const char *rmap);
 
index 292f6bc6004239001f71c2cfea97cee38799a7eb..9d8cee8bf787a43631144bbb48e9ad0b6c30a2c6 100644 (file)
@@ -500,7 +500,7 @@ static inline void rib_tables_iter_init(rib_tables_iter_t *iter)
 /*
  * rib_tables_iter_started
  *
- * Returns TRUE if this iterator has started iterating over the set of
+ * Returns true if this iterator has started iterating over the set of
  * tables.
  */
 static inline int rib_tables_iter_started(rib_tables_iter_t *iter)
index b05d037f960640d574524476d12c864fe2d3a62e..f951738b703d6097c4592ecf7e043c46dfda3258 100644 (file)
@@ -150,6 +150,9 @@ static inline int zebra2proto(int proto)
        case ZEBRA_ROUTE_OPENFABRIC:
                proto = RTPROT_OPENFABRIC;
                break;
+       case ZEBRA_ROUTE_TABLE:
+               proto = RTPROT_ZEBRA;
+               break;
        default:
                /*
                 * When a user adds a new protocol this will show up
index 32b9763c56a5ac4da95d3681ae35a75df7842a54..eaf43095bc8ec27d48a918d517332fedf6c7d7d0 100644 (file)
@@ -829,7 +829,7 @@ static bool zfpm_updates_pending(void)
 /*
  * zfpm_writes_pending
  *
- * Returns TRUE if we may have something to write to the FPM.
+ * Returns true if we may have something to write to the FPM.
  */
 static int zfpm_writes_pending(void)
 {
@@ -1403,7 +1403,7 @@ static void zfpm_start_connect_timer(const char *reason)
 /*
  * zfpm_is_enabled
  *
- * Returns TRUE if the zebra FPM module has been enabled.
+ * Returns true if the zebra FPM module has been enabled.
  */
 static inline int zfpm_is_enabled(void)
 {
@@ -1413,7 +1413,7 @@ static inline int zfpm_is_enabled(void)
 /*
  * zfpm_conn_is_up
  *
- * Returns TRUE if the connection to the FPM is up.
+ * Returns true if the connection to the FPM is up.
  */
 static inline int zfpm_conn_is_up(void)
 {
@@ -1969,10 +1969,10 @@ static struct cmd_node zebra_node = {ZEBRA_NODE, "", 1};
  * One-time initialization of the Zebra FPM module.
  *
  * @param[in] port port at which FPM is running.
- * @param[in] enable TRUE if the zebra FPM module should be enabled
+ * @param[in] enable true if the zebra FPM module should be enabled
  * @param[in] format to use to talk to the FPM. Can be 'netink' or 'protobuf'.
  *
- * Returns TRUE on success.
+ * Returns true on success.
  */
 static int zfpm_init(struct thread_master *master)
 {
index d5479bc627ae1ba777d636bf0ef166825995bec0..822def318a98208093f2600fb966aceedfc8aec5 100644 (file)
@@ -195,7 +195,7 @@ typedef struct netlink_route_info_t_ {
  * Add information about the given nexthop to the given route info
  * structure.
  *
- * Returns TRUE if a nexthop was added, FALSE otherwise.
+ * Returns true if a nexthop was added, false otherwise.
  */
 static int netlink_route_info_add_nh(netlink_route_info_t *ri,
                                     struct nexthop *nexthop,
@@ -278,7 +278,7 @@ static uint8_t netlink_proto_from_route_type(int type)
  *
  * Fill out the route information object from the given route.
  *
- * Returns TRUE on success and FALSE on failure.
+ * Returns true on success and false on failure.
  */
 static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,
                                   rib_dest_t *dest, struct route_entry *re)
index 5b0ca6570e72836a6f524a6818d0793150dcbf22..9cfaef3a895c714f8f48f12cc4d68016da11da51 100644 (file)
@@ -698,7 +698,7 @@ static void rib_uninstall(struct route_node *rn, struct route_entry *re)
 /*
  * rib_can_delete_dest
  *
- * Returns TRUE if the given dest can be deleted from the table.
+ * Returns true if the given dest can be deleted from the table.
  */
 static int rib_can_delete_dest(rib_dest_t *dest)
 {
@@ -816,7 +816,7 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
  * Garbage collect the rib dest corresponding to the given route node
  * if appropriate.
  *
- * Returns TRUE if the dest was deleted, FALSE otherwise.
+ * Returns true if the dest was deleted, false otherwise.
  */
 int rib_gc_dest(struct route_node *rn)
 {
@@ -2347,9 +2347,11 @@ static void rib_link(struct route_node *rn, struct route_entry *re, int process)
        afi = (rn->p.family == AF_INET)
                      ? AFI_IP
                      : (rn->p.family == AF_INET6) ? AFI_IP6 : AFI_MAX;
-       if (is_zebra_import_table_enabled(afi, re->table)) {
+       if (is_zebra_import_table_enabled(afi, re->vrf_id, re->table)) {
+               struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
+
                rmap_name = zebra_get_import_table_route_map(afi, re->table);
-               zebra_add_import_table_entry(rn, re, rmap_name);
+               zebra_add_import_table_entry(zvrf, rn, re, rmap_name);
        } else if (process)
                rib_queue_add(rn);
 }
@@ -2415,8 +2417,10 @@ void rib_delnode(struct route_node *rn, struct route_entry *re)
        afi = (rn->p.family == AF_INET)
                      ? AFI_IP
                      : (rn->p.family == AF_INET6) ? AFI_IP6 : AFI_MAX;
-       if (is_zebra_import_table_enabled(afi, re->table)) {
-               zebra_del_import_table_entry(rn, re);
+       if (is_zebra_import_table_enabled(afi, re->vrf_id, re->table)) {
+               struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(re->vrf_id);
+
+               zebra_del_import_table_entry(zvrf, rn, re);
                /* Just clean up if non main table */
                if (IS_ZEBRA_DEBUG_RIB) {
                        char buf[SRCDEST2STR_BUFFER];
@@ -2742,11 +2746,14 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
                else
                        src_buf[0] = '\0';
 
-               if (IS_ZEBRA_DEBUG_RIB)
-                       zlog_debug("%u:%s%s%s doesn't exist in rib", vrf_id,
-                                  dst_buf,
+               if (IS_ZEBRA_DEBUG_RIB) {
+                       struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+
+                       zlog_debug("%s[%d]:%s%s%s doesn't exist in rib",
+                                  vrf->name, table_id, dst_buf,
                                   (src_buf[0] != '\0') ? " from " : "",
                                   src_buf);
+               }
                return;
        }
 
@@ -3384,7 +3391,7 @@ void rib_init(void)
  *
  * Get the first vrf id that is greater than the given vrf id if any.
  *
- * Returns TRUE if a vrf id was found, FALSE otherwise.
+ * Returns true if a vrf id was found, false otherwise.
  */
 static inline int vrf_id_get_next(vrf_id_t vrf_id, vrf_id_t *next_id_p)
 {
index 5f397eb8c29f29a3fd5e28b465cce6a5e868987b..6f65f8ab7a1d917b3b24a4fd2d72c5631d5fb8ad 100644 (file)
@@ -759,7 +759,7 @@ static void zebra_rnh_eval_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
         * change.
         */
        zebra_rnh_remove_from_routing_table(rnh);
-       if (!prefix_same(&rnh->resolved_route, prn ? NULL : &prn->p)) {
+       if (!prefix_same(&rnh->resolved_route, prn ? &prn->p : NULL)) {
                if (prn)
                        prefix_copy(&rnh->resolved_route, &prn->p);
                else {
@@ -965,7 +965,6 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,
 
 static int compare_state(struct route_entry *r1, struct route_entry *r2)
 {
-
        if (!r1 && !r2)
                return 0;
 
@@ -981,8 +980,7 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2)
        if (r1->nexthop_num != r2->nexthop_num)
                return 1;
 
-       if (CHECK_FLAG(r1->status, ROUTE_ENTRY_NEXTHOPS_CHANGED)
-           || CHECK_FLAG(r1->status, ROUTE_ENTRY_LABELS_CHANGED))
+       if (nexthop_group_hash(&r1->ng) != nexthop_group_hash(&r2->ng))
                return 1;
 
        return 0;
index 1f8eec9cad1491c2cc901239eda85cadf6bb6c1c..74baabbf240c28e0cb53e3bda852fded4e0c6211 100644 (file)
@@ -2435,7 +2435,7 @@ static int zebra_ip_config(struct vty *vty)
 {
        int write = 0;
 
-       write += zebra_import_table_config(vty);
+       write += zebra_import_table_config(vty, VRF_DEFAULT);
 
        return write;
 }
@@ -2482,7 +2482,8 @@ DEFUN (ip_zebra_import_table_distance,
                return CMD_WARNING;
        }
 
-       ret = zebra_import_table(AFI_IP, table_id, distance, rmap, 1);
+       ret = zebra_import_table(AFI_IP, VRF_DEFAULT, table_id,
+                                distance, rmap, 1);
        if (rmap)
                XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
 
@@ -2573,10 +2574,10 @@ DEFUN (no_ip_zebra_import_table,
                return CMD_WARNING;
        }
 
-       if (!is_zebra_import_table_enabled(AFI_IP, table_id))
+       if (!is_zebra_import_table_enabled(AFI_IP, VRF_DEFAULT, table_id))
                return CMD_SUCCESS;
 
-       return (zebra_import_table(AFI_IP, table_id, 0, NULL, 0));
+       return (zebra_import_table(AFI_IP, VRF_DEFAULT, table_id, 0, NULL, 0));
 }
 
 static int config_write_protocol(struct vty *vty)