mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 04:47:05 +00:00
isisd: Don't set subtlv structure if we didn't unpack any subtlvs
This ensures deserialized and serialized TLV representation is consistent.
This commit is contained in:
parent
c1f9dd3227
commit
fdc615a4bb
@ -405,7 +405,7 @@ static int pack_subtlvs(struct isis_subtlvs *subtlvs, struct stream *s)
|
|||||||
|
|
||||||
static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len,
|
static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len,
|
||||||
struct stream *stream, struct sbuf *log, void *dest,
|
struct stream *stream, struct sbuf *log, void *dest,
|
||||||
int indent);
|
int indent, bool *unpacked_known_tlvs);
|
||||||
|
|
||||||
/* Functions related to TLVs 1 Area Addresses */
|
/* Functions related to TLVs 1 Area Addresses */
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ static int unpack_item_extended_reach(uint16_t mtid, uint8_t len,
|
|||||||
size_t subtlv_start = stream_get_getp(s);
|
size_t subtlv_start = stream_get_getp(s);
|
||||||
|
|
||||||
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_NE_REACH, subtlv_len, s,
|
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_NE_REACH, subtlv_len, s,
|
||||||
log, NULL, indent + 4)) {
|
log, NULL, indent + 4, NULL)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1386,10 +1386,16 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IP_REACH);
|
rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IP_REACH);
|
||||||
|
bool unpacked_known_tlvs = false;
|
||||||
|
|
||||||
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IP_REACH, subtlv_len, s,
|
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IP_REACH, subtlv_len, s,
|
||||||
log, rv->subtlvs, indent + 4)) {
|
log, rv->subtlvs, indent + 4, &unpacked_known_tlvs)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (!unpacked_known_tlvs) {
|
||||||
|
isis_free_subtlvs(rv->subtlvs);
|
||||||
|
rv->subtlvs = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
append_item(items, (struct isis_item *)rv);
|
append_item(items, (struct isis_item *)rv);
|
||||||
@ -1865,10 +1871,16 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH);
|
rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH);
|
||||||
|
bool unpacked_known_tlvs = false;
|
||||||
|
|
||||||
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH, subtlv_len, s,
|
if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH, subtlv_len, s,
|
||||||
log, rv->subtlvs, indent + 4)) {
|
log, rv->subtlvs, indent + 4, &unpacked_known_tlvs)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (!unpacked_known_tlvs) {
|
||||||
|
isis_free_subtlvs(rv->subtlvs);
|
||||||
|
rv->subtlvs = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
append_item(items, (struct isis_item *)rv);
|
append_item(items, (struct isis_item *)rv);
|
||||||
@ -2966,7 +2978,7 @@ static int unpack_tlv_unknown(enum isis_tlv_context context, uint8_t tlv_type,
|
|||||||
|
|
||||||
static int unpack_tlv(enum isis_tlv_context context, size_t avail_len,
|
static int unpack_tlv(enum isis_tlv_context context, size_t avail_len,
|
||||||
struct stream *stream, struct sbuf *log, void *dest,
|
struct stream *stream, struct sbuf *log, void *dest,
|
||||||
int indent)
|
int indent, bool *unpacked_known_tlvs)
|
||||||
{
|
{
|
||||||
uint8_t tlv_type, tlv_len;
|
uint8_t tlv_type, tlv_len;
|
||||||
const struct tlv_ops *ops;
|
const struct tlv_ops *ops;
|
||||||
@ -2997,6 +3009,8 @@ static int unpack_tlv(enum isis_tlv_context context, size_t avail_len,
|
|||||||
|
|
||||||
ops = tlv_table[context][tlv_type];
|
ops = tlv_table[context][tlv_type];
|
||||||
if (ops && ops->unpack) {
|
if (ops && ops->unpack) {
|
||||||
|
if (unpacked_known_tlvs)
|
||||||
|
*unpacked_known_tlvs = true;
|
||||||
return ops->unpack(context, tlv_type, tlv_len, stream, log,
|
return ops->unpack(context, tlv_type, tlv_len, stream, log,
|
||||||
dest, indent + 2);
|
dest, indent + 2);
|
||||||
}
|
}
|
||||||
@ -3007,7 +3021,7 @@ static int unpack_tlv(enum isis_tlv_context context, size_t avail_len,
|
|||||||
|
|
||||||
static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len,
|
static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len,
|
||||||
struct stream *stream, struct sbuf *log, void *dest,
|
struct stream *stream, struct sbuf *log, void *dest,
|
||||||
int indent)
|
int indent, bool *unpacked_known_tlvs)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
size_t tlv_start, tlv_pos;
|
size_t tlv_start, tlv_pos;
|
||||||
@ -3020,7 +3034,7 @@ static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len,
|
|||||||
|
|
||||||
while (tlv_pos < avail_len) {
|
while (tlv_pos < avail_len) {
|
||||||
rv = unpack_tlv(context, avail_len - tlv_pos, stream, log, dest,
|
rv = unpack_tlv(context, avail_len - tlv_pos, stream, log, dest,
|
||||||
indent + 2);
|
indent + 2, unpacked_known_tlvs);
|
||||||
if (rv)
|
if (rv)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@ -3052,7 +3066,7 @@ int isis_unpack_tlvs(size_t avail_len, struct stream *stream,
|
|||||||
|
|
||||||
result = isis_alloc_tlvs();
|
result = isis_alloc_tlvs();
|
||||||
rv = unpack_tlvs(ISIS_CONTEXT_LSP, avail_len, stream, &logbuf, result,
|
rv = unpack_tlvs(ISIS_CONTEXT_LSP, avail_len, stream, &logbuf, result,
|
||||||
indent);
|
indent, NULL);
|
||||||
|
|
||||||
*log = sbuf_buf(&logbuf);
|
*log = sbuf_buf(&logbuf);
|
||||||
*dest = result;
|
*dest = result;
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user