]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #4315 from lkrishnamoor/route_map_3rd_state
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 May 2019 01:25:18 +0000 (21:25 -0400)
committerGitHub <noreply@github.com>
Fri, 31 May 2019 01:25:18 +0000 (21:25 -0400)
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP

40 files changed:
bgpd/bgp_community.c
bgpd/bgp_fsm.c
bgpd/bgp_packet.c
bgpd/bgp_routemap.c
bgpd/bgp_zebra.c
bgpd/rfapi/rfapi_import.c
doc/developer/building-frr-for-centos7.rst
doc/developer/topotests.rst
doc/user/pim.rst
doc/user/rpki.rst
lib/command.c
lib/command_match.c
lib/debug.c
lib/debug.h
lib/libfrr.c
lib/log.c
lib/northbound_cli.c
lib/prefix.c
lib/table.h
lib/vty.c
ospfd/ospf_te.c
pbrd/pbr_nht.c
pimd/pim_cmd.c
pimd/pim_cmd.h
pimd/pim_iface.c
pimd/pim_iface.h
pimd/pim_igmpv3.c
pimd/pim_msdp.c
pimd/pim_upstream.c
pimd/pim_upstream.h
pimd/pim_vty.c
ripngd/ripngd.c
staticd/static_routes.c
vtysh/vtysh.c
zebra/ioctl.c
zebra/ioctl_solaris.c
zebra/kernel_socket.c
zebra/rt_netlink.c
zebra/zebra_mpls.c
zebra/zebra_rib.c

index 82762072df0966e37d2776ecef0beeea18fd7506..6fc52ff9e03195cec06a202fa7989fb8a2115ec3 100644 (file)
@@ -205,7 +205,6 @@ static void set_community_string(struct community *com, bool make_json)
 {
        int i;
        char *str;
-       char *pnt;
        int len;
        int first;
        uint32_t comval;
@@ -297,7 +296,7 @@ static void set_community_string(struct community *com, bool make_json)
        }
 
        /* Allocate memory.  */
-       str = pnt = XMALLOC(MTYPE_COMMUNITY_STR, len);
+       str = XCALLOC(MTYPE_COMMUNITY_STR, len);
        first = 1;
 
        /* Fill in string.  */
@@ -308,12 +307,11 @@ static void set_community_string(struct community *com, bool make_json)
                if (first)
                        first = 0;
                else
-                       *pnt++ = ' ';
+                       strlcat(str, " ", len);
 
                switch (comval) {
                case COMMUNITY_INTERNET:
-                       strcpy(pnt, "internet");
-                       pnt += strlen("internet");
+                       strlcat(str, "internet", len);
                        if (make_json) {
                                json_string =
                                        json_object_new_string("internet");
@@ -322,8 +320,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_GSHUT:
-                       strcpy(pnt, "graceful-shutdown");
-                       pnt += strlen("graceful-shutdown");
+                       strlcat(str, "graceful-shutdown", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "gracefulShutdown");
@@ -332,8 +329,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ACCEPT_OWN:
-                       strcpy(pnt, "accept-own");
-                       pnt += strlen("accept-own");
+                       strlcat(str, "accept-own", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "acceptown");
@@ -342,8 +338,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ROUTE_FILTER_TRANSLATED_v4:
-                       strcpy(pnt, "route-filter-translated-v4");
-                       pnt += strlen("route-filter-translated-v4");
+                       strlcat(str, "route-filter-translated-v4", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "routeFilterTranslatedV4");
@@ -352,8 +347,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ROUTE_FILTER_v4:
-                       strcpy(pnt, "route-filter-v4");
-                       pnt += strlen("route-filter-v4");
+                       strlcat(str, "route-filter-v4", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "routeFilterV4");
@@ -362,8 +356,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ROUTE_FILTER_TRANSLATED_v6:
-                       strcpy(pnt, "route-filter-translated-v6");
-                       pnt += strlen("route-filter-translated-v6");
+                       strlcat(str, "route-filter-translated-v6", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "routeFilterTranslatedV6");
@@ -372,8 +365,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ROUTE_FILTER_v6:
-                       strcpy(pnt, "route-filter-v6");
-                       pnt += strlen("route-filter-v6");
+                       strlcat(str, "route-filter-v6", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "routeFilterV6");
@@ -382,8 +374,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_LLGR_STALE:
-                       strcpy(pnt, "llgr-stale");
-                       pnt += strlen("llgr-stale");
+                       strlcat(str, "llgr-stale", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "llgrStale");
@@ -392,8 +383,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_NO_LLGR:
-                       strcpy(pnt, "no-llgr");
-                       pnt += strlen("no-llgr");
+                       strlcat(str, "no-llgr", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "noLlgr");
@@ -402,8 +392,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_ACCEPT_OWN_NEXTHOP:
-                       strcpy(pnt, "accept-own-nexthop");
-                       pnt += strlen("accept-own-nexthop");
+                       strlcat(str, "accept-own-nexthop", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "acceptownnexthop");
@@ -412,8 +401,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_BLACKHOLE:
-                       strcpy(pnt, "blackhole");
-                       pnt += strlen("blackhole");
+                       strlcat(str, "blackhole", len);
                        if (make_json) {
                                json_string = json_object_new_string(
                                        "blackhole");
@@ -422,8 +410,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_NO_EXPORT:
-                       strcpy(pnt, "no-export");
-                       pnt += strlen("no-export");
+                       strlcat(str, "no-export", len);
                        if (make_json) {
                                json_string =
                                        json_object_new_string("noExport");
@@ -432,8 +419,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_NO_ADVERTISE:
-                       strcpy(pnt, "no-advertise");
-                       pnt += strlen("no-advertise");
+                       strlcat(str, "no-advertise", len);
                        if (make_json) {
                                json_string =
                                        json_object_new_string("noAdvertise");
@@ -442,8 +428,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_LOCAL_AS:
-                       strcpy(pnt, "local-AS");
-                       pnt += strlen("local-AS");
+                       strlcat(str, "local-AS", len);
                        if (make_json) {
                                json_string = json_object_new_string("localAs");
                                json_object_array_add(json_community_list,
@@ -451,8 +436,7 @@ static void set_community_string(struct community *com, bool make_json)
                        }
                        break;
                case COMMUNITY_NO_PEER:
-                       strcpy(pnt, "no-peer");
-                       pnt += strlen("no-peer");
+                       strlcat(str, "no-peer", len);
                        if (make_json) {
                                json_string = json_object_new_string("noPeer");
                                json_object_array_add(json_community_list,
@@ -462,17 +446,17 @@ static void set_community_string(struct community *com, bool make_json)
                default:
                        as = (comval >> 16) & 0xFFFF;
                        val = comval & 0xFFFF;
-                       sprintf(pnt, "%u:%d", as, val);
+                       char buf[32];
+                       snprintf(buf, sizeof(buf), "%u:%d", as, val);
+                       strlcat(str, buf, len);
                        if (make_json) {
-                               json_string = json_object_new_string(pnt);
+                               json_string = json_object_new_string(buf);
                                json_object_array_add(json_community_list,
                                                      json_string);
                        }
-                       pnt += strlen(pnt);
                        break;
                }
        }
-       *pnt = '\0';
 
        if (make_json) {
                json_object_string_add(com->json, "string", str);
index 12ae1f841a511d20bb28434388f728662d51cdea..dd765731dcabc02f158327c1836ae6b2ac466031 100644 (file)
@@ -949,9 +949,15 @@ void bgp_fsm_change_status(struct peer *peer, int status)
        else if ((peer->status == Established) && (status != Established))
                bgp->established_peers--;
 
-       if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS))
-               zlog_debug("%s : vrf %u, established_peers %u", __func__,
-                               bgp->vrf_id, bgp->established_peers);
+       if (bgp_debug_neighbor_events(peer)) {
+               struct vrf *vrf = vrf_lookup_by_id(bgp->vrf_id);
+
+               zlog_debug("%s : vrf %s(%u), Status: %s established_peers %u", __func__,
+                          vrf ? vrf->name : "Unknown", bgp->vrf_id,
+                          lookup_msg(bgp_status_msg, status, NULL),
+                          bgp->established_peers);
+       }
+
        /* Set to router ID to the value provided by RIB if there are no peers
         * in the established state and peer count did not change
         */
index b5934fb56e220a67359c29430c08b48a54581e3a..655a4745cba045681bc37cd6cbfb882bfe0fb315 100644 (file)
@@ -709,12 +709,15 @@ void bgp_notify_send_with_data(struct peer *peer, uint8_t code,
                                XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
                        for (i = 0; i < bgp_notify.length; i++)
                                if (first) {
-                                       sprintf(c, " %02x", data[i]);
-                                       strcat(bgp_notify.data, c);
+                                       snprintf(c, sizeof(c), " %02x",
+                                                data[i]);
+                                       strlcat(bgp_notify.data, c,
+                                               bgp_notify.length);
                                } else {
                                        first = 1;
-                                       sprintf(c, "%02x", data[i]);
-                                       strcpy(bgp_notify.data, c);
+                                       snprintf(c, sizeof(c), "%02x", data[i]);
+                                       strlcpy(bgp_notify.data, c,
+                                               bgp_notify.length);
                                }
                }
                bgp_notify_print(peer, &bgp_notify, "sending");
@@ -1700,14 +1703,16 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size)
                                XMALLOC(MTYPE_TMP, bgp_notify.length * 3);
                        for (i = 0; i < bgp_notify.length; i++)
                                if (first) {
-                                       sprintf(c, " %02x",
+                                       snprintf(c, sizeof(c), " %02x",
                                                stream_getc(peer->curr));
-                                       strcat(bgp_notify.data, c);
+                                       strlcat(bgp_notify.data, c,
+                                               bgp_notify.length);
                                } else {
                                        first = 1;
-                                       sprintf(c, "%02x",
-                                               stream_getc(peer->curr));
-                                       strcpy(bgp_notify.data, c);
+                                       snprintf(c, sizeof(c), "%02x",
+                                                stream_getc(peer->curr));
+                                       strlcpy(bgp_notify.data, c,
+                                               bgp_notify.length);
                                }
                        bgp_notify.raw_data = (uint8_t *)peer->notify.data;
                }
@@ -2299,6 +2304,9 @@ int bgp_process_packet(struct thread *thread)
                                        __FUNCTION__, peer->host);
                        break;
                default:
+                       /* Suppress uninitialized variable warning */
+                       mprc = 0;
+                       (void)mprc;
                        /*
                         * The message type should have been sanitized before
                         * we ever got here. Receipt of a message with an
index debed4c456acec218d86350e6b8a538846dd31db..85cab0d59fe72d1a1dc6f474bbfbed143a72ffa2 100644 (file)
@@ -4181,10 +4181,10 @@ DEFUN (set_community,
        str = community_str(com, false);
 
        if (additive) {
-               argstr = XCALLOC(MTYPE_TMP,
-                                strlen(str) + strlen(" additive") + 1);
-               strcpy(argstr, str);
-               strcpy(argstr + strlen(str), " additive");
+               size_t argstr_sz = strlen(str) + strlen(" additive") + 1;
+               argstr = XCALLOC(MTYPE_TMP, argstr_sz);
+               strlcpy(argstr, str, argstr_sz);
+               strlcat(argstr, " additive", argstr_sz);
                ret = generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
                                      "community", argstr);
                XFREE(MTYPE_TMP, argstr);
index 013a23bde3dfe050bf492362e233ee0e79131f40..5e9fc57f59aeeb5edab641a4b3e8f839d31b1c1c 100644 (file)
@@ -2974,6 +2974,9 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh,
        SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
        api_nh = &api.nexthops[0];
 
+       api.distance = ZEBRA_EBGP_DISTANCE_DEFAULT;
+       SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
+
        /* redirect IP */
        if (nh->gate.ipv4.s_addr) {
                char buff[PREFIX_STRLEN];
index ad0900c2b8543f0b8e8f915211812ea84d50a918..b6d32d36eaa585ed625bb904bd4f4feb1672ade6 100644 (file)
@@ -4111,6 +4111,9 @@ static void rfapiProcessPeerDownRt(struct peer *peer,
                timer_service_func = rfapiWithdrawTimerEncap;
                break;
        default:
+               /* Suppress uninitialized variable warning */
+               rt = NULL;
+               timer_service_func = NULL;
                assert(0);
        }
 
index ea3c44478c02d535f2f9affb63db3c6bf7262a11..67f71bc3a5b811a763ba1ff76d10000cea248642 100644 (file)
@@ -70,7 +70,8 @@ an example.)
         --disable-ldpd \
         --enable-fpm \
         --with-pkg-git-version \
-        --with-pkg-extra-version=-MyOwnFRRVersion
+        --with-pkg-extra-version=-MyOwnFRRVersion \
+       SPHINXBUILD=/usr/bin/sphinx-build
     make
     make check
     sudo make install
index 09f12ec43641a3a17af07f0ba1a94cbc658f2c4f..e12bc37256b80973c663aae0769641dfff22b1e6 100644 (file)
@@ -145,30 +145,23 @@ the following env variable can be set::
 
    export TOPOTESTS_CHECK_STDERR=Yes
 
-(The value doesn't matter at this time. The check is if the env variable exists
-or not) There is no pass/fail on this reporting. The Output will be reported to
-the console::
-
-   export TOPOTESTS_CHECK_MEMLEAK="/home/mydir/memleak_"
-
-This will enable the check and output to console and the writing of the
-information to files with the given prefix (followed by testname), ie
-:file:`/home/mydir/memcheck_test_bgp_multiview_topo1.txt` in case of a memory
-leak.
+(The value doesn't matter at this time. The check is whether the env
+variable exists or not.) There is no pass/fail on this reporting; the
+Output will be reported to the console.
 
 Collect Memory Leak Information
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-FRR processes have the capabilities to report remaining memory allocations upon
-exit. To enable the reporting of the memory, define an environment variable
+FRR processes can report unfreed memory allocations upon exit. To
+enable the reporting of memory leaks, define an environment variable
 ``TOPOTESTS_CHECK_MEMLEAK`` with the file prefix, i.e.::
 
    export TOPOTESTS_CHECK_MEMLEAK="/home/mydir/memleak_"
 
-This will enable the check and output to console and the writing of the
-information to files with the given prefix (followed by testname), ie
-:file:`/home/mydir/memcheck_test_bgp_multiview_topo1.txt` in case of a memory
-leak.
+This will enable the check and output to console and the writing of
+the information to files with the given prefix (followed by testname),
+ie :file:`/home/mydir/memcheck_test_bgp_multiview_topo1.txt` in case
+of a memory leak.
 
 Running Topotests with AddressSanitizer
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index d05127059b4f4a8b319b1d4777451d05b55f9307..8b0fba5f834e24a360c442a8494950fe48db4a1e 100644 (file)
@@ -232,6 +232,19 @@ is in a vrf, enter the interface command with the vrf keyword at the end.
    or IGMP report is received on this interface and the Group is denied by the
    prefix-list, PIM will ignore the join or report.
 
+.. index:: ip igmp last-member-query-count (1-7)
+.. clicmd:: ip igmp last-member-query-count (1-7)
+
+   Set the IGMP last member query count. The default value is 2. 'no' form of
+   this command is used to to configure back to the default value.
+
+.. index:: ip igmp last-member-query-interval (1-255)
+.. clicmd:: ip igmp last-member-query-interval (1-255)
+
+   Set the IGMP last member query interval in deciseconds. The default value is
+   10 deciseconds. 'no' form of this command is used to to configure back to the
+   default value.
+
 .. _pim-multicast-rib-insertion:
 
 PIM Multicast RIB insertion:
index 295a26fda9f7a0ba2924dcfbae329a1efa09acb1..ca6b46d3cff2b40a75092c8ff0f20aae890cafa9 100644 (file)
@@ -188,10 +188,6 @@ Validating BGP Updates
     Create a clause for a route map to match prefixes with the specified RPKI
     state.
 
-    **Note** that the matching of invalid prefixes requires that invalid
-    prefixes are considered for best path selection, i.e.,
-    ``bgp bestpath prefix-validate disallow-invalid`` is not enabled.
-
     In the following example, the router prefers valid routes over invalid
     prefixes because invalid routes have a lower local preference.
 
index 18426e0c517eba127306834a1cd09a1d9e7413e9..5335969fbcbee9c36d9d3efc67dc0ba09530901b 100644 (file)
@@ -1760,10 +1760,10 @@ static int file_write_config(struct vty *vty)
                dirfd = open(".", O_DIRECTORY | O_RDONLY);
        /* if dirfd is invalid, directory sync fails, but we're still OK */
 
-       config_file_sav = XMALLOC(
-               MTYPE_TMP, strlen(config_file) + strlen(CONF_BACKUP_EXT) + 1);
-       strcpy(config_file_sav, config_file);
-       strcat(config_file_sav, CONF_BACKUP_EXT);
+       size_t config_file_sav_sz = strlen(config_file) + strlen(CONF_BACKUP_EXT) + 1;
+       config_file_sav = XMALLOC(MTYPE_TMP, config_file_sav_sz);
+       strlcpy(config_file_sav, config_file, config_file_sav_sz);
+       strlcat(config_file_sav, CONF_BACKUP_EXT, config_file_sav_sz);
 
 
        config_file_tmp = XMALLOC(MTYPE_TMP, strlen(config_file) + 8);
@@ -2803,9 +2803,10 @@ void cmd_init(int terminal)
        /* Each node's basic commands. */
        install_element(VIEW_NODE, &show_version_cmd);
        install_element(ENABLE_NODE, &show_startup_config_cmd);
-       install_element(ENABLE_NODE, &debug_memstats_cmd);
 
        if (terminal) {
+               install_element(ENABLE_NODE, &debug_memstats_cmd);
+
                install_element(VIEW_NODE, &config_list_cmd);
                install_element(VIEW_NODE, &config_exit_cmd);
                install_element(VIEW_NODE, &config_quit_cmd);
@@ -2839,9 +2840,10 @@ void cmd_init(int terminal)
        install_element(CONFIG_NODE, &domainname_cmd);
        install_element(CONFIG_NODE, &no_domainname_cmd);
        install_element(CONFIG_NODE, &frr_version_defaults_cmd);
-       install_element(CONFIG_NODE, &debug_memstats_cmd);
 
        if (terminal > 0) {
+               install_element(CONFIG_NODE, &debug_memstats_cmd);
+
                install_element(CONFIG_NODE, &password_cmd);
                install_element(CONFIG_NODE, &no_password_cmd);
                install_element(CONFIG_NODE, &enable_password_cmd);
index 8b34d1e3eb907e6848e75ea6af5edbe23d16c61a..9456e1585a9ece96b6dce18447efd5a5ce155e29 100644 (file)
@@ -723,7 +723,7 @@ static enum match_type match_ipv4(const char *str)
                if (str - sp > 3)
                        return no_match;
 
-               strncpy(buf, sp, str - sp);
+               memcpy(buf, sp, str - sp);
                if (atoi(buf) > 255)
                        return no_match;
 
@@ -774,7 +774,7 @@ static enum match_type match_ipv4_prefix(const char *str)
                if (str - sp > 3)
                        return no_match;
 
-               strncpy(buf, sp, str - sp);
+               memcpy(buf, sp, str - sp);
                if (atoi(buf) > 255)
                        return no_match;
 
index 72fd4648ee85ae97962ca288717c43d0b7cbc6c9..3248ceb13b53222e84a143a5a532a73c4cf8d0dd 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <zebra.h>
+#include "typesafe.h"
 #include "debug.h"
 #include "command.h"
 
-static const struct debug_callbacks *callbacks;
+static struct debug_cb_list_head cb_head;
+
+DECLARE_LIST(debug_cb_list, struct debug_callbacks, item)
 
 /* All code in this section should be reentrant and MT-safe */
 
 DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
           NO_STR DEBUG_STR "Toggle all debugging output\n")
 {
+       struct debug_callbacks *cb;
+
        bool set = !strmatch(argv[0]->text, "no");
        uint32_t mode = DEBUG_NODE2MODE(vty->node);
 
-       if (callbacks->debug_set_all)
-               callbacks->debug_set_all(mode, set);
+       frr_each (debug_cb_list, &cb_head, cb)
+               cb->debug_set_all(mode, set);
+
        return CMD_SUCCESS;
 }
 
 /* ------------------------------------------------------------------------- */
 
-void debug_init(const struct debug_callbacks *cb)
+void debug_init(struct debug_callbacks *cb)
+{
+       static bool inited = false;
+
+       if (!inited) {
+               inited = true;
+               debug_cb_list_init(&cb_head);
+       }
+
+       debug_cb_list_add_head(&cb_head, cb);
+}
+
+void debug_init_cli(void)
 {
-       callbacks = cb;
        install_element(ENABLE_NODE, &debug_all_cmd);
        install_element(CONFIG_NODE, &debug_all_cmd);
 }
index ace060d0578905fb64a0734da41a63b673c42a45..f25cd426913f8a0bb518df0e77b6e1933c6d060c 100644 (file)
@@ -84,6 +84,7 @@ struct debug {
        const char *desc;
 };
 
+PREDECL_LIST(debug_cb_list)
 /*
  * Callback set for debugging code.
  *
@@ -92,6 +93,11 @@ struct debug {
  *    mode set.
  */
 struct debug_callbacks {
+       /*
+        * Linked list of Callbacks to call
+        */
+       struct debug_cb_list_item item;
+
        /*
         * flags
         *    flags to set on debug flag fields
@@ -233,7 +239,13 @@ struct debug_callbacks {
  *
  * MT-Safe
  */
-void debug_init(const struct debug_callbacks *cb);
+void debug_init(struct debug_callbacks *cb);
+
+/*
+ * Turn on the cli to turn on/off debugs.
+ * Should only be called by libfrr
+ */
+void debug_init_cli(void);
 
 #ifdef __cplusplus
 }
index 5970e70a6bd493230f9b7cb5091cb963277178c5..15de96feee62f518c118a06881f1e93f27aa6102 100644 (file)
@@ -39,6 +39,7 @@
 #include "db.h"
 #include "northbound_cli.h"
 #include "northbound_db.h"
+#include "debug.h"
 
 DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
 DEFINE_KOOH(frr_early_fini, (), ())
@@ -80,8 +81,8 @@ static void opt_extend(const struct optspec *os)
 {
        const struct option *lo;
 
-       strcat(comb_optstr, os->optstr);
-       strcat(comb_helpstr, os->helpstr);
+       strlcat(comb_optstr, os->optstr, sizeof(comb_optstr));
+       strlcat(comb_helpstr, os->helpstr, sizeof(comb_helpstr));
        for (lo = os->longopts; lo->name; lo++)
                memcpy(comb_next_lo++, lo, sizeof(*lo));
 }
@@ -654,6 +655,9 @@ struct thread_master *frr_init(void)
        lib_error_init();
 
        yang_init();
+
+       debug_init_cli();
+
        nb_init(master, di->yang_modules, di->n_yang_modules);
        if (nb_db_init() != NB_OK)
                flog_warn(EC_LIB_NB_DATABASE,
index e64c00186be21204ab9137b0034bbeb9dd2b54cd..5e3064a8d8996f74deee58aa5c4b90d003395519 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -602,6 +602,8 @@ void zlog_backtrace_sigsafe(int priority, void *program_counter)
                backtrace_symbols_fd(array, size, FD);                         \
        }
 #elif defined(HAVE_PRINTSTACK)
+       size = 0;
+
 #define DUMP(FD)                                                               \
        {                                                                      \
                if (program_counter)                                           \
index ae1b0578a004ef473da89b2c97ea8c74a6a2a906..7b7b526af02a52a64f66b98b3f1454341d1c182a 100644 (file)
@@ -1722,8 +1722,8 @@ void nb_cli_init(struct thread_master *tm)
        /* Initialize the shared candidate configuration. */
        vty_shared_candidate_config = nb_config_new(NULL);
 
-       /* Install debug commands */
        debug_init(&nb_dbg_cbs);
+
        install_node(&nb_debug_node, nb_debug_config_write);
        install_element(ENABLE_NODE, &debug_nb_cmd);
        install_element(CONFIG_NODE, &debug_nb_cmd);
index d2a4c3a432351193e2c24fcb4ecb40784924ad78..42d202ddbce13dfe60321cc0b67fbb050b9f2e5a 100644 (file)
@@ -1365,7 +1365,7 @@ void prefix_mcast_inet4_dump(const char *onfail, struct in_addr addr,
        int save_errno = errno;
 
        if (addr.s_addr == INADDR_ANY)
-               strcpy(buf, "*");
+               strlcpy(buf, "*", buf_size);
        else {
                if (!inet_ntop(AF_INET, &addr, buf, buf_size)) {
                        if (onfail)
index 14be7ab65668216e1dd899696a76ca835c909189..eefd992546a5614e2b10e6ac9030d794452e411e 100644 (file)
@@ -298,6 +298,8 @@ static inline struct route_node *route_table_iter_next(route_table_iter_t *iter)
                return NULL;
 
        default:
+               /* Suppress uninitialized variable warning */
+               node = NULL;
                assert(0);
        }
 
index 0ee9b78b91f9afa77951178dbd734bd003396e08..2d97cca351bfacd76aa18af8dc2810b654c89261 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -84,7 +84,7 @@ static char *vty_ipv6_accesslist_name = NULL;
 static vector Vvty_serv_thread;
 
 /* Current directory. */
-char *vty_cwd = NULL;
+char vty_cwd[MAXPATHLEN];
 
 /* Login password check. */
 static int no_password_check = 0;
@@ -998,7 +998,7 @@ static void vty_describe_fold(struct vty *vty, int cmd_width,
                if (pos == 0)
                        break;
 
-               strncpy(buf, p, pos);
+               memcpy(buf, p, pos);
                buf[pos] = '\0';
                vty_out(vty, "  %-*s  %s\n", cmd_width, cmd, buf);
 
@@ -1659,7 +1659,7 @@ static struct vty *vty_create(int vty_sock, union sockunion *su)
 
        /* configurable parameters not part of basic init */
        vty->v_timeout = vty_timeout_val;
-       strcpy(vty->address, buf);
+       strlcpy(vty->address, buf, sizeof(vty->address));
        if (no_password_check) {
                if (host.advanced)
                        vty->node = ENABLE_NODE;
@@ -1795,7 +1795,7 @@ struct vty *vty_stdio(void (*atclose)(int isexit))
         */
        vty->node = ENABLE_NODE;
        vty->v_timeout = 0;
-       strcpy(vty->address, "console");
+       strlcpy(vty->address, "console", sizeof(vty->address));
 
        vty_stdio_resume();
        return vty;
@@ -2384,9 +2384,10 @@ static FILE *vty_use_backup_config(const char *fullpath)
        int c;
        char buffer[512];
 
-       fullpath_sav = malloc(strlen(fullpath) + strlen(CONF_BACKUP_EXT) + 1);
-       strcpy(fullpath_sav, fullpath);
-       strcat(fullpath_sav, CONF_BACKUP_EXT);
+       size_t fullpath_sav_sz = strlen(fullpath) + strlen(CONF_BACKUP_EXT) + 1;
+       fullpath_sav = malloc(fullpath_sav_sz);
+       strlcpy(fullpath_sav, fullpath, fullpath_sav_sz);
+       strlcat(fullpath_sav, CONF_BACKUP_EXT, fullpath_sav_sz);
 
        sav = open(fullpath_sav, O_RDONLY);
        if (sav < 0) {
@@ -3055,10 +3056,9 @@ void vty_reset(void)
 
 static void vty_save_cwd(void)
 {
-       char cwd[MAXPATHLEN];
        char *c;
 
-       c = getcwd(cwd, MAXPATHLEN);
+       c = getcwd(vty_cwd, sizeof(vty_cwd));
 
        if (!c) {
                /*
@@ -3072,15 +3072,12 @@ static void vty_save_cwd(void)
                                     SYSCONFDIR, errno);
                        exit(-1);
                }
-               if (getcwd(cwd, MAXPATHLEN) == NULL) {
+               if (getcwd(vty_cwd, sizeof(vty_cwd)) == NULL) {
                        flog_err_sys(EC_LIB_SYSTEM_CALL,
                                     "Failure to getcwd, errno: %d", errno);
                        exit(-1);
                }
        }
-
-       vty_cwd = XMALLOC(MTYPE_TMP, strlen(cwd) + 1);
-       strcpy(vty_cwd, cwd);
 }
 
 char *vty_get_cwd(void)
@@ -3146,7 +3143,7 @@ void vty_init(struct thread_master *master_thread)
 
 void vty_terminate(void)
 {
-       XFREE(MTYPE_TMP, vty_cwd);
+       memset(vty_cwd, 0x00, sizeof(vty_cwd));
 
        if (vtyvec && Vvty_serv_thread) {
                vty_reset();
index 1488aa88cd4edadbc8f6ec8bcfa37f9807b179d1..e68363663949b8d7c34965fcd2afc11b59d629cf 100644 (file)
@@ -2535,7 +2535,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
        struct interface *ifp = NULL;
        struct listnode *node;
        char *vrf_name = NULL;
-       bool all_vrf;
+       bool all_vrf = false;
        int inst = 0;
        int idx_vrf = 0;
        struct ospf *ospf = NULL;
index 52506542bc89657e2065181768556e589bac3b36..fc78b8ed1f54a1d502ccf5428b5debd0bb960219 100644 (file)
@@ -191,7 +191,7 @@ static void *pbr_nhgc_alloc(void *p)
 
        new = XCALLOC(MTYPE_PBR_NHG, sizeof(*new));
 
-       strcpy(new->name, pnhgc->name);
+       strlcpy(new->name, pnhgc->name, sizeof(pnhgc->name));
        new->table_id = pbr_nht_get_next_tableid(false);
 
        DEBUGD(&pbr_dbg_nht, "%s: NHT: %s assigned Table ID: %u",
index fe910591a65024252784c732793f7ac06210b6a9..8cbacf53adf10b59082eca03057d724239465f65 100644 (file)
@@ -658,6 +658,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
        long oqpi_msec; /* Other Querier Present Interval */
        long qri_msec;
        time_t now;
+       int lmqc;
 
        json_object *json = NULL;
        json_object *json_row = NULL;
@@ -702,8 +703,8 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
                                pim_ifp->igmp_query_max_response_time_dsec);
 
                        lmqt_msec = PIM_IGMP_LMQT_MSEC(
-                               pim_ifp->igmp_query_max_response_time_dsec,
-                               igmp->querier_robustness_variable);
+                               pim_ifp->igmp_specific_query_max_response_time_dsec,
+                               pim_ifp->igmp_last_member_query_count);
 
                        ohpi_msec =
                                PIM_IGMP_OHPI_DSEC(
@@ -719,6 +720,7 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
                                        pim_ifp->pim_sock_fd);
                        else
                                mloop = 0;
+                       lmqc = pim_ifp->igmp_last_member_query_count;
 
                        if (uj) {
                                json_row = json_object_new_object();
@@ -743,6 +745,9 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
                                        json_row,
                                        "timerGroupMembershipIntervalMsec",
                                        gmi_msec);
+                               json_object_int_add(json_row,
+                                                   "lastMemberQueryCount",
+                                                   lmqc);
                                json_object_int_add(json_row,
                                                    "timerLastMemberQueryMsec",
                                                    lmqt_msec);
@@ -809,6 +814,9 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
                                vty_out(vty,
                                        "Group Membership Interval      : %lis\n",
                                        gmi_msec / 1000);
+                               vty_out(vty,
+                                       "Last Member Query Count        : %d\n",
+                                       lmqc);
                                vty_out(vty,
                                        "Last Member Query Time         : %lis\n",
                                        lmqt_msec / 1000);
@@ -2001,9 +2009,9 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty,
                ifp_in = pim_if_find_by_vif_index(pim, c_oil->oil.mfcc_parent);
 
                if (ifp_in)
-                       strcpy(in_ifname, ifp_in->name);
+                       strlcpy(in_ifname, ifp_in->name, sizeof(in_ifname));
                else
-                       strcpy(in_ifname, "<iif?>");
+                       strlcpy(in_ifname, "<iif?>", sizeof(in_ifname));
 
                if (src_or_group) {
                        if (strcmp(src_or_group, src_str)
@@ -2085,9 +2093,9 @@ static void pim_show_state(struct pim_instance *pim, struct vty *vty,
                                now - c_oil->oif_creation[oif_vif_index]);
 
                        if (ifp_out)
-                               strcpy(out_ifname, ifp_out->name);
+                               strlcpy(out_ifname, ifp_out->name, sizeof(out_ifname));
                        else
-                               strcpy(out_ifname, "<oif?>");
+                               strlcpy(out_ifname, "<oif?>", sizeof(out_ifname));
 
                        if (uj) {
                                json_ifp_out = json_object_new_object();
@@ -2366,37 +2374,37 @@ static void json_object_pim_upstream_add(json_object *json,
 
 static const char *
 pim_upstream_state2brief_str(enum pim_upstream_state join_state,
-                            char *state_str)
+                            char *state_str, size_t state_str_len)
 {
        switch (join_state) {
        case PIM_UPSTREAM_NOTJOINED:
-               strcpy(state_str, "NotJ");
+               strlcpy(state_str, "NotJ", state_str_len);
                break;
        case PIM_UPSTREAM_JOINED:
-               strcpy(state_str, "J");
+               strlcpy(state_str, "J", state_str_len);
                break;
        default:
-               strcpy(state_str, "Unk");
+               strlcpy(state_str, "Unk", state_str_len);
        }
        return state_str;
 }
 
 static const char *pim_reg_state2brief_str(enum pim_reg_state reg_state,
-                                          char *state_str)
+                                          char *state_str, size_t state_str_len)
 {
        switch (reg_state) {
        case PIM_REG_NOINFO:
-               strcpy(state_str, "RegNI");
+               strlcpy(state_str, "RegNI", state_str_len);
                break;
        case PIM_REG_JOIN:
-               strcpy(state_str, "RegJ");
+               strlcpy(state_str, "RegJ", state_str_len);
                break;
        case PIM_REG_JOIN_PENDING:
        case PIM_REG_PRUNE:
-               strcpy(state_str, "RegP");
+               strlcpy(state_str, "RegP", state_str_len);
                break;
        default:
-               strcpy(state_str, "Unk");
+               strlcpy(state_str, "Unk", state_str_len);
        }
        return state_str;
 }
@@ -2464,13 +2472,13 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
                pim_time_timer_to_hhmmss(msdp_reg_timer, sizeof(msdp_reg_timer),
                                         up->t_msdp_reg_timer);
 
-               pim_upstream_state2brief_str(up->join_state, state_str);
+               pim_upstream_state2brief_str(up->join_state, state_str, sizeof(state_str));
                if (up->reg_state != PIM_REG_NOINFO) {
                        char tmp_str[PIM_REG_STATE_STR_LEN];
 
                        sprintf(state_str + strlen(state_str), ",%s",
-                               pim_reg_state2brief_str(up->reg_state,
-                                                       tmp_str));
+                               pim_reg_state2brief_str(up->reg_state, tmp_str,
+                                                       sizeof(tmp_str)));
                }
 
                if (uj) {
@@ -2521,7 +2529,7 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
                                pim_upstream_state2str(up->join_state));
                        json_object_string_add(
                                json_row, "regState",
-                               pim_reg_state2str(up->reg_state, state_str));
+                               pim_reg_state2str(up->reg_state, state_str, sizeof(state_str)));
                        json_object_string_add(json_row, "upTime", uptime);
                        json_object_string_add(json_row, "joinTimer",
                                               join_timer);
@@ -5234,9 +5242,9 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                ifp_in = pim_if_find_by_vif_index(pim, c_oil->oil.mfcc_parent);
 
                if (ifp_in)
-                       strcpy(in_ifname, ifp_in->name);
+                       strlcpy(in_ifname, ifp_in->name, sizeof(in_ifname));
                else
-                       strcpy(in_ifname, "<iif?>");
+                       strlcpy(in_ifname, "<iif?>", sizeof(in_ifname));
 
                if (uj) {
 
@@ -5291,9 +5299,9 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                        found_oif = 1;
 
                        if (ifp_out)
-                               strcpy(out_ifname, ifp_out->name);
+                               strlcpy(out_ifname, ifp_out->name, sizeof(out_ifname));
                        else
-                               strcpy(out_ifname, "<oif?>");
+                               strlcpy(out_ifname, "<oif?>", sizeof(out_ifname));
 
                        if (uj) {
                                json_ifp_out = json_object_new_object();
@@ -5351,27 +5359,27 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                        } else {
                                if (c_oil->oif_flags[oif_vif_index]
                                    & PIM_OIF_FLAG_PROTO_PIM) {
-                                       strcpy(proto, "PIM");
+                                       strlcpy(proto, "PIM", sizeof(proto));
                                }
 
                                if (c_oil->oif_flags[oif_vif_index]
                                    & PIM_OIF_FLAG_PROTO_IGMP) {
-                                       strcpy(proto, "IGMP");
+                                       strlcpy(proto, "IGMP", sizeof(proto));
                                }
 
                                if (c_oil->oif_flags[oif_vif_index]
                                    & PIM_OIF_FLAG_PROTO_VXLAN) {
-                                       strcpy(proto, "VxLAN");
+                                       strlcpy(proto, "VxLAN", sizeof(proto));
                                }
 
                                if (c_oil->oif_flags[oif_vif_index]
                                    & PIM_OIF_FLAG_PROTO_SOURCE) {
-                                       strcpy(proto, "SRC");
+                                       strlcpy(proto, "SRC", sizeof(proto));
                                }
 
                                if (c_oil->oif_flags[oif_vif_index]
                                    & PIM_OIF_FLAG_PROTO_STAR) {
-                                       strcpy(proto, "STAR");
+                                       strlcpy(proto, "STAR", sizeof(proto));
                                }
 
                                vty_out(vty,
@@ -5410,9 +5418,9 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                found_oif = 0;
 
                if (ifp_in)
-                       strcpy(in_ifname, ifp_in->name);
+                       strlcpy(in_ifname, ifp_in->name, sizeof(in_ifname));
                else
-                       strcpy(in_ifname, "<iif?>");
+                       strlcpy(in_ifname, "<iif?>", sizeof(in_ifname));
 
                if (uj) {
 
@@ -5439,7 +5447,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                        json_object_string_add(json_source, "iif", in_ifname);
                        json_oil = NULL;
                } else {
-                       strcpy(proto, "STATIC");
+                       strlcpy(proto, "STATIC", sizeof(proto));
                }
 
                for (oif_vif_index = 0; oif_vif_index < MAXVIFS;
@@ -5461,9 +5469,9 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
                        found_oif = 1;
 
                        if (ifp_out)
-                               strcpy(out_ifname, ifp_out->name);
+                               strlcpy(out_ifname, ifp_out->name, sizeof(out_ifname));
                        else
-                               strcpy(out_ifname, "<oif?>");
+                               strlcpy(out_ifname, "<oif?>", sizeof(out_ifname));
 
                        if (uj) {
                                json_ifp_out = json_object_new_object();
@@ -7161,6 +7169,106 @@ DEFUN_HIDDEN (interface_no_ip_igmp_query_max_response_time_dsec,
        return CMD_SUCCESS;
 }
 
+#define IGMP_LAST_MEMBER_QUERY_COUNT_MIN (1)
+#define IGMP_LAST_MEMBER_QUERY_COUNT_MAX (7)
+
+DEFUN (interface_ip_igmp_last_member_query_count,
+       interface_ip_igmp_last_member_query_count_cmd,
+       "ip igmp last-member-query-count (1-7)",
+       IP_STR
+       IFACE_IGMP_STR
+       IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR
+       "Last member query count\n")
+{
+       VTY_DECLVAR_CONTEXT(interface, ifp);
+       struct pim_interface *pim_ifp = ifp->info;
+       int last_member_query_count;
+       int ret;
+
+       if (!pim_ifp) {
+               ret = pim_cmd_igmp_start(vty, ifp);
+               if (ret != CMD_SUCCESS)
+                       return ret;
+               pim_ifp = ifp->info;
+       }
+
+       last_member_query_count = atoi(argv[3]->arg);
+
+       pim_ifp->igmp_last_member_query_count = last_member_query_count;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN (interface_no_ip_igmp_last_member_query_count,
+       interface_no_ip_igmp_last_member_query_count_cmd,
+       "no ip igmp last-member-query-count",
+       NO_STR
+       IP_STR
+       IFACE_IGMP_STR
+       IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR)
+{
+       VTY_DECLVAR_CONTEXT(interface, ifp);
+       struct pim_interface *pim_ifp = ifp->info;
+
+       if (!pim_ifp)
+               return CMD_SUCCESS;
+
+       pim_ifp->igmp_last_member_query_count =
+               IGMP_DEFAULT_ROBUSTNESS_VARIABLE;
+
+       return CMD_SUCCESS;
+}
+
+#define IGMP_LAST_MEMBER_QUERY_INTERVAL_MIN (1)
+#define IGMP_LAST_MEMBER_QUERY_INTERVAL_MAX (255)
+
+DEFUN (interface_ip_igmp_last_member_query_interval,
+       interface_ip_igmp_last_member_query_interval_cmd,
+       "ip igmp last-member-query-interval (1-255)",
+       IP_STR
+       IFACE_IGMP_STR
+       IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR
+       "Last member query interval in deciseconds\n")
+{
+       VTY_DECLVAR_CONTEXT(interface, ifp);
+       struct pim_interface *pim_ifp = ifp->info;
+       int last_member_query_interval;
+       int ret;
+
+       if (!pim_ifp) {
+               ret = pim_cmd_igmp_start(vty, ifp);
+               if (ret != CMD_SUCCESS)
+                       return ret;
+               pim_ifp = ifp->info;
+       }
+
+       last_member_query_interval = atoi(argv[3]->arg);
+       pim_ifp->igmp_specific_query_max_response_time_dsec
+               = last_member_query_interval;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN (interface_no_ip_igmp_last_member_query_interval,
+       interface_no_ip_igmp_last_member_query_interval_cmd,
+       "no ip igmp last-member-query-interval",
+       NO_STR
+       IP_STR
+       IFACE_IGMP_STR
+       IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR)
+{
+       VTY_DECLVAR_CONTEXT(interface, ifp);
+       struct pim_interface *pim_ifp = ifp->info;
+
+       if (!pim_ifp)
+               return CMD_SUCCESS;
+
+       pim_ifp->igmp_specific_query_max_response_time_dsec =
+               IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC;
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (interface_ip_pim_drprio,
        interface_ip_pim_drprio_cmd,
        "ip pim drpriority (1-4294967295)",
@@ -9089,7 +9197,7 @@ static void ip_msdp_show_peers(struct pim_instance *pim, struct vty *vty,
                        pim_time_uptime(timebuf, sizeof(timebuf),
                                        now - mp->uptime);
                } else {
-                       strcpy(timebuf, "-");
+                       strlcpy(timebuf, "-", sizeof(timebuf));
                }
                pim_inet4_dump("<peer?>", mp->peer, peer_str, sizeof(peer_str));
                pim_inet4_dump("<local?>", mp->local, local_str,
@@ -9146,7 +9254,7 @@ static void ip_msdp_show_peers_detail(struct pim_instance *pim, struct vty *vty,
                        pim_time_uptime(timebuf, sizeof(timebuf),
                                        now - mp->uptime);
                } else {
-                       strcpy(timebuf, "-");
+                       strlcpy(timebuf, "-", sizeof(timebuf));
                }
                pim_inet4_dump("<local?>", mp->local, local_str,
                               sizeof(local_str));
@@ -9325,18 +9433,18 @@ static void ip_msdp_show_sa(struct pim_instance *pim, struct vty *vty, bool uj)
                if (sa->flags & PIM_MSDP_SAF_PEER) {
                        pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
                        if (sa->up) {
-                               strcpy(spt_str, "yes");
+                               strlcpy(spt_str, "yes", sizeof(spt_str));
                        } else {
-                               strcpy(spt_str, "no");
+                               strlcpy(spt_str, "no", sizeof(spt_str));
                        }
                } else {
-                       strcpy(rp_str, "-");
-                       strcpy(spt_str, "-");
+                       strlcpy(rp_str, "-", sizeof(rp_str));
+                       strlcpy(spt_str, "-", sizeof(spt_str));
                }
                if (sa->flags & PIM_MSDP_SAF_LOCAL) {
-                       strcpy(local_str, "yes");
+                       strlcpy(local_str, "yes", sizeof(local_str));
                } else {
-                       strcpy(local_str, "no");
+                       strlcpy(local_str, "no", sizeof(local_str));
                }
                if (uj) {
                        json_object_object_get_ex(json, grp_str, &json_group);
@@ -9390,19 +9498,19 @@ static void ip_msdp_show_sa_entry_detail(struct pim_msdp_sa *sa,
                pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
                pim_inet4_dump("<peer?>", sa->peer, peer_str, sizeof(peer_str));
                if (sa->up) {
-                       strcpy(spt_str, "yes");
+                       strlcpy(spt_str, "yes", sizeof(spt_str));
                } else {
-                       strcpy(spt_str, "no");
+                       strlcpy(spt_str, "no", sizeof(spt_str));
                }
        } else {
-               strcpy(rp_str, "-");
-               strcpy(peer_str, "-");
-               strcpy(spt_str, "-");
+               strlcpy(rp_str, "-", sizeof(rp_str));
+               strlcpy(peer_str, "-", sizeof(peer_str));
+               strlcpy(spt_str, "-", sizeof(spt_str));
        }
        if (sa->flags & PIM_MSDP_SAF_LOCAL) {
-               strcpy(local_str, "yes");
+               strlcpy(local_str, "yes", sizeof(local_str));
        } else {
-               strcpy(local_str, "no");
+               strlcpy(local_str, "no", sizeof(local_str));
        }
        pim_time_timer_to_hhmmss(statetimer, sizeof(statetimer),
                                 sa->sa_state_timer);
@@ -10116,6 +10224,14 @@ void pim_cmd_init(void)
                        &interface_ip_igmp_query_max_response_time_dsec_cmd);
        install_element(INTERFACE_NODE,
                        &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
+       install_element(INTERFACE_NODE,
+                       &interface_ip_igmp_last_member_query_count_cmd);
+       install_element(INTERFACE_NODE,
+                       &interface_no_ip_igmp_last_member_query_count_cmd);
+       install_element(INTERFACE_NODE,
+                       &interface_ip_igmp_last_member_query_interval_cmd);
+       install_element(INTERFACE_NODE,
+                       &interface_no_ip_igmp_last_member_query_interval_cmd);
        install_element(INTERFACE_NODE, &interface_ip_pim_activeactive_cmd);
        install_element(INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
        install_element(INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
index 558f28231ba2278a2ddf9162259f9c1363ead4e4..f5bb316a7ae3b3648d6b7641db30566a700b3187 100644 (file)
@@ -35,6 +35,8 @@
 #define IFACE_IGMP_QUERY_INTERVAL_STR          "IGMP host query interval\n"
 #define IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR      "IGMP max query response value (seconds)\n"
 #define IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR "IGMP max query response value (deciseconds)\n"
+#define IFACE_IGMP_LAST_MEMBER_QUERY_INTERVAL_STR   "IGMP last member query interval\n"
+#define IFACE_IGMP_LAST_MEMBER_QUERY_COUNT_STR      "IGMP last member query count\n"
 #define DEBUG_IGMP_STR                              "IGMP protocol activity\n"
 #define DEBUG_IGMP_EVENTS_STR                       "IGMP protocol events\n"
 #define DEBUG_IGMP_PACKETS_STR                      "IGMP protocol packets\n"
index 08be38c138abe570908e2949650f3152652b172b..7b8f045697884cd7de1a85f7e8c7e841a77b883a 100644 (file)
@@ -131,6 +131,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
                IGMP_QUERY_MAX_RESPONSE_TIME_DSEC;
        pim_ifp->igmp_specific_query_max_response_time_dsec =
                IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC;
+       pim_ifp->igmp_last_member_query_count =
+               IGMP_DEFAULT_ROBUSTNESS_VARIABLE;
 
        /* BSM config on interface: TRUE by default */
        pim_ifp->bsm_enable = true;
index ab138589bd1252e41891a9409a1223ea50585329..1c11e85705189364f398a783d43055808c4b943f 100644 (file)
@@ -88,8 +88,14 @@ struct pim_interface {
        int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in
                                                  dsecs for general queries */
        int igmp_specific_query_max_response_time_dsec; /* IGMPv3 Max Response
-                                                          Time in dsecs for
-                                                          specific queries */
+                                                          Time in dsecs called
+                                                          as last member query
+                                                          interval, defines the
+                                                          maximum response time
+                                                          advertised in IGMP
+                                                          group-specific
+                                                          queries */
+       int igmp_last_member_query_count; /* IGMP last member query count */
        struct list *igmp_socket_list; /* list of struct igmp_sock */
        struct list *igmp_join_list;   /* list of struct igmp_join */
 
index b845f54f066d17e6e92246cfa5c6afb2e44e1aa6..bc0460fa0397072ae44198afc94dfbf3774b797b 100644 (file)
@@ -997,7 +997,7 @@ static void group_retransmit_group(struct igmp_group *group)
 
        char query_buf[query_buf_size];
 
-       lmqc = igmp->querier_robustness_variable;
+       lmqc = pim_ifp->igmp_last_member_query_count;
        lmqi_msec = 100 * pim_ifp->igmp_specific_query_max_response_time_dsec;
        lmqt_msec = lmqc * lmqi_msec;
 
@@ -1076,7 +1076,7 @@ static int group_retransmit_sources(struct igmp_group *group,
        igmp = group->group_igmp_sock;
        pim_ifp = igmp->interface->info;
 
-       lmqc = igmp->querier_robustness_variable;
+       lmqc = pim_ifp->igmp_last_member_query_count;
        lmqi_msec = 100 * pim_ifp->igmp_specific_query_max_response_time_dsec;
        lmqt_msec = lmqc * lmqi_msec;
 
@@ -1314,9 +1314,13 @@ static long igmp_source_timer_remain_msec(struct igmp_source *source)
 */
 static void group_query_send(struct igmp_group *group)
 {
+       struct pim_interface *pim_ifp;
+       struct igmp_sock *igmp;
        long lmqc; /* Last Member Query Count */
 
-       lmqc = group->group_igmp_sock->querier_robustness_variable;
+       igmp = group->group_igmp_sock;
+       pim_ifp = igmp->interface->info;
+       lmqc = pim_ifp->igmp_last_member_query_count;
 
        /* lower group timer to lmqt */
        igmp_group_timer_lower_to_lmqt(group);
@@ -1351,7 +1355,7 @@ static void source_query_send_by_flag(struct igmp_group *group,
        igmp = group->group_igmp_sock;
        pim_ifp = igmp->interface->info;
 
-       lmqc = igmp->querier_robustness_variable;
+       lmqc = pim_ifp->igmp_last_member_query_count;
        lmqi_msec = 100 * pim_ifp->igmp_specific_query_max_response_time_dsec;
        lmqt_msec = lmqc * lmqi_msec;
 
@@ -1509,7 +1513,7 @@ void igmp_group_timer_lower_to_lmqt(struct igmp_group *group)
        ifname = ifp->name;
 
        lmqi_dsec = pim_ifp->igmp_specific_query_max_response_time_dsec;
-       lmqc = igmp->querier_robustness_variable;
+       lmqc = pim_ifp->igmp_last_member_query_count;
        lmqt_msec = PIM_IGMP_LMQT_MSEC(
                lmqi_dsec, lmqc); /* lmqt_msec = (100 * lmqi_dsec) * lmqc */
 
@@ -1546,7 +1550,7 @@ void igmp_source_timer_lower_to_lmqt(struct igmp_source *source)
        ifname = ifp->name;
 
        lmqi_dsec = pim_ifp->igmp_specific_query_max_response_time_dsec;
-       lmqc = igmp->querier_robustness_variable;
+       lmqc = pim_ifp->igmp_last_member_query_count;
        lmqt_msec = PIM_IGMP_LMQT_MSEC(
                lmqi_dsec, lmqc); /* lmqt_msec = (100 * lmqi_dsec) * lmqc */
 
index 3287e137193c3eb6083036d9ff0e109b64dc9187..74a3a9836bc6b7436320775f3cdc2c61ffef8f93 100644 (file)
@@ -1078,7 +1078,7 @@ static enum pim_msdp_err pim_msdp_peer_new(struct pim_instance *pim,
        mp->mesh_group_name = XSTRDUP(MTYPE_PIM_MSDP_MG_NAME, mesh_group_name);
        mp->state = PIM_MSDP_INACTIVE;
        mp->fd = -1;
-       strcpy(mp->last_reset, "-");
+       strlcpy(mp->last_reset, "-", sizeof(mp->last_reset));
        /* higher IP address is listener */
        if (ntohl(mp->local.s_addr) > ntohl(mp->peer.s_addr)) {
                mp->flags |= PIM_MSDP_PEERF_LISTENER;
index a823962b23269c2aedc5889f0a9e7e5eeb81b6bd..44b8ecbfea4767c1a8912fe3b7c2fc274eded214 100644 (file)
@@ -1399,23 +1399,24 @@ const char *pim_upstream_state2str(enum pim_upstream_state join_state)
        return "Unknown";
 }
 
-const char *pim_reg_state2str(enum pim_reg_state reg_state, char *state_str)
+const char *pim_reg_state2str(enum pim_reg_state reg_state, char *state_str,
+                             size_t state_str_len)
 {
        switch (reg_state) {
        case PIM_REG_NOINFO:
-               strcpy(state_str, "RegNoInfo");
+               strlcpy(state_str, "RegNoInfo", state_str_len);
                break;
        case PIM_REG_JOIN:
-               strcpy(state_str, "RegJoined");
+               strlcpy(state_str, "RegJoined", state_str_len);
                break;
        case PIM_REG_JOIN_PENDING:
-               strcpy(state_str, "RegJoinPend");
+               strlcpy(state_str, "RegJoinPend", state_str_len);
                break;
        case PIM_REG_PRUNE:
-               strcpy(state_str, "RegPrune");
+               strlcpy(state_str, "RegPrune", state_str_len);
                break;
        default:
-               strcpy(state_str, "RegUnknown");
+               strlcpy(state_str, "RegUnknown", state_str_len);
        }
        return state_str;
 }
@@ -1432,7 +1433,7 @@ static int pim_upstream_register_stop_timer(struct thread *t)
                char state_str[PIM_REG_STATE_STR_LEN];
                zlog_debug("%s: (S,G)=%s[%s] upstream register stop timer %s",
                           __PRETTY_FUNCTION__, up->sg_str, pim->vrf->name,
-                          pim_reg_state2str(up->reg_state, state_str));
+                          pim_reg_state2str(up->reg_state, state_str, sizeof(state_str)));
        }
 
        switch (up->reg_state) {
index 102826ac71ca84af665ad5c73e5986da4352d058..02ae998290579f3a5355e2c054fb76316fe20679 100644 (file)
@@ -283,7 +283,8 @@ void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up,
 
 const char *pim_upstream_state2str(enum pim_upstream_state join_state);
 #define PIM_REG_STATE_STR_LEN 12
-const char *pim_reg_state2str(enum pim_reg_state state, char *state_str);
+const char *pim_reg_state2str(enum pim_reg_state state, char *state_str,
+                             size_t state_str_len);
 
 int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
                                        struct pim_upstream *up);
index 8d40f85132acb78fe150578b6413e00e6b4dc59d..468cd56ee55bf315726948b9433ba2b8ca065a99 100644 (file)
@@ -350,6 +350,24 @@ int pim_interface_config_write(struct vty *vty)
                                        ++writes;
                                }
 
+                               /* IF ip igmp last-member_query-count */
+                               if (pim_ifp->igmp_last_member_query_count
+                                   != IGMP_DEFAULT_ROBUSTNESS_VARIABLE) {
+                                       vty_out(vty,
+                                               " ip igmp last-member-query-count %d\n",
+                                               pim_ifp->igmp_last_member_query_count);
+                                       ++writes;
+                               }
+
+                               /* IF ip igmp last-member_query-interval */
+                               if (pim_ifp->igmp_specific_query_max_response_time_dsec
+                                   != IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) {
+                                       vty_out(vty,
+                                               " ip igmp last-member-query-interval %d\n",
+                                               pim_ifp->igmp_specific_query_max_response_time_dsec);
+                                         ++writes;
+                               }
+
                                /* IF ip igmp join */
                                if (pim_ifp->igmp_join_list) {
                                        struct listnode *node;
index 411689a7a720eeb761419d2483b55a6011d03ed7..71bc43049ab039b3a565fb766718b8cb7d2cd37a 100644 (file)
@@ -2011,26 +2011,26 @@ static char *ripng_route_subtype_print(struct ripng_info *rinfo)
        memset(str, 0, 3);
 
        if (rinfo->suppress)
-               strcat(str, "S");
+               strlcat(str, "S", sizeof(str));
 
        switch (rinfo->sub_type) {
        case RIPNG_ROUTE_RTE:
-               strcat(str, "n");
+               strlcat(str, "n", sizeof(str));
                break;
        case RIPNG_ROUTE_STATIC:
-               strcat(str, "s");
+               strlcat(str, "s", sizeof(str));
                break;
        case RIPNG_ROUTE_DEFAULT:
-               strcat(str, "d");
+               strlcat(str, "d", sizeof(str));
                break;
        case RIPNG_ROUTE_REDISTRIBUTE:
-               strcat(str, "r");
+               strlcat(str, "r", sizeof(str));
                break;
        case RIPNG_ROUTE_INTERFACE:
-               strcat(str, "i");
+               strlcat(str, "i", sizeof(str));
                break;
        default:
-               strcat(str, "?");
+               strlcat(str, "?", sizeof(str));
                break;
        }
 
index cde31df14fece75fe24d222d6f9e8ff28768829c..5f9ecad6946229f8c3db99da2def2165552f7163 100644 (file)
@@ -127,7 +127,7 @@ int static_add_route(afi_t afi, safi_t safi, uint8_t type, struct prefix *p,
        si->tag = tag;
        si->vrf_id = svrf->vrf->vrf_id;
        si->nh_vrf_id = nh_svrf->vrf->vrf_id;
-       strcpy(si->nh_vrfname, nh_svrf->vrf->name);
+       strlcpy(si->nh_vrfname, nh_svrf->vrf->name, sizeof(si->nh_vrfname));
        si->table_id = table_id;
        si->onlink = onlink;
 
index a0b119c3ebaf23679efac8f33af7d252667dd505..1ab70eeed223a694191e43b4fd9274c5d6c4337c 100644 (file)
@@ -681,7 +681,7 @@ int vtysh_mark_file(const char *filename)
        while (fgets(vty->buf, VTY_BUFSIZ, confp)) {
                lineno++;
                tried = 0;
-               strcpy(vty_buf_copy, vty->buf);
+               strlcpy(vty_buf_copy, vty->buf, VTY_BUFSIZ);
                vty_buf_trimmed = trim(vty_buf_copy);
 
                switch (vty->node) {
@@ -2553,6 +2553,15 @@ DEFUNSH(VTYSH_ALL, vtysh_log_timestamp_precision,
        return CMD_SUCCESS;
 }
 
+DEFUNSH(VTYSH_ALL, vtysh_debug_memstats,
+       vtysh_debug_memstats_cmd, "[no] debug memstats-at-exit",
+       NO_STR
+       "Debug\n"
+       "Print memory statistics at exit\n")
+{
+       return CMD_SUCCESS;
+}
+
 DEFUNSH(VTYSH_ALL, no_vtysh_log_timestamp_precision,
        no_vtysh_log_timestamp_precision_cmd, "no log timestamp precision",
        NO_STR
@@ -2702,9 +2711,10 @@ static void backup_config_file(const char *fbackup)
 {
        char *integrate_sav = NULL;
 
-       integrate_sav = malloc(strlen(fbackup) + strlen(CONF_BACKUP_EXT) + 1);
-       strcpy(integrate_sav, fbackup);
-       strcat(integrate_sav, CONF_BACKUP_EXT);
+       size_t integrate_sav_sz = strlen(fbackup) + strlen(CONF_BACKUP_EXT) + 1;
+       integrate_sav = malloc(integrate_sav_sz);
+       strlcpy(integrate_sav, fbackup, integrate_sav_sz);
+       strlcat(integrate_sav, CONF_BACKUP_EXT, integrate_sav_sz);
 
        /* Move current configuration file to backup config file. */
        if (unlink(integrate_sav) != 0) {
@@ -3848,6 +3858,8 @@ void vtysh_init_vty(void)
        install_element(VIEW_NODE, &vtysh_show_debugging_hashtable_cmd);
        install_element(ENABLE_NODE, &vtysh_debug_all_cmd);
        install_element(CONFIG_NODE, &vtysh_debug_all_cmd);
+       install_element(ENABLE_NODE, &vtysh_debug_memstats_cmd);
+       install_element(CONFIG_NODE, &vtysh_debug_memstats_cmd);
 
        /* misc lib show commands */
        install_element(VIEW_NODE, &vtysh_show_memory_cmd);
index 322527015bd5b440503fe0d68f69da2b69bfde89..8202e076afb49cf387408d95d38b12f077b3036b 100644 (file)
@@ -245,7 +245,7 @@ static int if_set_prefix_ctx(const struct zebra_dplane_ctx *ctx)
        p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx);
 
        memset(&addreq, 0, sizeof(addreq));
-       strncpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx),
+       strlcpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx),
                sizeof(addreq.ifra_name));
 
        memset(&addr, 0, sizeof(struct sockaddr_in));
@@ -296,7 +296,7 @@ static int if_unset_prefix_ctx(const struct zebra_dplane_ctx *ctx)
        p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx);
 
        memset(&addreq, 0, sizeof(addreq));
-       strncpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx),
+       strlcpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx),
                sizeof(addreq.ifra_name));
 
        memset(&addr, 0, sizeof(struct sockaddr_in));
index ccfa7a4a4c38f3111b9eb5f6fbf27aa0e1170986..1f96fa23ea3af4b2c1368c1171ecaa3b33f94395 100644 (file)
@@ -286,7 +286,7 @@ static int if_unset_prefix_ctx(const struct zebra_dplane_ctx *ctx)
 
        p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx);
 
-       strncpy(ifreq.ifr_name, dplane_ctx_get_ifname(ctx),
+       strlcpy(ifreq.ifr_name, dplane_ctx_get_ifname(ctx),
                sizeof(ifreq.ifr_name));
 
        memset(&addr, 0, sizeof(struct sockaddr_in));
index 5f4bd3bbc6ef7656b21cebcbcbadcabb97d7ea72..156ce50725ec758d6e99f5594006a9f38912bf1c 100644 (file)
@@ -304,12 +304,13 @@ size_t rta_getattr(caddr_t sap, void *destp, size_t destlen)
 size_t rta_getsdlname(caddr_t sap, void *destp, short *destlen)
 {
        struct sockaddr_dl *sdl = (struct sockaddr_dl *)sap;
-       struct sockaddr *sa = (struct sockaddr *)sap;
        uint8_t *dest = destp;
        size_t tlen, copylen;
 
        copylen = sdl->sdl_nlen;
 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+       struct sockaddr *sa = (struct sockaddr *)sap;
+
        tlen = (sa->sa_len == 0) ? sizeof(ROUNDUP_TYPE) : ROUNDUP(sa->sa_len);
 #else  /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
        tlen = SAROUNDUP(sap);
@@ -522,7 +523,7 @@ static enum zebra_link_type sdl_to_zebra_link_type(unsigned int sdlt)
 int ifm_read(struct if_msghdr *ifm)
 {
        struct interface *ifp = NULL;
-       struct sockaddr_dl *sdl;
+       struct sockaddr_dl *sdl = NULL;
        char ifname[IFNAMSIZ];
        short ifnlen = 0;
        int maskbit;
index def5bf7d88947db03ff7ec48e67feb78dadf4efe..92c78a4cbb144a4a7dbad1b06312ef1024407d2c 100644 (file)
@@ -813,7 +813,7 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
 
                        sprintf(temp, "%s(%d) ", ifp ? ifp->name : "Unknown",
                                oif[count]);
-                       strcat(oif_list, temp);
+                       strlcat(oif_list, temp, sizeof(oif_list));
                }
                struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(vrf);
                ifp = if_lookup_by_index(iif, vrf);
index 48366417dd78362adea3ad471c1ccfb1496205d6..5214f1f22d26cb8a7613bdc6b4caa3f4ad8b5204 100644 (file)
@@ -1693,8 +1693,9 @@ static char *snhlfe2str(zebra_snhlfe_t *snhlfe, char *buf, int size)
        case NEXTHOP_TYPE_IPV6_IFINDEX:
                inet_ntop(AF_INET6, &snhlfe->gate.ipv6, buf, size);
                if (snhlfe->ifindex)
-                       strcat(buf,
-                              ifindex2ifname(snhlfe->ifindex, VRF_DEFAULT));
+                       strlcat(buf,
+                               ifindex2ifname(snhlfe->ifindex, VRF_DEFAULT),
+                               size);
                break;
        default:
                break;
index 600e820bc47e3205029c9806caba4d689f436ee5..83eb5f42230f3dbda0a96c0ae74d303e5cab9d27 100644 (file)
@@ -129,7 +129,7 @@ _rnode_zlog(const char *_func, vrf_id_t vrf_id, struct route_node *rn,
                srcdest_rnode2str(rn, buf, sizeof(buf));
 
                if (info->safi == SAFI_MULTICAST)
-                       strcat(buf, " (MRIB)");
+                       strlcat(buf, " (MRIB)", sizeof(buf));
        } else {
                snprintf(buf, sizeof(buf), "{(route_node *) NULL}");
        }
@@ -2650,15 +2650,9 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
                apply_mask_ipv6(src_p);
 
        /* Set default distance by route type. */
-       if (re->distance == 0) {
+       if (re->distance == 0)
                re->distance = route_distance(re->type);
 
-               /* iBGP distance is 200. */
-               if (re->type == ZEBRA_ROUTE_BGP
-                   && CHECK_FLAG(re->flags, ZEBRA_FLAG_IBGP))
-                       re->distance = 200;
-       }
-
        /* Lookup route node.*/
        rn = srcdest_rnode_get(table, p, src_p);