bgpd throttling for peers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bgpd throttling for peers

Claudio Jeker
I noticed that the throttling for peers which was added some time ago is
incomplete. The following diff solved these issues.

In rde_update_queue_runner() only process peers which are currently not
throttled. Additionally only run the runners if not too many imsg are
pending in the RDE. Both these changes should help imporve responsiveness.
In the SE only set the throttled flag if the imsg sending was successful.

Does work fine on my systems with little or no effect on convergance time.
Please test on your systems and look for preformance changes.
--
:wq Claudio

Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.435
diff -u -p -r1.435 rde.c
--- rde.c 15 Oct 2018 10:44:47 -0000 1.435
+++ rde.c 17 Oct 2018 12:18:51 -0000
@@ -334,15 +334,16 @@ rde_main(int debug, int verbose)
  mctx = LIST_NEXT(mctx, entry);
  }
 
- rde_update_queue_runner();
- for (aid = AID_INET6; aid < AID_MAX; aid++)
- rde_update6_queue_runner(aid);
+ if (ibuf_se && ibuf_se->w.queued < SESS_MSG_HIGH_MARK) {
+ rde_update_queue_runner();
+ for (aid = AID_INET6; aid < AID_MAX; aid++)
+ rde_update6_queue_runner(aid);
+ }
  if (rde_dump_pending() &&
     ibuf_se_ctl && ibuf_se_ctl->w.queued <= 10)
  rde_dump_runner();
- if (softreconfig) {
+ if (softreconfig)
  rde_reload_runner();
- }
  }
 
  /* do not clean up on shutdown on production, it takes ages. */
@@ -2665,6 +2666,8 @@ rde_update_queue_runner(void)
  continue;
  if (peer->state != PEER_UP)
  continue;
+ if (peer->throttled)
+ continue;
  /* first withdraws */
  wpos = 2; /* reserve space for the length field */
  r = up_dump_prefix(queue_buf + wpos, len - wpos - 2,
@@ -2732,6 +2735,8 @@ rde_update6_queue_runner(u_int8_t aid)
  continue;
  if (peer->state != PEER_UP)
  continue;
+ if (peer->throttled)
+ continue;
  len = sizeof(queue_buf) - MSGSIZE_HEADER;
  b = up_dump_mp_unreach(queue_buf, &len, peer, aid);
 
@@ -2755,6 +2760,8 @@ rde_update6_queue_runner(u_int8_t aid)
  if (peer->conf.id == 0)
  continue;
  if (peer->state != PEER_UP)
+ continue;
+ if (peer->throttled)
  continue;
  len = sizeof(queue_buf) - MSGSIZE_HEADER;
  r = up_dump_mp_reach(queue_buf, &len, peer, aid);
Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
retrieving revision 1.369
diff -u -p -r1.369 session.c
--- session.c 29 Sep 2018 07:58:06 -0000 1.369
+++ session.c 17 Oct 2018 12:18:51 -0000
@@ -1382,7 +1382,8 @@ session_sendmsg(struct bgp_msg *msg, str
  if (!p->throttled && p->wbuf.queued > SESS_MSG_HIGH_MARK) {
  if (imsg_rde(IMSG_XOFF, p->conf.id, NULL, 0) == -1)
  log_peer_warn(&p->conf, "imsg_compose XOFF");
- p->throttled = 1;
+ else
+ p->throttled = 1;
  }
 
  free(msg);
@@ -1773,7 +1774,8 @@ session_dispatch_msg(struct pollfd *pfd,
  if (p->throttled && p->wbuf.queued < SESS_MSG_LOW_MARK) {
  if (imsg_rde(IMSG_XON, p->conf.id, NULL, 0) == -1)
  log_peer_warn(&p->conf, "imsg_compose XON");
- p->throttled = 0;
+ else
+ p->throttled = 0;
  }
  if (!(pfd->revents & POLLIN))
  return (1);

Reply | Threaded
Open this post in threaded view
|

Re: bgpd throttling for peers

Claudio Jeker
On Wed, Oct 17, 2018 at 02:37:48PM +0200, Claudio Jeker wrote:

> I noticed that the throttling for peers which was added some time ago is
> incomplete. The following diff solved these issues.
>
> In rde_update_queue_runner() only process peers which are currently not
> throttled. Additionally only run the runners if not too many imsg are
> pending in the RDE. Both these changes should help imporve responsiveness.
> In the SE only set the throttled flag if the imsg sending was successful.
>
> Does work fine on my systems with little or no effect on convergance time.
> Please test on your systems and look for preformance changes.

Updated version after recent commit.

--
:wq Claudio

Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.437
diff -u -p -r1.437 rde.c
--- rde.c 18 Oct 2018 12:19:09 -0000 1.437
+++ rde.c 19 Oct 2018 15:49:43 -0000
@@ -334,15 +334,16 @@ rde_main(int debug, int verbose)
  mctx = LIST_NEXT(mctx, entry);
  }
 
- rde_update_queue_runner();
- for (aid = AID_INET6; aid < AID_MAX; aid++)
- rde_update6_queue_runner(aid);
+ if (ibuf_se && ibuf_se->w.queued < SESS_MSG_HIGH_MARK) {
+ rde_update_queue_runner();
+ for (aid = AID_INET6; aid < AID_MAX; aid++)
+ rde_update6_queue_runner(aid);
+ }
  if (rde_dump_pending() &&
     ibuf_se_ctl && ibuf_se_ctl->w.queued <= 10)
  rde_dump_runner();
- if (softreconfig) {
+ if (softreconfig)
  rde_reload_runner();
- }
  }
 
  /* do not clean up on shutdown on production, it takes ages. */
@@ -2664,6 +2665,8 @@ rde_update_queue_runner(void)
  continue;
  if (peer->state != PEER_UP)
  continue;
+ if (peer->throttled)
+ continue;
  eor = 0;
  /* first withdraws */
  wpos = 2; /* reserve space for the length field */
@@ -2730,6 +2733,8 @@ rde_update6_queue_runner(u_int8_t aid)
  continue;
  if (peer->state != PEER_UP)
  continue;
+ if (peer->throttled)
+ continue;
  len = sizeof(queue_buf) - MSGSIZE_HEADER;
  b = up_dump_mp_unreach(queue_buf, &len, peer, aid);
 
@@ -2753,6 +2758,8 @@ rde_update6_queue_runner(u_int8_t aid)
  if (peer->conf.id == 0)
  continue;
  if (peer->state != PEER_UP)
+ continue;
+ if (peer->throttled)
  continue;
  len = sizeof(queue_buf) - MSGSIZE_HEADER;
  r = up_dump_mp_reach(queue_buf, &len, peer, aid);
Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
retrieving revision 1.369
diff -u -p -r1.369 session.c
--- session.c 29 Sep 2018 07:58:06 -0000 1.369
+++ session.c 17 Oct 2018 12:18:51 -0000
@@ -1382,7 +1382,8 @@ session_sendmsg(struct bgp_msg *msg, str
  if (!p->throttled && p->wbuf.queued > SESS_MSG_HIGH_MARK) {
  if (imsg_rde(IMSG_XOFF, p->conf.id, NULL, 0) == -1)
  log_peer_warn(&p->conf, "imsg_compose XOFF");
- p->throttled = 1;
+ else
+ p->throttled = 1;
  }
 
  free(msg);
@@ -1773,7 +1774,8 @@ session_dispatch_msg(struct pollfd *pfd,
  if (p->throttled && p->wbuf.queued < SESS_MSG_LOW_MARK) {
  if (imsg_rde(IMSG_XON, p->conf.id, NULL, 0) == -1)
  log_peer_warn(&p->conf, "imsg_compose XON");
- p->throttled = 0;
+ else
+ p->throttled = 0;
  }
  if (!(pfd->revents & POLLIN))
  return (1);

Reply | Threaded
Open this post in threaded view
|

Re: bgpd throttling for peers

Denis Fondras-3
On Fri, Oct 19, 2018 at 05:51:20PM +0200, Claudio Jeker wrote:

> On Wed, Oct 17, 2018 at 02:37:48PM +0200, Claudio Jeker wrote:
> > I noticed that the throttling for peers which was added some time ago is
> > incomplete. The following diff solved these issues.
> >
> > In rde_update_queue_runner() only process peers which are currently not
> > throttled. Additionally only run the runners if not too many imsg are
> > pending in the RDE. Both these changes should help imporve responsiveness.
> > In the SE only set the throttled flag if the imsg sending was successful.
> >
> > Does work fine on my systems with little or no effect on convergance time.
> > Please test on your systems and look for preformance changes.
>
> Updated version after recent commit.
>

OK denis@

> --
> :wq Claudio
>
> Index: rde.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
> retrieving revision 1.437
> diff -u -p -r1.437 rde.c
> --- rde.c 18 Oct 2018 12:19:09 -0000 1.437
> +++ rde.c 19 Oct 2018 15:49:43 -0000
> @@ -334,15 +334,16 @@ rde_main(int debug, int verbose)
>   mctx = LIST_NEXT(mctx, entry);
>   }
>  
> - rde_update_queue_runner();
> - for (aid = AID_INET6; aid < AID_MAX; aid++)
> - rde_update6_queue_runner(aid);
> + if (ibuf_se && ibuf_se->w.queued < SESS_MSG_HIGH_MARK) {
> + rde_update_queue_runner();
> + for (aid = AID_INET6; aid < AID_MAX; aid++)
> + rde_update6_queue_runner(aid);
> + }
>   if (rde_dump_pending() &&
>      ibuf_se_ctl && ibuf_se_ctl->w.queued <= 10)
>   rde_dump_runner();
> - if (softreconfig) {
> + if (softreconfig)
>   rde_reload_runner();
> - }
>   }
>  
>   /* do not clean up on shutdown on production, it takes ages. */
> @@ -2664,6 +2665,8 @@ rde_update_queue_runner(void)
>   continue;
>   if (peer->state != PEER_UP)
>   continue;
> + if (peer->throttled)
> + continue;
>   eor = 0;
>   /* first withdraws */
>   wpos = 2; /* reserve space for the length field */
> @@ -2730,6 +2733,8 @@ rde_update6_queue_runner(u_int8_t aid)
>   continue;
>   if (peer->state != PEER_UP)
>   continue;
> + if (peer->throttled)
> + continue;
>   len = sizeof(queue_buf) - MSGSIZE_HEADER;
>   b = up_dump_mp_unreach(queue_buf, &len, peer, aid);
>  
> @@ -2753,6 +2758,8 @@ rde_update6_queue_runner(u_int8_t aid)
>   if (peer->conf.id == 0)
>   continue;
>   if (peer->state != PEER_UP)
> + continue;
> + if (peer->throttled)
>   continue;
>   len = sizeof(queue_buf) - MSGSIZE_HEADER;
>   r = up_dump_mp_reach(queue_buf, &len, peer, aid);
> Index: session.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> retrieving revision 1.369
> diff -u -p -r1.369 session.c
> --- session.c 29 Sep 2018 07:58:06 -0000 1.369
> +++ session.c 17 Oct 2018 12:18:51 -0000
> @@ -1382,7 +1382,8 @@ session_sendmsg(struct bgp_msg *msg, str
>   if (!p->throttled && p->wbuf.queued > SESS_MSG_HIGH_MARK) {
>   if (imsg_rde(IMSG_XOFF, p->conf.id, NULL, 0) == -1)
>   log_peer_warn(&p->conf, "imsg_compose XOFF");
> - p->throttled = 1;
> + else
> + p->throttled = 1;
>   }
>  
>   free(msg);
> @@ -1773,7 +1774,8 @@ session_dispatch_msg(struct pollfd *pfd,
>   if (p->throttled && p->wbuf.queued < SESS_MSG_LOW_MARK) {
>   if (imsg_rde(IMSG_XON, p->conf.id, NULL, 0) == -1)
>   log_peer_warn(&p->conf, "imsg_compose XON");
> - p->throttled = 0;
> + else
> + p->throttled = 0;
>   }
>   if (!(pfd->revents & POLLIN))
>   return (1);
>