lib, isisd, bgpd: BGP-LS add several tlvs - #21376
Conversation
Greptile SummaryThis PR adds BGP-LS support for SR Capabilities (TLV 1034) and Node MSD (TLV 266), populates IS-IS Area Identifier into Confidence Score: 5/5PR is safe to merge; all four previously identified P1 issues have been addressed in this revision. All prior P1 findings (wrong ISIS Area bit in JSON, stream_forward_endp bug, TLV 1134 typo, missing bounds check in ls_parse_node) are corrected in the current diff. No new P1 or P0 issues were found. The parsing, encoding, comparison, and serialization logic for the new TLVs is consistent with existing patterns. Test coverage is added for all new functionality. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[IS-IS LSP] -->|lsp->tlvs->area_addresses| B[isisd/isis_te.c\nlsp_to_vertex]
B -->|LS_NODE_ISIS_AREA_ID\nLS_NODE_SR / LS_NODE_MSD| C[lib/link_state\nls_node]
C -->|bgp_ls_populate_node_attr| D[bgpd/bgp_ls_ted.c]
D -->|BGP_LS_ATTR_ISIS_AREA_BIT\nBGP_LS_ATTR_SR_CAPABILITIES_BIT\nBGP_LS_ATTR_NODE_MSD_BIT| E[bgp_ls_attr]
E -->|bgp_ls_encode_attr| F[Wire: TLV 1027\nTLV 1034\nTLV 266]
F -->|bgp_ls_parse_attr| G[parse_isis_area_id\nparse_sr_capabilities\nparse_node_msd]
G --> E
E -->|bgp_ls_attr_to_json| H[JSON Output\nisisAreaId\nsrCapabilities\nmsd]
E -->|bgp_ls_attr_display| I[VTY Output\nIS-IS Area ID\nSR Capabilities\nMSD]
Reviews (9): Last reviewed commit: "bgpd: BGP-LS: simplify bgp_ls_attr_to_js..." | Re-trigger Greptile |
88f20f3 to
b6f8faf
Compare
|
@greptile review |
b6f8faf to
b4c5646
Compare
|
Updated to fix appropriate comment from Greptile about |
|
@greptile review |
|
P2 findings from Greptile: (1) the unchecked inner stream_put_tlv_hdr in bgpd/bgp_ls_nlri.c:2171 - this is subTLV unlike other calls to the function and Greptile acknowledges that available stream buffer is checked right before the call correctly. I don't think it should be fixed for better readability, but if any human reviewer thinks it should - no problem from my side. (2) "only label encoding is valid under the SR Capabilities TLV.", 4 is invalid here, making whole NLRI invalid seems appropriate (RFC: https://datatracker.ietf.org/doc/html/rfc9085#section-2.1.2-6.10.2.4) Again, if any human reviewer thinks just warning + ignoring TLV is better - just write, I'll update the code. |
both of these look fine to me ... |
riw777
left a comment
There was a problem hiding this comment.
looks good, don't see any reason to address the last few ai notes
cscarpitta
left a comment
There was a problem hiding this comment.
Please rebase the PR and address the comments below.
b4c5646 to
d26c65d
Compare
|
@cscarpitta Thanks for review, I've updated branch with rebase + your comments fixes only. Here is diff of branch with rebased: diff --git a/bgpd/bgp_ls_nlri.c b/bgpd/bgp_ls_nlri.c
index 6519b37add..72630c77e0 100644
--- a/bgpd/bgp_ls_nlri.c
+++ b/bgpd/bgp_ls_nlri.c
@@ -2035,23 +2035,25 @@ int bgp_ls_encode_attr(struct stream *s, const struct bgp_ls_attr *attr)
/* SR Capabilities (TLV 1034) */
if (BGP_LS_TLV_CHECK(attr->present_tlvs, BGP_LS_ATTR_SR_CAPABILITIES_BIT)) {
- if (stream_put_tlv_hdr(s, BGP_LS_ATTR_SR_CAPABILITIES, 12) < 0)
- return -1;
- if (STREAM_WRITEABLE(s) < 12)
+ if (STREAM_WRITEABLE(s) < (size_t)BGP_LS_TLV_HDR_SIZE + 12)
return -1;
+ stream_putw(s, BGP_LS_ATTR_SR_CAPABILITIES);
+ stream_putw(s, 12);
stream_putc(s, attr->srgb.flag);
stream_putc(s, 0);
stream_put3(s, attr->srgb.range_size);
- stream_put_tlv_hdr(s, BGP_LS_ATTR_SID_LABEL, 3);
+ /* sub-TLV */
+ stream_putw(s, BGP_LS_ATTR_SID_LABEL);
+ stream_putw(s, 3);
stream_put3(s, attr->srgb.lower_bound);
}
/* Node MSD (TLV 266) */
if (BGP_LS_TLV_CHECK(attr->present_tlvs, BGP_LS_ATTR_NODE_MSD_BIT)) {
- if (stream_put_tlv_hdr(s, BGP_LS_ATTR_NODE_MSD, 2) < 0)
- return -1;
- if (STREAM_WRITEABLE(s) < 2)
+ if (STREAM_WRITEABLE(s) < (size_t)BGP_LS_TLV_HDR_SIZE + 2)
return -1;
+ stream_putw(s, BGP_LS_ATTR_NODE_MSD);
+ stream_putw(s, 2);
stream_putc(s, BGP_LS_IGP_MSD_TYPE_BASE_MPLS);
stream_putc(s, attr->msd);
}
diff --git a/bgpd/bgp_ls_ted.c b/bgpd/bgp_ls_ted.c
index d377b10274..3a32aa7203 100644
--- a/bgpd/bgp_ls_ted.c
+++ b/bgpd/bgp_ls_ted.c
@@ -56,7 +56,7 @@ int bgp_ls_populate_node_attr(struct ls_node *ls_node, struct bgp_ls_attr *attr)
attr->isis_area_id_len = ls_node->isis_area_id_len;
attr->isis_area_id = XCALLOC(MTYPE_BGP_LS_ATTR, attr->isis_area_id_len);
memcpy(attr->isis_area_id, ls_node->isis_area_id, attr->isis_area_id_len);
- attr->present_tlvs |= (1ULL << BGP_LS_ATTR_ISIS_AREA_BIT);
+ BGP_LS_TLV_SET(attr->present_tlvs, BGP_LS_ATTR_ISIS_AREA_BIT);
}
/* SR Capabilities (TLV 1034) */
@@ -64,13 +64,13 @@ int bgp_ls_populate_node_attr(struct ls_node *ls_node, struct bgp_ls_attr *attr)
attr->srgb.flag = ls_node->srgb.flag;
attr->srgb.lower_bound = ls_node->srgb.lower_bound;
attr->srgb.range_size = ls_node->srgb.range_size;
- attr->present_tlvs |= (1ULL << BGP_LS_ATTR_SR_CAPABILITIES_BIT);
+ BGP_LS_TLV_SET(attr->present_tlvs, BGP_LS_ATTR_SR_CAPABILITIES_BIT);
}
/* Node MSD (TLV 266) */
if (CHECK_FLAG(ls_node->flags, LS_NODE_MSD)) {
attr->msd = ls_node->msd;
- attr->present_tlvs |= (1ULL << BGP_LS_ATTR_NODE_MSD_BIT);
+ BGP_LS_TLV_SET(attr->present_tlvs, BGP_LS_ATTR_NODE_MSD_BIT);
}
/* IPv4 Router-ID (TLV 1028) */ |
|
@greptile review |
cscarpitta
left a comment
There was a problem hiding this comment.
Overall looks good. Just a few more comments.
d26c65d to
2b0e841
Compare
|
@cscarpitta I've updated MSD, thanks. |
|
@cscarpitta I'll look into this comment from Greptile about IS-IS Area ID - I've really tested only on single-area case. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
2b0e841 to
36a8280
Compare
|
@greptile review |
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
36a8280 to
6180a32
Compare
|
@cscarpitta Yes, Greptile was correct: the source of IS-IS Area ID I've used was wrong, it always gave Area ID of current router.
Hope now everything is fine. @greptile review |
|
@greptile can you verify your comments have been resolved? |
It is needed for BGP-LS IS-IS Area Identifier (TLV 1027) Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
* Console output (bgp_ls_attr_display) * JSON output (bgp_ls_attr_to_json) * Fill in from TED (bgp_ls_populate_node_attr) Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
Simplify bgp_ls_attr_to_json using json_object_string_addf instead of snprintfrr + json_object_string_add Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
6180a32 to
5ee1b95
Compare
|
Fixed new P2 issue from greptile (duplicate ISO_ADDR_SIZE definition). |
(In draft before I look into Greptile comment about IS-IS Area TLV)
This PR adds support for 2 TLVs:
Adds IS-IS Area Identifier to lib/link_state, and populates it in isisd.
Updates IS-IS Area Identifier (TLV 1027) (adds console/json output and population from TED)
For each of these TLVs testing is added.
Additionaly two fix/refactoring commits:
bgp_ls_attr_to_jsonusingjson_object_string_addfinstead ofsnprintfrr+json_object_string_add@cscarpitta I can split this into several PRs if that will be easier to review - all changes are in separate commits, so it will be quick and easy to do.
Thanks.