]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: uncork/nagle socket when sending BGP NOTIFY
authorLeonid Rosenboim <Leonid.Rosenboim@windriver.com>
Fri, 14 Dec 2012 19:12:17 +0000 (19:12 +0000)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 16 Jan 2013 00:45:57 +0000 (01:45 +0100)
This pushes out the NOTIFY message before closing a connection.

Previously, the TCP_CORK bandwidth optimization code caused NOTIFY
messages to disappear prior to when the connection is closed.

* bgpd/bgp_packet.c: unset CORK, set NODELAY, and replace
                     writen() by more correct write()

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_packet.c

index b0918fc52f014382bb6e59b6aac5f42eef50653f..d115353f8ba8ef822ca747374c634e41328aa0c8 100644 (file)
@@ -723,13 +723,21 @@ bgp_write_notify (struct peer *peer)
   val = fcntl (peer->fd, F_GETFL, 0);
   fcntl (peer->fd, F_SETFL, val & ~O_NONBLOCK);
 
-  ret = writen (peer->fd, STREAM_DATA (s), stream_get_endp (s));
+  /* Stop collecting data within the socket */
+  sockopt_cork (peer->fd, 0);
+
+  ret = write (peer->fd, STREAM_DATA (s), stream_get_endp (s));
   if (ret <= 0)
     {
       BGP_EVENT_ADD (peer, TCP_fatal_error);
       return 0;
     }
 
+  /* Disable Nagle, make NOTIFY packet go out right away */
+  val = 1;
+  (void) setsockopt (peer->fd, IPPROTO_TCP, TCP_NODELAY,
+                            (char *) &val, sizeof (val));
+
   /* Retrieve BGP packet type. */
   stream_set_getp (s, BGP_MARKER_SIZE + 2);
   type = stream_getc (s);