]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: use memcmp to check bgp marker
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 1 Jun 2017 16:20:58 +0000 (16:20 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:00 +0000 (16:18 -0500)
performance

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_io.c

index 2a2ea437dbc26e9afcb4b1c4e4e109525053c7ca..26aab7a617f7490a3d48f9f3a16dd265896f0a9e 100644 (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);