mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 12:49:18 +00:00
ospfd: fix crash when logging a Grace-LSA
Change the "show_ospf_grace_lsa_info" callback to account for the fact that the "vty" parameter can be null. This fixes a crash that happens when "debug ospf packet ls-update detail" is configured and a Grace-LSA is sent or received. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
802a573933
commit
f5f27b588a
@ -1020,72 +1020,115 @@ static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa)
|
|||||||
lsah = (struct lsa_header *)lsa->data;
|
lsah = (struct lsa_header *)lsa->data;
|
||||||
|
|
||||||
if (lsa->size <= OSPF_LSA_HEADER_SIZE) {
|
if (lsa->size <= OSPF_LSA_HEADER_SIZE) {
|
||||||
vty_out(vty, "%% Invalid LSA length: %d\n", length);
|
if (vty)
|
||||||
|
vty_out(vty, "%% Invalid LSA length: %d\n", length);
|
||||||
|
else
|
||||||
|
zlog_debug("%% Invalid LSA length: %d", length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = lsa->size - OSPF_LSA_HEADER_SIZE;
|
length = lsa->size - OSPF_LSA_HEADER_SIZE;
|
||||||
|
|
||||||
vty_out(vty, " TLV info:\n");
|
if (vty)
|
||||||
|
vty_out(vty, " TLV info:\n");
|
||||||
|
else
|
||||||
|
zlog_debug(" TLV info:");
|
||||||
|
|
||||||
for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh;
|
for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh;
|
||||||
tlvh = TLV_HDR_NEXT(tlvh)) {
|
tlvh = TLV_HDR_NEXT(tlvh)) {
|
||||||
/* Check TLV len */
|
/* Check TLV len */
|
||||||
if (sum + TLV_SIZE(tlvh) > length) {
|
if (sum + TLV_SIZE(tlvh) > length) {
|
||||||
vty_out(vty, "%% Invalid TLV length: %u\n",
|
if (vty)
|
||||||
TLV_SIZE(tlvh));
|
vty_out(vty, "%% Invalid TLV length: %u\n",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
|
else
|
||||||
|
zlog_debug("%% Invalid TLV length: %u",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ntohs(tlvh->type)) {
|
switch (ntohs(tlvh->type)) {
|
||||||
case GRACE_PERIOD_TYPE:
|
case GRACE_PERIOD_TYPE:
|
||||||
if (TLV_SIZE(tlvh) <
|
if (TLV_SIZE(tlvh)
|
||||||
sizeof(struct grace_tlv_graceperiod)) {
|
< sizeof(struct grace_tlv_graceperiod)) {
|
||||||
vty_out(vty,
|
if (vty)
|
||||||
"%% Invalid grace TLV length %u\n",
|
vty_out(vty,
|
||||||
TLV_SIZE(tlvh));
|
"%% Invalid grace TLV length %u\n",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
|
else
|
||||||
|
zlog_debug(
|
||||||
|
"%% Invalid grace TLV length %u",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gracePeriod = (struct grace_tlv_graceperiod *)tlvh;
|
gracePeriod = (struct grace_tlv_graceperiod *)tlvh;
|
||||||
sum += TLV_SIZE(tlvh);
|
sum += TLV_SIZE(tlvh);
|
||||||
|
|
||||||
vty_out(vty, " Grace period:%d\n",
|
if (vty)
|
||||||
ntohl(gracePeriod->interval));
|
vty_out(vty, " Grace period:%d\n",
|
||||||
|
ntohl(gracePeriod->interval));
|
||||||
|
else
|
||||||
|
zlog_debug(" Grace period:%d",
|
||||||
|
ntohl(gracePeriod->interval));
|
||||||
break;
|
break;
|
||||||
case RESTART_REASON_TYPE:
|
case RESTART_REASON_TYPE:
|
||||||
if (TLV_SIZE(tlvh) <
|
if (TLV_SIZE(tlvh)
|
||||||
sizeof(struct grace_tlv_restart_reason)) {
|
< sizeof(struct grace_tlv_restart_reason)) {
|
||||||
vty_out(vty,
|
if (vty)
|
||||||
"%% Invalid reason TLV length %u\n",
|
vty_out(vty,
|
||||||
TLV_SIZE(tlvh));
|
"%% Invalid reason TLV length %u\n",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
|
else
|
||||||
|
zlog_debug(
|
||||||
|
"%% Invalid reason TLV length %u",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
grReason = (struct grace_tlv_restart_reason *)tlvh;
|
grReason = (struct grace_tlv_restart_reason *)tlvh;
|
||||||
sum += TLV_SIZE(tlvh);
|
sum += TLV_SIZE(tlvh);
|
||||||
|
|
||||||
vty_out(vty, " Restart reason:%s\n",
|
if (vty)
|
||||||
ospf_restart_reason2str(grReason->reason));
|
vty_out(vty, " Restart reason:%s\n",
|
||||||
|
ospf_restart_reason2str(
|
||||||
|
grReason->reason));
|
||||||
|
else
|
||||||
|
zlog_debug(" Restart reason:%s",
|
||||||
|
ospf_restart_reason2str(
|
||||||
|
grReason->reason));
|
||||||
break;
|
break;
|
||||||
case RESTARTER_IP_ADDR_TYPE:
|
case RESTARTER_IP_ADDR_TYPE:
|
||||||
if (TLV_SIZE(tlvh) <
|
if (TLV_SIZE(tlvh)
|
||||||
sizeof(struct grace_tlv_restart_addr)) {
|
< sizeof(struct grace_tlv_restart_addr)) {
|
||||||
vty_out(vty,
|
if (vty)
|
||||||
"%% Invalid addr TLV length %u\n",
|
vty_out(vty,
|
||||||
TLV_SIZE(tlvh));
|
"%% Invalid addr TLV length %u\n",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
|
else
|
||||||
|
zlog_debug(
|
||||||
|
"%% Invalid addr TLV length %u",
|
||||||
|
TLV_SIZE(tlvh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
restartAddr = (struct grace_tlv_restart_addr *)tlvh;
|
restartAddr = (struct grace_tlv_restart_addr *)tlvh;
|
||||||
sum += TLV_SIZE(tlvh);
|
sum += TLV_SIZE(tlvh);
|
||||||
|
|
||||||
vty_out(vty, " Restarter address:%pI4\n",
|
if (vty)
|
||||||
&restartAddr->addr);
|
vty_out(vty, " Restarter address:%pI4\n",
|
||||||
|
&restartAddr->addr);
|
||||||
|
else
|
||||||
|
zlog_debug(" Restarter address:%pI4",
|
||||||
|
&restartAddr->addr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vty_out(vty, " Unknown TLV type %d\n",
|
if (vty)
|
||||||
ntohs(tlvh->type));
|
vty_out(vty, " Unknown TLV type %d\n",
|
||||||
|
ntohs(tlvh->type));
|
||||||
|
else
|
||||||
|
zlog_debug(" Unknown TLV type %d",
|
||||||
|
ntohs(tlvh->type));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user