Skip to content

Commit

Permalink
Merge pull request #15690 from FRRouting/mergify/bp/stable/9.1/pr-15640
Browse files Browse the repository at this point in the history
bgpd: Fix errors handling for MP/GR capabilities as dynamic capability (backport #15640)
  • Loading branch information
Jafaral committed Apr 8, 2024
2 parents ec5fd40 + 0ddeb8b commit 45021ae
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bgpd/bgp_packet.c
Expand Up @@ -3121,6 +3121,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
zlog_err("%pBP: Capability length error", peer);
bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
pnt += length;
return BGP_Stop;
}
action = *pnt;
Expand All @@ -3133,7 +3134,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
action);
bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
goto done;
}

if (bgp_debug_neighbor_events(peer))
Expand All @@ -3145,12 +3146,13 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
zlog_err("%pBP: Capability length error", peer);
bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
pnt += length;
return BGP_Stop;
}

/* Ignore capability when override-capability is set. */
if (CHECK_FLAG(peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
continue;
goto done;

capability = lookup_msg(capcode_str, hdr->code, "Unknown");

Expand All @@ -3165,7 +3167,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
peer, capability,
sizeof(struct capability_mp_data),
hdr->length);
return BGP_Stop;
goto done;
}

memcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data));
Expand All @@ -3180,7 +3182,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
peer, capability,
iana_afi2str(pkt_afi),
iana_safi2str(pkt_safi));
continue;
goto done;
}

/* Address family check. */
Expand All @@ -3207,7 +3209,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
if (peer_active_nego(peer))
bgp_clear_route(peer, afi, safi);
else
return BGP_Stop;
goto done;
}
break;
case CAPABILITY_CODE_RESTART:
Expand All @@ -3217,7 +3219,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
bgp_notify_send(peer->connection,
BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
goto done;
}

bgp_dynamic_capability_graceful_restart(pnt, action,
Expand All @@ -3243,7 +3245,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
bgp_notify_send(peer->connection,
BGP_NOTIFY_CEASE,
BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
goto done;
}

uint8_t role;
Expand All @@ -3265,6 +3267,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
break;
}

done:
pnt += hdr->length + 3;
}

Expand Down

0 comments on commit 45021ae

Please sign in to comment.