summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/agentx.c4
-rw-r--r--lib/atomlist.h22
-rw-r--r--lib/bfd.c640
-rw-r--r--lib/bfd.h327
-rw-r--r--lib/buffer.c4
-rw-r--r--lib/command.c4
-rw-r--r--lib/command.h2
-rw-r--r--lib/command_graph.c10
-rw-r--r--lib/command_graph.h2
-rw-r--r--lib/command_match.c2
-rw-r--r--lib/command_parse.y4
-rw-r--r--lib/compiler.h35
-rw-r--r--lib/debug.c2
-rw-r--r--lib/debug.h2
-rw-r--r--lib/defaults.h3
-rw-r--r--lib/distribute.c8
-rw-r--r--lib/elf_py.c4
-rw-r--r--lib/ferr.c2
-rw-r--r--lib/filter.c6
-rw-r--r--lib/frr_pthread.c4
-rw-r--r--lib/frr_zmq.c2
-rw-r--r--lib/frrcu.c10
-rw-r--r--lib/frrcu.h2
-rw-r--r--lib/grammar_sandbox.c2
-rw-r--r--lib/graph.c4
-rw-r--r--lib/hash.c6
-rw-r--r--lib/hook.c2
-rw-r--r--lib/hook.h13
-rw-r--r--lib/id_alloc.c13
-rw-r--r--lib/if.c16
-rw-r--r--lib/if.h10
-rw-r--r--lib/if_rmap.c9
-rw-r--r--lib/keychain.c8
-rw-r--r--lib/keychain.h8
-rw-r--r--lib/ldp_sync.c2
-rw-r--r--lib/libfrr.c8
-rw-r--r--lib/libfrr.h12
-rw-r--r--lib/link_state.c2
-rw-r--r--lib/link_state.h12
-rw-r--r--lib/linklist.c4
-rw-r--r--lib/log_vty.c34
-rw-r--r--lib/log_vty.h2
-rw-r--r--lib/memory.c4
-rw-r--r--lib/memory.h22
-rw-r--r--lib/module.c6
-rw-r--r--lib/module.h9
-rw-r--r--lib/netns_linux.c4
-rw-r--r--lib/netns_other.c4
-rw-r--r--lib/nexthop.c4
-rw-r--r--lib/nexthop_group.c4
-rw-r--r--lib/nexthop_group.h4
-rw-r--r--lib/northbound.c46
-rw-r--r--lib/northbound.h6
-rw-r--r--lib/northbound_confd.c5
-rw-r--r--lib/northbound_grpc.cpp3
-rw-r--r--lib/northbound_sysrepo.c5
-rw-r--r--lib/plist.c8
-rw-r--r--lib/prefix.c4
-rw-r--r--lib/printfrr.h24
-rw-r--r--lib/privs.c2
-rw-r--r--lib/pullwr.c4
-rw-r--r--lib/qobj.c2
-rw-r--r--lib/qobj.h13
-rw-r--r--lib/resolver.c2
-rw-r--r--lib/ringbuf.c2
-rw-r--r--lib/routemap.c22
-rw-r--r--lib/routemap.h14
-rw-r--r--lib/routing_nb.h2
-rw-r--r--lib/routing_nb_config.c2
-rw-r--r--lib/skiplist.c4
-rw-r--r--lib/smux.h2
-rw-r--r--lib/sockunion.c2
-rw-r--r--lib/spf_backoff.c4
-rw-r--r--lib/srcdest_table.c2
-rw-r--r--lib/stream.c4
-rw-r--r--lib/strlcat.c2
-rw-r--r--lib/subdir.am2
-rw-r--r--lib/table.c6
-rw-r--r--lib/table.h4
-rw-r--r--lib/termtable.c2
-rw-r--r--lib/thread.c12
-rw-r--r--lib/thread.h4
-rw-r--r--lib/typerb.h13
-rw-r--r--lib/typesafe.c6
-rw-r--r--lib/typesafe.h50
-rw-r--r--lib/vector.c4
-rw-r--r--lib/vrf.c6
-rw-r--r--lib/vrf.h4
-rw-r--r--lib/vty.c6
-rw-r--r--lib/wheel.c4
-rw-r--r--lib/workqueue.c6
-rw-r--r--lib/workqueue.h2
-rw-r--r--lib/xref.c2
-rw-r--r--lib/xref.h2
-rw-r--r--lib/yang.c4
-rw-r--r--lib/yang_translator.c6
-rw-r--r--lib/zassert.h7
-rw-r--r--lib/zclient.c4
-rw-r--r--lib/zebra.h15
-rw-r--r--lib/zlog.c80
-rw-r--r--lib/zlog.h50
-rw-r--r--lib/zlog_targets.c12
102 files changed, 1462 insertions, 366 deletions
diff --git a/lib/agentx.c b/lib/agentx.c
index c1ff7a61b1..b5a035ee2b 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -34,9 +34,9 @@
#include "lib_errors.h"
#include "xref.h"
-XREF_SETUP()
+XREF_SETUP();
-DEFINE_HOOK(agentx_enabled, (), ())
+DEFINE_HOOK(agentx_enabled, (), ());
static int agentx_enabled = 0;
diff --git a/lib/atomlist.h b/lib/atomlist.h
index 5ca19cbcd4..c795128a34 100644
--- a/lib/atomlist.h
+++ b/lib/atomlist.h
@@ -123,15 +123,16 @@ struct atomlist_head {
/* use as:
*
- * PREDECL_ATOMLIST(namelist)
+ * PREDECL_ATOMLIST(namelist);
* struct name {
* struct namelist_item nlitem;
* }
- * DECLARE_ATOMLIST(namelist, struct name, nlitem)
+ * DECLARE_ATOMLIST(namelist, struct name, nlitem);
*/
#define PREDECL_ATOMLIST(prefix) \
struct prefix ## _head { struct atomlist_head ah; }; \
-struct prefix ## _item { struct atomlist_item ai; };
+struct prefix ## _item { struct atomlist_item ai; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_ATOMLIST(var) { }
@@ -171,7 +172,7 @@ macro_inline void prefix ## _fini(struct prefix##_head *h) \
assert(prefix ## _count(h) == 0); \
memset(h, 0, sizeof(*h)); \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
/* add_head:
* - contention on ->first pointer
@@ -221,7 +222,8 @@ struct atomsort_head {
#define _PREDECL_ATOMSORT(prefix) \
struct prefix ## _head { struct atomsort_head ah; }; \
-struct prefix ## _item { struct atomsort_item ai; };
+struct prefix ## _item { struct atomsort_item ai; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_ATOMSORT_UNIQ(var) { }
#define INIT_ATOMSORT_NONUNIQ(var) { }
@@ -298,7 +300,7 @@ macro_inline type *prefix ## _pop(struct prefix##_head *h) \
struct atomsort_item *p = atomsort_pop(&h->ah); \
return p ? container_of(p, type, field.ai) : NULL; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_ATOMSORT_UNIQ(prefix) \
_PREDECL_ATOMSORT(prefix)
@@ -312,7 +314,7 @@ macro_inline int prefix ## __cmp(const struct atomsort_item *a, \
} \
\
_DECLARE_ATOMSORT(prefix, type, field, \
- prefix ## __cmp, prefix ## __cmp) \
+ prefix ## __cmp, prefix ## __cmp); \
\
atomic_find_warn \
macro_inline type *prefix ## _find(struct prefix##_head *h, const type *item) \
@@ -325,7 +327,7 @@ macro_inline type *prefix ## _find(struct prefix##_head *h, const type *item) \
return NULL; \
return p; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_ATOMSORT_NONUNIQ(prefix) \
_PREDECL_ATOMSORT(prefix)
@@ -352,8 +354,8 @@ macro_inline int prefix ## __cmp_uq(const struct atomsort_item *a, \
} \
\
_DECLARE_ATOMSORT(prefix, type, field, \
- prefix ## __cmp, prefix ## __cmp_uq) \
-/* ... */
+ prefix ## __cmp, prefix ## __cmp_uq); \
+MACRO_REQUIRE_SEMICOLON() /* end */
struct atomsort_item *atomsort_add(struct atomsort_head *h,
struct atomsort_item *item, int (*cmpfn)(
diff --git a/lib/bfd.c b/lib/bfd.c
index 3ab0e21af5..176269cc5b 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -27,12 +27,13 @@
#include "prefix.h"
#include "thread.h"
#include "stream.h"
+#include "vrf.h"
#include "zclient.h"
#include "table.h"
#include "vty.h"
#include "bfd.h"
-DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info")
+DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info");
static int bfd_debug = 0;
static struct bfd_gbl bfd_gbl;
@@ -568,3 +569,640 @@ int zclient_bfd_command(struct zclient *zc, struct bfd_session_arg *args)
return 0;
}
+
+/**
+ * BFD protocol integration configuration.
+ */
+
+/** Events definitions. */
+enum bfd_session_event {
+ /** Remove the BFD session configuration. */
+ BSE_UNINSTALL,
+ /** Install the BFD session configuration. */
+ BSE_INSTALL,
+};
+
+/**
+ * Data structure to do the necessary tricks to hide the BFD protocol
+ * integration internals.
+ */
+struct bfd_session_params {
+ /** Contains the session parameters and more. */
+ struct bfd_session_arg args;
+ /** Contains the session state. */
+ struct bfd_session_status bss;
+ /** Protocol implementation status update callback. */
+ bsp_status_update updatecb;
+ /** Protocol implementation custom data pointer. */
+ void *arg;
+
+ /**
+ * Next event.
+ *
+ * This variable controls what action to execute when the command batch
+ * finishes. Normally we'd use `thread_add_event` value, however since
+ * that function is going to be called multiple times and the value
+ * might be different we'll use this variable to keep track of it.
+ */
+ enum bfd_session_event lastev;
+ /**
+ * BFD session configuration event.
+ *
+ * Multiple actions might be asked during a command batch (either via
+ * configuration load or northbound batch), so we'll use this to
+ * install/uninstall the BFD session parameters only once.
+ */
+ struct thread *installev;
+
+ /** BFD session installation state. */
+ bool installed;
+ /** BFD session enabled. */
+ bool enabled;
+
+ /** Global BFD paramaters list. */
+ TAILQ_ENTRY(bfd_session_params) entry;
+};
+
+struct bfd_sessions_global {
+ /**
+ * Global BFD session parameters list for (re)installation and update
+ * without code duplication among daemons.
+ */
+ TAILQ_HEAD(bsplist, bfd_session_params) bsplist;
+
+ /** Pointer to FRR's event manager. */
+ struct thread_master *tm;
+ /** Pointer to zebra client data structure. */
+ struct zclient *zc;
+
+ /** Debugging state. */
+ bool debugging;
+ /** Is shutting down? */
+ bool shutting_down;
+};
+
+/** Global configuration variable. */
+static struct bfd_sessions_global bsglobal;
+
+/** Global empty address for IPv4/IPv6. */
+static const struct in6_addr i6a_zero;
+
+struct bfd_session_params *bfd_sess_new(bsp_status_update updatecb, void *arg)
+{
+ struct bfd_session_params *bsp;
+
+ bsp = XCALLOC(MTYPE_BFD_INFO, sizeof(*bsp));
+
+ /* Save application data. */
+ bsp->updatecb = updatecb;
+ bsp->arg = arg;
+
+ /* Set defaults. */
+ bsp->args.detection_multiplier = BFD_DEF_DETECT_MULT;
+ bsp->args.ttl = BFD_SINGLE_HOP_TTL;
+ bsp->args.min_rx = BFD_DEF_MIN_RX;
+ bsp->args.min_tx = BFD_DEF_MIN_TX;
+ bsp->args.vrf_id = VRF_DEFAULT;
+
+ /* Register in global list. */
+ TAILQ_INSERT_TAIL(&bsglobal.bsplist, bsp, entry);
+
+ return bsp;
+}
+
+static bool _bfd_sess_valid(const struct bfd_session_params *bsp)
+{
+ /* Peer/local address not configured. */
+ if (bsp->args.family == 0)
+ return false;
+
+ /* Address configured but invalid. */
+ if (bsp->args.family != AF_INET && bsp->args.family != AF_INET6) {
+ if (bsglobal.debugging)
+ zlog_debug("%s: invalid session family: %d", __func__,
+ bsp->args.family);
+ return false;
+ }
+
+ /* Invalid address. */
+ if (memcmp(&bsp->args.dst, &i6a_zero, sizeof(i6a_zero)) == 0) {
+ if (bsglobal.debugging) {
+ if (bsp->args.family == AF_INET)
+ zlog_debug("%s: invalid address: %pI4",
+ __func__,
+ (struct in_addr *)&bsp->args.dst);
+ else
+ zlog_debug("%s: invalid address: %pI6",
+ __func__, &bsp->args.dst);
+ }
+ return false;
+ }
+
+ /* Multi hop requires local address. */
+ if (bsp->args.mhop
+ && memcmp(&i6a_zero, &bsp->args.src, sizeof(i6a_zero)) == 0) {
+ if (bsglobal.debugging)
+ zlog_debug(
+ "%s: multi hop but no local address provided",
+ __func__);
+ return false;
+ }
+
+ /* Check VRF ID. */
+ if (bsp->args.vrf_id == VRF_UNKNOWN) {
+ if (bsglobal.debugging)
+ zlog_debug("%s: asked for unknown VRF", __func__);
+ return false;
+ }
+
+ return true;
+}
+
+static int _bfd_sess_send(struct thread *t)
+{
+ struct bfd_session_params *bsp = THREAD_ARG(t);
+ int rv;
+
+ /* Validate configuration before trying to send bogus data. */
+ if (!_bfd_sess_valid(bsp))
+ return 0;
+
+ if (bsp->lastev == BSE_INSTALL) {
+ bsp->args.command = bsp->installed ? ZEBRA_BFD_DEST_UPDATE
+ : ZEBRA_BFD_DEST_REGISTER;
+ } else
+ bsp->args.command = ZEBRA_BFD_DEST_DEREGISTER;
+
+ /* If not installed and asked for uninstall, do nothing. */
+ if (!bsp->installed && bsp->args.command == ZEBRA_BFD_DEST_DEREGISTER)
+ return 0;
+
+ rv = zclient_bfd_command(bsglobal.zc, &bsp->args);
+ /* Command was sent successfully. */
+ if (rv == 0) {
+ /* Update installation status. */
+ if (bsp->args.command == ZEBRA_BFD_DEST_DEREGISTER)
+ bsp->installed = false;
+ else if (bsp->args.command == ZEBRA_BFD_DEST_REGISTER)
+ bsp->installed = true;
+ }
+
+ return 0;
+}
+
+static void _bfd_sess_remove(struct bfd_session_params *bsp)
+{
+ /* Not installed, nothing to do. */
+ if (!bsp->installed)
+ return;
+
+ /* Cancel any pending installation request. */
+ THREAD_OFF(bsp->installev);
+
+ /* Send request to remove any session. */
+ bsp->lastev = BSE_UNINSTALL;
+ thread_execute(bsglobal.tm, _bfd_sess_send, bsp, 0);
+}
+
+void bfd_sess_free(struct bfd_session_params **bsp)
+{
+ if (*bsp == NULL)
+ return;
+
+ /* Remove any installed session. */
+ _bfd_sess_remove(*bsp);
+
+ /* Remove from global list. */
+ TAILQ_REMOVE(&bsglobal.bsplist, (*bsp), entry);
+
+ /* Free the memory and point to NULL. */
+ XFREE(MTYPE_BFD_INFO, (*bsp));
+}
+
+void bfd_sess_enable(struct bfd_session_params *bsp, bool enable)
+{
+ /* Remove the session when disabling. */
+ if (!enable)
+ _bfd_sess_remove(bsp);
+
+ bsp->enabled = enable;
+}
+
+void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
+ struct in_addr *src, struct in_addr *dst)
+{
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ bsp->args.family = AF_INET;
+
+ /* Clean memory, set zero value and avoid static analyser warnings. */
+ memset(&bsp->args.src, 0, sizeof(bsp->args.src));
+ memset(&bsp->args.dst, 0, sizeof(bsp->args.dst));
+
+ /* Copy the equivalent of IPv4 to arguments structure. */
+ if (src)
+ memcpy(&bsp->args.src, src, sizeof(struct in_addr));
+
+ assert(dst);
+ memcpy(&bsp->args.dst, dst, sizeof(struct in_addr));
+}
+
+void bfd_sess_set_ipv6_addrs(struct bfd_session_params *bsp,
+ struct in6_addr *src, struct in6_addr *dst)
+{
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ bsp->args.family = AF_INET6;
+
+ /* Clean memory, set zero value and avoid static analyser warnings. */
+ memset(&bsp->args.src, 0, sizeof(bsp->args.src));
+
+ if (src)
+ bsp->args.src = *src;
+
+ assert(dst);
+ bsp->args.dst = *dst;
+}
+
+void bfd_sess_set_interface(struct bfd_session_params *bsp, const char *ifname)
+{
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ if (ifname == NULL) {
+ bsp->args.ifname[0] = 0;
+ bsp->args.ifnamelen = 0;
+ return;
+ }
+
+ if (strlcpy(bsp->args.ifname, ifname, sizeof(bsp->args.ifname))
+ > sizeof(bsp->args.ifname))
+ zlog_warn("%s: interface name truncated: %s", __func__, ifname);
+
+ bsp->args.ifnamelen = strlen(bsp->args.ifname);
+}
+
+void bfd_sess_set_profile(struct bfd_session_params *bsp, const char *profile)
+{
+ if (profile == NULL) {
+ bsp->args.profile[0] = 0;
+ bsp->args.profilelen = 0;
+ return;
+ }
+
+ if (strlcpy(bsp->args.profile, profile, sizeof(bsp->args.profile))
+ > sizeof(bsp->args.profile))
+ zlog_warn("%s: profile name truncated: %s", __func__, profile);
+
+ bsp->args.profilelen = strlen(bsp->args.profile);
+}
+
+void bfd_sess_set_vrf(struct bfd_session_params *bsp, vrf_id_t vrf_id)
+{
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ bsp->args.vrf_id = vrf_id;
+}
+
+void bfd_sess_set_mininum_ttl(struct bfd_session_params *bsp, uint8_t min_ttl)
+{
+ assert(min_ttl != 0);
+
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ /* Invert TTL value: protocol expects number of hops. */
+ min_ttl = (BFD_SINGLE_HOP_TTL + 1) - min_ttl;
+ bsp->args.ttl = min_ttl;
+ bsp->args.mhop = (min_ttl > 1);
+}
+
+void bfd_sess_set_hop_count(struct bfd_session_params *bsp, uint8_t min_ttl)
+{
+ /* If already installed, remove the old setting. */
+ _bfd_sess_remove(bsp);
+
+ bsp->args.ttl = min_ttl;
+ bsp->args.mhop = (min_ttl > 1);
+}
+
+
+void bfd_sess_set_cbit(struct bfd_session_params *bsp, bool enable)
+{
+ bsp->args.cbit = enable;
+}
+
+void bfd_sess_set_timers(struct bfd_session_params *bsp,
+ uint8_t detection_multiplier, uint32_t min_rx,
+ uint32_t min_tx)
+{
+ bsp->args.detection_multiplier = detection_multiplier;
+ bsp->args.min_rx = min_rx;
+ bsp->args.min_tx = min_tx;
+}
+
+void bfd_sess_install(struct bfd_session_params *bsp)
+{
+ /* Don't attempt to install/update when disabled. */
+ if (!bsp->enabled)
+ return;
+
+ bsp->lastev = BSE_INSTALL;
+ thread_add_event(bsglobal.tm, _bfd_sess_send, bsp, 0, &bsp->installev);
+}
+
+void bfd_sess_uninstall(struct bfd_session_params *bsp)
+{
+ bsp->lastev = BSE_UNINSTALL;
+ thread_add_event(bsglobal.tm, _bfd_sess_send, bsp, 0, &bsp->installev);
+}
+
+enum bfd_session_state bfd_sess_status(const struct bfd_session_params *bsp)
+{
+ return bsp->bss.state;
+}
+
+uint8_t bfd_sess_minimum_ttl(const struct bfd_session_params *bsp)
+{
+ return ((BFD_SINGLE_HOP_TTL + 1) - bsp->args.ttl);
+}
+
+uint8_t bfd_sess_hop_count(const struct bfd_session_params *bsp)
+{
+ return bsp->args.ttl;
+}
+
+const char *bfd_sess_profile(const struct bfd_session_params *bsp)
+{
+ return bsp->args.profilelen ? bsp->args.profile : NULL;
+}
+
+void bfd_sess_addresses(const struct bfd_session_params *bsp, int *family,
+ struct in6_addr *src, struct in6_addr *dst)
+{
+ *family = bsp->args.family;
+ if (src)
+ *src = bsp->args.src;
+ if (dst)
+ *dst = bsp->args.dst;
+}
+
+const char *bfd_sess_interface(const struct bfd_session_params *bsp)
+{
+ if (bsp->args.ifnamelen)
+ return bsp->args.ifname;
+
+ return NULL;
+}
+
+const char *bfd_sess_vrf(const struct bfd_session_params *bsp)
+{
+ return vrf_id_to_name(bsp->args.vrf_id);
+}
+
+vrf_id_t bfd_sess_vrf_id(const struct bfd_session_params *bsp)
+{
+ return bsp->args.vrf_id;
+}
+
+bool bfd_sess_cbit(const struct bfd_session_params *bsp)
+{
+ return bsp->args.cbit;
+}
+
+void bfd_sess_timers(const struct bfd_session_params *bsp,
+ uint8_t *detection_multiplier, uint32_t *min_rx,
+ uint32_t *min_tx)
+{
+ *detection_multiplier = bsp->args.detection_multiplier;
+ *min_rx = bsp->args.min_rx;
+ *min_tx = bsp->args.min_tx;
+}
+
+void bfd_sess_show(struct vty *vty, struct json_object *json,
+ struct bfd_session_params *bsp)
+{
+ json_object *json_bfd = NULL;
+ char time_buf[64];
+
+ /* Show type. */
+ if (json) {
+ json_bfd = json_object_new_object();
+ if (bsp->args.mhop)
+ json_object_string_add(json_bfd, "type", "multi hop");
+ else
+ json_object_string_add(json_bfd, "type", "single hop");
+ } else
+ vty_out(vty, " BFD: Type: %s\n",
+ bsp->args.mhop ? "multi hop" : "single hop");
+
+ /* Show configuration. */
+ if (json) {
+ json_object_int_add(json_bfd, "detectMultiplier",
+ bsp->args.detection_multiplier);
+ json_object_int_add(json_bfd, "rxMinInterval",
+ bsp->args.min_rx);
+ json_object_int_add(json_bfd, "txMinInterval",
+ bsp->args.min_tx);
+ } else {
+ vty_out(vty,
+ " Detect Multiplier: %d, Min Rx interval: %d, Min Tx interval: %d\n",
+ bsp->args.detection_multiplier, bsp->args.min_rx,
+ bsp->args.min_tx);
+ }
+
+ bfd_last_update(bsp->bss.last_event, time_buf, sizeof(time_buf));
+ if (json) {
+ json_object_string_add(json_bfd, "status",
+ bfd_get_status_str(bsp->bss.state));
+ json_object_string_add(json_bfd, "lastUpdate", time_buf);
+ } else
+ vty_out(vty, " Status: %s, Last update: %s\n",
+ bfd_get_status_str(bsp->bss.state), time_buf);
+
+ if (json)
+ json_object_object_add(json, "peerBfdInfo", json_bfd);
+ else
+ vty_out(vty, "\n");
+}
+
+/*
+ * Zebra communication related.
+ */
+
+/**
+ * Callback for reinstallation of all registered BFD sessions.
+ *
+ * Use this as `zclient` `bfd_dest_replay` callback.
+ */
+static int zclient_bfd_session_reply(ZAPI_CALLBACK_ARGS)
+{
+ struct bfd_session_params *bsp;
+
+ /* Do nothing when shutting down. */
+ if (bsglobal.shutting_down)
+ return 0;
+
+ if (bsglobal.debugging)
+ zlog_debug("%s: sending all sessions registered", __func__);
+
+ /* Send the client registration */
+ bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf_id);
+
+ /* Replay all activated peers. */
+ TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
+ /* Skip disabled sessions. */
+ if (!bsp->enabled)
+ continue;
+
+ /* We are reconnecting, so we must send installation. */
+ bsp->installed = false;
+
+ /* Cancel any pending installation request. */
+ THREAD_OFF(bsp->installev);
+
+ /* Ask for installation. */
+ bsp->lastev = BSE_INSTALL;
+ thread_execute(bsglobal.tm, _bfd_sess_send, bsp, 0);
+ }
+
+ return 0;
+}
+
+static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
+{
+ struct bfd_session_params *bsp;
+ size_t sessions_updated = 0;
+ struct interface *ifp;
+ int remote_cbit = false;
+ int state = BFD_STATUS_UNKNOWN;
+ time_t now;
+ size_t addrlen;
+ struct prefix dp;
+ struct prefix sp;
+ char ifstr[128], cbitstr[32];
+
+ /* Do nothing when shutting down. */
+ if (bsglobal.shutting_down)
+ return 0;
+
+ ifp = bfd_get_peer_info(zclient->ibuf, &dp, &sp, &state, &remote_cbit,
+ vrf_id);
+
+ if (bsglobal.debugging) {
+ ifstr[0] = 0;
+ if (ifp)
+ snprintf(ifstr, sizeof(ifstr), " (interface %s)",
+ ifp->name);
+
+ snprintf(cbitstr, sizeof(cbitstr), " (CPI bit %s)",
+ remote_cbit ? "yes" : "no");
+
+ zlog_debug("%s: %pFX -> %pFX%s VRF %s(%u)%s: %s", __func__, &sp,
+ &dp, ifstr, vrf_id_to_name(vrf_id), vrf_id, cbitstr,
+ bfd_get_status_str(state));
+ }
+
+ switch (dp.family) {
+ case AF_INET:
+ addrlen = sizeof(struct in_addr);
+ break;
+ case AF_INET6:
+ addrlen = sizeof(struct in6_addr);
+ break;
+
+ default:
+ /* Unexpected value. */
+ assert(0);
+ break;
+ }
+
+ /* Cache current time to avoid multiple monotime clock calls. */
+ now = monotime(NULL);
+
+ /* Notify all matching sessions about update. */
+ TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
+ /* Skip disabled or not installed entries. */
+ if (!bsp->enabled || !bsp->installed)
+ continue;
+ /* Skip different VRFs. */
+ if (bsp->args.vrf_id != vrf_id)
+ continue;
+ /* Skip different families. */
+ if (bsp->args.family != dp.family)
+ continue;
+ /* Skip different interface. */
+ if (bsp->args.ifnamelen && ifp
+ && strcmp(bsp->args.ifname, ifp->name) != 0)
+ continue;
+ /* Skip non matching destination addresses. */
+ if (memcmp(&bsp->args.dst, &dp.u, addrlen) != 0)
+ continue;
+ /*
+ * Source comparison test:
+ * We will only compare source if BFD daemon provided the
+ * source address and the protocol set a source address in
+ * the configuration otherwise we'll just skip it.
+ */
+ if (sp.family && memcmp(&bsp->args.src, &i6a_zero, addrlen) != 0
+ && memcmp(&sp.u, &i6a_zero, addrlen) != 0
+ && memcmp(&bsp->args.src, &sp.u, addrlen) != 0)
+ continue;
+ /* No session state change. */
+ if ((int)bsp->bss.state == state)
+ continue;
+
+ bsp->bss.last_event = now;
+ bsp->bss.previous_state = bsp->bss.state;
+ bsp->bss.state = state;
+ bsp->bss.remote_cbit = remote_cbit;
+ bsp->updatecb(bsp, &bsp->bss, bsp->arg);
+ sessions_updated++;
+ }
+
+ if (bsglobal.debugging)
+ zlog_debug("%s: sessions updated: %zu", __func__,
+ sessions_updated);
+
+ return 0;
+}
+
+void bfd_protocol_integration_init(struct zclient *zc, struct thread_master *tm)
+{
+ /* Initialize data structure. */
+ TAILQ_INIT(&bsglobal.bsplist);
+
+ /* Copy pointers. */
+ bsglobal.zc = zc;
+ bsglobal.tm = tm;
+
+ /* Install our callbacks. */
+ zc->interface_bfd_dest_update = zclient_bfd_session_update;
+ zc->bfd_dest_replay = zclient_bfd_session_reply;
+
+ /* Send the client registration */
+ bfd_client_sendmsg(zc, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
+}
+
+void bfd_protocol_integration_set_debug(bool enable)
+{
+ bsglobal.debugging = enable;
+}
+
+void bfd_protocol_integration_set_shutdown(bool enable)
+{
+ bsglobal.shutting_down = enable;
+}
+
+bool bfd_protocol_integration_debug(void)
+{
+ return bsglobal.debugging;
+}
+
+bool bfd_protocol_integration_shutting_down(void)
+{
+ return bsglobal.shutting_down;
+}
diff --git a/lib/bfd.h b/lib/bfd.h
index ceab4628b6..1325f86a30 100644
--- a/lib/bfd.h
+++ b/lib/bfd.h
@@ -128,6 +128,305 @@ extern void bfd_gbl_exit(void);
* BFD new API.
*/
+/* Forward declaration of argument struct. */
+struct bfd_session_params;
+
+/** Session state definitions. */
+enum bfd_session_state {
+ /** Session state is unknown or not initialized. */
+ BSS_UNKNOWN = BFD_STATUS_UNKNOWN,
+ /** Local or remote peer administratively shutdown the session. */
+ BSS_ADMIN_DOWN = BFD_STATUS_ADMIN_DOWN,
+ /** Session is down. */
+ BSS_DOWN = BFD_STATUS_DOWN,
+ /** Session is up and working correctly. */
+ BSS_UP = BFD_STATUS_UP,
+};
+
+/** BFD session status information */
+struct bfd_session_status {
+ /** Current session state. */
+ enum bfd_session_state state;
+ /** Previous session state. */
+ enum bfd_session_state previous_state;
+ /** Remote Control Plane Independent bit state. */
+ bool remote_cbit;
+ /** Last event occurrence. */
+ time_t last_event;
+};
+
+/**
+ * Session status update callback.
+ *
+ * \param bsp BFD session parameters.
+ * \param bss BFD session status.
+ * \param arg application independent data.
+ */
+typedef void (*bsp_status_update)(struct bfd_session_params *bsp,
+ const struct bfd_session_status *bss,
+ void *arg);
+
+/**
+ * Allocates and initializes the session parameters.
+ *
+ * \param updatedb status update notification callback.
+ * \param args application independent data.
+ *
+ * \returns pointer to configuration storage.
+ */
+struct bfd_session_params *bfd_sess_new(bsp_status_update updatecb, void *args);
+
+/**
+ * Uninstall session if installed and free resources allocated by the
+ * parameters. Already sets pointer to `NULL` to avoid dangling references.
+ *
+ * \param bsp session parameters.
+ */
+void bfd_sess_free(struct bfd_session_params **bsp);
+
+/**
+ * Enable/disable session installation.
+ *
+ * \param bsp session parameters.
+ * \param enable knob variable.
+ */
+void bfd_sess_enable(struct bfd_session_params *bsp, bool enable);
+
+/**
+ * Set the local and peer address of the BFD session.
+ *
+ * \param bsp BFD session parameters.
+ * \param src local address (optional, can be `NULL`).
+ * \param dst remote address (mandatory).
+ */
+void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
+ struct in_addr *src, struct in_addr *dst);
+
+/**
+ * Set the local and peer address of the BFD session.
+ *
+ * \param bsp BFD session parameters.
+ * \param src local address (optional, can be `NULL`).
+ * \param dst remote address (mandatory).
+ */
+void bfd_sess_set_ipv6_addrs(struct bfd_session_params *bsp,
+ struct in6_addr *src, struct in6_addr *dst);
+
+/**
+ * Configure the BFD session interface.
+ *
+ * \param bsp BFD session parameters.
+ * \param ifname interface name (or `NULL` to remove it).
+ */
+void bfd_sess_set_interface(struct bfd_session_params *bsp, const char *ifname);
+
+/**
+ * Configure the BFD session profile name.
+ *
+ * \param bsp BFD session parameters.
+ * \param profile profile name (or `NULL` to remove it).
+ */
+void bfd_sess_set_profile(struct bfd_session_params *bsp, const char *profile);
+
+/**
+ * Configure the BFD session VRF.
+ *
+ * \param bsp BFD session parameters.
+ * \param vrf_id the VRF identification number.
+ */
+void bfd_sess_set_vrf(struct bfd_session_params *bsp, vrf_id_t vrf_id);
+
+/**
+ * Configure the BFD session single/multi hop setting.
+ *
+ * \param bsp BFD session parameters.
+ * \param min_ttl minimum TTL value expected (255 for single hop, 254 for
+ * multi hop with single hop, 253 for multi hop with two hops
+ * and so on). See `BFD_SINGLE_HOP_TTL` and
+ * `BFD_MULTI_HOP_MIN_TTL` for defaults.
+ *
+ * To simplify things if your protocol only knows the amount of hops it is
+ * better to use `bfd_sess_set_hops` instead.
+ */
+void bfd_sess_set_mininum_ttl(struct bfd_session_params *bsp, uint8_t min_ttl);
+
+/** To use single hop the minimum TTL must be set to this. */
+#define BFD_SINGLE_HOP_TTL 255
+/** To use multi hop the minimum TTL must be set to this or less. */
+#define BFD_MULTI_HOP_MIN_TTL 254
+
+/**
+ * This function is the inverted version of `bfd_sess_set_minimum_ttl`.
+ * Instead of receiving the minimum expected TTL, it receives the amount of
+ * hops the protocol will jump.
+ *
+ * \param bsp BFD session parameters.
+ * \param min_ttl minimum amount of hops expected (1 for single hop, 2 or
+ * more for multi hop).
+ */
+void bfd_sess_set_hop_count(struct bfd_session_params *bsp, uint8_t min_ttl);
+
+/**
+ * Configure the BFD session to set the Control Plane Independent bit.
+ *
+ * \param bsp BFD session parameters.
+ * \param enable BFD Control Plane Independent state.
+ */
+void bfd_sess_set_cbit(struct bfd_session_params *bsp, bool enable);
+
+/**
+ * DEPRECATED: please avoid using timers directly and use profiles instead.
+ *
+ * Configures the BFD session timers to use. This is specially useful with
+ * `ptm-bfd` which does not support timers.
+ *
+ * \param bsp BFD session parameters.
+ * \param detection_multiplier the detection multiplier value.
+ * \param min_rx minimum required receive period.
+ * \param min_tx minimum required transmission period.
+ */
+void bfd_sess_set_timers(struct bfd_session_params *bsp,
+ uint8_t detection_multiplier, uint32_t min_rx,
+ uint32_t min_tx);
+
+/**
+ * Installs or updates the BFD session based on the saved session arguments.
+ *
+ * \param bsp session parameters.
+ */
+void bfd_sess_install(struct bfd_session_params *bsp);
+
+/**
+ * Uninstall the BFD session based on the saved session arguments.
+ *
+ * \param bsp session parameters.
+ */
+void bfd_sess_uninstall(struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session current status.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns BFD session status data structure.
+ */
+enum bfd_session_state bfd_sess_status(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session minimum TTL configured value.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns configured minimum TTL.
+ */
+uint8_t bfd_sess_minimum_ttl(const struct bfd_session_params *bsp);
+
+/**
+ * Inverted version of `bfd_sess_minimum_ttl`. Gets the amount of hops in the
+ * way to the peer.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns configured amount of hops.
+ */
+uint8_t bfd_sess_hop_count(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session profile configured value.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns configured profile name (or `NULL` if empty).
+ */
+const char *bfd_sess_profile(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session addresses.
+ *
+ * \param bsp session parameters.
+ * \param family the address family being used (AF_INET or AF_INET6).
+ * \param src source address (optional, may be `NULL`).
+ * \param dst peer address (optional, may be `NULL`).
+ */
+void bfd_sess_addresses(const struct bfd_session_params *bsp, int *family,
+ struct in6_addr *src, struct in6_addr *dst);
+/**
+ * Get BFD session interface name.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns `NULL` if not set otherwise the interface name.
+ */
+const char *bfd_sess_interface(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session VRF name.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns the VRF name.
+ */
+const char *bfd_sess_vrf(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session VRF ID.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns the VRF name.
+ */
+vrf_id_t bfd_sess_vrf_id(const struct bfd_session_params *bsp);
+
+/**
+ * Get BFD session control plane independent bit configuration state.
+ *
+ * \param bsp session parameters.
+ *
+ * \returns `true` if enabled otherwise `false`.
+ */
+bool bfd_sess_cbit(const struct bfd_session_params *bsp);
+
+/**
+ * DEPRECATED: please avoid using timers directly and use profiles instead.
+ *
+ * Gets the configured timers.
+ *
+ * \param bsp BFD session parameters.
+ * \param detection_multiplier the detection multiplier value.
+ * \param min_rx minimum required receive period.
+ * \param min_tx minimum required transmission period.
+ */
+void bfd_sess_timers(const struct bfd_session_params *bsp,
+ uint8_t *detection_multiplier, uint32_t *min_rx,
+ uint32_t *min_tx);
+
+/**
+ * Show BFD session configuration and status. If `json` is provided (e.g. not
+ * `NULL`) then information will be inserted in object, otherwise printed to
+ * `vty`.
+ *
+ * \param vty Pointer to `vty` for outputting text.
+ * \param json (optional) JSON object pointer.
+ * \param bsp session parameters.
+ */
+void bfd_sess_show(struct vty *vty, struct json_object *json,
+ struct bfd_session_params *bsp);
+
+/**
+ * Initializes the BFD integration library. This function executes the
+ * following actions:
+ *
+ * - Copy the `struct thread_master` pointer to use as "thread" to execute
+ * the BFD session parameters installation.
+ * - Copy the `struct zclient` pointer to install its callbacks.
+ * - Initializes internal data structures.
+ *
+ * \param tm normally the daemon main thread event manager.
+ * \param zc the zebra client of the daemon.
+ */
+void bfd_protocol_integration_init(struct zclient *zc,
+ struct thread_master *tm);
+
/**
* BFD session registration arguments.
*/
@@ -205,6 +504,34 @@ struct bfd_session_arg {
*/
extern int zclient_bfd_command(struct zclient *zc, struct bfd_session_arg *arg);
+/**
+ * Enables or disables BFD protocol integration API debugging.
+ *
+ * \param enable new API debug state.
+ */
+extern void bfd_protocol_integration_set_debug(bool enable);
+
+/**
+ * Sets shutdown mode so no more events are processed.
+ *
+ * This is useful to avoid the event storm that happens caused by network,
+ * interfaces or VRFs removal. It should also avoid some crashes due hanging
+ * pointers left overs by protocol.
+ *
+ * \param enable new API shutdown state.
+ */
+extern void bfd_protocol_integration_set_shutdown(bool enable);
+
+/**
+ * Get API debugging state.
+ */
+extern bool bfd_protocol_integration_debug(void);
+
+/**
+ * Get API shutdown state.
+ */
+extern bool bfd_protocol_integration_shutting_down(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/buffer.c b/lib/buffer.c
index 42796faae8..7929b3709d 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -29,8 +29,8 @@
#include <stddef.h>
-DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer")
-DEFINE_MTYPE_STATIC(LIB, BUFFER_DATA, "Buffer data")
+DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer");
+DEFINE_MTYPE_STATIC(LIB, BUFFER_DATA, "Buffer data");
/* Buffer master. */
struct buffer {
diff --git a/lib/command.c b/lib/command.c
index 6a4d504b2f..770e2fc5ac 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -51,8 +51,8 @@
#include "frrscript.h"
-DEFINE_MTYPE_STATIC(LIB, HOST, "Host config")
-DEFINE_MTYPE(LIB, COMPLETION, "Completion item")
+DEFINE_MTYPE_STATIC(LIB, HOST, "Host config");
+DEFINE_MTYPE(LIB, COMPLETION, "Completion item");
#define item(x) \
{ \
diff --git a/lib/command.h b/lib/command.h
index 71abb20b05..14e51486ea 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -34,7 +34,7 @@
extern "C" {
#endif
-DECLARE_MTYPE(COMPLETION)
+DECLARE_MTYPE(COMPLETION);
/*
* From RFC 1123 (Requirements for Internet Hosts), Section 2.1 on hostnames:
diff --git a/lib/command_graph.c b/lib/command_graph.c
index d30d9ab702..c6c3840455 100644
--- a/lib/command_graph.c
+++ b/lib/command_graph.c
@@ -26,11 +26,11 @@
#include "command_graph.h"
-DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")
-DEFINE_MTYPE_STATIC(LIB, CMD_DESC, "Command Token Text")
-DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help")
-DEFINE_MTYPE(LIB, CMD_ARG, "Command Argument")
-DEFINE_MTYPE_STATIC(LIB, CMD_VAR, "Command Argument Name")
+DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens");
+DEFINE_MTYPE_STATIC(LIB, CMD_DESC, "Command Token Text");
+DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help");
+DEFINE_MTYPE(LIB, CMD_ARG, "Command Argument");
+DEFINE_MTYPE_STATIC(LIB, CMD_VAR, "Command Argument Name");
struct cmd_token *cmd_token_new(enum cmd_token_type type, uint8_t attr,
const char *text, const char *desc)
diff --git a/lib/command_graph.h b/lib/command_graph.h
index 86715410ce..2754dca67d 100644
--- a/lib/command_graph.h
+++ b/lib/command_graph.h
@@ -37,7 +37,7 @@
extern "C" {
#endif
-DECLARE_MTYPE(CMD_ARG)
+DECLARE_MTYPE(CMD_ARG);
struct vty;
diff --git a/lib/command_match.c b/lib/command_match.c
index 801b05f157..e9e8466ffd 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -26,7 +26,7 @@
#include "command_match.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack")
+DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack");
#ifdef TRACE_MATCHER
#define TM 1
diff --git a/lib/command_parse.y b/lib/command_parse.y
index 8135d02b4b..5ebc19b278 100644
--- a/lib/command_parse.y
+++ b/lib/command_parse.y
@@ -54,7 +54,7 @@
#include "command_graph.h"
#include "log.h"
- DECLARE_MTYPE(LEX)
+ DECLARE_MTYPE(LEX);
#define YYSTYPE CMD_YYSTYPE
#define YYLTYPE CMD_YYLTYPE
@@ -376,7 +376,7 @@ selector: '[' selector_seq_seq ']' varname_token
#undef scanner
-DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)")
+DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)");
void
cmd_graph_parse (struct graph *graph, const struct cmd_element *cmd)
diff --git a/lib/compiler.h b/lib/compiler.h
index 70ef8e9bc8..b7a142bdee 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -21,6 +21,21 @@
extern "C" {
#endif
+#ifdef __cplusplus
+# if __cplusplus < 201103L
+# error FRRouting headers must be compiled in C++11 mode or newer
+# endif
+/* C++ defines static_assert(), but not _Static_assert(). C defines
+ * _Static_assert() and has static_assert() in <assert.h>. However, we mess
+ * with assert() in zassert.h so let's not include <assert.h> here.
+ */
+# define _Static_assert static_assert
+#else
+# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+# error FRRouting must be compiled with min. -std=gnu11 (GNU ISO C11 dialect)
+# endif
+#endif
+
/* function attributes, use like
* void prototype(void) __attribute__((_CONSTRUCTOR(100)));
*/
@@ -121,6 +136,24 @@ extern "C" {
#define macro_inline static inline __attribute__((unused))
#define macro_pure static inline __attribute__((unused, pure))
+/* if the macro ends with a function definition */
+#define MACRO_REQUIRE_SEMICOLON() \
+ _Static_assert(1, "please add a semicolon after this macro")
+
+#if CONFDATE < 20210601
+#ifdef ENABLE_BGP_VNC
+/* temporarily disabled for transition for LabN CI
+ * NB: it's not possible to generate a deprecation warning for this, hence
+ * the shortened transition period (since otherwise new uses of the old syntax
+ * may creep in without errors)
+ */
+#undef MACRO_REQUIRE_SEMICOLON
+#define MACRO_REQUIRE_SEMICOLON() \
+ /* nothing */
+#endif /* ENABLE_BGP_VNC */
+#else /* CONFDATE >= 20210601 */
+CPP_NOTICE("time to remove this CONFDATE block")
+#endif
/* variadic macros, use like:
* #define V_0() ...
@@ -357,10 +390,8 @@ typedef signed long long _int64_t;
/* if this breaks, 128-bit machines may have entered reality (or <long long>
* is something weird)
*/
-#if __STDC_VERSION__ >= 201112L
_Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
"nobody expects the spanish intquisition");
-#endif
/* since we redefined int64_t, we also need to redefine PRI*64 */
#undef PRIu64
diff --git a/lib/debug.c b/lib/debug.c
index 3248ceb13b..e2ba4cd4ef 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -24,7 +24,7 @@
static struct debug_cb_list_head cb_head;
-DECLARE_LIST(debug_cb_list, struct debug_callbacks, item)
+DECLARE_LIST(debug_cb_list, struct debug_callbacks, item);
/* All code in this section should be reentrant and MT-safe */
diff --git a/lib/debug.h b/lib/debug.h
index f25cd42691..a72657bdaf 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -84,7 +84,7 @@ struct debug {
const char *desc;
};
-PREDECL_LIST(debug_cb_list)
+PREDECL_LIST(debug_cb_list);
/*
* Callback set for debugging code.
*
diff --git a/lib/defaults.h b/lib/defaults.h
index 20ef28db31..55250f0f81 100644
--- a/lib/defaults.h
+++ b/lib/defaults.h
@@ -98,7 +98,8 @@ struct frr_default {
static void _dfltinit_##varname(void) \
{ \
frr_default_add(&_dflt_##varname); \
- }
+ } \
+ MACRO_REQUIRE_SEMICOLON() /* end */
/* use:
* FRR_CFG_DEFAULT_LONG(SHARP_BLUNTNESS,
diff --git a/lib/distribute.c b/lib/distribute.c
index 3ea60c8772..60bd0a47bb 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -27,10 +27,10 @@
#include "distribute.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_CTX, "Distribute ctx")
-DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list")
-DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname")
-DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name")
+DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_CTX, "Distribute ctx");
+DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list");
+DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname");
+DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name");
static struct list *dist_ctx_list;
diff --git a/lib/elf_py.c b/lib/elf_py.c
index 0d8ad76e1c..d26e443b82 100644
--- a/lib/elf_py.c
+++ b/lib/elf_py.c
@@ -100,7 +100,7 @@ static PyObject *refuse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
struct elfreloc;
struct elfsect;
-PREDECL_HASH(elfrelocs)
+PREDECL_HASH(elfrelocs);
/* ELFFile and ELFSection intentionally share some behaviour, particularly
* subscript[123:456] access to file data. This is because relocatables
@@ -200,7 +200,7 @@ static int elfreloc_cmp(const struct elfreloc *a, const struct elfreloc *b);
static uint32_t elfreloc_hash(const struct elfreloc *reloc);
DECLARE_HASH(elfrelocs, struct elfreloc, elfrelocs_item,
- elfreloc_cmp, elfreloc_hash)
+ elfreloc_cmp, elfreloc_hash);
static Elf_Scn *elf_find_addr(struct elffile *ef, uint64_t addr, size_t *idx);
static PyObject *elffile_secbyidx(struct elffile *w, Elf_Scn *scn, size_t idx);
diff --git a/lib/ferr.c b/lib/ferr.c
index 691da495cf..513ef5ebec 100644
--- a/lib/ferr.c
+++ b/lib/ferr.c
@@ -35,7 +35,7 @@
#include "linklist.h"
#include "frr_pthread.h"
-DEFINE_MTYPE_STATIC(LIB, ERRINFO, "error information")
+DEFINE_MTYPE_STATIC(LIB, ERRINFO, "error information");
/*
* Thread-specific key for temporary storage of allocated ferr.
diff --git a/lib/filter.c b/lib/filter.c
index f5ae9ee2b7..83423ba321 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -31,9 +31,9 @@
#include "libfrr.h"
#include "northbound_cli.h"
-DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List")
-DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str")
-DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter")
+DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List");
+DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str");
+DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter");
/* Static structure for mac access_list's master. */
static struct access_master access_master_mac = {
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index 3f0179fbc1..03359f4d18 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -30,8 +30,8 @@
#include "zlog.h"
#include "libfrr_trace.h"
-DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread")
-DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives")
+DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread");
+DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives");
/* default frr_pthread start/stop routine prototypes */
static void *fpt_run(void *arg);
diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c
index 33adcd7b80..05f0fce5fc 100644
--- a/lib/frr_zmq.c
+++ b/lib/frr_zmq.c
@@ -26,7 +26,7 @@
#include "log.h"
#include "lib_errors.h"
-DEFINE_MTYPE_STATIC(LIB, ZEROMQ_CB, "ZeroMQ callback")
+DEFINE_MTYPE_STATIC(LIB, ZEROMQ_CB, "ZeroMQ callback");
/* libzmq's context */
void *frrzmq_context = NULL;
diff --git a/lib/frrcu.c b/lib/frrcu.c
index 7e6475b648..0e717a98a5 100644
--- a/lib/frrcu.c
+++ b/lib/frrcu.c
@@ -54,12 +54,12 @@
#include "seqlock.h"
#include "atomlist.h"
-DEFINE_MTYPE_STATIC(LIB, RCU_THREAD, "RCU thread")
-DEFINE_MTYPE_STATIC(LIB, RCU_NEXT, "RCU sequence barrier")
+DEFINE_MTYPE_STATIC(LIB, RCU_THREAD, "RCU thread");
+DEFINE_MTYPE_STATIC(LIB, RCU_NEXT, "RCU sequence barrier");
-DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head)
+DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head);
-PREDECL_ATOMLIST(rcu_threads)
+PREDECL_ATOMLIST(rcu_threads);
struct rcu_thread {
struct rcu_threads_item head;
@@ -70,7 +70,7 @@ struct rcu_thread {
/* only accessed by thread itself, not atomic */
unsigned depth;
};
-DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head)
+DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head);
static const struct rcu_action rcua_next = { .type = RCUA_NEXT };
static const struct rcu_action rcua_end = { .type = RCUA_END };
diff --git a/lib/frrcu.h b/lib/frrcu.h
index 47751ae7df..3808259040 100644
--- a/lib/frrcu.h
+++ b/lib/frrcu.h
@@ -116,7 +116,7 @@ struct rcu_action {
};
/* RCU cleanup function queue item */
-PREDECL_ATOMLIST(rcu_heads)
+PREDECL_ATOMLIST(rcu_heads);
struct rcu_head {
struct rcu_heads_item head;
const struct rcu_action *action;
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c
index a40b815caa..209765bd6f 100644
--- a/lib/grammar_sandbox.c
+++ b/lib/grammar_sandbox.c
@@ -34,7 +34,7 @@
#define GRAMMAR_STR "CLI grammar sandbox\n"
-DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
+DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc");
/** headers **/
void grammar_sandbox_init(void);
diff --git a/lib/graph.c b/lib/graph.c
index 128e45c570..1cbe1b90f9 100644
--- a/lib/graph.c
+++ b/lib/graph.c
@@ -25,8 +25,8 @@
#include "memory.h"
#include "buffer.h"
-DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph")
-DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node")
+DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph");
+DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node");
struct graph *graph_new(void)
{
struct graph *graph = XCALLOC(MTYPE_GRAPH, sizeof(struct graph));
diff --git a/lib/hash.c b/lib/hash.c
index ec616ee724..e9132f7907 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -31,9 +31,9 @@
#include "frr_pthread.h"
#include "libfrr_trace.h"
-DEFINE_MTYPE_STATIC(LIB, HASH, "Hash")
-DEFINE_MTYPE_STATIC(LIB, HASH_BUCKET, "Hash Bucket")
-DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index")
+DEFINE_MTYPE_STATIC(LIB, HASH, "Hash");
+DEFINE_MTYPE_STATIC(LIB, HASH_BUCKET, "Hash Bucket");
+DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index");
static pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct list *_hashes;
diff --git a/lib/hook.c b/lib/hook.c
index 5a8ad00d66..895243aad7 100644
--- a/lib/hook.c
+++ b/lib/hook.c
@@ -23,7 +23,7 @@
#include "memory.h"
#include "hook.h"
-DEFINE_MTYPE_STATIC(LIB, HOOK_ENTRY, "Hook entry")
+DEFINE_MTYPE_STATIC(LIB, HOOK_ENTRY, "Hook entry");
void _hook_register(struct hook *hook, struct hookent *stackent, void *funcptr,
void *arg, bool has_arg, struct frrmod_runtime *module,
diff --git a/lib/hook.h b/lib/hook.h
index bef5351e90..ff3ef29fa3 100644
--- a/lib/hook.h
+++ b/lib/hook.h
@@ -35,10 +35,10 @@ extern "C" {
*
* mydaemon.h:
* #include "hook.h"
- * DECLARE_HOOK (some_update_event, (struct eventinfo *info), (info))
+ * DECLARE_HOOK (some_update_event, (struct eventinfo *info), (info));
*
* mydaemon.c:
- * DEFINE_HOOK (some_update_event, (struct eventinfo *info), (info))
+ * DEFINE_HOOK (some_update_event, (struct eventinfo *info), (info));
* ...
* hook_call (some_update_event, info)
*
@@ -184,7 +184,7 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
#define HOOK_ADDARG(...) (hookarg , ## __VA_ARGS__)
/* use in header file - declares the hook and its arguments
- * usage: DECLARE_HOOK(my_hook, (int arg1, struct foo *arg2), (arg1, arg2))
+ * usage: DECLARE_HOOK(my_hook, (int arg1, struct foo *arg2), (arg1, arg2));
* as above, "passlist" must use the same order and same names as "arglist"
*
* theoretically passlist is not neccessary, but let's keep things simple and
@@ -201,7 +201,9 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
int(*funcptr) HOOK_ADDDEF arglist) \
{ \
return (void *)funcptr; \
- }
+ } \
+ MACRO_REQUIRE_SEMICOLON() /* end */
+
#define DECLARE_KOOH(hookname, arglist, passlist) \
DECLARE_HOOK(hookname, arglist, passlist)
@@ -230,7 +232,8 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
hooksum += hookp.farg HOOK_ADDARG passlist; \
} \
return hooksum; \
- }
+ } \
+ MACRO_REQUIRE_SEMICOLON() /* end */
#define DEFINE_HOOK(hookname, arglist, passlist) \
DEFINE_HOOK_INT(hookname, arglist, passlist, false)
diff --git a/lib/id_alloc.c b/lib/id_alloc.c
index 95096fa5f0..9179dc4299 100644
--- a/lib/id_alloc.c
+++ b/lib/id_alloc.c
@@ -29,13 +29,14 @@
#include <inttypes.h>
-DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR, "ID Number Allocator")
-DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR_NAME, "ID Number Allocator Name")
-DEFINE_MTYPE_STATIC(LIB, IDALLOC_DIRECTORY, "ID Number Allocator Directory")
+DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR, "ID Number Allocator");
+DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR_NAME, "ID Number Allocator Name");
+DEFINE_MTYPE_STATIC(LIB, IDALLOC_DIRECTORY, "ID Number Allocator Directory");
DEFINE_MTYPE_STATIC(LIB, IDALLOC_SUBDIRECTORY,
- "ID Number Allocator Subdirectory")
-DEFINE_MTYPE_STATIC(LIB, IDALLOC_PAGE, "ID Number Allocator Page")
-DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL, "ID Number temporary holding pool entry")
+ "ID Number Allocator Subdirectory");
+DEFINE_MTYPE_STATIC(LIB, IDALLOC_PAGE, "ID Number Allocator Page");
+DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL,
+ "ID Number temporary holding pool entry");
#if UINT_MAX >= UINT32_MAX
#define FFS32(x) ffs(x)
diff --git a/lib/if.c b/lib/if.c
index 7ec53d356d..629ef4e708 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -39,11 +39,11 @@
#include "lib/if_clippy.c"
#endif
-DEFINE_MTYPE_STATIC(LIB, IF, "Interface")
-DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected")
-DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected")
-DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
-DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
+DEFINE_MTYPE_STATIC(LIB, IF, "Interface");
+DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected");
+DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected");
+DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label");
+DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters");
static struct interface *if_lookup_by_ifindex(ifindex_t ifindex,
vrf_id_t vrf_id);
@@ -53,10 +53,10 @@ static int if_cmp_index_func(const struct interface *ifp1,
RB_GENERATE(if_name_head, interface, name_entry, if_cmp_func);
RB_GENERATE(if_index_head, interface, index_entry, if_cmp_index_func);
-DEFINE_QOBJ_TYPE(interface)
+DEFINE_QOBJ_TYPE(interface);
-DEFINE_HOOK(if_add, (struct interface * ifp), (ifp))
-DEFINE_KOOH(if_del, (struct interface * ifp), (ifp))
+DEFINE_HOOK(if_add, (struct interface * ifp), (ifp));
+DEFINE_KOOH(if_del, (struct interface * ifp), (ifp));
static struct interface_master{
int (*create_hook)(struct interface *ifp);
diff --git a/lib/if.h b/lib/if.h
index 5bf52936ae..f425ba8bce 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -31,7 +31,7 @@
extern "C" {
#endif
-DECLARE_MTYPE(CONNECTED_LABEL)
+DECLARE_MTYPE(CONNECTED_LABEL);
/* Interface link-layer type, if known. Derived from:
*
@@ -301,14 +301,14 @@ struct interface {
*/
bool configured;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
RB_HEAD(if_name_head, interface);
RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func)
RB_HEAD(if_index_head, interface);
RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_index_func)
-DECLARE_QOBJ_TYPE(interface)
+DECLARE_QOBJ_TYPE(interface);
#define IFNAME_RB_INSERT(vrf, ifp) \
({ \
@@ -378,8 +378,8 @@ DECLARE_QOBJ_TYPE(interface)
* can use 1000+ so they run after the daemon has initialised daemon-specific
* interface data
*/
-DECLARE_HOOK(if_add, (struct interface * ifp), (ifp))
-DECLARE_KOOH(if_del, (struct interface * ifp), (ifp))
+DECLARE_HOOK(if_add, (struct interface * ifp), (ifp));
+DECLARE_KOOH(if_del, (struct interface * ifp), (ifp));
#define METRIC_MAX (~0)
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 1973d40be4..8282e476df 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -26,10 +26,11 @@
#include "if.h"
#include "if_rmap.h"
-DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX, "Interface route map container")
-DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX_NAME, "Interface route map container name")
-DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map")
-DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name")
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX, "Interface route map container");
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX_NAME,
+ "Interface route map container name");
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map");
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name");
static struct list *if_rmap_ctx_list;
diff --git a/lib/keychain.c b/lib/keychain.c
index 82fd6a65f2..db5c23b1ba 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -25,11 +25,11 @@
#include "linklist.h"
#include "keychain.h"
-DEFINE_MTYPE_STATIC(LIB, KEY, "Key")
-DEFINE_MTYPE_STATIC(LIB, KEYCHAIN, "Key chain")
+DEFINE_MTYPE_STATIC(LIB, KEY, "Key");
+DEFINE_MTYPE_STATIC(LIB, KEYCHAIN, "Key chain");
-DEFINE_QOBJ_TYPE(keychain)
-DEFINE_QOBJ_TYPE(key)
+DEFINE_QOBJ_TYPE(keychain);
+DEFINE_QOBJ_TYPE(key);
/* Master list of key chain. */
static struct list *keychain_list;
diff --git a/lib/keychain.h b/lib/keychain.h
index e5cf39f7c6..eb6d2f175e 100644
--- a/lib/keychain.h
+++ b/lib/keychain.h
@@ -32,9 +32,9 @@ struct keychain {
struct list *key;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
-DECLARE_QOBJ_TYPE(keychain)
+DECLARE_QOBJ_TYPE(keychain);
struct key_range {
time_t start;
@@ -51,9 +51,9 @@ struct key {
struct key_range send;
struct key_range accept;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
-DECLARE_QOBJ_TYPE(key)
+DECLARE_QOBJ_TYPE(key);
extern void keychain_init(void);
extern struct keychain *keychain_lookup(const char *);
diff --git a/lib/ldp_sync.c b/lib/ldp_sync.c
index c9d7eb37cf..8912d15589 100644
--- a/lib/ldp_sync.c
+++ b/lib/ldp_sync.c
@@ -31,7 +31,7 @@
#include "ldp_sync.h"
/* Library code */
-DEFINE_MTYPE_STATIC(LIB, LDP_SYNC_INFO, "LDP SYNC info")
+DEFINE_MTYPE_STATIC(LIB, LDP_SYNC_INFO, "LDP SYNC info");
/*
* ldp_sync_info_create - Allocate the LDP_SYNC information
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 51b97369c9..5b0a523fb5 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -45,10 +45,10 @@
#include "defaults.h"
#include "frrscript.h"
-DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
-DEFINE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm))
-DEFINE_KOOH(frr_early_fini, (), ())
-DEFINE_KOOH(frr_fini, (), ())
+DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm));
+DEFINE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm));
+DEFINE_KOOH(frr_early_fini, (), ());
+DEFINE_KOOH(frr_fini, (), ());
const char frr_sysconfdir[] = SYSCONFDIR;
char frr_vtydir[256];
diff --git a/lib/libfrr.h b/lib/libfrr.h
index 825f502bdf..db0f364986 100644
--- a/lib/libfrr.h
+++ b/lib/libfrr.h
@@ -124,8 +124,8 @@ struct frr_daemon_info {
__VA_ARGS__}; \
FRR_COREMOD_SETUP(.name = #execname, \
.description = #execname " daemon", \
- .version = FRR_VERSION, ) \
-/* end */
+ .version = FRR_VERSION, ); \
+ MACRO_REQUIRE_SEMICOLON() /* end */
extern void frr_init_vtydir(void);
extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv);
@@ -141,8 +141,8 @@ extern enum frr_cli_mode frr_get_cli_mode(void);
extern uint32_t frr_get_fd_limit(void);
extern bool frr_is_startup_fd(int fd);
-DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
-DECLARE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm))
+DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm));
+DECLARE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm));
extern void frr_config_fork(void);
extern void frr_run(struct thread_master *master);
@@ -153,10 +153,10 @@ extern bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
/* these two are before the protocol daemon does its own shutdown
* it's named this way being the counterpart to frr_late_init */
-DECLARE_KOOH(frr_early_fini, (), ())
+DECLARE_KOOH(frr_early_fini, (), ());
extern void frr_early_fini(void);
/* and these two are after the daemon did its own cleanup */
-DECLARE_KOOH(frr_fini, (), ())
+DECLARE_KOOH(frr_fini, (), ());
extern void frr_fini(void);
extern char config_default[512];
diff --git a/lib/link_state.c b/lib/link_state.c
index ecf0d0698d..7f0d2a1245 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -36,7 +36,7 @@
#include "link_state.h"
/* Link State Memory allocation */
-DEFINE_MTYPE_STATIC(LIB, LS_DB, "Link State Database")
+DEFINE_MTYPE_STATIC(LIB, LS_DB, "Link State Database");
/**
* Link State Node management functions
diff --git a/lib/link_state.h b/lib/link_state.h
index 93669f5b23..f9eb59b76a 100644
--- a/lib/link_state.h
+++ b/lib/link_state.h
@@ -324,7 +324,7 @@ extern int ls_attributes_same(struct ls_attributes *a1,
*/
/* Link State Vertex structure */
-PREDECL_RBTREE_UNIQ(vertices)
+PREDECL_RBTREE_UNIQ(vertices);
struct ls_vertex {
struct vertices_item entry; /* Entry in RB Tree */
uint64_t key; /* Unique Key identifier */
@@ -335,7 +335,7 @@ struct ls_vertex {
};
/* Link State Edge structure */
-PREDECL_RBTREE_UNIQ(edges)
+PREDECL_RBTREE_UNIQ(edges);
struct ls_edge {
struct edges_item entry; /* Entry in RB tree */
uint64_t key; /* Unique Key identifier */
@@ -345,7 +345,7 @@ struct ls_edge {
};
/* Link State Subnet structure */
-PREDECL_RBTREE_UNIQ(subnets)
+PREDECL_RBTREE_UNIQ(subnets);
struct ls_subnet {
struct subnets_item entry; /* Entry in RB tree */
struct prefix key; /* Unique Key identifier */
@@ -359,21 +359,21 @@ macro_inline int vertex_cmp(const struct ls_vertex *node1,
{
return (node1->key - node2->key);
}
-DECLARE_RBTREE_UNIQ(vertices, struct ls_vertex, entry, vertex_cmp)
+DECLARE_RBTREE_UNIQ(vertices, struct ls_vertex, entry, vertex_cmp);
macro_inline int edge_cmp(const struct ls_edge *edge1,
const struct ls_edge *edge2)
{
return (edge1->key - edge2->key);
}
-DECLARE_RBTREE_UNIQ(edges, struct ls_edge, entry, edge_cmp)
+DECLARE_RBTREE_UNIQ(edges, struct ls_edge, entry, edge_cmp);
macro_inline int subnet_cmp(const struct ls_subnet *a,
const struct ls_subnet *b)
{
return prefix_cmp(&a->key, &b->key);
}
-DECLARE_RBTREE_UNIQ(subnets, struct ls_subnet, entry, subnet_cmp)
+DECLARE_RBTREE_UNIQ(subnets, struct ls_subnet, entry, subnet_cmp);
/* Link State TED Structure */
struct ls_ted {
diff --git a/lib/linklist.c b/lib/linklist.c
index 43c2002231..5de6c8a817 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -25,8 +25,8 @@
#include "memory.h"
#include "libfrr_trace.h"
-DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List")
-DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node")
+DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List");
+DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node");
struct list *list_new(void)
{
diff --git a/lib/log_vty.c b/lib/log_vty.c
index d1dcac2340..c26621ae99 100644
--- a/lib/log_vty.c
+++ b/lib/log_vty.c
@@ -33,7 +33,7 @@
#define ZLOG_MAXLVL(a, b) MAX(a, b)
-DEFINE_HOOK(zlog_rotate, (), ())
+DEFINE_HOOK(zlog_rotate, (), ());
static const int log_default_lvl = LOG_DEBUG;
@@ -532,6 +532,28 @@ DEFUN (no_config_log_timestamp_precision,
return CMD_SUCCESS;
}
+DEFPY (config_log_ec,
+ config_log_ec_cmd,
+ "[no] log error-category",
+ NO_STR
+ "Logging control\n"
+ "Prefix log message text with [EC 9999] code\n")
+{
+ zlog_set_prefix_ec(!no);
+ return CMD_SUCCESS;
+}
+
+DEFPY (config_log_xid,
+ config_log_xid_cmd,
+ "[no] log unique-id",
+ NO_STR
+ "Logging control\n"
+ "Prefix log message text with [XXXXX-XXXXX] identifier\n")
+{
+ zlog_set_prefix_xid(!no);
+ return CMD_SUCCESS;
+}
+
DEFPY (config_log_filterfile,
config_log_filterfile_cmd,
"log filtered-file FILENAME [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>$levelarg]",
@@ -699,6 +721,11 @@ void log_config_write(struct vty *vty)
if (zt_file.ts_subsec > 0)
vty_out(vty, "log timestamp precision %d\n",
zt_file.ts_subsec);
+
+ if (!zlog_get_prefix_ec())
+ vty_out(vty, "no log error-category\n");
+ if (!zlog_get_prefix_xid())
+ vty_out(vty, "no log unique-id\n");
}
static int log_vty_init(const char *progname, const char *protoname,
@@ -707,6 +734,9 @@ static int log_vty_init(const char *progname, const char *protoname,
zlog_progname = progname;
zlog_protoname = protoname;
+ zlog_set_prefix_ec(true);
+ zlog_set_prefix_xid(true);
+
zlog_filterfile_init(&zt_filterfile);
zlog_file_set_fd(&zt_stdout, STDOUT_FILENO);
@@ -737,6 +767,8 @@ void log_cmd_init(void)
install_element(CONFIG_NODE, &no_config_log_record_priority_cmd);
install_element(CONFIG_NODE, &config_log_timestamp_precision_cmd);
install_element(CONFIG_NODE, &no_config_log_timestamp_precision_cmd);
+ install_element(CONFIG_NODE, &config_log_ec_cmd);
+ install_element(CONFIG_NODE, &config_log_xid_cmd);
install_element(VIEW_NODE, &show_log_filter_cmd);
install_element(CONFIG_NODE, &log_filter_cmd);
diff --git a/lib/log_vty.h b/lib/log_vty.h
index 16c4475467..f0fb7d3dba 100644
--- a/lib/log_vty.h
+++ b/lib/log_vty.h
@@ -34,7 +34,7 @@ extern void log_config_write(struct vty *vty);
extern int log_level_match(const char *s);
extern void log_show_syslog(struct vty *vty);
-DECLARE_HOOK(zlog_rotate, (), ())
+DECLARE_HOOK(zlog_rotate, (), ());
extern void zlog_rotate(void);
#ifdef __cplusplus
diff --git a/lib/memory.c b/lib/memory.c
index a377d3b945..0dc8e90524 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -34,8 +34,8 @@
static struct memgroup *mg_first = NULL;
struct memgroup **mg_insert = &mg_first;
-DEFINE_MGROUP(LIB, "libfrr")
-DEFINE_MTYPE(LIB, TMP, "Temporary memory")
+DEFINE_MGROUP(LIB, "libfrr");
+DEFINE_MTYPE(LIB, TMP, "Temporary memory");
static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)
{
diff --git a/lib/memory.h b/lib/memory.h
index e9db12fce2..c95602f485 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -56,20 +56,20 @@ struct memgroup {
/* macro usage:
*
* mydaemon.h
- * DECLARE_MGROUP(MYDAEMON)
- * DECLARE_MTYPE(MYDAEMON_COMMON)
+ * DECLARE_MGROUP(MYDAEMON);
+ * DECLARE_MTYPE(MYDAEMON_COMMON);
*
* mydaemon.c
- * DEFINE_MGROUP(MYDAEMON, "my daemon memory")
+ * DEFINE_MGROUP(MYDAEMON, "my daemon memory");
* DEFINE_MTYPE(MYDAEMON, MYDAEMON_COMMON,
- * "this mtype is used in multiple files in mydaemon")
+ * "this mtype is used in multiple files in mydaemon");
* foo = qmalloc(MTYPE_MYDAEMON_COMMON, sizeof(*foo))
*
* mydaemon_io.c
* bar = qmalloc(MTYPE_MYDAEMON_COMMON, sizeof(*bar))
*
* DEFINE_MTYPE_STATIC(MYDAEMON, MYDAEMON_IO,
- * "this mtype is used only in this file")
+ * "this mtype is used only in this file");
* baz = qmalloc(MTYPE_MYDAEMON_IO, sizeof(*baz))
*
* Note: Naming conventions (MGROUP_ and MTYPE_ prefixes are enforced
@@ -78,7 +78,7 @@ struct memgroup {
* but MGROUP_* aren't.
*/
-#define DECLARE_MGROUP(name) extern struct memgroup _mg_##name;
+#define DECLARE_MGROUP(name) extern struct memgroup _mg_##name
#define _DEFINE_MGROUP(mname, desc, ...) \
struct memgroup _mg_##mname \
__attribute__((section(".data.mgroups"))) = { \
@@ -104,7 +104,7 @@ struct memgroup {
_mg_##mname.next->ref = _mg_##mname.ref; \
*_mg_##mname.ref = _mg_##mname.next; \
} \
- /* end */
+ MACRO_REQUIRE_SEMICOLON() /* end */
#define DEFINE_MGROUP(mname, desc) \
_DEFINE_MGROUP(mname, desc, )
@@ -112,7 +112,7 @@ struct memgroup {
_DEFINE_MGROUP(mname, desc, .active_at_exit = true)
#define DECLARE_MTYPE(name) \
- extern struct memtype MTYPE_##name[1]; \
+ extern struct memtype MTYPE_##name[1] \
/* end */
#define DEFINE_MTYPE_ATTR(group, mname, attr, desc) \
@@ -140,7 +140,7 @@ struct memgroup {
MTYPE_##mname->next->ref = MTYPE_##mname->ref; \
*MTYPE_##mname->ref = MTYPE_##mname->next; \
} \
- /* end */
+ MACRO_REQUIRE_SEMICOLON() /* end */
#define DEFINE_MTYPE(group, name, desc) \
DEFINE_MTYPE_ATTR(group, name, , desc) \
@@ -150,8 +150,8 @@ struct memgroup {
DEFINE_MTYPE_ATTR(group, name, static, desc) \
/* end */
-DECLARE_MGROUP(LIB)
-DECLARE_MTYPE(TMP)
+DECLARE_MGROUP(LIB);
+DECLARE_MTYPE(TMP);
extern void *qmalloc(struct memtype *mt, size_t size)
diff --git a/lib/module.c b/lib/module.c
index 3d299a6a2e..d2491a3479 100644
--- a/lib/module.c
+++ b/lib/module.c
@@ -27,8 +27,8 @@
#include "memory.h"
#include "version.h"
-DEFINE_MTYPE_STATIC(LIB, MODULE_LOADNAME, "Module loading name")
-DEFINE_MTYPE_STATIC(LIB, MODULE_LOADARGS, "Module loading arguments")
+DEFINE_MTYPE_STATIC(LIB, MODULE_LOADNAME, "Module loading name");
+DEFINE_MTYPE_STATIC(LIB, MODULE_LOADARGS, "Module loading arguments");
static struct frrmod_info frrmod_default_info = {
.name = "libfrr",
@@ -43,7 +43,7 @@ union _frrmod_runtime_u frrmod_default = {
},
};
-XREF_SETUP()
+XREF_SETUP();
// if defined(HAVE_SYS_WEAK_ALIAS_ATTRIBUTE)
// union _frrmod_runtime_u _frrmod_this_module
diff --git a/lib/module.h b/lib/module.h
index 5d8d9cfbcc..6275877cb3 100644
--- a/lib/module.h
+++ b/lib/module.h
@@ -79,12 +79,13 @@ extern union _frrmod_runtime_u _frrmod_this_module;
NULL, \
&_frrmod_info, \
}}; \
- XREF_SETUP() \
- /* end */
+ XREF_SETUP(); \
+ MACRO_REQUIRE_SEMICOLON() /* end */
#define FRR_MODULE_SETUP(...) \
- FRR_COREMOD_SETUP(__VA_ARGS__) \
- DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r;
+ FRR_COREMOD_SETUP(__VA_ARGS__); \
+ DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r; \
+ MACRO_REQUIRE_SEMICOLON() /* end */
extern struct frrmod_runtime *frrmod_list;
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index c688433983..cde842b88c 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -40,8 +40,8 @@
#include "vrf.h"
#include "lib_errors.h"
-DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context")
-DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name")
+DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context");
+DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name");
static inline int ns_compare(const struct ns *ns, const struct ns *ns2);
static struct ns *ns_lookup_name_internal(const char *name);
diff --git a/lib/netns_other.c b/lib/netns_other.c
index 3fc4b8df4b..b6570d3b9e 100644
--- a/lib/netns_other.c
+++ b/lib/netns_other.c
@@ -26,8 +26,8 @@
#include "log.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context")
-DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name")
+DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context");
+DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name");
static inline int ns_compare(const struct ns *ns, const struct ns *ns2);
diff --git a/lib/nexthop.c b/lib/nexthop.c
index dd8c108205..17ef95c687 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -34,8 +34,8 @@
#include "vrf.h"
#include "nexthop_group.h"
-DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop")
-DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label")
+DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop");
+DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label");
static int _nexthop_labels_cmp(const struct nexthop *nh1,
const struct nexthop *nh2)
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index dee98ad8d7..4fee9bde3c 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -32,7 +32,7 @@
#include "lib/nexthop_group_clippy.c"
#endif
-DEFINE_MTYPE_STATIC(LIB, NEXTHOP_GROUP, "Nexthop Group")
+DEFINE_MTYPE_STATIC(LIB, NEXTHOP_GROUP, "Nexthop Group");
/*
* Internal struct used to hold nhg config strings
@@ -620,7 +620,7 @@ static void nhgc_delete(struct nexthop_group_cmd *nhgc)
XFREE(MTYPE_TMP, nhgc);
}
-DEFINE_QOBJ_TYPE(nexthop_group_cmd)
+DEFINE_QOBJ_TYPE(nexthop_group_cmd);
DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NHGNAME",
"Enter into the nexthop-group submode\n"
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
index 5f7bde0def..8e75e5c6ac 100644
--- a/lib/nexthop_group.h
+++ b/lib/nexthop_group.h
@@ -97,12 +97,12 @@ struct nexthop_group_cmd {
struct list *nhg_list;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
RB_HEAD(nhgc_entry_head, nexthp_group_cmd);
RB_PROTOTYPE(nhgc_entry_head, nexthop_group_cmd, nhgc_entry,
nexthop_group_cmd_compare)
-DECLARE_QOBJ_TYPE(nexthop_group_cmd)
+DECLARE_QOBJ_TYPE(nexthop_group_cmd);
/*
* Initialize nexthop_groups. If you are interested in when
diff --git a/lib/northbound.c b/lib/northbound.c
index b6d3518285..34ad5dbfa9 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -32,9 +32,9 @@
#include "northbound_db.h"
#include "frrstr.h"
-DEFINE_MTYPE_STATIC(LIB, NB_NODE, "Northbound Node")
-DEFINE_MTYPE_STATIC(LIB, NB_CONFIG, "Northbound Configuration")
-DEFINE_MTYPE_STATIC(LIB, NB_CONFIG_ENTRY, "Northbound Configuration Entry")
+DEFINE_MTYPE_STATIC(LIB, NB_NODE, "Northbound Node");
+DEFINE_MTYPE_STATIC(LIB, NB_CONFIG, "Northbound Configuration");
+DEFINE_MTYPE_STATIC(LIB, NB_CONFIG_ENTRY, "Northbound Configuration Entry");
/* Running configuration - shouldn't be modified directly. */
struct nb_config *running_config;
@@ -1260,27 +1260,36 @@ static int nb_callback_configuration(struct nb_context *context,
}
if (ret != NB_OK) {
- int priority;
- enum lib_log_refs ref;
-
yang_dnode_get_path(dnode, xpath, sizeof(xpath));
switch (event) {
case NB_EV_VALIDATE:
- priority = LOG_WARNING;
- ref = EC_LIB_NB_CB_CONFIG_VALIDATE;
+ flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
+ "error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]%s%s",
+ nb_err_name(ret), nb_event_name(event),
+ nb_operation_name(operation), xpath,
+ errmsg[0] ? " message: " : "", errmsg);
break;
case NB_EV_PREPARE:
- priority = LOG_WARNING;
- ref = EC_LIB_NB_CB_CONFIG_PREPARE;
+ flog_warn(EC_LIB_NB_CB_CONFIG_PREPARE,
+ "error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]%s%s",
+ nb_err_name(ret), nb_event_name(event),
+ nb_operation_name(operation), xpath,
+ errmsg[0] ? " message: " : "", errmsg);
break;
case NB_EV_ABORT:
- priority = LOG_WARNING;
- ref = EC_LIB_NB_CB_CONFIG_ABORT;
+ flog_warn(EC_LIB_NB_CB_CONFIG_ABORT,
+ "error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]%s%s",
+ nb_err_name(ret), nb_event_name(event),
+ nb_operation_name(operation), xpath,
+ errmsg[0] ? " message: " : "", errmsg);
break;
case NB_EV_APPLY:
- priority = LOG_ERR;
- ref = EC_LIB_NB_CB_CONFIG_APPLY;
+ flog_err(EC_LIB_NB_CB_CONFIG_APPLY,
+ "error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]%s%s",
+ nb_err_name(ret), nb_event_name(event),
+ nb_operation_name(operation), xpath,
+ errmsg[0] ? " message: " : "", errmsg);
break;
default:
flog_err(EC_LIB_DEVELOPMENT,
@@ -1288,15 +1297,6 @@ static int nb_callback_configuration(struct nb_context *context,
event, xpath);
exit(1);
}
-
- flog(priority, ref,
- "error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]",
- nb_err_name(ret), nb_event_name(event),
- nb_operation_name(operation), xpath);
- if (strlen(errmsg) > 0)
- flog(priority, ref,
- "error processing configuration change: %s",
- errmsg);
}
return ret;
diff --git a/lib/northbound.h b/lib/northbound.h
index 3e1342f985..21aad64a09 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -677,9 +677,9 @@ typedef int (*nb_oper_data_cb)(const struct lys_node *snode,
/* Hooks. */
DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments),
- (xpath, arguments))
-DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty))
-DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set))
+ (xpath, arguments));
+DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
+DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
/* Northbound debugging records */
extern struct debug nb_dbg_cbs_config;
diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c
index 8acba9fd2b..3d8771ffbc 100644
--- a/lib/northbound_confd.c
+++ b/lib/northbound_confd.c
@@ -32,7 +32,7 @@
#include <confd_dp.h>
#include <confd_maapi.h>
-DEFINE_MTYPE_STATIC(LIB, CONFD, "ConfD module")
+DEFINE_MTYPE_STATIC(LIB, CONFD, "ConfD module");
static struct debug nb_dbg_client_confd = {0, "Northbound client: ConfD"};
@@ -1483,4 +1483,5 @@ static int frr_confd_module_init(void)
FRR_MODULE_SETUP(.name = "frr_confd", .version = FRR_VERSION,
.description = "FRR ConfD integration module",
- .init = frr_confd_module_init, )
+ .init = frr_confd_module_init,
+);
diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp
index abdae993b1..d042e15dad 100644
--- a/lib/northbound_grpc.cpp
+++ b/lib/northbound_grpc.cpp
@@ -1412,4 +1412,5 @@ static int frr_grpc_module_init(void)
FRR_MODULE_SETUP(.name = "frr_grpc", .version = FRR_VERSION,
.description = "FRR gRPC northbound module",
- .init = frr_grpc_module_init, )
+ .init = frr_grpc_module_init,
+);
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index c027f4de72..9fc640ceea 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -32,7 +32,7 @@
#include <sysrepo/values.h>
#include <sysrepo/xpath.h>
-DEFINE_MTYPE_STATIC(LIB, SYSREPO, "Sysrepo module")
+DEFINE_MTYPE_STATIC(LIB, SYSREPO, "Sysrepo module");
static struct debug nb_dbg_client_sysrepo = {0, "Northbound client: Sysrepo"};
@@ -768,4 +768,5 @@ static int frr_sr_module_init(void)
FRR_MODULE_SETUP(.name = "frr_sysrepo", .version = FRR_VERSION,
.description = "FRR sysrepo integration module",
- .init = frr_sr_module_init, )
+ .init = frr_sr_module_init,
+);
diff --git a/lib/plist.c b/lib/plist.c
index fe4689becd..92c8b8ee55 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -33,10 +33,10 @@
#include "plist_int.h"
-DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List")
-DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str")
-DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry")
-DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table")
+DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List");
+DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str");
+DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry");
+DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table");
/* not currently changeable, code assumes bytes further down */
#define PLC_BITS 8
diff --git a/lib/prefix.c b/lib/prefix.c
index 5e5c2d89a8..afc4d3d5c2 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -32,8 +32,8 @@
#include "printfrr.h"
#include "vxlan.h"
-DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix")
-DEFINE_MTYPE_STATIC(LIB, PREFIX_FLOWSPEC, "Prefix Flowspec")
+DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix");
+DEFINE_MTYPE_STATIC(LIB, PREFIX_FLOWSPEC, "Prefix Flowspec");
/* Maskbit. */
static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
diff --git a/lib/printfrr.h b/lib/printfrr.h
index a775e1517b..418e839d97 100644
--- a/lib/printfrr.h
+++ b/lib/printfrr.h
@@ -160,6 +160,30 @@ void printfrr_ext_reg(const struct printfrr_ext *);
} \
/* end */
+/* fbuf helper functions */
+
+static inline ssize_t bputs(struct fbuf *buf, const char *str)
+{
+ size_t len = strlen(str);
+ size_t ncopy;
+
+ if (!buf)
+ return len;
+
+ ncopy = MIN(len, (size_t)(buf->buf + buf->len - buf->pos));
+ memcpy(buf->pos, str, ncopy);
+ buf->pos += ncopy;
+
+ return len;
+}
+
+static inline ssize_t bputch(struct fbuf *buf, char ch)
+{
+ if (buf && buf->pos < buf->buf + buf->len)
+ *buf->pos++ = ch;
+ return 1;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/privs.c b/lib/privs.c
index 5ca3c0d886..49761af871 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -28,7 +28,7 @@
#include "lib_errors.h"
#include "lib/queue.h"
-DEFINE_MTYPE_STATIC(LIB, PRIVS, "Privilege information")
+DEFINE_MTYPE_STATIC(LIB, PRIVS, "Privilege information");
/*
* Different capabilities/privileges apis have different characteristics: some
diff --git a/lib/pullwr.c b/lib/pullwr.c
index 0c326f29d4..15563d2471 100644
--- a/lib/pullwr.c
+++ b/lib/pullwr.c
@@ -48,8 +48,8 @@ struct pullwr {
int64_t maxspin; /* PULLWR_MAXSPIN */
};
-DEFINE_MTYPE_STATIC(LIB, PULLWR_HEAD, "pull-driven write controller")
-DEFINE_MTYPE_STATIC(LIB, PULLWR_BUF, "pull-driven write buffer")
+DEFINE_MTYPE_STATIC(LIB, PULLWR_HEAD, "pull-driven write controller");
+DEFINE_MTYPE_STATIC(LIB, PULLWR_BUF, "pull-driven write buffer");
static int pullwr_run(struct thread *t);
diff --git a/lib/qobj.c b/lib/qobj.c
index cb3254cbe9..c6cb36c058 100644
--- a/lib/qobj.c
+++ b/lib/qobj.c
@@ -43,7 +43,7 @@ static int qobj_cmp(const struct qobj_node *na, const struct qobj_node *nb)
}
DECLARE_HASH(qobj_nodes, struct qobj_node, nodehash,
- qobj_cmp, qobj_hash)
+ qobj_cmp, qobj_hash);
static pthread_rwlock_t nodes_lock;
static struct qobj_nodes_head nodes = { };
diff --git a/lib/qobj.h b/lib/qobj.h
index 400ae0151c..5012c98d74 100644
--- a/lib/qobj.h
+++ b/lib/qobj.h
@@ -83,7 +83,7 @@ struct qobj_nodetype {
RESERVED_SPACE_STRUCT(qobj_nodetype_capnp, capnp, 256)
};
-PREDECL_HASH(qobj_nodes)
+PREDECL_HASH(qobj_nodes);
/* anchor to be embedded somewhere in the object's struct */
struct qobj_node {
@@ -92,7 +92,7 @@ struct qobj_node {
const struct qobj_nodetype *type;
};
-#define QOBJ_FIELDS struct qobj_node qobj_node;
+#define QOBJ_FIELDS struct qobj_node qobj_node
/* call these at the end of any _create function (QOBJ_REG)
* and beginning of any _destroy function (QOBJ_UNREG) */
@@ -118,16 +118,19 @@ void *qobj_get_typed(uint64_t id, const struct qobj_nodetype *type);
/* type declarations */
#define DECLARE_QOBJ_TYPE(structname) \
- extern const struct qobj_nodetype qobj_t_##structname;
+ extern const struct qobj_nodetype qobj_t_##structname \
+ /* end */
#define DEFINE_QOBJ_TYPE(structname) \
const struct qobj_nodetype qobj_t_##structname = { \
.node_member_offset = \
- (ptrdiff_t)offsetof(struct structname, qobj_node)};
+ (ptrdiff_t)offsetof(struct structname, qobj_node)} \
+ /* end */
#define DEFINE_QOBJ_TYPE_INIT(structname, ...) \
const struct qobj_nodetype qobj_t_##structname = { \
.node_member_offset = \
(ptrdiff_t)offsetof(struct structname, qobj_node), \
- __VA_ARGS__};
+ __VA_ARGS__} \
+ /* end */
/* ID dereference with typecheck.
* will return NULL if id not found or wrong type. */
diff --git a/lib/resolver.c b/lib/resolver.c
index c01284e29e..c2153e0a5e 100644
--- a/lib/resolver.c
+++ b/lib/resolver.c
@@ -21,7 +21,7 @@
#include "command.h"
#include "xref.h"
-XREF_SETUP()
+XREF_SETUP();
struct resolver_state {
ares_channel channel;
diff --git a/lib/ringbuf.c b/lib/ringbuf.c
index 26c4e744b4..49221e7cb3 100644
--- a/lib/ringbuf.c
+++ b/lib/ringbuf.c
@@ -22,7 +22,7 @@
#include "ringbuf.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer")
+DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer");
struct ringbuf *ringbuf_new(size_t size)
{
diff --git a/lib/routemap.c b/lib/routemap.c
index 7714086672..b836b55aad 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -33,17 +33,17 @@
#include "lib_errors.h"
#include "table.h"
-DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map")
-DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name")
-DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index")
-DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule")
-DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str")
-DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled")
-DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency")
-DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP_DATA, "Route map dependency data")
-
-DEFINE_QOBJ_TYPE(route_map_index)
-DEFINE_QOBJ_TYPE(route_map)
+DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map");
+DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name");
+DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index");
+DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule");
+DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str");
+DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled");
+DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency");
+DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP_DATA, "Route map dependency data");
+
+DEFINE_QOBJ_TYPE(route_map_index);
+DEFINE_QOBJ_TYPE(route_map);
#define IPv4_PREFIX_LIST "ip address prefix-list"
#define IPv6_PREFIX_LIST "ipv6 address prefix-list"
diff --git a/lib/routemap.h b/lib/routemap.h
index 3e208c8cb5..bad3ca6d3d 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -32,9 +32,9 @@
extern "C" {
#endif
-DECLARE_MTYPE(ROUTE_MAP_NAME)
-DECLARE_MTYPE(ROUTE_MAP_RULE)
-DECLARE_MTYPE(ROUTE_MAP_COMPILED)
+DECLARE_MTYPE(ROUTE_MAP_NAME);
+DECLARE_MTYPE(ROUTE_MAP_RULE);
+DECLARE_MTYPE(ROUTE_MAP_COMPILED);
/* Route map's type. */
enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };
@@ -190,9 +190,9 @@ struct route_map_index {
/* List of match/sets contexts. */
TAILQ_HEAD(, routemap_hook_context) rhclist;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
-DECLARE_QOBJ_TYPE(route_map_index)
+DECLARE_QOBJ_TYPE(route_map_index);
/* Route map list structure. */
struct route_map {
@@ -225,9 +225,9 @@ struct route_map {
struct route_table *ipv4_prefix_table;
struct route_table *ipv6_prefix_table;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
-DECLARE_QOBJ_TYPE(route_map)
+DECLARE_QOBJ_TYPE(route_map);
/* Prototypes. */
extern void route_map_init(void);
diff --git a/lib/routing_nb.h b/lib/routing_nb.h
index ffba631a10..bdd12b262b 100644
--- a/lib/routing_nb.h
+++ b/lib/routing_nb.h
@@ -24,7 +24,7 @@ int routing_control_plane_protocols_control_plane_protocol_destroy(
* callbacks for routing to handle configuration events
* based on the control plane protocol
*/
-DECLARE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args))
+DECLARE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args));
void routing_control_plane_protocols_register_vrf_dependency(void);
diff --git a/lib/routing_nb_config.c b/lib/routing_nb_config.c
index 17698d2b87..f66f32015d 100644
--- a/lib/routing_nb_config.c
+++ b/lib/routing_nb_config.c
@@ -24,7 +24,7 @@
#include "routing_nb.h"
-DEFINE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args))
+DEFINE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args));
/*
* XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol
diff --git a/lib/skiplist.c b/lib/skiplist.c
index b79dfa6772..fc42857418 100644
--- a/lib/skiplist.c
+++ b/lib/skiplist.c
@@ -63,8 +63,8 @@
#include "lib_errors.h"
#include "network.h"
-DEFINE_MTYPE_STATIC(LIB, SKIP_LIST, "Skip List")
-DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node")
+DEFINE_MTYPE_STATIC(LIB, SKIP_LIST, "Skip List");
+DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node");
#define BitsInRandom 31
diff --git a/lib/smux.h b/lib/smux.h
index 57128b7928..c063833e41 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -157,7 +157,7 @@ extern void oid_copy_int(oid oid[], int *val);
extern void oid2string(oid oid[], int len, char *string);
extern void oid_copy_str(oid oid[], const char *string, int len);
-DECLARE_HOOK(agentx_enabled, (), ())
+DECLARE_HOOK(agentx_enabled, (), ());
#ifdef __cplusplus
}
diff --git a/lib/sockunion.c b/lib/sockunion.c
index c701da1e03..d65235b41c 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -29,7 +29,7 @@
#include "lib_errors.h"
#include "printfrr.h"
-DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union")
+DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union");
const char *inet_sutop(const union sockunion *su, char *str)
{
diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c
index ac6dd29f06..a273e93463 100644
--- a/lib/spf_backoff.c
+++ b/lib/spf_backoff.c
@@ -33,8 +33,8 @@
#include "thread.h"
#include "vty.h"
-DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF, "SPF backoff")
-DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF_NAME, "SPF backoff name")
+DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF, "SPF backoff");
+DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF_NAME, "SPF backoff name");
static bool debug_spf_backoff = false;
#define backoff_debug(...) \
diff --git a/lib/srcdest_table.c b/lib/srcdest_table.c
index ef82b7ac01..a115507192 100644
--- a/lib/srcdest_table.c
+++ b/lib/srcdest_table.c
@@ -30,7 +30,7 @@
#include "table.h"
#include "printfrr.h"
-DEFINE_MTYPE_STATIC(LIB, ROUTE_SRC_NODE, "Route source node")
+DEFINE_MTYPE_STATIC(LIB, ROUTE_SRC_NODE, "Route source node");
/* ----- functions to manage rnodes _with_ srcdest table ----- */
struct srcdest_rnode {
diff --git a/lib/stream.c b/lib/stream.c
index ef73c2fdc9..904ee73b10 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -31,8 +31,8 @@
#include "frr_pthread.h"
#include "lib_errors.h"
-DEFINE_MTYPE_STATIC(LIB, STREAM, "Stream")
-DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
+DEFINE_MTYPE_STATIC(LIB, STREAM, "Stream");
+DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO");
/* Tests whether a position is valid */
#define GETP_VALID(S, G) ((G) <= (S)->endp)
diff --git a/lib/strlcat.c b/lib/strlcat.c
index 39773d9ac8..a046822a94 100644
--- a/lib/strlcat.c
+++ b/lib/strlcat.c
@@ -64,10 +64,8 @@ size_t strlcat(char *__restrict dest,
(which the static_assert checks), then by the pigeonhole
principle, the two input strings must overlap, which is
undefined. */
-#if __STDC_VERSION__ >= 201112L
_Static_assert(sizeof(uintptr_t) == sizeof(size_t),
"theoretical maximum object size covers address space");
-#endif
return dest_length + src_length;
}
#endif /* HAVE_STRLCAT */
diff --git a/lib/subdir.am b/lib/subdir.am
index 38d1a3f773..bfd367b134 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -313,7 +313,7 @@ if SNMP
lib_LTLIBRARIES += lib/libfrrsnmp.la
endif
-lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99
+lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu11
lib_libfrrsnmp_la_LDFLAGS = -version-info 0:0:0
lib_libfrrsnmp_la_LIBADD = $(SNMP_LIBS)
lib_libfrrsnmp_la_SOURCES = \
diff --git a/lib/table.c b/lib/table.c
index 89e32182b5..dfd92c6189 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -29,8 +29,8 @@
#include "sockunion.h"
#include "libfrr_trace.h"
-DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table")
-DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
+DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table");
+DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node");
static void route_table_free(struct route_table *);
@@ -41,7 +41,7 @@ static int route_table_hash_cmp(const struct route_node *a,
}
DECLARE_HASH(rn_hash_node, struct route_node, nodehash, route_table_hash_cmp,
- prefix_hash_key)
+ prefix_hash_key);
/*
* route_table_init_with_delegate
*/
diff --git a/lib/table.h b/lib/table.h
index 5d620d332b..7e383dce80 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -31,7 +31,7 @@
extern "C" {
#endif
-DECLARE_MTYPE(ROUTE_NODE)
+DECLARE_MTYPE(ROUTE_NODE);
/*
* Forward declarations.
@@ -59,7 +59,7 @@ struct route_table_delegate_t_ {
route_table_destroy_node_func_t destroy_node;
};
-PREDECL_HASH(rn_hash_node)
+PREDECL_HASH(rn_hash_node);
/* Routing table top structure. */
struct route_table {
diff --git a/lib/termtable.c b/lib/termtable.c
index b22a1ad387..ddf8822853 100644
--- a/lib/termtable.c
+++ b/lib/termtable.c
@@ -24,7 +24,7 @@
#include "memory.h"
#include "termtable.h"
-DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table")
+DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table");
/* clang-format off */
const struct ttable_style ttable_styles[] = {
diff --git a/lib/thread.c b/lib/thread.c
index af01c75a44..866090341e 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -38,12 +38,12 @@
#include "libfrr_trace.h"
#include "libfrr.h"
-DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread")
-DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master")
-DEFINE_MTYPE_STATIC(LIB, THREAD_POLL, "Thread Poll Info")
-DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats")
+DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread");
+DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master");
+DEFINE_MTYPE_STATIC(LIB, THREAD_POLL, "Thread Poll Info");
+DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats");
-DECLARE_LIST(thread_list, struct thread, threaditem)
+DECLARE_LIST(thread_list, struct thread, threaditem);
struct cancel_req {
int flags;
@@ -68,7 +68,7 @@ static int thread_timer_cmp(const struct thread *a, const struct thread *b)
return 0;
}
-DECLARE_HEAP(thread_timer_list, struct thread, timeritem, thread_timer_cmp)
+DECLARE_HEAP(thread_timer_list, struct thread, timeritem, thread_timer_cmp);
#if defined(__APPLE__)
#include <mach/mach.h>
diff --git a/lib/thread.h b/lib/thread.h
index cdef531ad4..af68331131 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -41,8 +41,8 @@ struct rusage_t {
#define GETRUSAGE(X) thread_getrusage(X)
-PREDECL_LIST(thread_list)
-PREDECL_HEAP(thread_timer_list)
+PREDECL_LIST(thread_list);
+PREDECL_HEAP(thread_timer_list);
struct fd_handler {
/* number of pfd that fit in the allocated space of pfds. This is a
diff --git a/lib/typerb.h b/lib/typerb.h
index fca45e20d1..60e6d09016 100644
--- a/lib/typerb.h
+++ b/lib/typerb.h
@@ -65,7 +65,8 @@ struct typed_rb_entry *typed_rb_next(const struct typed_rb_entry *rbe);
#define _PREDECL_RBTREE(prefix) \
struct prefix ## _head { struct typed_rb_root rr; }; \
-struct prefix ## _item { struct typed_rb_entry re; };
+struct prefix ## _item { struct typed_rb_entry re; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_RBTREE_UNIQ(var) { }
#define INIT_RBTREE_NONUNIQ(var) { }
@@ -140,7 +141,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->rr.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_RBTREE_UNIQ(prefix) \
_PREDECL_RBTREE(prefix)
@@ -161,8 +162,8 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \
} \
TYPESAFE_FIND(prefix, type) \
\
-_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp) \
-/* ... */
+_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp); \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_RBTREE_NONUNIQ(prefix) \
_PREDECL_RBTREE(prefix)
@@ -188,8 +189,8 @@ macro_inline int prefix ## __cmp_uq(const struct typed_rb_entry *a, \
return 0; \
} \
\
-_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp_uq) \
-/* ... */
+_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp_uq); \
+MACRO_REQUIRE_SEMICOLON() /* end */
#ifdef __cplusplus
}
diff --git a/lib/typesafe.c b/lib/typesafe.c
index 69796e2d81..76705fad0d 100644
--- a/lib/typesafe.c
+++ b/lib/typesafe.c
@@ -25,9 +25,9 @@
#include "memory.h"
#include "network.h"
-DEFINE_MTYPE_STATIC(LIB, TYPEDHASH_BUCKET, "Typed-hash bucket")
-DEFINE_MTYPE_STATIC(LIB, SKIPLIST_OFLOW, "Skiplist overflow")
-DEFINE_MTYPE_STATIC(LIB, HEAP_ARRAY, "Typed-heap array")
+DEFINE_MTYPE_STATIC(LIB, TYPEDHASH_BUCKET, "Typed-hash bucket");
+DEFINE_MTYPE_STATIC(LIB, SKIPLIST_OFLOW, "Skiplist overflow");
+DEFINE_MTYPE_STATIC(LIB, HEAP_ARRAY, "Typed-heap array");
#if 0
static void hash_consistency_check(struct thash_head *head)
diff --git a/lib/typesafe.h b/lib/typesafe.h
index e134316dd9..27e7be1286 100644
--- a/lib/typesafe.h
+++ b/lib/typesafe.h
@@ -105,15 +105,16 @@ static inline void typesafe_list_add(struct slist_head *head,
/* use as:
*
- * PREDECL_LIST(namelist)
+ * PREDECL_LIST(namelist);
* struct name {
* struct namelist_item nlitem;
* }
- * DECLARE_LIST(namelist, struct name, nlitem)
+ * DECLARE_LIST(namelist, struct name, nlitem);
*/
#define PREDECL_LIST(prefix) \
struct prefix ## _head { struct slist_head sh; }; \
-struct prefix ## _item { struct slist_item si; };
+struct prefix ## _item { struct slist_item si; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_LIST(var) { .sh = { .last_next = &var.sh.first, }, }
@@ -191,7 +192,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->sh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
/* don't use these structs directly */
struct dlist_item {
@@ -218,7 +219,8 @@ static inline void typesafe_dlist_add(struct dlist_head *head,
*/
#define PREDECL_DLIST(prefix) \
struct prefix ## _head { struct dlist_head dh; }; \
-struct prefix ## _item { struct dlist_item di; };
+struct prefix ## _item { struct dlist_item di; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_DLIST(var) { .dh = { \
.hitem = { &var.dh.hitem, &var.dh.hitem }, }, }
@@ -295,7 +297,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->dh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
/* note: heap currently caps out at 4G items */
@@ -319,7 +321,8 @@ struct heap_head {
#define PREDECL_HEAP(prefix) \
struct prefix ## _head { struct heap_head hh; }; \
-struct prefix ## _item { struct heap_item hi; };
+struct prefix ## _item { struct heap_item hi; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_HEAP(var) { }
@@ -402,7 +405,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->hh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
extern void typesafe_heap_resize(struct heap_head *head, bool grow);
extern void typesafe_heap_pushdown(struct heap_head *head, uint32_t index,
@@ -438,7 +441,8 @@ struct ssort_head {
*/
#define _PREDECL_SORTLIST(prefix) \
struct prefix ## _head { struct ssort_head sh; }; \
-struct prefix ## _item { struct ssort_item si; };
+struct prefix ## _item { struct ssort_item si; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_SORTLIST_UNIQ(var) { }
#define INIT_SORTLIST_NONUNIQ(var) { }
@@ -537,10 +541,10 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->sh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define DECLARE_SORTLIST_UNIQ(prefix, type, field, cmpfn) \
- _DECLARE_SORTLIST(prefix, type, field, cmpfn, cmpfn) \
+ _DECLARE_SORTLIST(prefix, type, field, cmpfn, cmpfn); \
\
macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \
const type *item) \
@@ -555,7 +559,7 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \
return container_of(sitem, type, field.si); \
} \
TYPESAFE_FIND(prefix, type) \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define DECLARE_SORTLIST_NONUNIQ(prefix, type, field, cmpfn) \
macro_inline int _ ## prefix ## _cmp(const type *a, const type *b) \
@@ -569,8 +573,8 @@ macro_inline int _ ## prefix ## _cmp(const type *a, const type *b) \
return 1; \
return 0; \
} \
- _DECLARE_SORTLIST(prefix, type, field, cmpfn, _ ## prefix ## _cmp) \
-/* ... */
+ _DECLARE_SORTLIST(prefix, type, field, cmpfn, _ ## prefix ## _cmp); \
+MACRO_REQUIRE_SEMICOLON() /* end */
/* hash, "sorted" by hash value
@@ -616,7 +620,8 @@ extern void typesafe_hash_shrink(struct thash_head *head);
*/
#define PREDECL_HASH(prefix) \
struct prefix ## _head { struct thash_head hh; }; \
-struct prefix ## _item { struct thash_item hi; };
+struct prefix ## _item { struct thash_item hi; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_HASH(var) { }
@@ -734,7 +739,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->hh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
/* skiplist, sorted.
* can be used as priority queue with add / pop
@@ -769,7 +774,8 @@ struct sskip_head {
*/
#define _PREDECL_SKIPLIST(prefix) \
struct prefix ## _head { struct sskip_head sh; }; \
-struct prefix ## _item { struct sskip_item si; };
+struct prefix ## _item { struct sskip_item si; }; \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define INIT_SKIPLIST_UNIQ(var) { }
#define INIT_SKIPLIST_NONUNIQ(var) { }
@@ -840,7 +846,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->sh.count; \
} \
-/* ... */
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_SKIPLIST_UNIQ(prefix) \
_PREDECL_SKIPLIST(prefix)
@@ -862,8 +868,8 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \
TYPESAFE_FIND(prefix, type) \
\
_DECLARE_SKIPLIST(prefix, type, field, \
- prefix ## __cmp, prefix ## __cmp) \
-/* ... */
+ prefix ## __cmp, prefix ## __cmp); \
+MACRO_REQUIRE_SEMICOLON() /* end */
#define PREDECL_SKIPLIST_NONUNIQ(prefix) \
_PREDECL_SKIPLIST(prefix)
@@ -890,8 +896,8 @@ macro_inline int prefix ## __cmp_uq(const struct sskip_item *a, \
} \
\
_DECLARE_SKIPLIST(prefix, type, field, \
- prefix ## __cmp, prefix ## __cmp_uq) \
-/* ... */
+ prefix ## __cmp, prefix ## __cmp_uq); \
+MACRO_REQUIRE_SEMICOLON() /* end */
extern struct sskip_item *typesafe_skiplist_add(struct sskip_head *head,
diff --git a/lib/vector.c b/lib/vector.c
index 0631e836f6..565c49fd59 100644
--- a/lib/vector.c
+++ b/lib/vector.c
@@ -23,8 +23,8 @@
#include "vector.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector")
-DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index")
+DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector");
+DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index");
/* Initialize vector : allocate memory and return vector. */
vector vector_init(unsigned int size)
diff --git a/lib/vrf.c b/lib/vrf.c
index 0a91f4bc86..dff041cbc7 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -42,10 +42,10 @@
/* default VRF name value used when VRF backend is not NETNS */
#define VRF_DEFAULT_NAME_INTERNAL "default"
-DEFINE_MTYPE_STATIC(LIB, VRF, "VRF")
-DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map")
+DEFINE_MTYPE_STATIC(LIB, VRF, "VRF");
+DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map");
-DEFINE_QOBJ_TYPE(vrf)
+DEFINE_QOBJ_TYPE(vrf);
static __inline int vrf_id_compare(const struct vrf *, const struct vrf *);
static __inline int vrf_name_compare(const struct vrf *, const struct vrf *);
diff --git a/lib/vrf.h b/lib/vrf.h
index 333d68ce96..6cdb52244d 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -95,13 +95,13 @@ struct vrf {
/* Back pointer to namespace context */
void *ns_ctxt;
- QOBJ_FIELDS
+ QOBJ_FIELDS;
};
RB_HEAD(vrf_id_head, vrf);
RB_PROTOTYPE(vrf_id_head, vrf, id_entry, vrf_id_compare)
RB_HEAD(vrf_name_head, vrf);
RB_PROTOTYPE(vrf_name_head, vrf, name_entry, vrf_name_compare)
-DECLARE_QOBJ_TYPE(vrf)
+DECLARE_QOBJ_TYPE(vrf);
/* Allow VRF with netns as backend */
enum vrf_backend_type {
diff --git a/lib/vty.c b/lib/vty.c
index 4cefb5e80c..d44cc904c5 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -56,9 +56,9 @@
#include "lib/vty_clippy.c"
#endif
-DEFINE_MTYPE_STATIC(LIB, VTY, "VTY")
-DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer")
-DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history")
+DEFINE_MTYPE_STATIC(LIB, VTY, "VTY");
+DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer");
+DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history");
/* Vty events */
enum event {
diff --git a/lib/wheel.c b/lib/wheel.c
index 5bdd6292f9..1a0469b256 100644
--- a/lib/wheel.c
+++ b/lib/wheel.c
@@ -24,8 +24,8 @@
#include "wheel.h"
#include "log.h"
-DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL, "Timer Wheel")
-DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List")
+DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL, "Timer Wheel");
+DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List");
static int debug_timer_wheel = 0;
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 8eabdf52e7..2a8326c056 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -28,9 +28,9 @@
#include "command.h"
#include "log.h"
-DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue")
-DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_ITEM, "Work queue item")
-DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_NAME, "Work queue name string")
+DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue");
+DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_ITEM, "Work queue item");
+DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_NAME, "Work queue name string");
/* master list of work_queues */
static struct list _work_queues;
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 7c610f5dd6..b076ed0d28 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -30,7 +30,7 @@
extern "C" {
#endif
-DECLARE_MTYPE(WORK_QUEUE)
+DECLARE_MTYPE(WORK_QUEUE);
/* Hold time for the initial schedule of a queue run, in millisec */
#define WORK_QUEUE_DEFAULT_HOLD 50
diff --git a/lib/xref.c b/lib/xref.c
index 40efe51363..a41f91a228 100644
--- a/lib/xref.c
+++ b/lib/xref.c
@@ -93,8 +93,6 @@ static void xref_add_one(const struct xref *xref)
q = memrchr(filename, '/', p - filename);
if (q)
filename = q + 1;
- else
- filename = p + 1;
}
SHA256_Init(&sha);
diff --git a/lib/xref.h b/lib/xref.h
index b3243fa058..b1cb172b41 100644
--- a/lib/xref.h
+++ b/lib/xref.h
@@ -162,7 +162,7 @@ extern const struct xref * const __stop_xref_array[1] DSO_LOCAL;
xref_block_add(&_xref_block); \
} \
asm(XREF_NOTE); \
- /* end */
+ MACRO_REQUIRE_SEMICOLON() /* end */
/* the following blurb emits an ELF note indicating start and end of the xref
* array in the binary. This is technically the "correct" entry point for
diff --git a/lib/yang.c b/lib/yang.c
index 383dc9f5eb..df3b07fb09 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -27,8 +27,8 @@
#include <libyang/user_types.h>
-DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module")
-DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure")
+DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module");
+DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure");
/* libyang container. */
struct ly_ctx *ly_native_ctx;
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index 1f64675d6a..5b1d96f24c 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -26,9 +26,9 @@
#include "yang_translator.h"
#include "frrstr.h"
-DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR, "YANG Translator")
-DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MODULE, "YANG Translator Module")
-DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MAPPING, "YANG Translator Mapping")
+DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR, "YANG Translator");
+DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MODULE, "YANG Translator Module");
+DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MAPPING, "YANG Translator Mapping");
/* Generate the yang_translators tree. */
static inline int yang_translator_compare(const struct yang_translator *a,
diff --git a/lib/zassert.h b/lib/zassert.h
index e6b254ee8d..527282c4f2 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -28,14 +28,7 @@ extern void _zlog_assert_failed(const char *assertion, const char *file,
__attribute__((noreturn));
#undef __ASSERT_FUNCTION
-
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __ASSERT_FUNCTION __func__
-#elif defined(__GNUC__)
-#define __ASSERT_FUNCTION __FUNCTION__
-#else
-#define __ASSERT_FUNCTION NULL
-#endif
#define zassert(EX) \
((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
diff --git a/lib/zclient.c b/lib/zclient.c
index c5e844933c..c78937c1ec 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -42,8 +42,8 @@
#include "srte.h"
#include "printfrr.h"
-DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient")
-DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs")
+DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient");
+DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs");
/* Zebra client events. */
enum event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT };
diff --git a/lib/zebra.h b/lib/zebra.h
index ded44ac636..5c3d91ba74 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -80,21 +80,6 @@
/* misc include group */
#include <stdarg.h>
-#if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-/* Not C99; do we need to define va_copy? */
-#ifndef va_copy
-#ifdef __va_copy
-#define va_copy(DST,SRC) __va_copy(DST,SRC)
-#else
-/* Now we are desperate; this should work on many typical platforms.
- But this is slightly dangerous, because the standard does not require
- va_copy to be a macro. */
-#define va_copy(DST,SRC) memcpy(&(DST), &(SRC), sizeof(va_list))
-#warning "Not C99 and no va_copy macro available, falling back to memcpy"
-#endif /* __va_copy */
-#endif /* !va_copy */
-#endif /* !C99 */
-
#ifdef HAVE_LCAPS
#include <sys/capability.h>
diff --git a/lib/zlog.c b/lib/zlog.c
index 51509e24f4..f546709328 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -54,20 +54,22 @@
#include "zlog.h"
#include "libfrr_trace.h"
-DEFINE_MTYPE_STATIC(LIB, LOG_MESSAGE, "log message")
-DEFINE_MTYPE_STATIC(LIB, LOG_TLSBUF, "log thread-local buffer")
+DEFINE_MTYPE_STATIC(LIB, LOG_MESSAGE, "log message");
+DEFINE_MTYPE_STATIC(LIB, LOG_TLSBUF, "log thread-local buffer");
DEFINE_HOOK(zlog_init, (const char *progname, const char *protoname,
unsigned short instance, uid_t uid, gid_t gid),
- (progname, protoname, instance, uid, gid))
-DEFINE_KOOH(zlog_fini, (), ())
+ (progname, protoname, instance, uid, gid));
+DEFINE_KOOH(zlog_fini, (), ());
DEFINE_HOOK(zlog_aux_init, (const char *prefix, int prio_min),
- (prefix, prio_min))
+ (prefix, prio_min));
char zlog_prefix[128];
size_t zlog_prefixsz;
int zlog_tmpdirfd = -1;
+static atomic_bool zlog_ec = true, zlog_xid = true;
+
/* these are kept around because logging is initialized (and directories
* & files created) before zprivs code switches to the FRR user; therefore
* we need to chown() things so we don't get permission errors later when
@@ -530,12 +532,54 @@ const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen)
{
if (!msg->text) {
va_list args;
+ bool do_xid, do_ec;
+ size_t need = 0, hdrlen;
+ struct fbuf fb = {
+ .buf = msg->stackbuf,
+ .pos = msg->stackbuf,
+ .len = msg->stackbufsz,
+ };
+
+ do_ec = atomic_load_explicit(&zlog_ec, memory_order_relaxed);
+ do_xid = atomic_load_explicit(&zlog_xid, memory_order_relaxed);
+
+ if (msg->xref && do_xid && msg->xref->xref.xrefdata->uid[0]) {
+ need += bputch(&fb, '[');
+ need += bputs(&fb, msg->xref->xref.xrefdata->uid);
+ need += bputch(&fb, ']');
+ }
+ if (msg->xref && do_ec && msg->xref->ec)
+ need += bprintfrr(&fb, "[EC %u]", msg->xref->ec);
+ if (need)
+ need += bputch(&fb, ' ');
+
+ hdrlen = need;
+ assert(hdrlen < msg->stackbufsz);
va_copy(args, msg->args);
- msg->text = vasnprintfrr(MTYPE_LOG_MESSAGE, msg->stackbuf,
- msg->stackbufsz, msg->fmt, args);
- msg->textlen = strlen(msg->text);
+ need += vbprintfrr(&fb, msg->fmt, args);
va_end(args);
+
+ msg->textlen = need;
+ need += bputch(&fb, '\0');
+
+ if (need <= msg->stackbufsz)
+ msg->text = msg->stackbuf;
+ else {
+ msg->text = XMALLOC(MTYPE_LOG_MESSAGE, need);
+
+ memcpy(msg->text, msg->stackbuf, hdrlen);
+
+ fb.buf = msg->text;
+ fb.len = need;
+ fb.pos = msg->text + hdrlen;
+
+ va_copy(args, msg->args);
+ vbprintfrr(&fb, msg->fmt, args);
+ va_end(args);
+
+ bputch(&fb, '\0');
+ }
}
if (textlen)
*textlen = msg->textlen;
@@ -619,6 +663,26 @@ size_t zlog_msg_ts(struct zlog_msg *msg, char *out, size_t outsz,
}
}
+void zlog_set_prefix_ec(bool enable)
+{
+ atomic_store_explicit(&zlog_ec, enable, memory_order_relaxed);
+}
+
+bool zlog_get_prefix_ec(void)
+{
+ return atomic_load_explicit(&zlog_ec, memory_order_relaxed);
+}
+
+void zlog_set_prefix_xid(bool enable)
+{
+ atomic_store_explicit(&zlog_xid, enable, memory_order_relaxed);
+}
+
+bool zlog_get_prefix_xid(void)
+{
+ return atomic_load_explicit(&zlog_xid, memory_order_relaxed);
+}
+
/* setup functions */
struct zlog_target *zlog_target_clone(struct memtype *mt,
diff --git a/lib/zlog.h b/lib/zlog.h
index 4fdb47bb95..66d8f1e5d7 100644
--- a/lib/zlog.h
+++ b/lib/zlog.h
@@ -85,31 +85,6 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
va_end(ap);
}
-#define _zlog_ref(prio, msg, ...) \
- do { \
- static struct xrefdata _xrefdata = { \
- .xref = NULL, \
- .uid = {}, \
- .hashstr = (msg), \
- .hashu32 = {(prio), 0}, \
- }; \
- static const struct xref_logmsg _xref __attribute__( \
- (used)) = { \
- .xref = XREF_INIT(XREFT_LOGMSG, &_xrefdata, __func__), \
- .fmtstring = (msg), \
- .priority = (prio), \
- .args = (#__VA_ARGS__), \
- }; \
- XREF_LINK(_xref.xref); \
- zlog_ref(&_xref, (msg), ##__VA_ARGS__); \
- } while (0)
-
-#define zlog_err(...) _zlog_ref(LOG_ERR, __VA_ARGS__)
-#define zlog_warn(...) _zlog_ref(LOG_WARNING, __VA_ARGS__)
-#define zlog_info(...) _zlog_ref(LOG_INFO, __VA_ARGS__)
-#define zlog_notice(...) _zlog_ref(LOG_NOTICE, __VA_ARGS__)
-#define zlog_debug(...) _zlog_ref(LOG_DEBUG, __VA_ARGS__)
-
#define _zlog_ecref(ec_, prio, msg, ...) \
do { \
static struct xrefdata _xrefdata = { \
@@ -127,18 +102,22 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
.args = (#__VA_ARGS__), \
}; \
XREF_LINK(_xref.xref); \
- zlog_ref(&_xref, "[EC %u] " msg, ec_, ##__VA_ARGS__); \
+ zlog_ref(&_xref, (msg), ##__VA_ARGS__); \
} while (0)
+#define zlog_err(...) _zlog_ecref(0, LOG_ERR, __VA_ARGS__)
+#define zlog_warn(...) _zlog_ecref(0, LOG_WARNING, __VA_ARGS__)
+#define zlog_info(...) _zlog_ecref(0, LOG_INFO, __VA_ARGS__)
+#define zlog_notice(...) _zlog_ecref(0, LOG_NOTICE, __VA_ARGS__)
+#define zlog_debug(...) _zlog_ecref(0, LOG_DEBUG, __VA_ARGS__)
+
#define flog_err(ferr_id, format, ...) \
_zlog_ecref(ferr_id, LOG_ERR, format, ## __VA_ARGS__)
#define flog_warn(ferr_id, format, ...) \
_zlog_ecref(ferr_id, LOG_WARNING, format, ## __VA_ARGS__)
#define flog_err_sys(ferr_id, format, ...) \
- flog_err(ferr_id, format, ##__VA_ARGS__)
-#define flog(priority, ferr_id, format, ...) \
- zlog(priority, "[EC %u] " format, ferr_id, ##__VA_ARGS__)
+ _zlog_ecref(ferr_id, LOG_ERR, format, ## __VA_ARGS__)
extern void zlog_sigsafe(const char *text, size_t len);
@@ -203,7 +182,7 @@ extern size_t zlog_msg_ts(struct zlog_msg *msg, char *out, size_t outsz,
* additional options. It MUST be the first field in that larger struct.
*/
-PREDECL_ATOMLIST(zlog_targets)
+PREDECL_ATOMLIST(zlog_targets);
struct zlog_target {
struct zlog_targets_item head;
@@ -247,17 +226,22 @@ extern void zlog_init(const char *progname, const char *protoname,
unsigned short instance, uid_t uid, gid_t gid);
DECLARE_HOOK(zlog_init, (const char *progname, const char *protoname,
unsigned short instance, uid_t uid, gid_t gid),
- (progname, protoname, instance, uid, gid))
+ (progname, protoname, instance, uid, gid));
extern void zlog_fini(void);
-DECLARE_KOOH(zlog_fini, (), ())
+DECLARE_KOOH(zlog_fini, (), ());
+
+extern void zlog_set_prefix_ec(bool enable);
+extern bool zlog_get_prefix_ec(void);
+extern void zlog_set_prefix_xid(bool enable);
+extern bool zlog_get_prefix_xid(void);
/* for tools & test programs, i.e. anything not a daemon.
* (no cleanup needed at exit)
*/
extern void zlog_aux_init(const char *prefix, int prio_min);
DECLARE_HOOK(zlog_aux_init, (const char *prefix, int prio_min),
- (prefix, prio_min))
+ (prefix, prio_min));
extern void zlog_startup_end(void);
diff --git a/lib/zlog_targets.c b/lib/zlog_targets.c
index 8f4c2a46a8..f258a8fbbd 100644
--- a/lib/zlog_targets.c
+++ b/lib/zlog_targets.c
@@ -31,13 +31,13 @@
* absolute end.
*/
-DECLARE_MGROUP(LOG)
-DEFINE_MGROUP_ACTIVEATEXIT(LOG, "logging subsystem")
+DECLARE_MGROUP(LOG);
+DEFINE_MGROUP_ACTIVEATEXIT(LOG, "logging subsystem");
-DEFINE_MTYPE_STATIC(LOG, LOG_FD, "log file target")
-DEFINE_MTYPE_STATIC(LOG, LOG_FD_NAME, "log file name")
-DEFINE_MTYPE_STATIC(LOG, LOG_FD_ROTATE, "log file rotate helper")
-DEFINE_MTYPE_STATIC(LOG, LOG_SYSL, "syslog target")
+DEFINE_MTYPE_STATIC(LOG, LOG_FD, "log file target");
+DEFINE_MTYPE_STATIC(LOG, LOG_FD_NAME, "log file name");
+DEFINE_MTYPE_STATIC(LOG, LOG_FD_ROTATE, "log file rotate helper");
+DEFINE_MTYPE_STATIC(LOG, LOG_SYSL, "syslog target");
struct zlt_fd {
struct zlog_target zt;