diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bfd.c | 19 | ||||
| -rw-r--r-- | lib/bfd.h | 4 | ||||
| -rw-r--r-- | lib/event.c | 22 | ||||
| -rw-r--r-- | lib/frrevent.h | 8 | ||||
| -rw-r--r-- | lib/privs.c | 9 | 
5 files changed, 42 insertions, 20 deletions
@@ -18,6 +18,7 @@  #include "table.h"  #include "vty.h"  #include "bfd.h" +#include "bfdd/bfd.h"  DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info");  DEFINE_MTYPE_STATIC(LIB, BFD_SOURCE, "BFD source cache"); @@ -140,14 +141,15 @@ static void bfd_source_cache_put(struct bfd_session_params *session);   * bfd_get_peer_info - Extract the Peer information for which the BFD session   *                     went down from the message sent from Zebra to clients.   */ -static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, -					   struct prefix *sp, int *status, -					   int *remote_cbit, vrf_id_t vrf_id) +static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp, struct prefix *sp, +					   int *status, int *remote_cbit, vrf_id_t vrf_id, +					   char *bfd_name)  {  	unsigned int ifindex;  	struct interface *ifp = NULL;  	int plen;  	int local_remote_cbit; +	uint8_t bfd_name_len = 0;  	/*  	 * If the ifindex lookup fails the @@ -194,6 +196,13 @@ static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,  	STREAM_GETC(s, local_remote_cbit);  	if (remote_cbit)  		*remote_cbit = local_remote_cbit; + +	STREAM_GETC(s, bfd_name_len); +	if (bfd_name_len) { +		STREAM_GET(bfd_name, s, bfd_name_len); +		*(bfd_name + bfd_name_len) = 0; +	} +  	return ifp;  stream_failure: @@ -918,6 +927,7 @@ int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)  	struct prefix dp;  	struct prefix sp;  	char ifstr[128], cbitstr[32]; +	char bfd_name[BFD_NAME_SIZE + 1] = { 0 };  	if (!zclient->bfd_integration)  		return 0; @@ -926,8 +936,7 @@ int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)  	if (bsglobal.shutting_down)  		return 0; -	ifp = bfd_get_peer_info(zclient->ibuf, &dp, &sp, &state, &remote_cbit, -				vrf_id); +	ifp = bfd_get_peer_info(zclient->ibuf, &dp, &sp, &state, &remote_cbit, vrf_id, bfd_name);  	/*  	 * When interface lookup fails or an invalid stream is read, we must  	 * not proceed otherwise it will trigger an assertion while checking @@ -26,6 +26,8 @@ extern "C" {  #define BFD_PROFILE_NAME_LEN 64 +#define BFD_NAME_SIZE 255 +  const char *bfd_get_status_str(int status);  extern void bfd_client_sendmsg(struct zclient *zclient, int command, @@ -409,6 +411,8 @@ struct bfd_session_arg {  	uint32_t min_tx;  	/** Detection multiplier. */  	uint32_t detection_multiplier; +	/* bfd session name*/ +	char bfd_name[BFD_NAME_SIZE + 1];  };  /** diff --git a/lib/event.c b/lib/event.c index d95b3021a7..6081ba4727 100644 --- a/lib/event.c +++ b/lib/event.c @@ -111,6 +111,11 @@ static struct cpu_event_history *cpu_records_get(struct event_loop *loop,  	return res;  } +static void cpu_records_clear(struct cpu_event_history *p) +{ +	memset(p->_clear_begin, 0, p->_clear_end - p->_clear_begin); +} +  static void cpu_records_free(struct cpu_event_history **p)  {  	XFREE(MTYPE_EVENT_STATS, *p); @@ -250,20 +255,15 @@ static void cpu_record_clear(uint8_t filter)  		for (ALL_LIST_ELEMENTS_RO(masters, ln, m)) {  			frr_with_mutex (&m->mtx) {  				struct cpu_event_history *item; -				struct cpu_records_head old[1]; -				cpu_records_init(old); -				cpu_records_swap_all(old, m->cpu_records); - -				while ((item = cpu_records_pop(old))) { +				/* it isn't possible to free the memory here +				 * because some of these will be in use (e.g. +				 * the one we're currently running in!) +				 */ +				frr_each (cpu_records, m->cpu_records, item) {  					if (item->types & filter) -						cpu_records_free(&item); -					else -						cpu_records_add(m->cpu_records, -								item); +						cpu_records_clear(item);  				} - -				cpu_records_fini(old);  			}  		}  	} diff --git a/lib/frrevent.h b/lib/frrevent.h index 44776b29a7..c35b39a147 100644 --- a/lib/frrevent.h +++ b/lib/frrevent.h @@ -139,6 +139,10 @@ struct cpu_event_history {  	struct cpu_records_item item;  	void (*func)(struct event *e); + +	/* fields between the pair of these two are nulled on "clear event cpu" */ +	char _clear_begin[0]; +  	atomic_size_t total_cpu_warn;  	atomic_size_t total_wall_warn;  	atomic_size_t total_starv_warn; @@ -149,6 +153,10 @@ struct cpu_event_history {  	} real;  	struct time_stats cpu;  	atomic_uint_fast32_t types; + +	/* end of cleared region */ +	char _clear_end[0]; +  	const char *funcname;  }; diff --git a/lib/privs.c b/lib/privs.c index b0809bf690..e7df383e5d 100644 --- a/lib/privs.c +++ b/lib/privs.c @@ -210,10 +210,11 @@ int zprivs_change_caps(zebra_privs_ops_t op)  {  	cap_flag_value_t cflag; -	/* should be no possibility of being called without valid caps */ -	assert(zprivs_state.syscaps_p && zprivs_state.caps); -	if (!(zprivs_state.syscaps_p && zprivs_state.caps)) -		exit(1); +	/* Called without valid caps - just return. Not every daemon needs +	 * privs. +	 */ +	if (zprivs_state.syscaps_p == NULL || zprivs_state.caps == NULL) +		return 0;  	if (op == ZPRIVS_RAISE)  		cflag = CAP_SET;  | 
