diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/agg_table.h | 6 | ||||
| -rw-r--r-- | lib/lib_vty.c | 2 | ||||
| -rw-r--r-- | lib/libfrr.h | 3 | ||||
| -rw-r--r-- | lib/memory.h | 3 | ||||
| -rw-r--r-- | lib/mlag.c | 5 | ||||
| -rw-r--r-- | lib/monotime.h | 20 | ||||
| -rw-r--r-- | lib/ntop.c | 2 | ||||
| -rw-r--r-- | lib/prefix.h | 2 | ||||
| -rw-r--r-- | lib/stream.h | 3 | ||||
| -rw-r--r-- | lib/zclient.c | 5 | ||||
| -rw-r--r-- | lib/zclient.h | 2 |
11 files changed, 40 insertions, 13 deletions
diff --git a/lib/agg_table.h b/lib/agg_table.h index 40ffe8c755..f95fed6758 100644 --- a/lib/agg_table.h +++ b/lib/agg_table.h @@ -86,13 +86,13 @@ static inline struct agg_node *agg_route_next(struct agg_node *node) } static inline struct agg_node *agg_node_get(struct agg_table *table, - struct prefix *p) + const struct prefix *p) { return agg_node_from_rnode(route_node_get(table->route_table, p)); } static inline struct agg_node * -agg_node_lookup(const struct agg_table *const table, struct prefix *p) +agg_node_lookup(const struct agg_table *const table, const struct prefix *p) { return agg_node_from_rnode(route_node_lookup(table->route_table, p)); } @@ -109,7 +109,7 @@ static inline struct agg_node *agg_route_next_until(struct agg_node *node, } static inline struct agg_node *agg_node_match(struct agg_table *table, - struct prefix *p) + const struct prefix *p) { return agg_node_from_rnode(route_node_match(table->route_table, p)); } diff --git a/lib/lib_vty.c b/lib/lib_vty.c index 787da08e28..9c927ca4af 100644 --- a/lib/lib_vty.c +++ b/lib/lib_vty.c @@ -93,7 +93,7 @@ static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt) #endif ); } else { - if (mt->n_alloc != 0) { + if (mt->n_max != 0) { char size[32]; snprintf(size, sizeof(size), "%6zu", mt->size); #ifdef HAVE_MALLOC_USABLE_SIZE diff --git a/lib/libfrr.h b/lib/libfrr.h index f964c9e2a1..9d91ea9154 100644 --- a/lib/libfrr.h +++ b/lib/libfrr.h @@ -128,7 +128,8 @@ extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv); extern void frr_opt_add(const char *optstr, const struct option *longopts, const char *helpstr); extern int frr_getopt(int argc, char *const argv[], int *longindex); -extern void frr_help_exit(int status); + +extern __attribute__((__noreturn__)) void frr_help_exit(int status); extern struct thread_master *frr_init(void); extern const char *frr_get_progname(void); diff --git a/lib/memory.h b/lib/memory.h index 44ea19b557..e4e05faa4f 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -179,7 +179,8 @@ extern int qmem_walk(qmem_walk_fn *func, void *arg); extern int log_memstats(FILE *fp, const char *); #define log_memstats_stderr(prefix) log_memstats(stderr, prefix) -extern void memory_oom(size_t size, const char *name); +extern __attribute__((__noreturn__)) void memory_oom(size_t size, + const char *name); #ifdef __cplusplus } diff --git a/lib/mlag.c b/lib/mlag.c index 733dd41ea8..653fbe8fe9 100644 --- a/lib/mlag.c +++ b/lib/mlag.c @@ -85,9 +85,12 @@ int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg, size_t *length) { #define LIB_MLAG_HDR_LENGTH 8 + if (s == NULL || msg == NULL) + return -1; + *length = stream_get_endp(s); - if (s == NULL || msg == NULL || *length < LIB_MLAG_HDR_LENGTH) + if (*length < LIB_MLAG_HDR_LENGTH) return -1; *length -= LIB_MLAG_HDR_LENGTH; diff --git a/lib/monotime.h b/lib/monotime.h index e246f177de..dda763784f 100644 --- a/lib/monotime.h +++ b/lib/monotime.h @@ -112,6 +112,26 @@ static inline char *time_to_string(time_t ts, char *buf) return ctime_r(&tbuf, buf); } +/* Convert interval to human-friendly string, used in cli output e.g. */ +static inline const char *frrtime_to_interval(time_t t, char *buf, + size_t buflen) +{ + struct tm tm; + + gmtime_r(&t, &tm); + + if (t < ONE_DAY_SECOND) + snprintf(buf, buflen, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, + tm.tm_sec); + else if (t < ONE_WEEK_SECOND) + snprintf(buf, buflen, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, + tm.tm_min); + else + snprintf(buf, buflen, "%02dw%dd%02dh", tm.tm_yday / 7, + tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour); + return buf; +} + #ifdef __cplusplus } #endif diff --git a/lib/ntop.c b/lib/ntop.c index 066e10e3e4..ccbf8793d3 100644 --- a/lib/ntop.c +++ b/lib/ntop.c @@ -165,7 +165,7 @@ inet4: return dst; } -#ifndef INET_NTOP_NO_OVERRIDE +#if !defined(INET_NTOP_NO_OVERRIDE) && !defined(__APPLE__) /* we want to override libc inet_ntop, but make sure it shows up in backtraces * as frr_inet_ntop (to avoid confusion while debugging) */ diff --git a/lib/prefix.h b/lib/prefix.h index b01f7d1fdc..51b3dacb8d 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -531,7 +531,7 @@ static inline int is_host_route(struct prefix *p) return 0; } -static inline int is_default_host_route(struct prefix *p) +static inline int is_default_host_route(const struct prefix *p) { if (p->family == AF_INET) { return (p->u.prefix4.s_addr == INADDR_ANY && diff --git a/lib/stream.h b/lib/stream.h index 36c65afa3c..425f0c5edd 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -354,9 +354,10 @@ extern void stream_fifo_free(struct stream_fifo *fifo); * bit), for 64-bit values (you need to cast them anyway), and neither for * encoding (because it's downcasted.) */ -static inline uint8_t *ptr_get_be32(uint8_t *ptr, uint32_t *out) +static inline const uint8_t *ptr_get_be32(const uint8_t *ptr, uint32_t *out) { uint32_t tmp; + memcpy(&tmp, ptr, sizeof(tmp)); *out = ntohl(tmp); return ptr + 4; diff --git a/lib/zclient.c b/lib/zclient.c index eac6c7081d..93c5fe39af 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -690,8 +690,9 @@ static int zclient_connect(struct thread *t) return zclient_start(zclient); } -int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p, - bool exact_match, vrf_id_t vrf_id) +int zclient_send_rnh(struct zclient *zclient, int command, + const struct prefix *p, bool exact_match, + vrf_id_t vrf_id) { struct stream *s; diff --git a/lib/zclient.h b/lib/zclient.h index e6f4c747e3..f18511dc81 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -738,7 +738,7 @@ extern void zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, struct zapi_pw_statu extern int zclient_route_send(uint8_t, struct zclient *, struct zapi_route *); extern int zclient_send_rnh(struct zclient *zclient, int command, - struct prefix *p, bool exact_match, + const struct prefix *p, bool exact_match, vrf_id_t vrf_id); int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh, uint32_t api_flags); |
