]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IS-IS: Add support for Node/Prefix SIDs as per rfc 8667
authorHannes Gredler <[email protected]>
Fri, 3 Apr 2020 10:04:56 +0000 (12:04 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 7 Apr 2020 08:42:19 +0000 (10:42 +0200)
(pull request #845)

print-isoclns.c
tests/TESTLIST
tests/isis_cap_tlv.out
tests/isis_iid_tlv.out
tests/isis_sr.out [new file with mode: 0644]
tests/isis_sr.pcap [new file with mode: 0644]

index 166cead09b141fc442c430f0e736bfa8cb5def80..f2235d289e205d261431151abd3b8af1150da3cb 100644 (file)
@@ -348,6 +348,19 @@ static const struct tok isis_tlv_router_capability_flags[] = {
     { 0, NULL }
 };
 
+#define ISIS_SUBTLV_ROUTER_CAP_SR 2 /* rfc 8667 */
+
+static const struct tok isis_router_capability_subtlv_values[] = {
+    { ISIS_SUBTLV_ROUTER_CAP_SR, "SR-Capabilities"},
+    { 0, NULL }
+};
+
+static const struct tok isis_router_capability_sr_flags[] = {
+    { 0x80, "ipv4"},
+    { 0x40, "ipv6"},
+    { 0, NULL }
+};
+
 #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP           3 /* rfc5305 */
 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID  4 /* rfc4205 */
 #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID        5 /* rfc5305 */
@@ -392,15 +405,42 @@ static const struct tok isis_ext_is_reach_subtlv_values[] = {
 
 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32          1 /* draft-ietf-isis-admin-tags-01 */
 #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64          2 /* draft-ietf-isis-admin-tags-01 */
+#define ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID           3 /* rfc8667 */
 #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR  117 /* draft-ietf-isis-wg-multi-topology-05 */
 
 static const struct tok isis_ext_ip_reach_subtlv_values[] = {
     { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32,           "32-Bit Administrative tag" },
     { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64,           "64-Bit Administrative tag" },
+    { ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID,            "Prefix SID" },
     { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR,     "Management Prefix Color" },
     { 0, NULL }
 };
 
+#define ISIS_PREFIX_SID_FLAG_R 0x80 /* rfc 8667 */
+#define ISIS_PREFIX_SID_FLAG_N 0x40 /* rfc 8667 */
+#define ISIS_PREFIX_SID_FLAG_P 0x20 /* rfc 8667 */
+#define ISIS_PREFIX_SID_FLAG_E 0x10 /* rfc 8667 */
+#define ISIS_PREFIX_SID_FLAG_V 0x08 /* rfc 8667 */
+#define ISIS_PREFIX_SID_FLAG_L 0x04 /* rfc 8667 */
+
+static const struct tok prefix_sid_flag_values[] = {
+    { ISIS_PREFIX_SID_FLAG_R, "Readvertisement"},
+    { ISIS_PREFIX_SID_FLAG_N, "Node"},
+    { ISIS_PREFIX_SID_FLAG_P, "No-PHP"},
+    { ISIS_PREFIX_SID_FLAG_E, "Explicit NULL"},
+    { ISIS_PREFIX_SID_FLAG_V, "Value"},
+    { ISIS_PREFIX_SID_FLAG_L, "Local"},
+    { 0, NULL}
+};
+
+
+/* rfc 8667 */
+static const struct tok prefix_sid_algo_values[] = {
+    { 0, "SPF"},
+    { 1, "strict-SPF"},
+    { 0, NULL}
+};
+
 static const struct tok isis_subtlv_link_attribute_values[] = {
     { 0x01, "Local Protection Available" },
     { 0x02, "Link excluded from local protection path" },
@@ -1860,6 +1900,31 @@ isis_print_ip_reach_subtlv(netdissect_options *ndo,
            subl-=8;
        }
        break;
+    case ISIS_SUBTLV_EXTD_IP_REACH_PREFIX_SID:
+       {
+           uint8_t algo, flags;
+           uint32_t sid;
+
+           flags = GET_U_1(tptr);
+           algo = GET_U_1(tptr+1);
+
+           if (flags & ISIS_PREFIX_SID_FLAG_V) {
+               sid = GET_BE_U_3(tptr+2);
+               tptr+=5;
+               subl-=5;
+           } else {
+               sid = GET_BE_U_4(tptr+2);
+               tptr+=6;
+               subl-=6;
+           }
+
+           ND_PRINT(", Flags [%s], Algo %s (%u), %s %u",
+                    bittok2str(prefix_sid_flag_values, "None", flags),
+                    tok2str(prefix_sid_algo_values, "Unknown", algo), algo,
+                    flags & ISIS_PREFIX_SID_FLAG_V ? "label" : "index",
+                    sid);
+       }
+       break;
     default:
        if (!print_unknown_data(ndo, tptr, "\n\t\t    ", subl))
          return(0);
@@ -2266,6 +2331,90 @@ trunc:
     return 0;
 }
 
+static void
+isis_print_router_cap_subtlv(netdissect_options *ndo, const uint8_t *tptr, uint8_t tlen)
+{
+    uint8_t subt, subl;
+
+    while (tlen >= 2) {
+       ND_TCHECK_LEN(tptr, 2);
+       subt = GET_U_1(tptr);
+       subl = GET_U_1(tptr+1);
+       tlen -= 2;
+       tptr += 2;
+
+       /* first lets see if we know the subTLVs name*/
+       ND_PRINT("\n\t\t%s subTLV #%u, length: %u",
+              tok2str(isis_router_capability_subtlv_values, "unknown", subt),
+              subt, subl);
+
+       /*
+        * Boundary check.
+        */
+       if (subl > tlen) {
+           break;
+       }
+       ND_TCHECK_LEN(tptr, subl);
+
+       switch (subt) {
+       case ISIS_SUBTLV_ROUTER_CAP_SR:
+           {
+               uint8_t flags, sid_tlen, sid_type, sid_len;
+               uint32_t range;
+               const uint8_t *sid_ptr;
+
+               flags = GET_U_1(tptr);
+               range = GET_BE_U_3(tptr+1);
+               ND_PRINT(", Flags [%s], Range %u",
+                        bittok2str(isis_router_capability_sr_flags, "None", flags),
+                        range);
+               sid_ptr = tptr + 4;
+               sid_tlen = subl - 4;
+
+               while (sid_tlen >= 5) {
+                   sid_type = GET_U_1(sid_ptr);
+                   sid_len = GET_U_1(sid_ptr+1);
+                   sid_tlen -= 2;
+                   sid_ptr += 2;
+
+                   /*
+                    * Boundary check.
+                    */
+                   if (sid_len > sid_tlen) {
+                       break;
+                   }
+
+                   switch (sid_type) {
+                   case 1:
+                       if (sid_len == 3) {
+                           ND_PRINT(", SID value %u", GET_BE_U_3(sid_ptr));
+                       } else if (sid_len == 4) {
+                           ND_PRINT(", SID value %u", GET_BE_U_4(sid_ptr));
+                       } else {
+                           ND_PRINT(", Unknown SID length%u", sid_len);
+                       }
+                       break;
+                   default:
+                       print_unknown_data(ndo, sid_ptr, "\n\t\t  ", sid_len);
+                   }
+
+                   sid_ptr += sid_len;
+                   sid_tlen -= sid_len;
+               }
+           }
+           break;
+       default:
+           print_unknown_data(ndo, tptr, "\n\t\t", subl);
+           break;
+       }
+
+       tlen -= subl;
+       tptr += subl;
+    }
+ trunc:
+    return;
+}
+
 /*
  * Clear checksum and lifetime prior to signature verification.
  */
@@ -3325,12 +3474,14 @@ isis_print(netdissect_options *ndo,
                 break;
             }
             ND_TCHECK_5(tptr); /* router-id + flags */
-            ND_PRINT("\n\t\tRouter-id: %s", GET_IPADDR_STRING(tptr));
-            ND_PRINT("\n\t\tFlags: [%s]",
-                      bittok2str(isis_tlv_router_capability_flags,
-                        "none",
-                        GET_U_1(tptr+4)));
-            /* FIXME Optional set of sub-TLV */
+            ND_PRINT("\n\t      Router-ID %s", GET_IPADDR_STRING(tptr));
+            ND_PRINT(", Flags [%s]",
+                    bittok2str(isis_tlv_router_capability_flags, "none", GET_U_1(tptr+4)));
+
+           /* Optional set of sub-TLV */
+           if (tlen > 5) {
+               isis_print_router_cap_subtlv(ndo, tptr+5, tlen-5);
+           }
             break;
 
         case ISIS_TLV_VENDOR_PRIVATE:
index 6f79ad6f0bb9d7344576fecd8217e83e49b9247b..c178f24f6fed2cc1c35c91d365c08267e132dd97 100644 (file)
@@ -312,6 +312,7 @@ isis_3-v    ISIS_level2_adjacency.pcap      isis_3-v.out    -v
 isis_4-v       ISIS_p2p_adjacency.pcap         isis_4-v.out    -v
 isis_cap_tlv   isis_cap_tlv.pcap               isis_cap_tlv.out        -v
 isis_iid-v      isis_iid_tlv.pcap               isis_iid_tlv.out        -v
+isis_sr-v      isis_sr.pcap                    isis_sr.out     -v
 # fuzzed pcap
 # isis-seg-fault-1-v is now conditionally handled by isis-seg-fault-1-v.sh
 isis-seg-fault-2-v isis-seg-fault-2.pcapng isis-seg-fault-2-v.out -v
index 336dc7456ae2aadd0586bbd54ef8fecac1a9509b..e47f28b693cf85c9f0534328d9b446be841639fb 100644 (file)
@@ -85,5 +85,6 @@
              IPv4 prefix:     172.16.11.0/24, Distribution: up, Metric: 63
              IPv4 prefix:     192.168.0.1/32, Distribution: up, Metric: 63
            IS-IS Router Capability TLV #242, length: 8
-               Router-id: 192.168.0.1
-               Flags: [none]
+             Router-ID 192.168.0.1, Flags [none]
+               unknown subTLV #19, length: 1
+               0x0000:  00
index 4bd13e321d5f29bd2fe6908bda5a0ea746e7755c..b4865492bcd1d70e02919575280583f5225bdd96 100644 (file)
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 2222.2222.2222.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.1
-               Flags: [none]
+             Router-ID 1.1.1.1, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.1
              IPv4 interface address: 1.1.1.1
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 2222.2222.2222.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.1
-               Flags: [none]
+             Router-ID 1.1.1.1, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.1
              IPv4 interface address: 1.1.1.1
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 2222.2222.2222.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.1
-               Flags: [none]
+             Router-ID 1.1.1.1, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.1
              IPv4 interface address: 1.1.1.1
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 2222.2222.2222.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.1
-               Flags: [none]
+             Router-ID 1.1.1.1, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.1
              IPv4 interface address: 1.1.1.1
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 1111.1111.1111.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.2
-               Flags: [none]
+             Router-ID 1.1.1.2, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.2
              IPv4 interface address: 1.1.1.2
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 1111.1111.1111.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.2
-               Flags: [none]
+             Router-ID 1.1.1.2, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            IPv4 Interface address(es) TLV #132, length: 8
              IPv4 interface address: 2.2.2.2
              IPv4 interface address: 1.1.1.2
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 1111.1111.1111.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.2
-               Flags: [none]
+             Router-ID 1.1.1.2, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            Extended IPv4 Reachability TLV #135, length: 9
              IPv4 prefix:         2.2.2.1/32, Distribution: up, Metric: 20
            IPv4 Interface address(es) TLV #132, length: 8
            Extended IS Reachability TLV #22, length: 11
              IS Neighbor: 2222.2222.2222.00, Metric: 10, no sub-TLVs present
            IS-IS Router Capability TLV #242, length: 9
-               Router-id: 1.1.1.1
-               Flags: [none]
+             Router-ID 1.1.1.1, Flags [none]
+               unknown subTLV #27, length: 2
+               0x0000:  fa00
            Extended IPv4 Reachability TLV #135, length: 9
              IPv4 prefix:         2.2.2.2/32, Distribution: up, Metric: 20
            IPv4 Interface address(es) TLV #132, length: 8
diff --git a/tests/isis_sr.out b/tests/isis_sr.out
new file mode 100644 (file)
index 0000000..9515114
--- /dev/null
@@ -0,0 +1,17 @@
+    1  18:42:19.016934 IS-IS, length 97
+       L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+         lsp-id: 1920.0000.0008.00-00, seq: 0x00000031, lifetime: 65534s
+         chksum: 0xc3ad (correct), PDU length: 97, Flags: [ L2 IS ]
+           Area address(es) TLV #1, length: 4
+             Area address (length: 3): 49.0002
+           Protocols supported TLV #129, length: 2
+             NLPID(s): IPv6 (0x8e), IPv4 (0xcc)
+           Extended IPv4 Reachability TLV #135, length: 27
+             IPv4 prefix:       10.0.27.0/31, Distribution: up, Metric: 1000000
+             IPv4 prefix:         7.7.7.1/32, Distribution: up, Metric: 1000000, sub-TLVs present (8)
+               Prefix SID subTLV #3, length: 6, Flags [Node], Algo SPF (0), index 40
+           Extended IS Reachability TLV #22, length: 11
+             IS Neighbor: 1921.6800.1003.00, Metric: 1000000, no sub-TLVs present
+           IS-IS Router Capability TLV #242, length: 16
+             Router-ID 7.7.7.1, Flags [none]
+               SR-Capabilities subTLV #2, length: 9, Flags [ipv4, ipv6], Range 1000, SID value 4000
diff --git a/tests/isis_sr.pcap b/tests/isis_sr.pcap
new file mode 100644 (file)
index 0000000..c9a069e
Binary files /dev/null and b/tests/isis_sr.pcap differ