From 50f25480be6793bde30e6550c6858b4fbdb934a0 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 20 Nov 2019 19:37:46 -0500 Subject: [PATCH] bgpd ultra fast wagyu mode Signed-off-by: Quentin Young --- bgpd/bgp_fsm.c | 4 ++++ bgpd/bgp_main.c | 12 +++++++++--- bgpd/bgp_packet.c | 4 ++++ bgpd/bgpd.c | 12 ++++++++++++ lib/command.c | 4 ++++ lib/zebra.h | 1 + 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 91265ed358..6ccbb1e276 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -18,6 +18,7 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define FUZZING 1 #include @@ -352,6 +353,9 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) structure. */ void bgp_timer_set(struct peer *peer) { +#ifdef FUZZING + return; +#endif switch (peer->status) { case Idle: /* First entry point of peer's finite state machine. In Idle diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 3f4f3231de..c4f5af192e 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -423,7 +423,7 @@ int main(int argc, char **argv) frr_preinit(&bgpd_di, argc, argv); #ifdef FUZZING - bgp_master_init(frr_init(), buffer_size); + bgp_master_init(frr_init_fast(), buffer_size); bm->port = bgp_port; if (bgp_port == 0) bgp_option_set(BGP_OPT_NO_LISTEN); @@ -434,7 +434,7 @@ int main(int argc, char **argv) bgp_option_set(BGP_OPT_NO_ZEBRA); bgp_error_init(); /* Initializations. */ - bgp_vrf_init(); + //bgp_vrf_init(); /* BGP related initialization. */ bgp_init((unsigned short)instance); @@ -445,13 +445,19 @@ int main(int argc, char **argv) union sockunion su; sockunion_init(&su); - inet_pton(AF_INET, "192.168.0.1", &su.sin.sin_addr); + inet_pton(AF_INET, "10.1.1.1", &su.sin.sin_addr); su.sin.sin_family = AF_INET; su.sin.sin_port = 2001; struct peer *p = peer_create(&su, NULL, bgp_get_default(), 65000, 65001, 0, AFI_IP, SAFI_UNICAST, NULL); p->bgp->rpkt_quanta = 1; p->status = Established; + p->as_type = AS_EXTERNAL; + SET_FLAG(p->cap, PEER_CAP_AS4_RCV); + SET_FLAG(p->cap, PEER_CAP_ADDPATH_AF_RX_RCV); + SET_FLAG(p->cap, PEER_CAP_ADDPATH_AF_TX_RCV); + SET_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV); + SET_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV); struct thread t = {}; t.arg = p; diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 852791d3ae..2a864d7595 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1345,12 +1345,14 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) return BGP_Stop; /* Get sockname. */ +#ifndef FUZZING if (bgp_getsockname(peer) < 0) { flog_err_sys(EC_LIB_SOCKET, "%s: bgp_getsockname() failed for peer: %s", __func__, peer->host); return BGP_Stop; } +#endif /* Set remote router-id */ peer->remote_id = remote_id; @@ -1471,7 +1473,9 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) #endif } } +#ifndef FUZZING peer->rtt = sockopt_tcp_rtt(peer->fd); +#endif return Receive_OPEN_message; } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 9316d71baf..df91d50a2c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7793,33 +7793,43 @@ void bgp_init(unsigned short instance) /* allocates some vital data structures used by peer commands in * vty_init */ +#ifndef FUZZING /* pre-init pthreads */ bgp_pthreads_init(); /* Init zebra. */ bgp_zebra_init(bm->master, instance); +#endif #ifdef ENABLE_BGP_VNC vnc_zebra_init(bm->master); #endif /* BGP VTY commands installation. */ +#ifndef FUZZING bgp_vty_init(); +#endif /* BGP inits. */ bgp_attr_init(); +#ifndef FUZZING bgp_debug_init(); bgp_community_alias_init(); bgp_dump_init(); +#endif bgp_route_init(); bgp_route_map_init(); +#ifndef FUZZING bgp_scan_vty_init(); +#endif bgp_mplsvpn_init(); +#ifndef FUZZING #ifdef ENABLE_BGP_VNC rfapi_init(); #endif bgp_ethernetvpn_init(); bgp_flowspec_vty_init(); +#endif /* Access list initialize. */ access_list_init(); @@ -7839,12 +7849,14 @@ void bgp_init(unsigned short instance) /* Community list initialize. */ bgp_clist = community_list_init(); +#ifndef FUZZING /* BFD init */ bgp_bfd_init(bm->master); bgp_lp_vty_init(); cmd_variable_handler_register(bgp_viewvrf_var_handlers); +#endif } void bgp_terminate(void) diff --git a/lib/command.c b/lib/command.c index ea66a17bb0..256e0a7074 100644 --- a/lib/command.c +++ b/lib/command.c @@ -23,6 +23,7 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define FUZZING 1 #include #include @@ -296,6 +297,9 @@ void cmd_defer_tree(bool val) /* Install a command into a node. */ void _install_element(enum node_type ntype, const struct cmd_element *cmd) { +#ifdef FUZZING + return; +#endif struct cmd_node *cnode; /* cmd_init hasn't been called */ diff --git a/lib/zebra.h b/lib/zebra.h index c9794352c7..0a5e652bb1 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define FUZZING 1 #ifndef _ZEBRA_H #define _ZEBRA_H -- 2.39.5