diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-01 18:20:58 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-11-30 22:18:00 +0100 |
commit | 442c9afbd26a739e34a1d07a128c8f98d9274211 (patch) | |
tree | 2b84343d2a0fd4414399bd02fe5c1d80e3b4bfbf /bgpd/bgp_io.c | |
parent | bgpd: copyright style (diff) | |
download | frr-442c9afbd26a739e34a1d07a128c8f98d9274211.tar.xz frr-442c9afbd26a739e34a1d07a128c8f98d9274211.zip |
bgpd: use memcmp to check bgp marker
performance
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_io.c')
-rw-r--r-- | bgpd/bgp_io.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 2a2ea437d..26aab7a61 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); |