From 442c9afbd26a739e34a1d07a128c8f98d9274211 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 1 Jun 2017 16:20:58 +0000 Subject: [PATCH] bgpd: use memcmp to check bgp marker performance Signed-off-by: Quentin Young --- bgpd/bgp_io.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 2a2ea437db..26aab7a617 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -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); -- 2.39.5