From ea6179e78025dc661ea22db88201853008ef1215 Mon Sep 17 00:00:00 2001 From: claudio Date: Sun, 25 Oct 2015 18:49:01 +0000 Subject: [PATCH] Rename imsg_compose_parent and imsg_compose_rde to imsg_ctl_parent and imsg_ctl_rde since these function should only be used by the control code. Also switch ibuf_rde to ibuf_rde_ctl so that the control imsgs don't need to queue behind all the incoming bgp UPDATES. This speeds up 'bgpctl show' from taking minutes to a few seconds. The RDE was doing this since a very long time but it seems the SE was not adjusted. Yikes --- usr.sbin/bgpd/control.c | 26 +++++++++++++------------- usr.sbin/bgpd/session.c | 12 ++++++++---- usr.sbin/bgpd/session.h | 6 +++--- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index b46c5a3f50d..5fc453d2588 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.79 2015/10/24 15:15:55 benno Exp $ */ +/* $OpenBSD: control.c,v 1.80 2015/10/25 18:49:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -272,10 +272,10 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) break; } if (!neighbor->show_timers) { - imsg_compose_rde(imsg.hdr.type, + imsg_ctl_rde(imsg.hdr.type, imsg.hdr.pid, p, sizeof(struct peer)); - imsg_compose_rde(IMSG_CTL_END, + imsg_ctl_rde(IMSG_CTL_END, imsg.hdr.pid, NULL, 0); } else { u_int i; @@ -299,10 +299,10 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) } } else { for (p = peers; p != NULL; p = p->next) - imsg_compose_rde(imsg.hdr.type, + imsg_ctl_rde(imsg.hdr.type, imsg.hdr.pid, p, sizeof(struct peer)); - imsg_compose_rde(IMSG_CTL_END, imsg.hdr.pid, + imsg_ctl_rde(IMSG_CTL_END, imsg.hdr.pid, NULL, 0); } break; @@ -314,7 +314,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) break; case IMSG_CTL_FIB_COUPLE: case IMSG_CTL_FIB_DECOUPLE: - imsg_compose_parent(imsg.hdr.type, imsg.hdr.peerid, + imsg_ctl_parent(imsg.hdr.type, imsg.hdr.peerid, 0, NULL, 0); break; case IMSG_CTL_NEIGHBOR_UP: @@ -389,14 +389,14 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) case IMSG_CTL_SHOW_INTERFACE: case IMSG_CTL_SHOW_FIB_TABLES: c->ibuf.pid = imsg.hdr.pid; - imsg_compose_parent(imsg.hdr.type, 0, imsg.hdr.pid, + imsg_ctl_parent(imsg.hdr.type, 0, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_SHOW_NEXTHOP: c->ibuf.pid = imsg.hdr.pid; - imsg_compose_parent(imsg.hdr.type, imsg.hdr.peerid, + imsg_ctl_parent(imsg.hdr.type, imsg.hdr.peerid, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; @@ -453,7 +453,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) break; } c->ibuf.pid = imsg.hdr.pid; - imsg_compose_rde(imsg.hdr.type, imsg.hdr.pid, + imsg_ctl_rde(imsg.hdr.type, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); } else log_warnx("got IMSG_CTL_SHOW_RIB with " @@ -463,7 +463,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) case IMSG_CTL_SHOW_RIB_COMMUNITY: case IMSG_CTL_SHOW_NETWORK: c->ibuf.pid = imsg.hdr.pid; - imsg_compose_rde(imsg.hdr.type, imsg.hdr.pid, + imsg_ctl_rde(imsg.hdr.type, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; case IMSG_NETWORK_ADD: @@ -473,7 +473,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) case IMSG_NETWORK_FLUSH: case IMSG_NETWORK_DONE: case IMSG_FILTER_SET: - imsg_compose_rde(imsg.hdr.type, 0, + imsg_ctl_rde(imsg.hdr.type, 0, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; case IMSG_CTL_LOG_VERBOSE: @@ -482,9 +482,9 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) break; /* forward to other processes */ - imsg_compose_parent(imsg.hdr.type, 0, imsg.hdr.pid, + imsg_ctl_parent(imsg.hdr.type, 0, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); - imsg_compose_rde(imsg.hdr.type, 0, + imsg_ctl_rde(imsg.hdr.type, 0, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); memcpy(&verbose, imsg.data, sizeof(verbose)); diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index ff6f4623aae..c5287d65dd0 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.344 2015/10/09 01:37:09 deraadt Exp $ */ +/* $OpenBSD: session.c,v 1.345 2015/10/25 18:49:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -3130,16 +3130,20 @@ session_up(struct peer *p) } int -imsg_compose_parent(int type, u_int32_t peerid, pid_t pid, void *data, +imsg_ctl_parent(int type, u_int32_t peerid, pid_t pid, void *data, u_int16_t datalen) { return (imsg_compose(ibuf_main, type, peerid, pid, -1, data, datalen)); } int -imsg_compose_rde(int type, pid_t pid, void *data, u_int16_t datalen) +imsg_ctl_rde(int type, pid_t pid, void *data, u_int16_t datalen) { - return (imsg_compose(ibuf_rde, type, 0, pid, -1, data, datalen)); + /* + * Use control socket to talk to RDE to bypass the queue of the + * regular imsg socket. + */ + return (imsg_compose(ibuf_rde_ctl, type, 0, pid, -1, data, datalen)); } void diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 430dae0753b..bd11ac4efe4 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.120 2015/10/11 19:25:06 phessler Exp $ */ +/* $OpenBSD: session.h,v 1.121 2015/10/25 18:49:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -291,8 +291,8 @@ void bgp_fsm(struct peer *, enum session_events); int session_neighbor_rrefresh(struct peer *p); struct peer *getpeerbyaddr(struct bgpd_addr *); struct peer *getpeerbydesc(const char *); -int imsg_compose_parent(int, u_int32_t, pid_t, void *, u_int16_t); -int imsg_compose_rde(int, pid_t, void *, u_int16_t); +int imsg_ctl_parent(int, u_int32_t, pid_t, void *, u_int16_t); +int imsg_ctl_rde(int, pid_t, void *, u_int16_t); void session_stop(struct peer *, u_int8_t); /* timer.c */ -- 2.20.1