]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
IO: Replace RX priority heuristic with explicit mark
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 6 Apr 2016 09:49:34 +0000 (11:49 +0200)
committerPavel Tvrdik <pawel.tvrdik@gmail.com>
Tue, 3 May 2016 07:25:37 +0000 (09:25 +0200)
In BIRD, RX has lower priority than TX with the exception of RX from
control socket. The patch replaces heuristic based on socket type with
explicit mark and uses it for both control socket and BGP session waiting
to be established.

This should avoid an issue when during heavy load, outgoing connection
could connect (TX event), send open, but then failed to receive OPEN /
establish in time, not sending notifications between and therefore
got hold timer expired error from the neighbor immediately after it
finally established the connection.

lib/socket.h
proto/bgp/bgp.c
sysdep/unix/io.c
sysdep/unix/main.c

index fbea92aa79570775d354335b10e593e79e82c26e..0327e9e5bc24815912379bca729ede132d1b299c 100644 (file)
@@ -28,6 +28,7 @@ typedef struct birdsock {
   struct iface *iface;                 /* Interface; specify this for broad/multicast sockets */
 
   byte *rbuf, *rpos;                   /* NULL=allocate automatically */
+  uint fast_rx;                                /* RX has higher priority in event loop */
   uint rbsize;
   int (*rx_hook)(struct birdsock *, int size); /* NULL=receiving turned off, returns 1 to clear rx buffer */
 
index e94fd4edf8b6f7fd9c561910a8f800581c37327c..5841e5bd3b29f24581718137089612099e016a6f 100644 (file)
@@ -376,6 +376,8 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
   if (ipa_zero(p->source_addr))
     p->source_addr = conn->sk->saddr;
 
+  conn->sk->fast_rx = 0;
+
   p->conn = conn;
   p->last_error_class = 0;
   p->last_error_code = 0;
@@ -698,6 +700,7 @@ bgp_setup_sk(struct bgp_conn *conn, sock *s)
 {
   s->data = conn;
   s->err_hook = bgp_sock_err;
+  s->fast_rx = 1;
   conn->sk = s;
 }
 
index 13b30240b060d670e2ba289570c6bf65fcfaed52..a747580db89631cc8b760e2e2a38c9d3b5e21bc7 100644 (file)
@@ -2147,7 +2147,7 @@ io_loop(void)
              int steps;
 
              steps = MAX_STEPS;
-             if ((s->type >= SK_MAGIC) && (pfd[s->index].revents & (POLLIN | POLLHUP | POLLERR)) && s->rx_hook)
+             if (s->fast_rx && (pfd[s->index].revents & (POLLIN | POLLHUP | POLLERR)) && s->rx_hook)
                do
                  {
                    steps--;
@@ -2192,7 +2192,7 @@ io_loop(void)
                  goto next2;
                }
 
-             if ((s->type < SK_MAGIC) && (pfd[s->index].revents & (POLLIN | POLLHUP | POLLERR)) && s->rx_hook)
+             if (!s->fast_rx && (pfd[s->index].revents & (POLLIN | POLLHUP | POLLERR)) && s->rx_hook)
                {
                  count++;
                  io_log_event(s->rx_hook, s->data);
index 24d34f6017e1a37b1b2442eef2ae2e982f4f12ee..5d5586a02f2a28c00f7eaf1b07fc92ff300695af 100644 (file)
@@ -450,6 +450,7 @@ cli_connect(sock *s, int size UNUSED)
   s->err_hook = cli_err;
   s->data = c = cli_new(s);
   s->pool = c->pool;           /* We need to have all the socket buffers allocated in the cli pool */
+  s->fast_rx = 1;
   c->rx_pos = c->rx_buf;
   c->rx_aux = NULL;
   rmove(s, c->pool);
@@ -466,6 +467,7 @@ cli_init_unix(uid_t use_uid, gid_t use_gid)
   s->type = SK_UNIX_PASSIVE;
   s->rx_hook = cli_connect;
   s->rbsize = 1024;
+  s->fast_rx = 1;
 
   /* Return value intentionally ignored */
   unlink(path_control_socket);