]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #13250 from chiragshah6/fdev1
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 11 Apr 2023 17:05:34 +0000 (20:05 +0300)
committerGitHub <noreply@github.com>
Tue, 11 Apr 2023 17:05:34 +0000 (20:05 +0300)
bgpd:add local_es_df_preference into l2vpn-evpn es json output

50 files changed:
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_vty.c
doc/developer/logging.rst
doc/user/isisd.rst
doc/user/mgmtd.rst
doc/user/ospfd.rst
isisd/fabricd.c
isisd/isis_adjacency.c
isisd/isis_adjacency.h
isisd/isis_circuit.c
isisd/isis_cli.c
isisd/isis_common.h
isisd/isis_dynhn.c
isisd/isis_events.c
isisd/isis_lfa.c
isisd/isis_lsp.c
isisd/isis_misc.c
isisd/isis_misc.h
isisd/isis_mt.c
isisd/isis_nb.c
isisd/isis_nb.h
isisd/isis_nb_config.c
isisd/isis_nb_notifications.c
isisd/isis_nb_state.c
isisd/isis_pdu.c
isisd/isis_pdu.h
isisd/isis_pdu_counter.c
isisd/isis_pdu_counter.h
isisd/isis_snmp.c
isisd/isis_spf.c
isisd/isis_sr.c
isisd/isis_te.c
isisd/isis_tlvs.c
isisd/isis_tx_queue.c
isisd/isisd.c
isisd/isisd.h
lib/if_rmap.c
lib/iso.c [new file with mode: 0644]
lib/iso.h [new file with mode: 0644]
lib/link_state.c
lib/subdir.am
ospfd/ospf_network.c
ospfd/ospf_network.h
ospfd/ospf_vty.c
ospfd/ospfd.c
ospfd/ospfd.h
ripd/ripd.c
yang/frr-isisd.yang

index 96feb19c29d03e99cbec771192ada90ae446cf8a..81117e94ef467384ecc6257a246af6fde7308acf 100644 (file)
@@ -6235,6 +6235,14 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id,
                        l3vni);
                return -1;
        }
+
+       if (CHECK_FLAG(bgp_evpn->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
+               flog_err(EC_BGP_NO_DFLT,
+                         "Cannot process L3VNI %u ADD - EVPN BGP instance is shutting down",
+                         l3vni);
+               return -1;
+       }
+
        as = bgp_evpn->as;
 
        /* if the BGP vrf instance doesn't exist - create one */
@@ -6377,6 +6385,13 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id)
                return -1;
        }
 
+       if (CHECK_FLAG(bgp_evpn->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
+               flog_err(EC_BGP_NO_DFLT,
+                         "Cannot process L3VNI %u ADD - EVPN BGP instance is shutting down",
+                         l3vni);
+               return -1;
+       }
+
        /* Remove remote routes from BGT VRF even if BGP_VRF_AUTO is configured,
         * bgp_delete would not remove/decrement bgp_path_info of the ip_prefix
         * routes. This will uninstalling the routes from zebra and decremnt the
index c43d79d71a3ecdab6582945fe23933de57a9e6b9..4aff93514fbeaaefdd4502bdfc63ffb25e659ec3 100644 (file)
@@ -1071,7 +1071,8 @@ void update_type1_routes_for_evi(struct bgp *bgp, struct bgpevpn *vpn)
                        continue;
 
                /* Update EAD-ES */
-               bgp_evpn_ead_es_route_update(bgp, es);
+               if (bgp_evpn_local_es_is_active(es))
+                       bgp_evpn_ead_es_route_update(bgp, es);
 
                /* Update EAD-EVI */
                if (CHECK_FLAG(es->flags, BGP_EVPNES_ADV_EVI)) {
index c08f95cdf43b11b088f5778550acac61f11b5f01..63168f1e7a826ccbbbf38a5b340bb5418d3c3474 100644 (file)
@@ -1103,7 +1103,7 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn,
        struct bgp_path_info *new;
        struct bgp_path_info_extra *extra;
        uint32_t num_sids = 0;
-       void *parent = source_bpi;
+       struct bgp_path_info *parent = source_bpi;
 
        if (new_attr->srv6_l3vpn || new_attr->srv6_vpn)
                num_sids = 1;
@@ -1311,7 +1311,7 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn,
 
        new->extra->parent = bgp_path_info_lock(parent);
        bgp_dest_lock_node(
-               (struct bgp_dest *)((struct bgp_path_info *)parent)->net);
+               (struct bgp_dest *)parent->net);
        if (bgp_orig)
                new->extra->bgp_orig = bgp_lock(bgp_orig);
        if (nexthop_orig)
index a436490ba1deddcf596a2484e337394fbd282fcd..f7b0caf493b148048f91d5ab4d6e243f83aaade5 100644 (file)
@@ -1675,28 +1675,46 @@ DEFUN (no_router_bgp,
                        for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) {
                                if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF)
                                        continue;
-                               if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
-                                              BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
-                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
-                                              BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
-                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
-                                              BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
-                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
-                                              BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
-                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
+                               if (CHECK_FLAG(
+                                           tmp_bgp->af_flags[AFI_IP]
+                                                            [SAFI_UNICAST],
+                                           BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
+                                   CHECK_FLAG(
+                                           tmp_bgp->af_flags[AFI_IP6]
+                                                            [SAFI_UNICAST],
+                                           BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
+                                   CHECK_FLAG(
+                                           tmp_bgp->af_flags[AFI_IP]
+                                                            [SAFI_UNICAST],
+                                           BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
+                                   CHECK_FLAG(
+                                           tmp_bgp->af_flags[AFI_IP6]
+                                                            [SAFI_UNICAST],
+                                           BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
+                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP]
+                                                               [SAFI_UNICAST],
                                               BGP_CONFIG_VRF_TO_VRF_EXPORT) ||
-                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
+                                   CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6]
+                                                               [SAFI_UNICAST],
                                               BGP_CONFIG_VRF_TO_VRF_EXPORT) ||
                                    (bgp == bgp_get_evpn() &&
-                                   (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
-                                               BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) ||
-                                    CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
-                                               BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) ||
-                                    CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
-                                               BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) ||
-                                    CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
-                                               BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) ||
-                                   (hashcount(tmp_bgp->vnihash))) {
+                                    (CHECK_FLAG(
+                                             tmp_bgp->af_flags[AFI_L2VPN]
+                                                              [SAFI_EVPN],
+                                             BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) ||
+                                     CHECK_FLAG(
+                                             tmp_bgp->af_flags[AFI_L2VPN]
+                                                              [SAFI_EVPN],
+                                             BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) ||
+                                     CHECK_FLAG(
+                                             tmp_bgp->af_flags[AFI_L2VPN]
+                                                              [SAFI_EVPN],
+                                             BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) ||
+                                     CHECK_FLAG(
+                                             tmp_bgp->af_flags[AFI_L2VPN]
+                                                              [SAFI_EVPN],
+                                             BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) ||
+                                   (tmp_bgp->l3vni)) {
                                        vty_out(vty,
                                                "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
                                        return CMD_WARNING_CONFIG_FAILED;
index b7021b69a12acd8f63294daffa9ca0d1545ca5a8..2fe0a5989b94d8a81612fb3ac1a49cb39653d50f 100644 (file)
@@ -502,6 +502,51 @@ General utility formats
    representation for a hexdump.  Non-printable characters are replaced with
    a dot.
 
+.. frrfmt:: %pIS (struct iso_address *)
+
+   ([IS]o Network address) - Format ISO Network Address
+
+   ``%pIS``: :frrfmtout:`01.0203.04O5`
+   ISO Network address is printed as separated byte. The number of byte of the
+   address is embeded in the `iso_net` structure.
+
+   ``%pISl``: :frrfmtout:`01.0203.04O5.0607.0809.1011.1213.14` - long format to
+   print the long version of the ISO Network address which include the System
+   ID and the PSEUDO-ID of the IS-IS system
+
+   Note that the `ISO_ADDR_STRLEN` define gives the total size of the string
+   that could be used in conjunction to snprintfrr. Use like::
+
+     char buf[ISO_ADDR_STRLEN];
+     struct iso_net addr = {.len = 4, .addr = {1, 2, 3, 4}};
+     snprintfrr(buf, ISO_ADDR_STRLEN, "%pIS", &addr);
+
+.. frrfmt:: %pSY (uint8_t *)
+
+   (IS-IS [SY]stem ID) - Format IS-IS System ID
+
+   ``%pSY``: :frrfmtout:`0102.0304.0506`
+
+.. frrfmt:: %pPN (uint8_t *)
+
+   (IS-IS [P]seudo [N]ode System ID) - Format IS-IS Pseudo Node System ID
+
+   ``%pPN``: :frrfmtout:`0102.0304.0506.07`
+
+.. frrfmt:: %pLS (uint8_t *)
+
+   (IS-IS [L]sp fragment [S]ystem ID) - Format IS-IS Pseudo System ID
+
+   ``%pLS``: :frrfmtout:`0102.0304.0506.07-08`
+
+   Note that the `ISO_SYSID_STRLEN` define gives the total size of the string
+   that could be used in conjunction to snprintfrr. Use like::
+
+     char buf[ISO_SYSID_STRLEN];
+     uint8_t id[8] = {1, 2, 3, 4 , 5 , 6 , 7, 8};
+     snprintfrr(buf, SYS_ID_SIZE, "%pSY", id);
+
+
 Integer formats
 ^^^^^^^^^^^^^^^
 
index 90c13d4f932878c031864aa894a61f0c6bc324fc..88fa78ddfa2c4a2eef9916587ccd761d0ac00618 100644 (file)
@@ -68,6 +68,10 @@ writing, *isisd* does not support multiple ISIS processes.
 
    Log changes in adjacency state.
 
+.. clicmd:: log-pdu-drops
+
+   Log any dropped PDUs.
+
 .. clicmd:: metric-style [narrow | transition | wide]
 
    Set old-style (ISO 10589) or new-style packet formats:
index 6ea7e7891a0067f28775c3a0aa75d348114095d6..6614a568f849c73f78c9d19d11463c5e85e42071 100644 (file)
@@ -70,14 +70,6 @@ Frontend Interface and MGMTd:
     database.
   - Data can be retrieved anytime using GET_CONFIG/GET_DATA API.
 
- - Startup Database:
-
-  - Consists of configuration data items only.
-  - This is a copy of Running database that is stored in persistent
-    storage and is used to load configurations on Running database during
-    MGMT daemon startup.
-  - Data cannot be edited/retrieved directly via Frontend interface.
-
  - Operational Database:
 
   - Consists of non-configurational data items.
@@ -313,8 +305,7 @@ MGMT Configuration commands
 .. clicmd:: mgmt commit apply
 
     This command commits any uncommited changes in the Candidate DB to the
-    Running DB. It also dumps a copy of the tree in JSON format into
-    frr_startup.json.
+    Running DB.
 
 .. clicmd:: mgmt commit check
 
index 67c0d15750ec0f7b0eaf994f9032de600ef9be17..a99785204b4582f20f02906af8f2bf3d0c6f0d72 100644 (file)
@@ -310,6 +310,11 @@ To start OSPF process you have to specify the OSPF router.
    of packets to process before returning. The defult value of this parameter
    is 20.
 
+.. clicmd:: socket buffer <send | recv | all> (1-4000000000)
+
+   This command controls the ospf instance's socket buffer sizes. The
+   'no' form resets one or both values to the default.
+   
 .. _ospf-area:
 
 Areas
index 4fd39498a0bd57024c794b48bf6804addad2f782..0be36e175ac49602a83f40b4dfbbfe0be122e439 100644 (file)
@@ -273,8 +273,8 @@ void fabricd_initial_sync_hello(struct isis_circuit *circuit)
 
        if (IS_DEBUG_ADJ_PACKETS)
                zlog_debug(
-                       "OpenFabric: Started initial synchronization with %s on %s",
-                       sysid_print(circuit->u.p2p.neighbor->sysid),
+                       "OpenFabric: Started initial synchronization with %pSY on %s",
+                       circuit->u.p2p.neighbor->sysid,
                        circuit->interface->name);
 }
 
@@ -359,7 +359,9 @@ static uint8_t fabricd_calculate_fabric_tier(struct isis_area *area)
                return ISIS_TIER_UNDEFINED;
        }
 
-       zlog_info("OpenFabric: Found %s as furthest t0 from local system, dist == %u", rawlspid_print(furthest_t0->N.id), furthest_t0->d_N);
+       zlog_info(
+               "OpenFabric: Found %pLS as furthest t0 from local system, dist == %u",
+               furthest_t0->N.id, furthest_t0->d_N);
 
        struct isis_spftree *remote_tree =
                isis_run_hopcount_spf(area, furthest_t0->N.id, NULL);
@@ -372,8 +374,9 @@ static uint8_t fabricd_calculate_fabric_tier(struct isis_area *area)
                isis_spftree_del(remote_tree);
                return ISIS_TIER_UNDEFINED;
        } else {
-               zlog_info("OpenFabric: Found %s as furthest from remote dist == %u", rawlspid_print(furthest_from_remote->N.id),
-                         furthest_from_remote->d_N);
+               zlog_info(
+                       "OpenFabric: Found %pLS as furthest from remote dist == %u",
+                       furthest_from_remote->N.id, furthest_from_remote->d_N);
        }
 
        int64_t tier = furthest_from_remote->d_N - furthest_t0->d_N;
index 1871078cc165734824784f9b484099a0e73796da..30b71537e0e5ea2062e426062c77f9bf3b718abc 100644 (file)
@@ -283,6 +283,8 @@ void isis_adj_process_threeway(struct isis_adjacency *adj,
 }
 const char *isis_adj_name(const struct isis_adjacency *adj)
 {
+       static char buf[ISO_SYSID_STRLEN];
+
        if (!adj)
                return "NONE";
 
@@ -291,8 +293,9 @@ const char *isis_adj_name(const struct isis_adjacency *adj)
        dyn = dynhn_find_by_id(adj->circuit->isis, adj->sysid);
        if (dyn)
                return dyn->hostname;
-       else
-               return sysid_print(adj->sysid);
+
+       snprintfrr(buf, sizeof(buf), "%pSY", adj->sysid);
+       return buf;
 }
 void isis_log_adj_change(struct isis_adjacency *adj,
                         enum isis_adj_state old_state,
@@ -439,9 +442,8 @@ void isis_adj_print(struct isis_adjacency *adj)
        if (dyn)
                zlog_debug("%s", dyn->hostname);
 
-       zlog_debug("SystemId %20s SNPA %s, level %d; Holding Time %d",
-                  sysid_print(adj->sysid), snpa_print(adj->snpa), adj->level,
-                  adj->hold_time);
+       zlog_debug("SystemId %20pSY SNPA %pSY, level %d; Holding Time %d",
+                  adj->sysid, adj->snpa, adj->level, adj->hold_time);
        if (adj->ipv4_address_count) {
                zlog_debug("IPv4 Address(es):");
                for (unsigned int i = 0; i < adj->ipv4_address_count; i++)
@@ -530,7 +532,7 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json,
                                        time2string(adj->last_upd +
                                                    adj->hold_time - now));
                }
-               json_object_string_add(json, "snpa", snpa_print(adj->snpa));
+               json_object_string_addf(json, "snpa", "%pSY", adj->snpa);
        }
 
        if (detail == ISIS_UI_LEVEL_DETAIL) {
@@ -581,8 +583,7 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json,
                                        isis_mtid2str(adj->mt_set[i]));
                        }
                }
-               json_object_string_add(iface_json, "snpa",
-                                      snpa_print(adj->snpa));
+               json_object_string_addf(iface_json, "snpa", "%pSY", adj->snpa);
                if (adj->circuit &&
                    (adj->circuit->circ_type == CIRCUIT_T_BROADCAST)) {
                        dyn = dynhn_find_by_id(adj->circuit->isis, adj->lanid);
@@ -593,11 +594,8 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json,
                                json_object_string_add(iface_json, "lan-id",
                                                       buf);
                        } else {
-                               snprintfrr(buf, sizeof(buf), "%s-%02x",
-                                          sysid_print(adj->lanid),
-                                          adj->lanid[ISIS_SYS_ID_LEN]);
-                               json_object_string_add(iface_json, "lan-id",
-                                                      buf);
+                               json_object_string_addf(iface_json, "lan-id",
+                                                       "%pSY", adj->lanid);
                        }
 
                        json_object_int_add(iface_json, "lan-prio",
@@ -626,12 +624,9 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json,
                                               area_addr_json);
                        for (unsigned int i = 0; i < adj->area_address_count;
                             i++) {
-                               json_object_string_add(
-                                       area_addr_json, "isonet",
-                                       isonet_print(adj->area_addresses[i]
-                                                            .area_addr,
-                                                    adj->area_addresses[i]
-                                                            .addr_len));
+                               json_object_string_addf(
+                                       area_addr_json, "isonet", "%pIS",
+                                       &adj->area_addresses[i]);
                        }
                }
                if (adj->ipv4_address_count) {
@@ -736,7 +731,7 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
                                                + adj->hold_time - now);
                } else
                        vty_out(vty, "-        ");
-               vty_out(vty, "%-10s", snpa_print(adj->snpa));
+               vty_out(vty, "%-10pSY", adj->snpa);
                vty_out(vty, "\n");
        }
 
@@ -780,7 +775,7 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
                                vty_out(vty, "      %s\n",
                                        isis_mtid2str(adj->mt_set[i]));
                }
-               vty_out(vty, "    SNPA: %s", snpa_print(adj->snpa));
+               vty_out(vty, "    SNPA: %pSY", adj->snpa);
                if (adj->circuit
                    && (adj->circuit->circ_type == CIRCUIT_T_BROADCAST)) {
                        dyn = dynhn_find_by_id(adj->circuit->isis, adj->lanid);
@@ -788,9 +783,7 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
                                vty_out(vty, ", LAN id: %s.%02x", dyn->hostname,
                                        adj->lanid[ISIS_SYS_ID_LEN]);
                        else
-                               vty_out(vty, ", LAN id: %s.%02x",
-                                       sysid_print(adj->lanid),
-                                       adj->lanid[ISIS_SYS_ID_LEN]);
+                               vty_out(vty, ", LAN id: %pPN", adj->lanid);
 
                        vty_out(vty, "\n");
                        vty_out(vty, "    LAN Priority: %u",
@@ -811,11 +804,8 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
                        vty_out(vty, "    Area Address(es):\n");
                        for (unsigned int i = 0; i < adj->area_address_count;
                             i++) {
-                               vty_out(vty, "      %s\n",
-                                       isonet_print(adj->area_addresses[i]
-                                                            .area_addr,
-                                                    adj->area_addresses[i]
-                                                            .addr_len));
+                               vty_out(vty, "      %pIS\n",
+                                       &adj->area_addresses[i]);
                        }
                }
                if (adj->ipv4_address_count) {
index f02f7a68eac6a9c6a3e793adf7fe974dce2c6052..c0c8e68145d2633946169be5c949e3b5ecf07612 100644 (file)
@@ -69,7 +69,7 @@ struct isis_adjacency {
        struct isis_dis_record dis_record[DIS_RECORDS * ISIS_LEVELS];
        enum isis_adj_state adj_state;    /* adjacencyState */
        enum isis_adj_usage adj_usage;    /* adjacencyUsage */
-       struct area_addr *area_addresses; /* areaAdressesOfNeighbour */
+       struct iso_address *area_addresses; /* areaAdressesOfNeighbour */
        unsigned int area_address_count;
        struct nlpids nlpids; /* protocols spoken ... */
        struct in_addr *ipv4_addresses;
index 64b405737f0f896130684763a2f7b89cbdbf24c0..feab45123383e3027376080b57b446bb43f042d0 100644 (file)
@@ -695,10 +695,9 @@ int isis_circuit_up(struct isis_circuit *circuit)
                }
 #ifdef EXTREME_DEGUG
                if (IS_DEBUG_EVENTS)
-                       zlog_debug("%s: if_id %d, isomtu %d snpa %s", __func__,
-                                  circuit->interface->ifindex,
-                                  ISO_MTU(circuit),
-                                  snpa_print(circuit->u.bc.snpa));
+                       zlog_debug("%s: if_id %d, isomtu %d snpa %pSY",
+                                  __func__, circuit->interface->ifindex,
+                                  ISO_MTU(circuit), circuit->u.bc.snpa);
 #endif /* EXTREME_DEBUG */
 
                circuit->u.bc.adjdb[0] = list_new();
@@ -995,8 +994,8 @@ void isis_circuit_print_json(struct isis_circuit *circuit,
                json_object_string_add(iface_json, "level",
                                       circuit_t2string(circuit->is_type));
                if (circuit->circ_type == CIRCUIT_T_BROADCAST)
-                       json_object_string_add(iface_json, "snpa",
-                                              snpa_print(circuit->u.bc.snpa));
+                       json_object_string_addf(iface_json, "snpa", "%pSY",
+                                               circuit->u.bc.snpa);
 
 
                levels_json = json_object_new_array();
@@ -1122,8 +1121,7 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
                        circuit_type2string(circuit->circ_type));
                vty_out(vty, ", Level: %s", circuit_t2string(circuit->is_type));
                if (circuit->circ_type == CIRCUIT_T_BROADCAST)
-                       vty_out(vty, ", SNPA: %-10s",
-                               snpa_print(circuit->u.bc.snpa));
+                       vty_out(vty, ", SNPA: %-10pSY", circuit->u.bc.snpa);
                vty_out(vty, "\n");
                if (circuit->is_type & IS_LEVEL_1) {
                        vty_out(vty, "    Level-1 Information:\n");
index 7e1bb9255c491b984c43f6321e7a1c3bce737c2d..ee51e468587009a15b709b903593f84c874217a7 100644 (file)
@@ -3025,6 +3025,26 @@ void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode,
        vty_out(vty, " log-adjacency-changes\n");
 }
 
+/*
+ * XPath: /frr-isisd:isis/instance/log-pdu-drops
+ */
+DEFPY_YANG(log_pdu_drops, log_pdu_drops_cmd, "[no] log-pdu-drops",
+          NO_STR "Log any dropped PDUs\n")
+{
+       nb_cli_enqueue_change(vty, "./log-pdu-drops", NB_OP_MODIFY,
+                             no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode,
+                                bool show_defaults)
+{
+       if (!yang_dnode_get_bool(dnode, NULL))
+               vty_out(vty, " no");
+       vty_out(vty, " log-pdu-drops\n");
+}
+
 /*
  * XPath: /frr-isisd:isis/instance/mpls/ldp-sync
  */
@@ -3290,6 +3310,7 @@ void isis_cli_init(void)
        install_element(INTERFACE_NODE, &isis_ti_lfa_cmd);
 
        install_element(ISIS_NODE, &log_adj_changes_cmd);
+       install_element(ISIS_NODE, &log_pdu_drops_cmd);
 
        install_element(ISIS_NODE, &isis_mpls_ldp_sync_cmd);
        install_element(ISIS_NODE, &no_isis_mpls_ldp_sync_cmd);
index c908dc2e24632c3d0af7d05c48ed709c8115b966..2ded68f84d5b5ef24c0488f9cf38755d886cdb6b 100644 (file)
 #ifndef ISIS_COMMON_H
 #define ISIS_COMMON_H
 
-/*
- * Area Address
- */
-struct area_addr {
-       uint8_t addr_len;
-       uint8_t area_addr[20];
-};
-
 struct isis_passwd {
        uint8_t len;
 #define ISIS_PASSWD_TYPE_UNUSED   0
index 446e52201998c3068aae4bce3c2078c4c225b728..61c49d08a742af88b924940594941561ffba9bd8 100644 (file)
@@ -145,12 +145,10 @@ void dynhn_print_all(struct vty *vty, struct isis *isis)
        vty_out(vty, "Level  System ID      Dynamic Hostname\n");
        for (ALL_LIST_ELEMENTS_RO(isis->dyn_cache, node, dyn)) {
                vty_out(vty, "%-7d", dyn->level);
-               vty_out(vty, "%-15s%-15s\n", sysid_print(dyn->id),
-                       dyn->hostname);
+               vty_out(vty, "%pSY %-15s\n", dyn->id, dyn->hostname);
        }
 
-       vty_out(vty, "     * %s %s\n", sysid_print(isis->sysid),
-               cmd_hostname_get());
+       vty_out(vty, "     * %pSY %s\n", isis->sysid, cmd_hostname_get());
        return;
 }
 
index 8a2a2ab971edd084dd1bf4f36f03d67a478bb727..32231a079f1af104800e085d00a65d180eb2e74a 100644 (file)
@@ -217,8 +217,8 @@ void isis_event_auth_failure(char *area_tag, const char *error_string,
                             uint8_t *sysid)
 {
        if (IS_DEBUG_EVENTS)
-               zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s",
-                          area_tag, error_string, sysid_print(sysid));
+               zlog_debug("ISIS-Evt (%s) Authentication failure %s from %pSY",
+                          area_tag, error_string, sysid);
 
        return;
 }
index 7a25a9253553385e304d10a1a92580b8b99382a5..abb6168393cd9e6c3e3ee616fce4ea17e50e3b36 100644 (file)
@@ -1466,8 +1466,8 @@ int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa,
                if (ldp_label == MPLS_INVALID_LABEL) {
                        if (IS_DEBUG_LFA)
                                zlog_debug(
-                                       "ISIS-LFA: failed to activate RLFA: missing LDP label to reach PQ node through %s",
-                                       sysid_print(vadj->sadj->id));
+                                       "ISIS-LFA: failed to activate RLFA: missing LDP label to reach PQ node through %pSY",
+                                       vadj->sadj->id);
                        return -1;
                }
 
index d569f6bd5be66e67685b5d5bcb03ee4954884863..fb69448d042c966635803c01c7bbe23a2be2a4ad 100644 (file)
@@ -193,10 +193,9 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
                || (lsp->hdr.rem_lifetime != 0 && rem_lifetime != 0))) {
                if (IS_DEBUG_SNP_PACKETS) {
                        zlog_debug(
-                               "ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus",
-                               areatag, rawlspid_print(lsp->hdr.lsp_id),
-                               lsp->hdr.seqno, lsp->hdr.checksum,
-                               lsp->hdr.rem_lifetime);
+                               "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus",
+                               areatag, lsp->hdr.lsp_id, lsp->hdr.seqno,
+                               lsp->hdr.checksum, lsp->hdr.rem_lifetime);
                        zlog_debug(
                                "ISIS-Snp (%s):         is equal to ours seq 0x%08x, cksum 0x%04hx, lifetime %hus",
                                areatag, seqno, checksum, rem_lifetime);
@@ -223,9 +222,9 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
                        && lsp->hdr.rem_lifetime)))) {
                if (IS_DEBUG_SNP_PACKETS) {
                        zlog_debug(
-                               "ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus",
-                               areatag, rawlspid_print(lsp->hdr.lsp_id), seqno,
-                               checksum, rem_lifetime);
+                               "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus",
+                               areatag, lsp->hdr.lsp_id, seqno, checksum,
+                               rem_lifetime);
                        zlog_debug(
                                "ISIS-Snp (%s):       is newer than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus",
                                areatag, lsp->hdr.seqno, lsp->hdr.checksum,
@@ -234,9 +233,10 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
                return LSP_NEWER;
        }
        if (IS_DEBUG_SNP_PACKETS) {
-               zlog_debug("ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus",
-                          areatag, rawlspid_print(lsp->hdr.lsp_id), seqno,
-                          checksum, rem_lifetime);
+               zlog_debug(
+                       "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus",
+                       areatag, lsp->hdr.lsp_id, seqno, checksum,
+                       rem_lifetime);
                zlog_debug(
                        "ISIS-Snp (%s):       is older than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus",
                        areatag, lsp->hdr.seqno, lsp->hdr.checksum,
@@ -554,8 +554,8 @@ void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr,
        if (lsp->own_lsp) {
                flog_err(
                        EC_LIB_DEVELOPMENT,
-                       "ISIS-Upd (%s): BUG updating LSP %s still marked as own LSP",
-                       area->area_tag, rawlspid_print(lsp->hdr.lsp_id));
+                       "ISIS-Upd (%s): BUG updating LSP %pLS still marked as own LSP",
+                       area->area_tag, lsp->hdr.lsp_id);
                lsp_clear_data(lsp);
                lsp->own_lsp = 0;
        }
@@ -634,10 +634,8 @@ struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id,
        put_lsp_hdr(lsp, NULL, false);
 
        if (IS_DEBUG_EVENTS)
-               zlog_debug("New LSP with ID %s-%02x-%02x len %d seqnum %08x",
-                          sysid_print(lsp_id), LSP_PSEUDO_ID(lsp->hdr.lsp_id),
-                          LSP_FRAGMENT(lsp->hdr.lsp_id), lsp->hdr.pdu_len,
-                          lsp->hdr.seqno);
+               zlog_debug("New LSP with ID %pLS len %d seqnum %08x", lsp_id,
+                          lsp->hdr.pdu_len, lsp->hdr.seqno);
 
        return lsp;
 }
@@ -704,7 +702,7 @@ void lspid_print(uint8_t *lsp_id, char *dest, size_t dest_len, char dynhost,
        else if (!memcmp(isis->sysid, lsp_id, ISIS_SYS_ID_LEN) && dynhost)
                snprintf(id, sizeof(id), "%.14s", cmd_hostname_get());
        else
-               memcpy(id, sysid_print(lsp_id), 15);
+               snprintf(id, sizeof(id), "%pSY", lsp_id);
 
        if (frag)
                snprintf(dest, dest_len, "%s.%02x-%02x", id,
@@ -1250,10 +1248,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                                if (LSP_PSEUDO_ID(ne_id)) {
                                        if (area->oldmetric) {
                                                lsp_debug(
-                                                       "ISIS (%s): Adding DIS %s.%02x as old-style neighbor",
-                                                       area->area_tag,
-                                                       sysid_print(ne_id),
-                                                       LSP_PSEUDO_ID(ne_id));
+                                                       "ISIS (%s): Adding DIS %pPN as old-style neighbor",
+                                                       area->area_tag, ne_id);
                                                isis_tlvs_add_oldstyle_reach(
                                                        lsp->tlvs, ne_id,
                                                        metric);
@@ -1279,9 +1275,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
 
                                if (area->oldmetric) {
                                        lsp_debug(
-                                               "ISIS (%s): Adding old-style is reach for %s",
-                                               area->area_tag,
-                                               sysid_print(ne_id));
+                                               "ISIS (%s): Adding old-style is reach for %pSY",
+                                               area->area_tag, ne_id);
                                        isis_tlvs_add_oldstyle_reach(
                                                lsp->tlvs, ne_id, metric);
                                }
@@ -1424,12 +1419,12 @@ int lsp_generate(struct isis_area *area, int level)
                        refresh_time, &area->t_lsp_refresh[level - 1]);
 
        if (IS_DEBUG_UPDATE_PACKETS) {
-               zlog_debug("ISIS-Upd (%s): Building L%d LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus",
-                          area->area_tag, level,
-                          rawlspid_print(newlsp->hdr.lsp_id),
-                          newlsp->hdr.pdu_len, newlsp->hdr.seqno,
-                          newlsp->hdr.checksum, newlsp->hdr.rem_lifetime,
-                          refresh_time);
+               zlog_debug(
+                       "ISIS-Upd (%s): Building L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus",
+                       area->area_tag, level, newlsp->hdr.lsp_id,
+                       newlsp->hdr.pdu_len, newlsp->hdr.seqno,
+                       newlsp->hdr.checksum, newlsp->hdr.rem_lifetime,
+                       refresh_time);
        }
        sched_debug(
                "ISIS (%s): Built L%d LSP. Set triggered regenerate to non-pending.",
@@ -1506,8 +1501,8 @@ static int lsp_regenerate(struct isis_area *area, int level)
 
        if (IS_DEBUG_UPDATE_PACKETS) {
                zlog_debug(
-                       "ISIS-Upd (%s): Refreshed our L%d LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus",
-                       area->area_tag, level, rawlspid_print(lsp->hdr.lsp_id),
+                       "ISIS-Upd (%s): Refreshed our L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus",
+                       area->area_tag, level, lsp->hdr.lsp_id,
                        lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum,
                        lsp->hdr.rem_lifetime, refresh_time);
        }
@@ -1698,9 +1693,9 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
        lsp_clear_data(lsp);
        lsp->tlvs = isis_alloc_tlvs();
        lsp_debug(
-               "ISIS (%s): Constructing pseudo LSP %s for interface %s level %d",
-               area->area_tag, rawlspid_print(lsp->hdr.lsp_id),
-               circuit->interface->name, level);
+               "ISIS (%s): Constructing pseudo LSP %pLS for interface %s level %d",
+               area->area_tag, lsp->hdr.lsp_id, circuit->interface->name,
+               level);
 
        lsp->level = level;
        /* RFC3787  section 4 SHOULD not set overload bit in pseudo LSPs */
@@ -1717,10 +1712,8 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
 
        if (circuit->area->oldmetric) {
                isis_tlvs_add_oldstyle_reach(lsp->tlvs, ne_id, 0);
-               lsp_debug(
-                       "ISIS (%s): Adding %s.%02x as old-style neighbor (self)",
-                       area->area_tag, sysid_print(ne_id),
-                       LSP_PSEUDO_ID(ne_id));
+               lsp_debug("ISIS (%s): Adding %pPN as old-style neighbor (self)",
+                         area->area_tag, ne_id);
        }
        if (circuit->area->newmetric) {
                if (area_is_mt(circuit->area))
@@ -1728,10 +1721,8 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
                else
                        mtid = ISIS_MT_DISABLE;
                isis_tlvs_add_extended_reach(lsp->tlvs, mtid, ne_id, 0, NULL);
-               lsp_debug(
-                       "ISIS (%s): Adding %s.%02x as te-style neighbor (self)",
-                       area->area_tag, sysid_print(ne_id),
-                       LSP_PSEUDO_ID(ne_id));
+               lsp_debug("ISIS (%s): Adding %pPN as te-style neighbor (self)",
+                         area->area_tag, ne_id);
        }
 
        adj_list = list_new();
@@ -1740,8 +1731,8 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
        for (ALL_LIST_ELEMENTS_RO(adj_list, node, adj)) {
                if (!(adj->level & level)) {
                        lsp_debug(
-                               "ISIS (%s): Ignoring neighbor %s, level does not intersect",
-                               area->area_tag, sysid_print(adj->sysid));
+                               "ISIS (%s): Ignoring neighbor %pSY, level does not intersect",
+                               area->area_tag, adj->sysid);
                        continue;
                }
 
@@ -1753,8 +1744,8 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
                    && !(level == IS_LEVEL_2
                         && adj->sys_type == ISIS_SYSTYPE_L2_IS)) {
                        lsp_debug(
-                               "ISIS (%s): Ignoring neighbor %s, level does not match",
-                               area->area_tag, sysid_print(adj->sysid));
+                               "ISIS (%s): Ignoring neighbor %pSY, level does not match",
+                               area->area_tag, adj->sysid);
                        continue;
                }
 
@@ -1762,18 +1753,16 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
                if (circuit->area->oldmetric) {
                        isis_tlvs_add_oldstyle_reach(lsp->tlvs, ne_id, 0);
                        lsp_debug(
-                               "ISIS (%s): Adding %s.%02x as old-style neighbor (peer)",
-                               area->area_tag, sysid_print(ne_id),
-                               LSP_PSEUDO_ID(ne_id));
+                               "ISIS (%s): Adding %pPN as old-style neighbor (peer)",
+                               area->area_tag, ne_id);
                }
                if (circuit->area->newmetric) {
                        isis_tlvs_add_extended_reach(lsp->tlvs,
                                                     ISIS_MT_IPV4_UNICAST,
                                                     ne_id, 0, NULL);
                        lsp_debug(
-                               "ISIS (%s): Adding %s.%02x as te-style neighbor (peer)",
-                               area->area_tag, sysid_print(ne_id),
-                               LSP_PSEUDO_ID(ne_id));
+                               "ISIS (%s): Adding %pPN as te-style neighbor (peer)",
+                               area->area_tag, ne_id);
                }
        }
        list_delete(&adj_list);
@@ -1832,10 +1821,9 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level)
 
        if (IS_DEBUG_UPDATE_PACKETS) {
                zlog_debug(
-                       "ISIS-Upd (%s): Built L%d Pseudo LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus",
-                       circuit->area->area_tag, level,
-                       rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.pdu_len,
-                       lsp->hdr.seqno, lsp->hdr.checksum,
+                       "ISIS-Upd (%s): Built L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus",
+                       circuit->area->area_tag, level, lsp->hdr.lsp_id,
+                       lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum,
                        lsp->hdr.rem_lifetime, refresh_time);
        }
 
@@ -1863,8 +1851,8 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level)
 
        if (!lsp) {
                flog_err(EC_LIB_DEVELOPMENT,
-                        "lsp_regenerate_pseudo: no l%d LSP %s found!", level,
-                        rawlspid_print(lsp_id));
+                        "lsp_regenerate_pseudo: no l%d LSP %pLS found!", level,
+                        lsp_id);
                return ISIS_ERROR;
        }
 
@@ -1887,10 +1875,9 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level)
 
        if (IS_DEBUG_UPDATE_PACKETS) {
                zlog_debug(
-                       "ISIS-Upd (%s): Refreshed L%d Pseudo LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus",
-                       circuit->area->area_tag, level,
-                       rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.pdu_len,
-                       lsp->hdr.seqno, lsp->hdr.checksum,
+                       "ISIS-Upd (%s): Refreshed L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus",
+                       circuit->area->area_tag, level, lsp->hdr.lsp_id,
+                       lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum,
                        lsp->hdr.rem_lifetime, refresh_time);
        }
 
@@ -2101,10 +2088,9 @@ void lsp_tick(struct event *thread)
 
                        if (lsp->age_out == 0) {
                                zlog_debug(
-                                       "ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out",
+                                       "ISIS-Upd (%s): L%u LSP %pLS seq 0x%08x aged out",
                                        area->area_tag, lsp->level,
-                                       rawlspid_print(lsp->hdr.lsp_id),
-                                       lsp->hdr.seqno);
+                                       lsp->hdr.lsp_id, lsp->hdr.seqno);
 
                                /* if we're aging out fragment 0, lsp_destroy()
                                 * below will delete all other fragments too,
@@ -2207,11 +2193,10 @@ void _lsp_flood(struct isis_lsp *lsp, struct isis_circuit *circuit,
                const char *func, const char *file, int line)
 {
        if (IS_DEBUG_FLOODING) {
-               zlog_debug("Flooding LSP %s%s%s (From %s %s:%d)",
-                          rawlspid_print(lsp->hdr.lsp_id),
-                          circuit ? " except on " : "",
-                          circuit ? circuit->interface->name : "",
-                          func, file, line);
+               zlog_debug("Flooding LSP %pLS%s%s (From %s %s:%d)",
+                          lsp->hdr.lsp_id, circuit ? " except on " : "",
+                          circuit ? circuit->interface->name : "", func, file,
+                          line);
        }
 
        if (!fabricd)
index 95d24036ec534f900abf913ca013cddc07a5c6c7..09ffa3479a62056f888498af636225aa96eed32b 100644 (file)
 #include "isisd/isis_dynhn.h"
 
 /* staticly assigned vars for printing purposes */
+static char sys_hostname[ISO_SYSID_STRLEN];
 struct in_addr new_prefix;
-/* len of xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx */
-/* + place for #0 termination */
-char isonet[51];
 /* len of xxYxxMxWxdxxhxxmxxs + place for #0 termination */
 char datestring[20];
 char nlpidstring[30];
 
-/*
- * This converts the isonet to its printable format
- */
-const char *isonet_print(const uint8_t *from, int len)
-{
-       int i = 0;
-       char tbuf[4];
-       isonet[0] = '\0';
-
-       if (!from)
-               return "unknown";
-
-       while (i < len) {
-               if (i & 1) {
-                       snprintf(tbuf, sizeof(tbuf), "%02x", *(from + i));
-                       strlcat(isonet, tbuf, sizeof(isonet));
-               } else {
-                       if (i == (len - 1)) { /* No dot at the end of address */
-                               snprintf(tbuf, sizeof(tbuf), "%02x",
-                                        *(from + i));
-                               strlcat(isonet, tbuf, sizeof(isonet));
-                       } else {
-                               snprintf(tbuf, sizeof(tbuf), "%02x.",
-                                        *(from + i));
-                               strlcat(isonet, tbuf, sizeof(isonet));
-                       }
-               }
-               i++;
-       }
-
-       return isonet;
-}
-
 /*
  * Returns 0 on error, length of buff on ok
  * extract dot from the dotted str, and insert all the number in a buff
@@ -307,60 +272,6 @@ const char *isis_hello_padding2string(int hello_padding_type)
        return NULL; /* not reached */
 }
 
-/*
- * Print functions - we print to static vars
- */
-const char *snpa_print(const uint8_t *from)
-{
-       return isis_format_id(from, ISIS_SYS_ID_LEN);
-}
-
-const char *sysid_print(const uint8_t *from)
-{
-       return isis_format_id(from, ISIS_SYS_ID_LEN);
-}
-
-const char *rawlspid_print(const uint8_t *from)
-{
-       return isis_format_id(from, 8);
-}
-
-#define FORMAT_ID_SIZE sizeof("0000.0000.0000.00-00")
-const char *isis_format_id(const uint8_t *id, size_t len)
-{
-#define FORMAT_BUF_COUNT 4
-       static char buf_ring[FORMAT_BUF_COUNT][FORMAT_ID_SIZE];
-       static size_t cur_buf = 0;
-
-       char *rv;
-
-       cur_buf++;
-       if (cur_buf >= FORMAT_BUF_COUNT)
-               cur_buf = 0;
-
-       rv = buf_ring[cur_buf];
-
-       if (!id) {
-               snprintf(rv, FORMAT_ID_SIZE, "unknown");
-               return rv;
-       }
-
-       if (len < 6) {
-               snprintf(rv, FORMAT_ID_SIZE, "Short ID");
-               return rv;
-       }
-
-       snprintf(rv, FORMAT_ID_SIZE, "%02x%02x.%02x%02x.%02x%02x", id[0], id[1],
-                id[2], id[3], id[4], id[5]);
-
-       if (len > 6)
-               snprintf(rv + 14, FORMAT_ID_SIZE - 14, ".%02x", id[6]);
-       if (len > 7)
-               snprintf(rv + 17, FORMAT_ID_SIZE - 17, "-%02x", id[7]);
-
-       return rv;
-}
-
 const char *time2string(uint32_t time)
 {
        uint32_t rest;
@@ -474,7 +385,8 @@ const char *print_sys_hostname(const uint8_t *sysid)
                        return dyn->hostname;
        }
 
-       return sysid_print(sysid);
+       snprintfrr(sys_hostname, ISO_SYSID_STRLEN, "%pSY", sysid);
+       return sys_hostname;
 }
 
 /*
@@ -508,11 +420,11 @@ void zlog_dump_data(void *data, int len)
 
                /* store hex str (for left side) */
                snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
-               strncat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
+               strlcat(hexstr, bytestr, sizeof(hexstr) - strlen(hexstr) - 1);
 
                /* store char str (for right side) */
                snprintf(bytestr, sizeof(bytestr), "%c", c);
-               strncat(charstr, bytestr,
+               strlcat(charstr, bytestr,
                        sizeof(charstr) - strlen(charstr) - 1);
 
                if ((i % 16) == 0) {
@@ -523,9 +435,9 @@ void zlog_dump_data(void *data, int len)
                        charstr[0] = 0;
                } else if ((i % 8) == 0) {
                        /* half line: add whitespaces */
-                       strncat(hexstr, "  ",
+                       strlcat(hexstr, "  ",
                                sizeof(hexstr) - strlen(hexstr) - 1);
-                       strncat(charstr, " ",
+                       strlcat(charstr, " ",
                                sizeof(charstr) - strlen(charstr) - 1);
                }
                p++; /* next byte */
index 01d9abe8693346cf6e64a711894f1692dc1403a1..3a1d136b1d926e61020ef49df0fe9559a6334df1 100644 (file)
@@ -28,11 +28,6 @@ int sysid2buff(uint8_t *, const char *);
 /*
  * Printing functions
  */
-const char *isonet_print(const uint8_t *, int len);
-const char *sysid_print(const uint8_t *);
-const char *snpa_print(const uint8_t *);
-const char *rawlspid_print(const uint8_t *);
-const char *isis_format_id(const uint8_t *id, size_t len);
 const char *time2string(uint32_t);
 const char *nlpid2str(uint8_t nlpid);
 /* typedef struct nlpids nlpids; */
index fcc0f53815edd8d07a80ac708ac060c7e1d6875d..d04a24dc46838c5bc271be883f4cc6af3285f680 100644 (file)
@@ -507,8 +507,8 @@ static void tlvs_add_mt_set(struct isis_area *area, struct isis_tlvs *tlvs,
        /* Check if MT is enable for this area */
        if (!area_is_mt(area)) {
                lsp_debug(
-                       "ISIS (%s): Adding %s.%02x as te-style neighbor (MT disable)",
-                       area->area_tag, sysid_print(id), LSP_PSEUDO_ID(id));
+                       "ISIS (%s): Adding %pPN as te-style neighbor (MT disable)",
+                       area->area_tag, id);
                isis_tlvs_add_extended_reach(tlvs, ISIS_MT_DISABLE, id, metric,
                                             ext);
                return;
@@ -518,15 +518,12 @@ static void tlvs_add_mt_set(struct isis_area *area, struct isis_tlvs *tlvs,
        for (unsigned int i = 0; i < mt_count; i++) {
                uint16_t mtid = mt_set[i];
                if (mt_set[i] == ISIS_MT_IPV4_UNICAST) {
-                       lsp_debug(
-                               "ISIS (%s): Adding %s.%02x as te-style neighbor",
-                               area->area_tag, sysid_print(id),
-                               LSP_PSEUDO_ID(id));
+                       lsp_debug("ISIS (%s): Adding %pPN as te-style neighbor",
+                                 area->area_tag, id);
                } else {
                        lsp_debug(
-                               "ISIS (%s): Adding %s.%02x as mt-style neighbor for %s",
-                               area->area_tag, sysid_print(id),
-                               LSP_PSEUDO_ID(id), isis_mtid2str(mtid));
+                               "ISIS (%s): Adding %pPN as mt-style neighbor for %s",
+                               area->area_tag, id, isis_mtid2str(mtid));
                }
                isis_tlvs_add_extended_reach(tlvs, mtid, id, metric, ext);
        }
index 7dc3a0eb3da6025cc425e478b903a29a26653f0f..9141bfc46ce7b10e5dc1112a56e46f59e3d1a66b 100644 (file)
@@ -558,6 +558,13 @@ const struct frr_yang_module_info frr_isisd_info = {
                                .modify = isis_instance_log_adjacency_changes_modify,
                        },
                },
+               {
+                       .xpath = "/frr-isisd:isis/instance/log-pdu-drops",
+                       .cbs = {
+                               .cli_show = cli_show_isis_log_pdu_drops,
+                               .modify = isis_instance_log_pdu_drops_modify,
+                       },
+               },
                {
                        .xpath = "/frr-isisd:isis/instance/mpls-te",
                        .cbs = {
index 480b2ce04132927a660a08e543ce854b30408c43..9a1f1f786f41febcc2f0705b1bca35cb3af1213f 100644 (file)
@@ -196,6 +196,7 @@ int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify(
 int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_destroy(
        struct nb_cb_destroy_args *args);
 int isis_instance_log_adjacency_changes_modify(struct nb_cb_modify_args *args);
+int isis_instance_log_pdu_drops_modify(struct nb_cb_modify_args *args);
 int isis_instance_mpls_te_create(struct nb_cb_create_args *args);
 int isis_instance_mpls_te_destroy(struct nb_cb_destroy_args *args);
 int isis_instance_mpls_te_router_address_modify(struct nb_cb_modify_args *args);
@@ -609,6 +610,8 @@ void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode,
                               bool show_defaults);
 void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode,
                                 bool show_defaults);
+void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode,
+                                bool show_defaults);
 void cli_show_isis_mpls_ldp_sync(struct vty *vty, const struct lyd_node *dnode,
                                 bool show_defaults);
 void cli_show_isis_mpls_ldp_sync_holddown(struct vty *vty,
index 3817465a643a3796b873051873f7a9ce30ab7708..022bfbed6e4480c8047be925744eed1879e941f8 100644 (file)
@@ -103,14 +103,14 @@ int isis_instance_is_type_modify(struct nb_cb_modify_args *args)
 }
 
 struct sysid_iter {
-       struct area_addr *addr;
+       struct iso_address *addr;
        bool same;
 };
 
 static int sysid_iter_cb(const struct lyd_node *dnode, void *arg)
 {
        struct sysid_iter *iter = arg;
-       struct area_addr addr;
+       struct iso_address addr;
        const char *net;
 
        net = yang_dnode_get_string(dnode, NULL);
@@ -130,7 +130,7 @@ static int sysid_iter_cb(const struct lyd_node *dnode, void *arg)
 int isis_instance_area_address_create(struct nb_cb_create_args *args)
 {
        struct isis_area *area;
-       struct area_addr addr, *addrr = NULL, *addrp = NULL;
+       struct iso_address addr, *addrr = NULL, *addrp = NULL;
        struct listnode *node;
        struct sysid_iter iter;
        uint8_t buff[255];
@@ -161,7 +161,8 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args)
                }
                break;
        case NB_EV_PREPARE:
-               addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr));
+               addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR,
+                               sizeof(struct iso_address));
                addrr->addr_len = dotformat2buff(buff, net_title);
                memcpy(addrr->area_addr, buff, addrr->addr_len);
                args->resource->ptr = addrr;
@@ -217,7 +218,7 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args)
 
 int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args)
 {
-       struct area_addr addr, *addrp = NULL;
+       struct iso_address addr, *addrp = NULL;
        struct listnode *node;
        uint8_t buff[255];
        struct isis_area *area;
@@ -1829,6 +1830,23 @@ int isis_instance_log_adjacency_changes_modify(struct nb_cb_modify_args *args)
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-isisd:isis/instance/log-pdu-drops
+ */
+int isis_instance_log_pdu_drops_modify(struct nb_cb_modify_args *args)
+{
+       struct isis_area *area;
+       bool log = yang_dnode_get_bool(args->dnode, NULL);
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       area = nb_running_get_entry(args->dnode, NULL, true);
+       area->log_pdu_drops = log ? 1 : 0;
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-isisd:isis/instance/mpls-te
  */
index 94b1c47d3efe15dce277d6f184c3d25e4300ee43..5a1e312b4dbfb4ed5ce5ade906fd10b2e6dbd59e 100644 (file)
@@ -134,6 +134,7 @@ void isis_notif_lsp_too_large(const struct isis_circuit *circuit,
        const char *xpath = "/frr-isisd:lsp-too-large";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_area *area = circuit->area;
 
@@ -143,7 +144,8 @@ void isis_notif_lsp_too_large(const struct isis_circuit *circuit,
        data = yang_data_new_uint32(xpath_arg, pdu_size);
        listnode_add(arguments, data);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        hook_call(isis_hook_lsp_too_large, circuit, pdu_size, lsp_id);
@@ -180,11 +182,13 @@ void isis_notif_corrupted_lsp(const struct isis_area *area,
        const char *xpath = "/frr-isisd:corrupted-lsp-detected";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        hook_call(isis_hook_corrupted_lsp, area);
@@ -201,11 +205,13 @@ void isis_notif_lsp_exceed_max(const struct isis_area *area,
        const char *xpath = "/frr-isisd:attempt-to-exceed-max-sequence";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        hook_call(isis_hook_lsp_exceed_max, area, lsp_id);
@@ -299,6 +305,7 @@ void isis_notif_adj_state_change(const struct isis_adjacency *adj,
        const char *xpath = "/frr-isisd:adjacency-state-change";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_circuit *circuit = adj->circuit;
        struct isis_area *area = circuit->area;
@@ -312,7 +319,8 @@ void isis_notif_adj_state_change(const struct isis_adjacency *adj,
                listnode_add(arguments, data);
        }
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath);
-       data = yang_data_new_string(xpath_arg, sysid_print(adj->sysid));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pSY", adj->sysid);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath);
@@ -389,13 +397,15 @@ void isis_notif_lsp_received(const struct isis_circuit *circuit,
        const char *xpath = "/frr-isisd:lsp-received";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_area *area = circuit->area;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        notif_prepr_iface_hdr(xpath, circuit, arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath);
        data = yang_data_new_uint32(xpath_arg, seqno);
@@ -419,11 +429,13 @@ void isis_notif_lsp_gen(const struct isis_area *area, const uint8_t *lsp_id,
        const char *xpath = "/frr-isisd:lsp-generation";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath);
        data = yang_data_new_uint32(xpath_arg, seqno);
@@ -503,13 +515,15 @@ void isis_notif_lsp_error(const struct isis_circuit *circuit,
        const char *xpath = "/frr-isisd:lsp-error-detected";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_area *area = circuit->area;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        notif_prepr_iface_hdr(xpath, circuit, arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
        data = yang_data_new_binary(xpath_arg, raw_pdu, raw_pdu_len);
@@ -530,13 +544,15 @@ void isis_notif_seqno_skipped(const struct isis_circuit *circuit,
        const char *xpath = "/frr-isisd:sequence-number-skipped";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_area *area = circuit->area;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        notif_prepr_iface_hdr(xpath, circuit, arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        hook_call(isis_hook_seqno_skipped, circuit, lsp_id);
@@ -553,13 +569,15 @@ void isis_notif_own_lsp_purge(const struct isis_circuit *circuit,
        const char *xpath = "/frr-isisd:own-lsp-purge";
        struct list *arguments = yang_data_list_new();
        char xpath_arg[XPATH_MAXLEN];
+       char xpath_value[ISO_SYSID_STRLEN];
        struct yang_data *data;
        struct isis_area *area = circuit->area;
 
        notif_prep_instance_hdr(xpath, area, "default", arguments);
        notif_prepr_iface_hdr(xpath, circuit, arguments);
        snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
-       data = yang_data_new_string(xpath_arg, rawlspid_print(lsp_id));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pLS", lsp_id);
+       data = yang_data_new_string(xpath_arg, xpath_value);
        listnode_add(arguments, data);
 
        hook_call(isis_hook_own_lsp_purge, circuit, lsp_id);
index 13fdddf555c92f1f9dff2439a51b8f8da739057f..b7c33ed27b8b7b1b89fd11aec1d8f9af32a25beb 100644 (file)
@@ -132,8 +132,11 @@ lib_interface_state_isis_adjacencies_adjacency_neighbor_sysid_get_elem(
        struct nb_cb_get_elem_args *args)
 {
        const struct isis_adjacency *adj = args->list_entry;
+       char xpath_value[ISO_SYSID_STRLEN];
 
-       return yang_data_new_string(args->xpath, sysid_print(adj->sysid));
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pSY", adj->sysid);
+
+       return yang_data_new_string(args->xpath, xpath_value);
 }
 
 /*
@@ -158,8 +161,11 @@ lib_interface_state_isis_adjacencies_adjacency_neighbor_snpa_get_elem(
        struct nb_cb_get_elem_args *args)
 {
        const struct isis_adjacency *adj = args->list_entry;
+       char xpath_value[ISO_SYSID_STRLEN];
+
+       snprintfrr(xpath_value, ISO_SYSID_STRLEN, "%pSY", adj->snpa);
 
-       return yang_data_new_string(args->xpath, snpa_print(adj->snpa));
+       return yang_data_new_string(args->xpath, xpath_value);
 }
 
 /*
index d53d43ad0ecb5cca964750097bd03acb55f2ac78..0cd43a7abc9e5cfef40c5878c6ed33e93f1e7972 100644 (file)
@@ -514,9 +514,9 @@ static int process_lan_hello(struct iih_info *iih)
 
        if (IS_DEBUG_ADJ_PACKETS) {
                zlog_debug(
-                       "ISIS-Adj (%s): Rcvd L%d LAN IIH from %s on %s, cirType %s, cirID %u, length %zd",
-                       iih->circuit->area->area_tag, iih->level,
-                       snpa_print(iih->ssnpa), iih->circuit->interface->name,
+                       "ISIS-Adj (%s): Rcvd L%d LAN IIH from %pSY on %s, cirType %s, cirID %u, length %zd",
+                       iih->circuit->area->area_tag, iih->level, iih->ssnpa,
+                       iih->circuit->interface->name,
                        circuit_t2string(iih->circuit->is_type),
                        iih->circuit->circuit_id,
                        stream_get_endp(iih->circuit->rcv_stream));
@@ -862,31 +862,32 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
 
 #ifndef FABRICD
        /* send northbound notification */
+       char buf[ISO_SYSID_STRLEN];
+
+       snprintfrr(buf, ISO_SYSID_STRLEN, "%pSY", hdr.lsp_id);
        isis_notif_lsp_received(circuit, hdr.lsp_id, hdr.seqno, time(NULL),
-                               sysid_print(hdr.lsp_id));
+                               buf);
 #endif /* ifndef FABRICD */
 
        if (pdu_len_validate(hdr.pdu_len, circuit)) {
-               zlog_debug("ISIS-Upd (%s): LSP %s invalid LSP length %hu",
-                          circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                          hdr.pdu_len);
+               zlog_debug("ISIS-Upd (%s): LSP %pLS invalid LSP length %hu",
+                          circuit->area->area_tag, hdr.lsp_id, hdr.pdu_len);
                return ISIS_WARNING;
        }
 
        if (IS_DEBUG_UPDATE_PACKETS) {
-               zlog_debug("ISIS-Upd (%s): Rcvd L%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus, len %hu, on %s",
-                          circuit->area->area_tag, level,
-                          rawlspid_print(hdr.lsp_id), hdr.seqno, hdr.checksum,
-                          hdr.rem_lifetime, hdr.pdu_len,
-                          circuit->interface->name);
+               zlog_debug(
+                       "ISIS-Upd (%s): Rcvd L%d LSP %pLS, seq 0x%08x, cksum 0x%04hx, lifetime %hus, len %hu, on %s",
+                       circuit->area->area_tag, level, hdr.lsp_id, hdr.seqno,
+                       hdr.checksum, hdr.rem_lifetime, hdr.pdu_len,
+                       circuit->interface->name);
        }
 
        /* lsp is_type check */
        if ((hdr.lsp_bits & IS_LEVEL_1) != IS_LEVEL_1) {
-               zlog_debug(
-                       "ISIS-Upd (%s): LSP %s invalid LSP is type 0x%x",
-                       circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                       hdr.lsp_bits & IS_LEVEL_1_AND_2);
+               zlog_debug("ISIS-Upd (%s): LSP %pLS invalid LSP is type 0x%x",
+                          circuit->area->area_tag, hdr.lsp_id,
+                          hdr.lsp_bits & IS_LEVEL_1_AND_2);
                /* continue as per RFC1122 Be liberal in what you accept, and
                 * conservative in what you send */
        }
@@ -896,27 +897,25 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
        if (iso_csum_verify(STREAM_DATA(circuit->rcv_stream) + 12,
                            hdr.pdu_len - 12, hdr.checksum, 12)) {
                zlog_debug(
-                       "ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04hx",
-                       circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                       hdr.checksum);
+                       "ISIS-Upd (%s): LSP %pLS invalid LSP checksum 0x%04hx",
+                       circuit->area->area_tag, hdr.lsp_id, hdr.checksum);
                return ISIS_WARNING;
        }
 
        /* 7.3.15.1 a) 1 - external domain circuit will discard lsps */
        if (circuit->ext_domain) {
                zlog_debug(
-                       "ISIS-Upd (%s): LSP %s received at level %d over circuit with externalDomain = true",
-                       circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                       level);
+                       "ISIS-Upd (%s): LSP %pLS received at level %d over circuit with externalDomain = true",
+                       circuit->area->area_tag, hdr.lsp_id, level);
                return ISIS_WARNING;
        }
 
        /* 7.3.15.1 a) 2,3 - manualL2OnlyMode not implemented */
        if (!(circuit->is_type & level)) {
                zlog_debug(
-                       "ISIS-Upd (%s): LSP %s received at level %d over circuit of type %s",
-                       circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                       level, circuit_t2string(circuit->is_type));
+                       "ISIS-Upd (%s): LSP %pLS received at level %d over circuit of type %s",
+                       circuit->area->area_tag, hdr.lsp_id, level,
+                       circuit_t2string(circuit->is_type));
                return ISIS_WARNING;
        }
 
@@ -1016,11 +1015,11 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
        if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
                if (!isis_adj_lookup_snpa(ssnpa,
                                          circuit->u.bc.adjdb[level - 1])) {
-                       zlog_debug("(%s): DS ======= LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s",
-                                  circuit->area->area_tag,
-                                  rawlspid_print(hdr.lsp_id), hdr.seqno,
-                                  hdr.checksum, hdr.rem_lifetime,
-                                  circuit->interface->name);
+                       zlog_debug(
+                               "(%s): DS ======= LSP %pLS, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s",
+                               circuit->area->area_tag, hdr.lsp_id, hdr.seqno,
+                               hdr.checksum, hdr.rem_lifetime,
+                               circuit->interface->name);
                        goto out; /* Silently discard */
                }
        }
@@ -1057,9 +1056,9 @@ dontcheckadj:
        if (lsp && (lsp->hdr.seqno == hdr.seqno)
            && (lsp->hdr.checksum != hdr.checksum)
            && hdr.rem_lifetime) {
-               zlog_warn("ISIS-Upd (%s): LSP %s seq 0x%08x with confused checksum received.",
-                         circuit->area->area_tag, rawlspid_print(hdr.lsp_id),
-                         hdr.seqno);
+               zlog_warn(
+                       "ISIS-Upd (%s): LSP %pLS seq 0x%08x with confused checksum received.",
+                       circuit->area->area_tag, hdr.lsp_id, hdr.seqno);
                hdr.rem_lifetime = 0;
                lsp_confusion = true;
        } else
@@ -1153,10 +1152,9 @@ dontcheckadj:
                                }
                                if (IS_DEBUG_UPDATE_PACKETS)
                                        zlog_debug(
-                                               "ISIS-Upd (%s): (1) re-originating LSP %s new seq 0x%08x",
+                                               "ISIS-Upd (%s): (1) re-originating LSP %pLS new seq 0x%08x",
                                                circuit->area->area_tag,
-                                               rawlspid_print(hdr.lsp_id),
-                                               lsp->hdr.seqno);
+                                               hdr.lsp_id, lsp->hdr.seqno);
                        } else {
                                /* our own LSP with 0 remaining life time */
 #ifndef FABRICD
@@ -1194,9 +1192,8 @@ dontcheckadj:
 #endif /* ifndef FABRICD */
                        if (IS_DEBUG_UPDATE_PACKETS) {
                                zlog_debug(
-                                       "ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08x",
-                                       circuit->area->area_tag,
-                                       rawlspid_print(hdr.lsp_id),
+                                       "ISIS-Upd (%s): (2) re-originating LSP %pLS new seq 0x%08x",
+                                       circuit->area->area_tag, hdr.lsp_id,
                                        lsp->hdr.seqno);
                        }
                        lsp_flood(lsp, NULL);
@@ -1361,9 +1358,9 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
        if (!is_csnp && (circuit->circ_type == CIRCUIT_T_BROADCAST)
            && !circuit->u.bc.is_dr[level - 1]) {
                zlog_debug(
-                       "ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s, skipping: we are not the DIS",
-                       circuit->area->area_tag, level, typechar,
-                       snpa_print(ssnpa), circuit->interface->name);
+                       "ISIS-Snp (%s): Rcvd L%d %cSNP from %pSY on %s, skipping: we are not the DIS",
+                       circuit->area->area_tag, level, typechar, ssnpa,
+                       circuit->interface->name);
 
                return ISIS_OK;
        }
@@ -1452,16 +1449,16 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
 
        /* debug isis snp-packets */
        if (IS_DEBUG_SNP_PACKETS) {
-               zlog_debug("ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s",
-                          circuit->area->area_tag, level, typechar,
-                          snpa_print(ssnpa), circuit->interface->name);
+               zlog_debug("ISIS-Snp (%s): Rcvd L%d %cSNP from %pSY on %s",
+                          circuit->area->area_tag, level, typechar, ssnpa,
+                          circuit->interface->name);
                for (struct isis_lsp_entry *entry = entry_head; entry;
                     entry = entry->next) {
                        zlog_debug(
-                               "ISIS-Snp (%s):         %cSNP entry %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus",
-                               circuit->area->area_tag, typechar,
-                               rawlspid_print(entry->id), entry->seqno,
-                               entry->checksum, entry->rem_lifetime);
+                               "ISIS-Snp (%s):         %cSNP entry %pLS, seq 0x%08x, cksum 0x%04hx, lifetime %hus",
+                               circuit->area->area_tag, typechar, entry->id,
+                               entry->seqno, entry->checksum,
+                               entry->rem_lifetime);
                }
        }
 
@@ -1654,14 +1651,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
        if (idrp == ISO9542_ESIS) {
                flog_err(EC_LIB_DEVELOPMENT,
                         "No support for ES-IS packet IDRP=%hhx", idrp);
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
        if (idrp != ISO10589_ISIS) {
                flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%hhx",
                         idrp);
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
@@ -1672,7 +1669,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                isis_notif_version_skew(circuit, version1, raw_pdu,
                                        sizeof(raw_pdu));
 #endif /* ifndef FABRICD */
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_WARNING;
        }
 
@@ -1696,14 +1693,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                isis_notif_id_len_mismatch(circuit, id_len, raw_pdu,
                                           sizeof(raw_pdu));
 #endif /* ifndef FABRICD */
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
        uint8_t expected_length;
        if (pdu_size(pdu_type, &expected_length)) {
                zlog_warn("Unsupported ISIS PDU %hhu", pdu_type);
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_WARNING;
        }
 
@@ -1711,7 +1708,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                flog_err(EC_ISIS_PACKET,
                         "Expected fixed header length = %hhu but got %hhu",
                         expected_length, length);
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
@@ -1719,7 +1716,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                flog_err(
                        EC_ISIS_PACKET,
                        "PDU is too short to contain fixed header of given PDU type.");
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
@@ -1730,14 +1727,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                isis_notif_version_skew(circuit, version2, raw_pdu,
                                        sizeof(raw_pdu));
 #endif /* ifndef FABRICD */
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_WARNING;
        }
 
        if (circuit->is_passive) {
                zlog_warn("Received ISIS PDU on passive circuit %s",
                          circuit->interface->name);
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_WARNING;
        }
 
@@ -1756,7 +1753,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                isis_notif_max_area_addr_mismatch(circuit, max_area_addrs,
                                                  raw_pdu, sizeof(raw_pdu));
 #endif /* ifndef FABRICD */
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
@@ -1765,8 +1762,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
        case L2_LAN_HELLO:
        case P2P_HELLO:
                if (fabricd && pdu_type != P2P_HELLO) {
-                       pdu_counter_count(circuit->area->pdu_drop_counters,
-                                         pdu_type);
+                       pdu_counter_count_drop(circuit->area, pdu_type);
                        return ISIS_ERROR;
                }
 
@@ -1777,8 +1773,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
        case FS_LINK_STATE:
                if (fabricd && pdu_type != L2_LINK_STATE &&
                    pdu_type != FS_LINK_STATE) {
-                       pdu_counter_count(circuit->area->pdu_drop_counters,
-                                         pdu_type);
+                       pdu_counter_count_drop(circuit->area, pdu_type);
                        return ISIS_ERROR;
                }
 
@@ -1791,12 +1786,12 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
                retval = process_snp(pdu_type, circuit, ssnpa);
                break;
        default:
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
                return ISIS_ERROR;
        }
 
        if (retval != ISIS_OK)
-               pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type);
+               pdu_counter_count_drop(circuit->area, pdu_type);
 
        return retval;
 }
@@ -2481,11 +2476,11 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp,
        if (stream_get_endp(lsp->pdu) > stream_get_size(circuit->snd_stream)) {
                flog_err(
                        EC_ISIS_PACKET,
-                       "ISIS-Upd (%s): Can't send L%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s. LSP Size is %zu while interface stream size is %zu.",
-                       circuit->area->area_tag, lsp->level,
-                       rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno,
-                       lsp->hdr.checksum, lsp->hdr.rem_lifetime,
-                       circuit->interface->name, stream_get_endp(lsp->pdu),
+                       "ISIS-Upd (%s): Can't send L%d LSP %pLS, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s. LSP Size is %zu while interface stream size is %zu.",
+                       circuit->area->area_tag, lsp->level, lsp->hdr.lsp_id,
+                       lsp->hdr.seqno, lsp->hdr.checksum,
+                       lsp->hdr.rem_lifetime, circuit->interface->name,
+                       stream_get_endp(lsp->pdu),
                        stream_get_size(circuit->snd_stream));
 #ifndef FABRICD
                /* send a northbound notification */
@@ -2509,14 +2504,14 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp,
        }
 
        if (IS_DEBUG_UPDATE_PACKETS) {
-               zlog_debug("ISIS-Upd (%s): Sending %sL%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s",
-                          circuit->area->area_tag,
-                          (tx_type == TX_LSP_CIRCUIT_SCOPED)
-                               ? "Circuit scoped " : "",
-                          lsp->level,
-                          rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno,
-                          lsp->hdr.checksum, lsp->hdr.rem_lifetime,
-                          circuit->interface->name);
+               zlog_debug(
+                       "ISIS-Upd (%s): Sending %sL%d LSP %pLS, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s",
+                       circuit->area->area_tag,
+                       (tx_type == TX_LSP_CIRCUIT_SCOPED) ? "Circuit scoped "
+                                                          : "",
+                       lsp->level, lsp->hdr.lsp_id, lsp->hdr.seqno,
+                       lsp->hdr.checksum, lsp->hdr.rem_lifetime,
+                       circuit->interface->name);
                if (IS_DEBUG_PACKET_DUMP)
                        zlog_dump_data(STREAM_DATA(circuit->snd_stream),
                                       stream_get_endp(circuit->snd_stream));
@@ -2554,3 +2549,37 @@ out:
                isis_tx_queue_del(circuit->tx_queue, lsp);
        }
 }
+
+void isis_log_pdu_drops(struct isis_area *area, const char *pdu_type)
+{
+       uint64_t total_drops = 0;
+
+       for (int i = 0; i < PDU_COUNTER_SIZE; i++) {
+               if (!area->pdu_drop_counters[i])
+                       continue;
+               total_drops += area->pdu_drop_counters[i];
+       }
+
+       zlog_info("PDU drop detected of type: %s. %" PRIu64
+                 " Total Drops; %" PRIu64 " L1 IIH drops;  %" PRIu64
+                 " L2 IIH drops; %" PRIu64 " P2P IIH drops; %" PRIu64
+                 " L1 LSP drops; %" PRIu64 " L2 LSP drops; %" PRIu64
+                 " FS LSP drops; %" PRIu64 " L1 CSNP drops; %" PRIu64
+                 " L2 CSNP drops; %" PRIu64 " L1 PSNP drops; %" PRIu64
+                 " L2 PSNP drops.",
+                 pdu_type, total_drops,
+                 pdu_counter_get_count(area->pdu_drop_counters, L1_LAN_HELLO),
+                 pdu_counter_get_count(area->pdu_drop_counters, L2_LAN_HELLO),
+                 pdu_counter_get_count(area->pdu_drop_counters, P2P_HELLO),
+                 pdu_counter_get_count(area->pdu_drop_counters, L1_LINK_STATE),
+                 pdu_counter_get_count(area->pdu_drop_counters, L2_LINK_STATE),
+                 pdu_counter_get_count(area->pdu_drop_counters, FS_LINK_STATE),
+                 pdu_counter_get_count(area->pdu_drop_counters,
+                                       L1_COMPLETE_SEQ_NUM),
+                 pdu_counter_get_count(area->pdu_drop_counters,
+                                       L2_COMPLETE_SEQ_NUM),
+                 pdu_counter_get_count(area->pdu_drop_counters,
+                                       L1_PARTIAL_SEQ_NUM),
+                 pdu_counter_get_count(area->pdu_drop_counters,
+                                       L2_PARTIAL_SEQ_NUM));
+}
index ccd89a70f1b0676c74b761bfa7cfd1300ed590d7..5303c61d38a273ea39bfadcb5ef000dce5ea3b7d 100644 (file)
@@ -206,4 +206,6 @@ void send_lsp(struct isis_circuit *circuit,
 void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
 int send_hello(struct isis_circuit *circuit, int level);
 int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa);
+void isis_log_pdu_drops(struct isis_area *area, const char *pdu_type);
+
 #endif /* _ZEBRA_ISIS_PDU_H */
index 9d07b5e5989d3017296a93b38a59ae357f6683b0..a3605a32a16234db97ea524d474844565379a6f3 100644 (file)
@@ -8,10 +8,10 @@
 
 #include "vty.h"
 
-#include "isisd/isis_pdu_counter.h"
 #include "isisd/isisd.h"
 #include "isisd/isis_circuit.h"
 #include "isisd/isis_pdu.h"
+#include "isisd/isis_pdu_counter.h"
 
 static int pdu_type_to_counter_index(uint8_t pdu_type)
 {
@@ -91,3 +91,23 @@ void pdu_counter_print(struct vty *vty, const char *prefix,
                        pdu_counter_index_to_name(i), counter[i]);
        }
 }
+
+void pdu_counter_count_drop(struct isis_area *area, uint8_t pdu_type)
+{
+       pdu_counter_count(area->pdu_drop_counters, pdu_type);
+
+       if (area->log_pdu_drops) {
+               isis_log_pdu_drops(
+                       area, pdu_counter_index_to_name(
+                                     pdu_type_to_counter_index(pdu_type)));
+       }
+}
+
+uint64_t pdu_counter_get_count(pdu_counter_t counter, uint8_t pdu_type)
+{
+       int index = pdu_type_to_counter_index(pdu_type);
+
+       if (index < 0)
+               return -1;
+       return counter[index];
+}
index c53c47368f46af0224ec346df9331e7e40474612..5c35b4fb51daf27cc7b0cd072f169b1bf02675cb 100644 (file)
@@ -24,5 +24,7 @@ typedef uint64_t pdu_counter_t[PDU_COUNTER_SIZE];
 void pdu_counter_print(struct vty *vty, const char *prefix,
                       pdu_counter_t counter);
 void pdu_counter_count(pdu_counter_t counter, uint8_t pdu_type);
+void pdu_counter_count_drop(struct isis_area *area, uint8_t pdu_type);
+uint64_t pdu_counter_get_count(pdu_counter_t counter, uint8_t pdu_type);
 
 #endif
index 6d9974fe9fe0ade1c8b7fe9ea421c3e454e3b525..f9e3780e29e3c78ffcb34a038bdf8139fd5af266 100644 (file)
@@ -833,12 +833,12 @@ static int isis_snmp_conv_next(uint8_t *buf, size_t max_len, size_t *out_len,
  */
 static int isis_snmp_area_addr_lookup_exact(oid *oid_idx, size_t oid_idx_len,
                                            struct isis_area **ret_area,
-                                           struct area_addr **ret_addr)
+                                           struct iso_address **ret_addr)
 {
        uint8_t cmp_buf[ISIS_SNMP_OSI_ADDR_LEN_MAX];
        size_t addr_len;
        struct isis_area *area = NULL;
-       struct area_addr *addr = NULL;
+       struct iso_address *addr = NULL;
        struct listnode *addr_node;
        struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
 
@@ -880,15 +880,15 @@ static int isis_snmp_area_addr_lookup_exact(oid *oid_idx, size_t oid_idx_len,
 
 static int isis_snmp_area_addr_lookup_next(oid *oid_idx, size_t oid_idx_len,
                                           struct isis_area **ret_area,
-                                          struct area_addr **ret_addr)
+                                          struct iso_address **ret_addr)
 {
        uint8_t cmp_buf[ISIS_SNMP_OSI_ADDR_LEN_MAX];
        size_t addr_len;
        int try_exact = 0;
        struct isis_area *found_area = NULL;
        struct isis_area *area = NULL;
-       struct area_addr *found_addr = NULL;
-       struct area_addr *addr = NULL;
+       struct iso_address *found_addr = NULL;
+       struct iso_address *addr = NULL;
        struct listnode *addr_node;
        struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT);
 
@@ -1501,7 +1501,7 @@ static uint8_t *isis_snmp_find_man_area(struct variable *v, oid *name,
                                        WriteMethod **write_method)
 {
        int res;
-       struct area_addr *area_addr = NULL;
+       struct iso_address *area_addr = NULL;
        oid *oid_idx;
        size_t oid_idx_len;
        size_t off = 0;
@@ -2485,6 +2485,11 @@ static uint8_t *isis_snmp_find_isadj(struct variable *v, oid *name,
        uint32_t delta_ticks;
        time_t now_time;
 
+       /* Ring buffer to print SNPA */
+#define FORMAT_BUF_COUNT 4
+       static char snpa[FORMAT_BUF_COUNT][ISO_SYSID_STRLEN];
+       static size_t cur_buf = 0;
+
        *write_method = NULL;
 
        if (*length <= v->namelen) {
@@ -2531,9 +2536,10 @@ static uint8_t *isis_snmp_find_isadj(struct variable *v, oid *name,
                return SNMP_INTEGER(adj->threeway_state);
 
        case ISIS_ISADJ_NEIGHSNPAADDRESS: {
-               const char *snpa = (char *)snpa_print(adj->snpa);
-               *var_len = strlen(snpa);
-               return (uint8_t *)snpa;
+               cur_buf = (cur_buf + 1) % FORMAT_BUF_COUNT;
+               snprintfrr(snpa[cur_buf], ISO_SYSID_STRLEN, "%pSY", adj->snpa);
+               *var_len = strlen(snpa[cur_buf]);
+               return (uint8_t *)snpa[cur_buf];
        }
 
        case ISIS_ISADJ_NEIGHSYSTYPE:
index bfe3758cd898d77e18aad50b3d08eb6a658616ab..8597049ac098a170981950637b3008fe534cfcb9 100644 (file)
@@ -1067,8 +1067,8 @@ end:
            && !isis_level2_adj_up(spftree->area)) {
                struct prefix_pair ip_info = { {0} };
                if (IS_DEBUG_RTE_EVENTS)
-                       zlog_debug("ISIS-Spf (%s): add default %s route",
-                                  rawlspid_print(lsp->hdr.lsp_id),
+                       zlog_debug("ISIS-Spf (%pLS): add default %s route",
+                                  lsp->hdr.lsp_id,
                                   spftree->family == AF_INET ? "ipv4"
                                                              : "ipv6");
 
@@ -1207,9 +1207,8 @@ static void isis_spf_preload_tent(struct isis_spftree *spftree,
 
                if (isis_lfa_excise_adj_check(spftree, adj_id)) {
                        if (IS_DEBUG_LFA)
-                               zlog_debug("ISIS-SPF: excising adjacency %s",
-                                          isis_format_id(sadj->id,
-                                                         ISIS_SYS_ID_LEN + 1));
+                               zlog_debug("ISIS-SPF: excising adjacency %pPN",
+                                          sadj->id);
                        continue;
                }
 
@@ -1324,8 +1323,8 @@ static void spf_adj_list_parse_tlv(struct isis_spftree *spftree,
        LSP_FRAGMENT(lspid) = 0;
        lsp = lsp_search(spftree->lspdb, lspid);
        if (lsp == NULL || lsp->hdr.rem_lifetime == 0) {
-               zlog_warn("ISIS-SPF: No LSP found from root to L%d %s",
-                         spftree->level, rawlspid_print(lspid));
+               zlog_warn("ISIS-SPF: No LSP found from root to L%d %pLS",
+                         spftree->level, lspid);
                return;
        }
 
@@ -1663,9 +1662,8 @@ static void isis_spf_loop(struct isis_spftree *spftree,
 
                lsp = lsp_for_vertex(spftree, vertex);
                if (!lsp) {
-                       zlog_warn("ISIS-SPF: No LSP found for %s",
-                                 isis_format_id(vertex->N.id,
-                                                sizeof(vertex->N.id)));
+                       zlog_warn("ISIS-SPF: No LSP found for %pPN",
+                                 vertex->N.id);
                        continue;
                }
 
index cb330603e4198588eb1cc6b84e9f349f9f26dab5..e43b84ab2e4d5385c20457cd31b801297a29d8b3 100644 (file)
@@ -1022,14 +1022,14 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)
                if (!cap)
                        continue;
 
-               ttable_add_row(
-                       tt, "%s|%u - %u|%u - %u|%s|%u",
-                       sysid_print(lsp->hdr.lsp_id), cap->srgb.lower_bound,
-                       cap->srgb.lower_bound + cap->srgb.range_size - 1,
-                       cap->srlb.lower_bound,
-                       cap->srlb.lower_bound + cap->srlb.range_size - 1,
-                       cap->algo[0] == SR_ALGORITHM_SPF ? "SPF" : "S-SPF",
-                       cap->msd);
+               ttable_add_row(tt, "%pSY|%u - %u|%u - %u|%s|%u",
+                              lsp->hdr.lsp_id, cap->srgb.lower_bound,
+                              cap->srgb.lower_bound + cap->srgb.range_size - 1,
+                              cap->srlb.lower_bound,
+                              cap->srlb.lower_bound + cap->srlb.range_size - 1,
+                              cap->algo[0] == SR_ALGORITHM_SPF ? "SPF"
+                                                               : "S-SPF",
+                              cap->msd);
        }
 
        /* Dump the generated table. */
index 3ecd2a6f65bff9870528e7bcad53688f6d20be55..4e180ead6189cd6a935e51abc8e08d2dae116127 100644 (file)
@@ -903,7 +903,7 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric,
        struct ls_edge *edge, *dst;
        struct ls_attributes *attr;
 
-       te_debug("  |- Process Extended IS for %s", sysid_print(id));
+       te_debug("  |- Process Extended IS for %pSY", id);
 
        /* Check parameters */
        if (old_metric || !args || !tlvs)
@@ -1180,14 +1180,14 @@ static void isis_te_parse_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp)
 
        ted = mta->ted;
 
-       te_debug("ISIS-TE(%s): Parse LSP %s", lsp->area->area_tag,
-                sysid_print(lsp->hdr.lsp_id));
+       te_debug("ISIS-TE(%s): Parse LSP %pSY", lsp->area->area_tag,
+                lsp->hdr.lsp_id);
 
        /* First parse LSP to obtain the corresponding Vertex */
        vertex = lsp_to_vertex(ted, lsp);
        if (!vertex) {
-               zlog_warn("Unable to build Vertex from LSP %s. Abort!",
-                         sysid_print(lsp->hdr.lsp_id));
+               zlog_warn("Unable to build Vertex from LSP %pSY. Abort!",
+                         lsp->hdr.lsp_id);
                return;
        }
 
@@ -1251,8 +1251,8 @@ static void isis_te_delete_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp)
        if (!IS_MPLS_TE(mta) || !mta->ted || !lsp)
                return;
 
-       te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %s",
-                lsp->area->area_tag, sysid_print(lsp->hdr.lsp_id));
+       te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %pSY",
+                lsp->area->area_tag, lsp->hdr.lsp_id);
 
        /* Compute Link State Node ID from IS-IS sysID ... */
        if (lsp->level == ISIS_LEVEL1)
index b52a38be7f878398158d446fdf10ea003cbfb829..3b6db0ee17f488c774a583db2f7f2b850d2631ba 100644 (file)
@@ -661,7 +661,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts,
                                sbuf_push(
                                        buf, indent,
                                        "Lan-Adjacency-SID: %u, Weight: %hhu, Flags: F:%c B:%c, V:%c, L:%c, S:%c, P:%c\n"
-                                       "  Neighbor-ID: %s\n",
+                                       "  Neighbor-ID: %pSY\n",
                                        lan->sid, lan->weight,
                                        lan->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG
                                                ? '1'
@@ -681,7 +681,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts,
                                        lan->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG
                                                ? '1'
                                                : '0',
-                                       isis_format_id(lan->neighbor_id, 6));
+                                       lan->neighbor_id);
                        }
        }
 }
@@ -1590,14 +1590,14 @@ static void format_item_area_address(uint16_t mtid, struct isis_item *i,
                                     int indent)
 {
        struct isis_area_address *addr = (struct isis_area_address *)i;
+       struct iso_address iso_addr;
 
-       if (json) {
-               json_object_string_add(json, "area-addr",
-                                      isonet_print(addr->addr, addr->len));
-       } else {
-               sbuf_push(buf, indent, "Area Address: %s\n",
-                         isonet_print(addr->addr, addr->len));
-       }
+       memcpy(iso_addr.area_addr, addr->addr, ISO_ADDR_SIZE);
+       iso_addr.addr_len = addr->len;
+       if (json)
+               json_object_string_addf(json, "area-addr", "%pIS", &iso_addr);
+       else
+               sbuf_push(buf, indent, "Area Address: %pIS\n", &iso_addr);
 }
 
 static void free_item_area_address(struct isis_item *i)
@@ -1678,17 +1678,18 @@ static void format_item_oldstyle_reach(uint16_t mtid, struct isis_item *i,
                                       struct json_object *json, int indent)
 {
        struct isis_oldstyle_reach *r = (struct isis_oldstyle_reach *)i;
+       char sys_id[ISO_SYSID_STRLEN];
 
+       snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pPN", r->id);
        if (json) {
                struct json_object *old_json;
                old_json = json_object_new_object();
                json_object_object_add(json, "old-reach-style", old_json);
-               json_object_string_add(old_json, "is-reach",
-                                      isis_format_id(r->id, 7));
+               json_object_string_add(old_json, "is-reach", sys_id);
                json_object_int_add(old_json, "metric", r->metric);
        } else
                sbuf_push(buf, indent, "IS Reachability: %s (Metric: %hhu)\n",
-                         isis_format_id(r->id, 7), r->metric);
+                         sys_id, r->metric);
 }
 
 static void free_item_oldstyle_reach(struct isis_item *i)
@@ -1760,13 +1761,13 @@ static void format_item_lan_neighbor(uint16_t mtid, struct isis_item *i,
                                     int indent)
 {
        struct isis_lan_neighbor *n = (struct isis_lan_neighbor *)i;
+       char sys_id[ISO_SYSID_STRLEN];
 
-       if (json) {
-               json_object_string_add(json, "lan-neighbor",
-                                      isis_format_id(n->mac, 6));
-       } else
-               sbuf_push(buf, indent, "LAN Neighbor: %s\n",
-                         isis_format_id(n->mac, 6));
+       snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pSY", n->mac);
+       if (json)
+               json_object_string_add(json, "lan-neighbor", sys_id);
+       else
+               sbuf_push(buf, indent, "LAN Neighbor: %s\n", sys_id);
 }
 
 static void free_item_lan_neighbor(struct isis_item *i)
@@ -1831,23 +1832,25 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i,
                                  int indent)
 {
        struct isis_lsp_entry *e = (struct isis_lsp_entry *)i;
+       char sys_id[ISO_SYSID_STRLEN];
 
+       snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pLS", e->id);
        if (json) {
                char buf[255];
                struct json_object *lsp_json;
                lsp_json = json_object_new_object();
                json_object_object_add(json, "lsp-entry", lsp_json);
-               json_object_string_add(lsp_json, "id", isis_format_id(e->id, 8));
+               json_object_string_add(lsp_json, "id", sys_id);
                snprintfrr(buf,sizeof(buf),"0x%08x",e->seqno);
                json_object_string_add(lsp_json, "seq", buf);
                snprintfrr(buf,sizeof(buf),"0x%04hx",e->checksum);
                json_object_string_add(lsp_json, "chksum", buf);
                json_object_int_add(lsp_json, "lifetime", e->checksum);
        } else
-       sbuf_push(buf, indent,
-                 "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n",
-                 isis_format_id(e->id, 8), e->seqno, e->checksum,
-                 e->rem_lifetime);
+               sbuf_push(
+                       buf, indent,
+                       "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n",
+                       sys_id, e->seqno, e->checksum, e->rem_lifetime);
 }
 
 static void free_item_lsp_entry(struct isis_item *i)
@@ -1919,7 +1922,9 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i,
                                       struct json_object *json, int indent)
 {
        struct isis_extended_reach *r = (struct isis_extended_reach *)i;
+       char sys_id[ISO_SYSID_STRLEN];
 
+       snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pPN", r->id);
        if (json) {
                struct json_object *reach_json;
                reach_json = json_object_new_object();
@@ -1927,8 +1932,7 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i,
                json_object_string_add(
                        reach_json, "mt-id",
                        (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT");
-               json_object_string_add(reach_json, "id",
-                                      isis_format_id(r->id, 7));
+               json_object_string_add(reach_json, "id", sys_id);
                json_object_int_add(reach_json, "metric", r->metric);
                if (mtid != ISIS_MT_IPV4_UNICAST)
                        json_object_string_add(reach_json, "mt-name",
@@ -1940,7 +1944,7 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i,
        } else {
                sbuf_push(buf, indent, "%s Reachability: %s (Metric: %u)",
                          (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT",
-                         isis_format_id(r->id, 7), r->metric);
+                         sys_id, r->metric);
                if (mtid != ISIS_MT_IPV4_UNICAST)
                        sbuf_push(buf, 0, " %s", isis_mtid2str(mtid));
                sbuf_push(buf, 0, "\n");
@@ -3125,9 +3129,12 @@ static void
 format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj,
                        struct sbuf *buf, struct json_object *json, int indent)
 {
+       char sys_id[ISO_SYSID_STRLEN];
+
        if (!threeway_adj)
                return;
 
+       snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pSY", threeway_adj->neighbor_id);
        if (json) {
                struct json_object *three_json;
                three_json = json_object_new_object();
@@ -3140,9 +3147,7 @@ format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj,
                                    threeway_adj->local_circuit_id);
                if (!threeway_adj->neighbor_set)
                        return;
-               json_object_string_add(
-                       three_json, "neigh-system-id",
-                       isis_format_id(threeway_adj->neighbor_id, 6));
+               json_object_string_add(three_json, "neigh-system-id", sys_id);
                json_object_int_add(three_json, "neigh-ext-circuit-id",
                                    threeway_adj->neighbor_circuit_id);
        } else {
@@ -3155,8 +3160,7 @@ format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj,
                if (!threeway_adj->neighbor_set)
                        return;
 
-               sbuf_push(buf, indent, "  Neighbor System ID: %s\n",
-                         isis_format_id(threeway_adj->neighbor_id, 6));
+               sbuf_push(buf, indent, "  Neighbor System ID: %s\n", sys_id);
                sbuf_push(buf, indent, "  Neighbor Extended Circuit ID: %u\n",
                          threeway_adj->neighbor_circuit_id);
        }
@@ -3988,33 +3992,29 @@ static void format_tlv_purge_originator(struct isis_purge_originator *poi,
                                        struct sbuf *buf,
                                        struct json_object *json, int indent)
 {
+       char sen_id[ISO_SYSID_STRLEN];
+       char gen_id[ISO_SYSID_STRLEN];
+
        if (!poi)
                return;
 
+       snprintfrr(gen_id, ISO_SYSID_STRLEN, "%pSY", poi->generator);
+       if (poi->sender_set)
+               snprintfrr(sen_id, ISO_SYSID_STRLEN, "%pSY", poi->sender);
+
        if (json) {
                struct json_object *purge_json;
                purge_json = json_object_new_object();
                json_object_object_add(json, "purge_originator", purge_json);
 
-               json_object_string_add(
-                       purge_json, "id",
-                       isis_format_id(poi->generator, sizeof(poi->generator)));
-               if (poi->sender_set) {
-                       json_object_string_add(
-                               purge_json, "rec-from",
-                               isis_format_id(poi->sender,
-                                              sizeof(poi->sender)));
-               }
+               json_object_string_add(purge_json, "id", gen_id);
+               if (poi->sender_set)
+                       json_object_string_add(purge_json, "rec-from", sen_id);
        } else {
                sbuf_push(buf, indent, "Purge Originator Identification:\n");
-               sbuf_push(
-                       buf, indent, "  Generator: %s\n",
-                       isis_format_id(poi->generator, sizeof(poi->generator)));
-               if (poi->sender_set) {
-                       sbuf_push(buf, indent, "  Received-From: %s\n",
-                                 isis_format_id(poi->sender,
-                                                sizeof(poi->sender)));
-               }
+               sbuf_push(buf, indent, "  Generator: %s\n", gen_id);
+               if (poi->sender_set)
+                       sbuf_push(buf, indent, "  Received-From: %s\n", sen_id);
        }
 }
 
@@ -5271,14 +5271,14 @@ void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs,
                                  struct list *addresses)
 {
        struct listnode *node;
-       struct area_addr *area_addr;
+       struct iso_address *area_addr;
 
        for (ALL_LIST_ELEMENTS_RO(addresses, node, area_addr)) {
                struct isis_area_address *a =
                        XCALLOC(MTYPE_ISIS_TLV, sizeof(*a));
 
                a->len = area_addr->addr_len;
-               memcpy(a->addr, area_addr->area_addr, 20);
+               memcpy(a->addr, area_addr->area_addr, ISO_ADDR_SIZE);
                append_item(&tlvs->area_addresses, (struct isis_item *)a);
        }
 }
@@ -5475,7 +5475,7 @@ bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs,
        for (struct isis_area_address *addr = addr_head; addr;
             addr = addr->next) {
                struct listnode *node;
-               struct area_addr *a;
+               struct iso_address *a;
 
                for (ALL_LIST_ELEMENTS_RO(addresses, node, a)) {
                        if (a->addr_len == addr->len
index ec2d50d60a47d643d504f06f8564bb681f07bee4..caf97f11749c9315b6b5e33753e4af0c959c44cf 100644 (file)
@@ -126,12 +126,12 @@ void _isis_tx_queue_add(struct isis_tx_queue *queue,
                return;
 
        if (IS_DEBUG_TX_QUEUE) {
-               zlog_debug("Add LSP %s to %s queue as %s LSP. (From %s %s:%d)",
-                          rawlspid_print(lsp->hdr.lsp_id),
-                          queue->circuit->interface->name,
-                          (type == TX_LSP_CIRCUIT_SCOPED) ?
-                          "circuit scoped" : "regular",
-                          func, file, line);
+               zlog_debug(
+                       "Add LSP %pLS to %s queue as %s LSP. (From %s %s:%d)",
+                       lsp->hdr.lsp_id, queue->circuit->interface->name,
+                       (type == TX_LSP_CIRCUIT_SCOPED) ? "circuit scoped"
+                                                       : "regular",
+                       func, file, line);
        }
 
        struct isis_tx_queue_entry *e = tx_queue_find(queue, lsp);
@@ -164,9 +164,8 @@ void _isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp,
                return;
 
        if (IS_DEBUG_TX_QUEUE) {
-               zlog_debug("Remove LSP %s from %s queue. (From %s %s:%d)",
-                          rawlspid_print(lsp->hdr.lsp_id),
-                          queue->circuit->interface->name,
+               zlog_debug("Remove LSP %pLS from %s queue. (From %s %s:%d)",
+                          lsp->hdr.lsp_id, queue->circuit->interface->name,
                           func, file, line);
        }
 
index c6369a884e3b626ed23804616aabe17489da0cbf..fd6b91b42e1f5af10874940d15281e660ddd3736 100644 (file)
@@ -272,7 +272,7 @@ void isis_area_del_circuit(struct isis_area *area, struct isis_circuit *circuit)
 
 static void delete_area_addr(void *arg)
 {
-       struct area_addr *addr = (struct area_addr *)arg;
+       struct iso_address *addr = (struct iso_address *)arg;
 
        XFREE(MTYPE_ISIS_AREA_ADDR, addr);
 }
@@ -809,8 +809,8 @@ static void area_set_mt_overload(struct isis_area *area, uint16_t mtid,
 int area_net_title(struct vty *vty, const char *net_title)
 {
        VTY_DECLVAR_CONTEXT(isis_area, area);
-       struct area_addr *addr;
-       struct area_addr *addrp;
+       struct iso_address *addr;
+       struct iso_address *addrp;
        struct listnode *node;
 
        uint8_t buff[255];
@@ -823,14 +823,14 @@ int area_net_title(struct vty *vty, const char *net_title)
                return CMD_ERR_NOTHING_TODO;
        }
 
-       addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr));
+       addr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct iso_address));
        addr->addr_len = dotformat2buff(buff, net_title);
        memcpy(addr->area_addr, buff, addr->addr_len);
 #ifdef EXTREME_DEBUG
        zlog_debug("added area address %s for area %s (address length %d)",
                   net_title, area->area_tag, addr->addr_len);
 #endif /* EXTREME_DEBUG */
-       if (addr->addr_len < 8 || addr->addr_len > 20) {
+       if (addr->addr_len < ISO_ADDR_MIN || addr->addr_len > ISO_ADDR_SIZE) {
                vty_out(vty,
                        "area address must be at least 8..20 octets long (%d)\n",
                        addr->addr_len);
@@ -852,8 +852,8 @@ int area_net_title(struct vty *vty, const char *net_title)
                memcpy(area->isis->sysid, GETSYSID(addr), ISIS_SYS_ID_LEN);
                area->isis->sysid_set = 1;
                if (IS_DEBUG_EVENTS)
-                       zlog_debug("Router has SystemID %s",
-                                  sysid_print(area->isis->sysid));
+                       zlog_debug("Router has SystemID %pSY",
+                                  area->isis->sysid);
        } else {
                /*
                 * Check that the SystemID portions match
@@ -899,12 +899,12 @@ int area_net_title(struct vty *vty, const char *net_title)
 int area_clear_net_title(struct vty *vty, const char *net_title)
 {
        VTY_DECLVAR_CONTEXT(isis_area, area);
-       struct area_addr addr, *addrp = NULL;
+       struct iso_address addr, *addrp = NULL;
        struct listnode *node;
        uint8_t buff[255];
 
        addr.addr_len = dotformat2buff(buff, net_title);
-       if (addr.addr_len < 8 || addr.addr_len > 20) {
+       if (addr.addr_len < ISO_ADDR_MIN || addr.addr_len > ISO_ADDR_SIZE) {
                vty_out(vty,
                        "Unsupported area address length %d, should be 8...20 \n",
                        addr.addr_len);
@@ -2348,11 +2348,11 @@ static void common_isis_summary_json(struct json_object *json,
        time_t cur;
        char uptime[MONOTIME_STRLEN];
        char stier[5];
+
        json_object_string_add(json, "vrf", isis->name);
        json_object_int_add(json, "process-id", isis->process_id);
        if (isis->sysid_set)
-               json_object_string_add(json, "system-id",
-                                      sysid_print(isis->sysid));
+               json_object_string_addf(json, "system-id", "%pSY", isis->sysid);
 
        cur = time(NULL);
        cur -= isis->uptime;
@@ -2380,16 +2380,11 @@ static void common_isis_summary_json(struct json_object *json,
                }
 
                if (listcount(area->area_addrs) > 0) {
-                       struct area_addr *area_addr;
+                       struct iso_address *area_addr;
                        for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
-                                                 area_addr)) {
-                               json_object_string_add(
-                                       area_json, "net",
-                                       isonet_print(area_addr->area_addr,
-                                                    area_addr->addr_len +
-                                                            ISIS_SYS_ID_LEN +
-                                                            1));
-                       }
+                                                 area_addr))
+                               json_object_string_addf(area_json, "net",
+                                                       "%pISl", area_addr);
                }
 
                tx_pdu_json = json_object_new_object();
@@ -2462,8 +2457,7 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
        vty_out(vty, "vrf             : %s\n", isis->name);
        vty_out(vty, "Process Id      : %ld\n", isis->process_id);
        if (isis->sysid_set)
-               vty_out(vty, "System Id       : %s\n",
-                       sysid_print(isis->sysid));
+               vty_out(vty, "System Id       : %pSY\n", isis->sysid);
 
        vty_out(vty, "Up time         : ");
        vty_out_timestr(vty, isis->uptime);
@@ -2485,15 +2479,10 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
                }
 
                if (listcount(area->area_addrs) > 0) {
-                       struct area_addr *area_addr;
+                       struct iso_address *area_addr;
                        for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2,
-                                                 area_addr)) {
-                               vty_out(vty, "  Net: %s\n",
-                                       isonet_print(area_addr->area_addr,
-                                                    area_addr->addr_len
-                                                            + ISIS_SYS_ID_LEN
-                                                            + 1));
-                       }
+                                                 area_addr))
+                               vty_out(vty, "  Net: %pISl\n", area_addr);
                }
 
                vty_out(vty, "  TX counters per PDU type:\n");
@@ -3497,15 +3486,10 @@ static int isis_config_write(struct vty *vty)
                        write++;
                        /* ISIS - Net */
                        if (listcount(area->area_addrs) > 0) {
-                               struct area_addr *area_addr;
+                               struct iso_address *area_addr;
                                for (ALL_LIST_ELEMENTS_RO(area->area_addrs,
                                                          node2, area_addr)) {
-                                       vty_out(vty, " net %s\n",
-                                               isonet_print(
-                                                       area_addr->area_addr,
-                                                       area_addr->addr_len
-                                                               + ISIS_SYS_ID_LEN
-                                                               + 1));
+                                       vty_out(vty, " net %pISl\n", area_addr);
                                        write++;
                                }
                        }
index 0b1f1cb620c18e85b5e461297b135453cbef890a..12d9cd36c4f2c81e10b1db3bdb8ae8882466964a 100644 (file)
@@ -24,6 +24,7 @@
 #include "isis_lfa.h"
 #include "qobj.h"
 #include "ldp_sync.h"
+#include "iso.h"
 
 DECLARE_MGROUP(ISISD);
 
@@ -87,7 +88,7 @@ struct isis {
        uint32_t router_id;             /* Router ID from zebra */
        struct list *area_list; /* list of IS-IS areas */
        uint8_t max_area_addrs;           /* maximumAreaAdresses */
-       struct area_addr *man_area_addrs; /* manualAreaAddresses */
+       struct iso_address *man_area_addrs; /* manualAreaAddresses */
        time_t uptime;                    /* when did we start */
        struct event *t_dync_clean; /* dynamic hostname cache cleanup thread */
        uint32_t circuit_ids_used[8];     /* 256 bits to track circuit ids 1 through 255 */
@@ -195,6 +196,8 @@ struct isis_area {
        int ip_circuits;
        /* logging adjacency changes? */
        uint8_t log_adj_changes;
+       /* logging pdu drops? */
+       uint8_t log_pdu_drops;
        /* multi topology settings */
        struct list *mt_settings;
        /* MPLS-TE settings */
index 4a5bc361983caddcf24fc26f2598990143555dff..0d305a7af1ad5dfbadc094ff484037f3eab90170 100644 (file)
@@ -284,7 +284,7 @@ void if_rmap_ctx_delete(struct if_rmap_ctx *ctx)
        listnode_delete(if_rmap_ctx_list, ctx);
        hash_clean_and_free(&ctx->ifrmaphash, (void (*)(void *))if_rmap_free);
        if (ctx->name)
-               XFREE(MTYPE_IF_RMAP_CTX_NAME, ctx);
+               XFREE(MTYPE_IF_RMAP_CTX_NAME, ctx->name);
        XFREE(MTYPE_IF_RMAP_CTX, ctx);
 }
 
diff --git a/lib/iso.c b/lib/iso.c
new file mode 100644 (file)
index 0000000..fe97776
--- /dev/null
+++ b/lib/iso.c
@@ -0,0 +1,144 @@
+/*
+ * ISO Network functions - iso_net.c
+ *
+ * Author: Olivier Dugeon <olivier.dugeon@orange.com>
+ *
+ * Copyright (C) 2023 Orange http://www.orange.com
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "compiler.h"
+
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "printfrr.h"
+#include "iso.h"
+
+/**
+ * Print ISO System ID as 0000.0000.0000
+ *
+ * @param      Print buffer
+ * @param      Print argument
+ * @param      Pointer to the System ID to be printed
+ *
+ * @return     Number of printed characters
+ */
+printfrr_ext_autoreg_p("SY", printfrr_iso_sysid);
+static ssize_t printfrr_iso_sysid(struct fbuf *buf, struct printfrr_eargs *ea,
+                                 const void *vptr)
+{
+       const uint8_t *id = vptr;
+
+       if (!id)
+               return bputs(buf, "(null)");
+
+       return bprintfrr(buf, "%02x%02x.%02x%02x.%02x%02x",
+                        id[0], id[1], id[2], id[3], id[4], id[5]);
+}
+
+/**
+ * Print ISO Pseudo Node system ID as 0000.0000.0000.00
+ *
+ * @param      Print buffer
+ * @param      Print argument
+ * @param      Pointer to the System ID to be printed
+ *
+ * @return     Number of printed characters
+ */
+printfrr_ext_autoreg_p("PN", printfrr_iso_pseudo);
+static ssize_t printfrr_iso_pseudo(struct fbuf *buf, struct printfrr_eargs *ea,
+                                  const void *vptr)
+{
+       const uint8_t *id = vptr;
+
+       if (!id)
+               return bputs(buf, "(null)");
+
+       return bprintfrr(buf, "%02x%02x.%02x%02x.%02x%02x.%02x",
+                        id[0], id[1], id[2], id[3], id[4], id[5], id[6]);
+}
+
+/**
+ * Print ISO LSP Fragment System ID as 0000.0000.0000.00-00
+ *
+ * @param      Print buffer
+ * @param      Print argument
+ * @param      Pointer to the System ID to be printed
+ *
+ * @return     Number of printed characters
+ */
+printfrr_ext_autoreg_p("LS", printfrr_iso_frag_id);
+static ssize_t printfrr_iso_frag_id(struct fbuf *buf, struct printfrr_eargs *ea,
+                                   const void *vptr)
+{
+       const uint8_t *id = vptr;
+
+       if (!id)
+               return bputs(buf, "(null)");
+
+       return bprintfrr(buf, "%02x%02x.%02x%02x.%02x%02x.%02x-%02x",
+                        id[0], id[1], id[2], id[3], id[4], id[5], id[6],
+                        id[7]);
+}
+
+/**
+ * Print ISO Network address as 00.0000.0000.0000 ... with the System ID
+ * as 0000.0000.0000.00 when long 'l' option is added to '%pIS'
+ *
+ * @param      Print buffer
+ * @param      Print argument
+ * @param      Pointer to the ISO Network address
+ *
+ * @return     Number of printed characters
+ */
+printfrr_ext_autoreg_p("IS", printfrr_iso_addr);
+static ssize_t printfrr_iso_addr(struct fbuf *buf, struct printfrr_eargs *ea,
+                                const void *vptr)
+{
+       const struct iso_address *ia = vptr;
+       uint8_t len = 0;
+       int i = 0;
+       ssize_t ret = 0;
+
+       if (ea->fmt[0] == 'l') {
+               len = 7; /* ISO SYSTEM ID + 1 */
+               ea->fmt++;
+       }
+
+       if (!ia)
+               return bputs(buf, "(null)");
+
+       len += ia->addr_len;
+       while (i < len) {
+               /* No dot for odd index and at the end of address */
+               if ((i & 1) || (i == (len - 1)))
+                       ret += bprintfrr(buf, "%02x", ia->area_addr[i]);
+               else
+                       ret += bprintfrr(buf, "%02x.", ia->area_addr[i]);
+               i++;
+       }
+
+       return ret;
+}
+
diff --git a/lib/iso.h b/lib/iso.h
new file mode 100644 (file)
index 0000000..975d3c1
--- /dev/null
+++ b/lib/iso.h
@@ -0,0 +1,49 @@
+/*
+ * ISO Network definition - iso_net.h
+ *
+ * Author: Olivier Dugeon <olivier.dugeon@orange.com>
+ *
+ * Copyright (C) 2023 Orange http://www.orange.com
+ *
+ * This file is part of Free Range Routing (FRR).
+ *
+ * FRR 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, or (at your option) any
+ * later version.
+ *
+ * FRR 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 LIB_ISO_H_
+#define LIB_ISO_H_
+
+#include "compiler.h"
+
+/* len of "xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx" + '\0' */
+#define ISO_ADDR_STRLEN        51
+#define ISO_ADDR_MIN   8
+#define ISO_ADDR_SIZE  20
+struct iso_address {
+       uint8_t addr_len;
+       uint8_t area_addr[ISO_ADDR_SIZE];
+};
+
+/* len of "xxxx.xxxx.xxxx.xx-xx" + '\0' */
+#define ISO_SYSID_STRLEN 21
+
+#ifdef _FRR_ATTRIBUTE_PRINTFRR
+#pragma FRR printfrr_ext "%pSY" (uint8_t *)
+#pragma FRR printfrr_ext "%pPN" (uint8_t *)
+#pragma FRR printfrr_ext "%pLS" (uint8_t *)
+#pragma FRR printfrr_ext "%pIS" (struct iso_address *)
+#endif
+
+#endif /* LIB_ISO_H_ */
index 0aba021b1af7f7597f051db7016b6226441fecb0..076030a83974ee00b061ff2258d967dcdc73aa76 100644 (file)
@@ -26,6 +26,7 @@
 #include "printfrr.h"
 #include <lib/json.h>
 #include "link_state.h"
+#include "iso.h"
 
 /* Link State Memory allocation */
 DEFINE_MTYPE_STATIC(LIB, LS_DB, "Link State Database");
@@ -1966,13 +1967,9 @@ static const char *const status2txt[] = {
 static const char *ls_node_id_to_text(struct ls_node_id lnid, char *str,
                                      size_t size)
 {
-       if (lnid.origin == ISIS_L1 || lnid.origin == ISIS_L2) {
-               uint8_t *id;
-
-               id = lnid.id.iso.sys_id;
-               snprintfrr(str, size, "%02x%02x.%02x%02x.%02x%02x", id[0],
-                          id[1], id[2], id[3], id[4], id[5]);
-       } else
+       if (lnid.origin == ISIS_L1 || lnid.origin == ISIS_L2)
+               snprintfrr(str, size, "%pSY", lnid.id.iso.sys_id);
+       else
                snprintfrr(str, size, "%pI4", &lnid.id.ip.addr);
 
        return str;
index 0f5bbef0b251c1650ef184c7d1d72ee1c8aa8937..83eecbee577638db4a788202fa6d6f1520248bed 100644 (file)
@@ -47,6 +47,7 @@ lib_libfrr_la_SOURCES = \
        lib/if_rmap.c \
        lib/imsg-buffer.c \
        lib/imsg.c \
+       lib/iso.c \
        lib/jhash.c \
        lib/json.c \
        lib/keychain.c \
@@ -224,6 +225,7 @@ pkginclude_HEADERS += \
        lib/if_rmap.h \
        lib/imsg.h \
        lib/ipaddr.h \
+       lib/iso.h \
        lib/jhash.h \
        lib/json.h \
        lib/keychain.h \
index d3f30ce1ee81c93ec10ad522afbb39dc44a3b4ff..bd5cd7682a6034be245ec99825b2691d78d8f764 100644 (file)
@@ -111,7 +111,7 @@ int ospf_if_drop_alldrouters(struct ospf *top, struct prefix *p,
                         "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %pI4, ifindex %u, AllDRouters): %s",
                         top->fd, &p->u.prefix4, ifindex,
                         safe_strerror(errno));
-       else
+       else if (IS_DEBUG_OSPF_EVENT)
                zlog_debug(
                        "interface %pI4 [%u] leave AllDRouters Multicast group.",
                        &p->u.prefix4, ifindex);
@@ -159,7 +159,6 @@ int ospf_sock_init(struct ospf *ospf)
 {
        int ospf_sock;
        int ret, hincl = 1;
-       int bufsize = (8 * 1024 * 1024);
 
        /* silently ignore. already done */
        if (ospf->fd > 0)
@@ -213,9 +212,28 @@ int ospf_sock_init(struct ospf *ospf)
                                 ospf_sock);
        }
 
-       setsockopt_so_sendbuf(ospf_sock, bufsize);
-       setsockopt_so_recvbuf(ospf_sock, bufsize);
+       /* Update socket buffer sizes */
+       ospf_sock_bufsize_update(ospf, ospf_sock, OSPF_SOCK_BOTH);
 
        ospf->fd = ospf_sock;
        return ret;
 }
+
+/*
+ * Update a socket bufsize(s), based on its ospf instance
+ */
+void ospf_sock_bufsize_update(const struct ospf *ospf, int sock,
+                             enum ospf_sock_type_e type)
+{
+       int bufsize;
+
+       if (type == OSPF_SOCK_BOTH || type == OSPF_SOCK_RECV) {
+               bufsize = ospf->recv_sock_bufsize;
+               setsockopt_so_recvbuf(sock, bufsize);
+       }
+
+       if (type == OSPF_SOCK_BOTH || type == OSPF_SOCK_SEND) {
+               bufsize = ospf->send_sock_bufsize;
+               setsockopt_so_sendbuf(sock, bufsize);
+       }
+}
index 33fd8980bff20366716be1a3fd495f5358977574..d9b579c04a448260e76667cf1d72c31ea6d13264 100644 (file)
@@ -16,4 +16,14 @@ extern int ospf_if_drop_alldrouters(struct ospf *, struct prefix *, ifindex_t);
 extern int ospf_if_ipmulticast(struct ospf *, struct prefix *, ifindex_t);
 extern int ospf_sock_init(struct ospf *ospf);
 
+enum ospf_sock_type_e {
+       OSPF_SOCK_NONE = 0,
+       OSPF_SOCK_RECV,
+       OSPF_SOCK_SEND,
+       OSPF_SOCK_BOTH
+};
+
+void ospf_sock_bufsize_update(const struct ospf *ospf, int sock,
+                             enum ospf_sock_type_e type);
+
 #endif /* _ZEBRA_OSPF_NETWORK_H */
index d3d67ee88446cd99fe8fb64ed2fe76fd9f63dbf8..9b918798c04c11ff30e5c5bdbdbe75067f77fec4 100644 (file)
@@ -3403,6 +3403,23 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf,
        /* show LDP-Sync status */
        ospf_ldp_sync_show_info(vty, ospf, json_vrf, json ? 1 : 0);
 
+       /* Socket buffer sizes */
+       if (json) {
+               if (ospf->recv_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE)
+                       json_object_int_add(json_vrf, "recvSockBufsize",
+                                           ospf->recv_sock_bufsize);
+               if (ospf->send_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE)
+                       json_object_int_add(json_vrf, "sendSockBufsize",
+                                           ospf->send_sock_bufsize);
+       } else {
+               if (ospf->recv_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE)
+                       vty_out(vty, " Receive socket bufsize: %u\n",
+                               ospf->recv_sock_bufsize);
+               if (ospf->send_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE)
+                       vty_out(vty, " Send socket bufsize: %u\n",
+                               ospf->send_sock_bufsize);
+       }
+
        /* Show each area status. */
        for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area))
                show_ip_ospf_area(vty, area, json_areas, json ? 1 : 0);
@@ -12550,6 +12567,22 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
        /* LDP-Sync print */
        ospf_ldp_sync_write_config(vty, ospf);
 
+       /* Socket buffer sizes */
+       if (ospf->recv_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE) {
+               if (ospf->send_sock_bufsize == ospf->recv_sock_bufsize)
+                       vty_out(vty, " socket buffer all %u\n",
+                               ospf->recv_sock_bufsize);
+               else
+                       vty_out(vty, " socket buffer recv %u\n",
+                               ospf->recv_sock_bufsize);
+       }
+
+       if (ospf->send_sock_bufsize != OSPF_DEFAULT_SOCK_BUFSIZE &&
+           ospf->send_sock_bufsize != ospf->recv_sock_bufsize)
+               vty_out(vty, " socket buffer send %u\n",
+                       ospf->send_sock_bufsize);
+
+
        vty_out(vty, "exit\n");
 
        write++;
@@ -13006,6 +13039,42 @@ DEFPY(no_flood_reduction_area, no_flood_reduction_area_cmd,
        return CMD_SUCCESS;
 }
 
+DEFPY(ospf_socket_bufsizes,
+      ospf_socket_bufsizes_cmd,
+      "[no] socket buffer <send$send_val | recv$recv_val | all$all_val> \
+         ![(1-4000000000)$bufsize]",
+      NO_STR
+      "Socket parameters\n"
+      "Buffer size configuration\n"
+      "Send buffer size\n"
+      "Receive buffer size\n"
+      "Both send and receive buffer sizes\n"
+      "Buffer size, in bytes\n")
+{
+       VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+       uint32_t recvsz, sendsz;
+
+       if (no)
+               bufsize = OSPF_DEFAULT_SOCK_BUFSIZE;
+
+       if (all_val) {
+               recvsz = bufsize;
+               sendsz = bufsize;
+       } else if (send_val) {
+               sendsz = bufsize;
+               recvsz = ospf->recv_sock_bufsize;
+       } else if (recv_val) {
+               recvsz = bufsize;
+               sendsz = ospf->send_sock_bufsize;
+       } else
+               return CMD_SUCCESS;
+
+       /* React to a change by modifying existing sockets */
+       ospf_update_bufsize(ospf, recvsz, sendsz);
+
+       return CMD_SUCCESS;
+}
+
 void ospf_vty_clear_init(void)
 {
        install_element(ENABLE_NODE, &clear_ip_ospf_interface_cmd);
@@ -13169,6 +13238,8 @@ void ospf_vty_init(void)
        install_element(OSPF_NODE, &flood_reduction_area_cmd);
        install_element(OSPF_NODE, &no_flood_reduction_area_cmd);
 
+       install_element(OSPF_NODE, &ospf_socket_bufsizes_cmd);
+
        /* Init interface related vty commands. */
        ospf_vty_if_init();
 
index 4737643bc424f8f3d1bd5f9deb9b213cb530cf4e..15ce1c48a436d6fa773bc7db5acfc80e825644a4 100644 (file)
@@ -420,6 +420,9 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name)
 
        new->fd = -1;
 
+       new->recv_sock_bufsize = OSPF_DEFAULT_SOCK_BUFSIZE;
+       new->send_sock_bufsize = OSPF_DEFAULT_SOCK_BUFSIZE;
+
        return new;
 }
 
@@ -2180,6 +2183,32 @@ int ospf_nbr_nbma_poll_interval_unset(struct ospf *ospf, struct in_addr addr)
        return 1;
 }
 
+/*
+ * Update socket bufsize(s), usually after config change
+ */
+void ospf_update_bufsize(struct ospf *ospf, uint32_t recvsize,
+                        uint32_t sendsize)
+{
+       enum ospf_sock_type_e type = OSPF_SOCK_NONE;
+
+       /* Figure out whether there's been a change */
+       if (recvsize != ospf->recv_sock_bufsize) {
+               type = OSPF_SOCK_RECV;
+               ospf->recv_sock_bufsize = recvsize;
+
+               if (sendsize != ospf->send_sock_bufsize) {
+                       type = OSPF_SOCK_BOTH;
+                       ospf->send_sock_bufsize = sendsize;
+               }
+       } else if (sendsize != ospf->send_sock_bufsize) {
+               type = OSPF_SOCK_SEND;
+               ospf->send_sock_bufsize = sendsize;
+       }
+
+       if (type != OSPF_SOCK_NONE)
+               ospf_sock_bufsize_update(ospf, ospf->fd, type);
+}
+
 void ospf_master_init(struct event_loop *master)
 {
        memset(&ospf_master, 0, sizeof(ospf_master));
index af60e6cad042ec842ddd9433f02e130865703652..1b66d4d9304c97e2fc2b7d744962f4c41a97bfbe 100644 (file)
@@ -67,6 +67,9 @@
 #define OSPF_LS_REFRESH_SHIFT       (60 * 15)
 #define OSPF_LS_REFRESH_JITTER      60
 
+/* Default socket buffer size */
+#define OSPF_DEFAULT_SOCK_BUFSIZE   (8 * 1024 * 1024)
+
 struct ospf_external {
        unsigned short instance;
        struct route_table *external_info;
@@ -424,6 +427,10 @@ struct ospf {
        /* Flood Reduction configuration state */
        bool fr_configured;
 
+       /* Socket buffer sizes */
+       uint32_t recv_sock_bufsize;
+       uint32_t send_sock_bufsize;
+
        QOBJ_FIELDS;
 };
 DECLARE_QOBJ_TYPE(ospf);
@@ -793,6 +800,9 @@ int ospf_area_nssa_no_summary_set(struct ospf *ospf, struct in_addr area_id);
 const char *ospf_get_name(const struct ospf *ospf);
 extern struct ospf_interface *add_ospf_interface(struct connected *co,
                                                 struct ospf_area *area);
+/* Update socket bufsize(s), after config change */
+void ospf_update_bufsize(struct ospf *ospf, uint32_t recvsize,
+                        uint32_t sendsize);
 
 extern int p_spaces_compare_func(const struct p_space *a,
                                 const struct p_space *b);
index ae4d93b4f5853f82835077737dcb02a877bb0fab..7dbe2bbccf7d696bf0f127bc5049fa8e5e307670 100644 (file)
@@ -1500,7 +1500,7 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
        ret = sendmsg(rip->sock, &msg, 0);
 
        if (IS_RIP_DEBUG_EVENT)
-               zlog_debug("SEND to  %pI4%d", &sin.sin_addr,
+               zlog_debug("SEND to %pI4 port %d", &sin.sin_addr,
                           ntohs(sin.sin_port));
 
        if (ret < 0)
@@ -2836,16 +2836,11 @@ uint8_t rip_distance_apply(struct rip *rip, struct rip_info *rinfo)
                        if (access_list_apply(alist, &rinfo->rp->p)
                            == FILTER_DENY)
                                return 0;
-
-                       return rdistance->distance;
-               } else
-                       return rdistance->distance;
+               }
+               return rdistance->distance;
        }
 
-       if (rip->distance)
-               return rip->distance;
-
-       return 0;
+       return rip->distance;
 }
 
 static void rip_distance_show(struct vty *vty, struct rip *rip)
index 66ec6a410d5b682c6086183ebc7b1d26573dec46..de925b48238a887dd62f37e0f5edafe775ff71c9 100644 (file)
@@ -1594,6 +1594,13 @@ module frr-isisd {
           "Log changes to the IS-IS adjacencies in this area.";
       }
 
+      leaf log-pdu-drops {
+        type boolean;
+        default "false";
+        description
+          "Log any dropped PDUs in this area.";
+      }
+
       container mpls-te {
         presence "Present if MPLS-TE is enabled.";
         description