bgpd: use memcmp to check bgp marker

performance

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2017-06-01 16:20:58 +00:00
parent 958b450c69
commit 442c9afbd2
No known key found for this signature in database
GPG Key ID: DAF48E0F57E0834F

View File

@ -522,13 +522,15 @@ static bool validate_header(struct peer *peer)
{
u_int16_t size, type;
/* Marker check */
for (int i = 0; i < BGP_MARKER_SIZE; i++)
if (peer->ibuf_work->data[i] != 0xff) {
bgp_notify_send(peer, BGP_NOTIFY_HEADER_ERR,
BGP_NOTIFY_HEADER_NOT_SYNC);
return false;
}
static uint8_t marker[BGP_MARKER_SIZE] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
if (memcmp(marker, peer->ibuf_work->data, BGP_MARKER_SIZE) != 0) {
bgp_notify_send(peer, BGP_NOTIFY_HEADER_ERR,
BGP_NOTIFY_HEADER_NOT_SYNC);
return false;
}
/* Get size and type. */
size = stream_getw_from(peer->ibuf_work, BGP_MARKER_SIZE);