From 7936827a85fca997e2b68091c183b1565a27c883 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 10:14:26 -0500 Subject: [PATCH 1/7] cumulus: Fixup function only needed for linux Signed-off-by: Donald Sharp --- cumulus/start-stop-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/start-stop-daemon.c b/cumulus/start-stop-daemon.c index 4d447d9051..a195e9e2fc 100644 --- a/cumulus/start-stop-daemon.c +++ b/cumulus/start-stop-daemon.c @@ -223,6 +223,7 @@ clear(struct pid_list **list) *list = NULL; } +#ifdef linux static const char * next_dirname(const char *s) { @@ -242,7 +243,6 @@ next_dirname(const char *s) return cur; } -#ifdef linux static void add_namespace(const char *path) { From 9bf7536273d673b8f37ffb9f6297465e245547e6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 10:17:20 -0500 Subject: [PATCH 2/7] zebra: Fix compile warnings under freebsd Compiling under clang we see compiler warnings Fix them. Signed-off-by: Donald Sharp --- zebra/kernel_socket.c | 10 +++++----- zebra/zebra_fpm.c | 2 ++ zebra/zserv.c | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 6d81c9d052..fd059dfee7 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -927,7 +927,7 @@ rtm_read (struct rt_msghdr *rtm) int ret; if (! IS_ZEBRA_DEBUG_RIB) return; - ret = rib_lookup_ipv4_route (&p, &gate, VRF_DEFAULT); + ret = rib_lookup_ipv4_route ((struct prefix_ipv4 *)&p, &gate, VRF_DEFAULT); prefix2str (&p, buf, sizeof(buf)); switch (rtm->rtm_type) { @@ -951,7 +951,7 @@ rtm_read (struct rt_msghdr *rtm) case ZEBRA_RIB_FOUND_EXACT: /* RIB RR == FIB RR */ zlog_debug ("%s: %s %s: done Ok", __func__, lookup (rtm_type_str, rtm->rtm_type), buf); - rib_lookup_and_dump (&p, VRF_DEFAULT); + rib_lookup_and_dump ((struct prefix_ipv4 *)&p, VRF_DEFAULT); return; break; } @@ -964,18 +964,18 @@ rtm_read (struct rt_msghdr *rtm) case ZEBRA_RIB_FOUND_EXACT: zlog_debug ("%s: %s %s: desync: RR is still in RIB, while already not in FIB", __func__, lookup (rtm_type_str, rtm->rtm_type), buf); - rib_lookup_and_dump (&p, VRF_DEFAULT); + rib_lookup_and_dump ((struct prefix_ipv4 *)&p, VRF_DEFAULT); break; case ZEBRA_RIB_FOUND_CONNECTED: case ZEBRA_RIB_FOUND_NOGATE: zlog_debug ("%s: %s %s: desync: RR is still in RIB, plus gate differs", __func__, lookup (rtm_type_str, rtm->rtm_type), buf); - rib_lookup_and_dump (&p, VRF_DEFAULT); + rib_lookup_and_dump ((struct prefix_ipv4 *)&p, VRF_DEFAULT); break; case ZEBRA_RIB_NOTFOUND: /* RIB RR == FIB RR */ zlog_debug ("%s: %s %s: done Ok", __func__, lookup (rtm_type_str, rtm->rtm_type), buf); - rib_lookup_and_dump (&p, VRF_DEFAULT); + rib_lookup_and_dump ((struct prefix_ipv4 *)&p, VRF_DEFAULT); return; break; } diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 8b337152b4..d91cda9fb0 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -883,7 +883,9 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf, size_t in_buf_len, fpm_msg_type_e *msg_type) { size_t len; +#ifdef HAVE_NETLINK int cmd; +#endif len = 0; *msg_type = FPM_MSG_TYPE_NONE; diff --git a/zebra/zserv.c b/zebra/zserv.c index 6a15b9a251..f53b2270f1 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2386,7 +2386,7 @@ zebra_find_client (u_char proto) return NULL; } - +#ifdef HAVE_NETLINK /* Display default rtm_table for all clients. */ DEFUN (show_table, show_table_cmd, @@ -2419,6 +2419,7 @@ DEFUN (no_config_table, zebrad.rtm_table_default = 0; return CMD_SUCCESS; } +#endif DEFUN (ip_forwarding, ip_forwarding_cmd, From e2064401d33c24e6a2fa07f6d1c52b76ca34bff3 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 19:04:40 -0500 Subject: [PATCH 3/7] lib: Add some documentation to wheel.h Add some hopefully useful documentation to the timer wheel.h code. Signed-off-by: Donald Sharp --- lib/wheel.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/wheel.h b/lib/wheel.h index ddb79988b4..79d21e124b 100644 --- a/lib/wheel.h +++ b/lib/wheel.h @@ -40,9 +40,49 @@ struct timer_wheel void (*slot_run) (void *); }; +/* + * Creates a timer wheel + * + * master - Thread master structure for the process + * period - The Time in seconds that the timer wheel will + * take before it starts issuing commands again + * for items in each slot + * slots - The number of slots to have in this particular + * timer wheel + * slot_key - A hashing function of some sort that will allow + * the timer wheel to put items into individual slots + * slot_run - The function to run over each item in a particular slot + * + * Creates a timer wheel that will wake up 'slots' times over the entire + * wheel. Each time the timer wheel wakes up it will iterate through + * and run the slot_run function for each item stored in that particular + * slot. + * + * The timer code is 'intelligent' in that it notices if anything is + * in a particular slot and can schedule the next timer to skip + * the empty slot. + * + * The general purpose of a timer wheel is to reduce events in a system. + * A perfect example of usage for this is say hello packets that need + * to be sent out to all your neighbors. Suppose a large routing protocol + * has to send keepalive packets every Y seconds to each of it's peers. + * At scale we can have a very large number of peers, X. + * This means that we will have X timing events every Y seconds. + * If you replace these events with a timer wheel that has Z slots + * you will have at most Y/Z timer events if each slot has a work item + * in it. + * + * When X is large the number of events in a system can quickly escalate + * and cause significant amount of time handling thread events instead + * of running your code. + */ struct timer_wheel *wheel_init (struct thread_master *master, int period, size_t slots, unsigned int (*slot_key) (void *), void (*slot_run) (void *)); + +/* + * Delete the specified timer wheel created + */ void wheel_delete (struct timer_wheel *); /* @@ -51,17 +91,25 @@ void wheel_delete (struct timer_wheel *); int wheel_stop (struct timer_wheel *wheel); /* - * Start the wheel from running again + * Start the wheel running again */ int wheel_start (struct timer_wheel *wheel); /* + * wheel - The Timer wheel being modified + * item - The generic data structure that will be handed + * to the slot_run function. + * * Add item to a slot setup by the slot_key, * possibly change next time pop. */ int wheel_add_item (struct timer_wheel *wheel, void *item); /* + * wheel - The Timer wheel being modified. + * item - The item to remove from one of the slots in + * the timer wheel. + * * Remove a item to a slot setup by the slot_key, * possibly change next time pop. */ From 389e3fe0dabed6fe7f2fe52e135df61f23d8bf85 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 19:30:47 -0500 Subject: [PATCH 4/7] bgpd: Cleanup some compiler warnings Cleanup some compiler warnings discovered by omnios. Signed-off-by: Donald Sharp --- bgpd/bgp_damp.c | 14 +++++++------- bgpd/bgp_vty.c | 21 +++++++++++++-------- bgpd/rfapi/rfapi_import.c | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index f4a83d720b..b0bdb247d5 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -700,16 +700,16 @@ bgp_show_dampening_parameters (struct vty *vty, afi_t afi, safi_t safi) if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) { - vty_out (vty, "Half-life time: %ld min%s", - damp->half_life / 60, VTY_NEWLINE); + vty_out (vty, "Half-life time: %lld min%s", + (long long )damp->half_life / 60, VTY_NEWLINE); vty_out (vty, "Reuse penalty: %d%s", - damp->reuse_limit, VTY_NEWLINE); + damp->reuse_limit, VTY_NEWLINE); vty_out (vty, "Suppress penalty: %d%s", - damp->suppress_value, VTY_NEWLINE); - vty_out (vty, "Max suppress time: %ld min%s", - damp->max_suppress_time / 60, VTY_NEWLINE); + damp->suppress_value, VTY_NEWLINE); + vty_out (vty, "Max suppress time: %lld min%s", + (long long)damp->max_suppress_time / 60, VTY_NEWLINE); vty_out (vty, "Max supress penalty: %u%s", - damp->ceiling, VTY_NEWLINE); + damp->ceiling, VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE); } else diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 6d23af03e4..20e4dd831d 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7407,7 +7407,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js /* BGP Version. */ json_object_int_add(json_neigh, "bgpVersion", 4); - json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ)); + json_object_string_add(json_neigh, "remoteRouterId", + inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); /* Confederation */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) @@ -7474,7 +7475,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js /* BGP Version. */ vty_out (vty, " BGP version 4"); - vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ), + vty_out (vty, ", remote router ID %s%s", + inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), VTY_NEWLINE); /* Confederation */ @@ -8276,9 +8278,12 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js { if (use_json) { - json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); - json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); - json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); + json_object_string_add(json_neigh, "nexthop", + inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); + json_object_string_add(json_neigh, "nexthopGlobal", + inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); + json_object_string_add(json_neigh, "nexthopLocal", + inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); if (p->shared_network) json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); else @@ -8287,13 +8292,13 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { vty_out (vty, "Nexthop: %s%s", - inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), + inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), VTY_NEWLINE); vty_out (vty, "Nexthop global: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), + inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), VTY_NEWLINE); vty_out (vty, "Nexthop local: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ), + inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), VTY_NEWLINE); vty_out (vty, "BGP connection: %s%s", p->shared_network ? "shared network" : "non shared network", diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 716a1fb537..f7873ce2ba 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -113,7 +113,7 @@ rfapiDebugBacktrace (void) for (i = 0; i < size && i < RFAPI_DEBUG_BACKTRACE_NENTRIES; ++i) { - vnc_zlog_debug_verbose ("backtrace[%2lu]: %s", i, syms[i]); + vnc_zlog_debug_verbose ("backtrace[%2zu]: %s", i, syms[i]); } free (syms); From bc3d64008824a0dd7c5410b3aa95f4e9f2fa073f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 19:31:52 -0500 Subject: [PATCH 5/7] zebra: Fix signed/unsigned comparison Fix a signed/unsigned comparison. Signed-off-by: Donald Sharp --- zebra/if_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 36b0a6c795..a4498a84f6 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -105,7 +105,7 @@ interface_list_ioctl (void) #ifdef OPEN_BSD for (n = 0; n < ifconf.ifc_len; ) { - int size; + unsigned int size; ifreq = (struct ifreq *)((caddr_t) ifconf.ifc_req + n); ifp = if_get_by_name_len(ifreq->ifr_name, From f94d4e70f63d86bcd22b42f5522ee95a2455ad1c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 18 Jan 2017 19:32:25 -0500 Subject: [PATCH 6/7] isisd: Fix unused variable in some situations. Fix an unused variable for certain compile options. Signed-off-by: Donald Sharp --- isisd/isis_bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index 8775e12a24..3a5eaf5585 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -78,7 +78,10 @@ open_bpf_dev (struct isis_circuit *circuit) int i = 0, fd; char bpfdev[128]; struct ifreq ifr; - u_int blen, immediate, seesent; + u_int blen, immediate; +#ifdef BIOCSSEESENT + u_int seesent; +#endif struct timeval timeout; struct bpf_program bpf_prog; From 44b8cd53c57c3a5b62e9517c0aca6b3db5b6ee0f Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 24 Jan 2017 03:15:26 +0100 Subject: [PATCH 7/7] bgpd: fix whitespace Signed-off-by: David Lamparter --- bgpd/bgp_damp.c | 10 +++++----- bgpd/bgp_vty.c | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index b0bdb247d5..168dbd0122 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -701,15 +701,15 @@ bgp_show_dampening_parameters (struct vty *vty, afi_t afi, safi_t safi) if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) { vty_out (vty, "Half-life time: %lld min%s", - (long long )damp->half_life / 60, VTY_NEWLINE); + (long long)damp->half_life / 60, VTY_NEWLINE); vty_out (vty, "Reuse penalty: %d%s", - damp->reuse_limit, VTY_NEWLINE); + damp->reuse_limit, VTY_NEWLINE); vty_out (vty, "Suppress penalty: %d%s", - damp->suppress_value, VTY_NEWLINE); + damp->suppress_value, VTY_NEWLINE); vty_out (vty, "Max suppress time: %lld min%s", - (long long)damp->max_suppress_time / 60, VTY_NEWLINE); + (long long)damp->max_suppress_time / 60, VTY_NEWLINE); vty_out (vty, "Max supress penalty: %u%s", - damp->ceiling, VTY_NEWLINE); + damp->ceiling, VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE); } else diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 20e4dd831d..d0d917875a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7408,7 +7408,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js /* BGP Version. */ json_object_int_add(json_neigh, "bgpVersion", 4); json_object_string_add(json_neigh, "remoteRouterId", - inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); + inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); /* Confederation */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) @@ -7476,7 +7476,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js /* BGP Version. */ vty_out (vty, " BGP version 4"); vty_out (vty, ", remote router ID %s%s", - inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), + inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), VTY_NEWLINE); /* Confederation */ @@ -8279,11 +8279,11 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) { json_object_string_add(json_neigh, "nexthop", - inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); + inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); json_object_string_add(json_neigh, "nexthopGlobal", - inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); + inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); json_object_string_add(json_neigh, "nexthopLocal", - inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); + inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); if (p->shared_network) json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); else @@ -8292,17 +8292,17 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { vty_out (vty, "Nexthop: %s%s", - inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), - VTY_NEWLINE); + inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), + VTY_NEWLINE); vty_out (vty, "Nexthop global: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), - VTY_NEWLINE); + inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), + VTY_NEWLINE); vty_out (vty, "Nexthop local: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), - VTY_NEWLINE); + inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), + VTY_NEWLINE); vty_out (vty, "BGP connection: %s%s", - p->shared_network ? "shared network" : "non shared network", - VTY_NEWLINE); + p->shared_network ? "shared network" : "non shared network", + VTY_NEWLINE); } }