summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.c29
-rw-r--r--lib/command.h8
-rw-r--r--lib/compiler.h16
-rw-r--r--lib/debug.c46
-rw-r--r--lib/debug.h216
-rw-r--r--lib/ferr.c23
-rw-r--r--lib/ferr.h87
-rw-r--r--lib/freebsd-queue.h3
-rw-r--r--lib/frratomic.h16
-rw-r--r--lib/grammar_sandbox.c4
-rw-r--r--lib/hook.c5
-rw-r--r--lib/hook.h10
-rw-r--r--lib/if.c19
-rw-r--r--lib/if.h8
-rw-r--r--lib/if_rmap.c4
-rw-r--r--lib/imsg-buffer.c103
-rw-r--r--lib/imsg.c117
-rw-r--r--lib/imsg.h110
-rw-r--r--lib/keychain.c6
-rw-r--r--lib/libfrr.c18
-rw-r--r--lib/linklist.h10
-rw-r--r--lib/log.c27
-rw-r--r--lib/logicalrouter.c3
-rw-r--r--lib/memory.c2
-rw-r--r--lib/module.c9
-rw-r--r--lib/netns_linux.c35
-rw-r--r--lib/nexthop.c52
-rw-r--r--lib/nexthop.h31
-rw-r--r--lib/nexthop_group.c100
-rw-r--r--lib/nexthop_group.h54
-rw-r--r--lib/openbsd-tree.c146
-rw-r--r--lib/openbsd-tree.h809
-rw-r--r--lib/plist.c8
-rw-r--r--lib/plist.h7
-rw-r--r--lib/prefix.c652
-rw-r--r--lib/prefix.h15
-rw-r--r--lib/qobj.c4
-rw-r--r--lib/queue.h3
-rw-r--r--lib/ringbuf.c2
-rw-r--r--lib/routemap.c29
-rw-r--r--lib/routemap.h12
-rw-r--r--lib/sbuf.h6
-rw-r--r--lib/spf_backoff.c6
-rw-r--r--lib/stream.c27
-rw-r--r--lib/stream.h44
-rw-r--r--lib/subdir.am6
-rw-r--r--lib/thread.c7
-rw-r--r--lib/vrf.c76
-rw-r--r--lib/vrf.h16
-rw-r--r--lib/vty.c31
-rw-r--r--lib/vty.h4
-rw-r--r--lib/workqueue.c15
-rw-r--r--lib/workqueue.h26
-rw-r--r--lib/zclient.c111
-rw-r--r--lib/zclient.h36
-rw-r--r--lib/zebra.h16
56 files changed, 1922 insertions, 1363 deletions
diff --git a/lib/command.c b/lib/command.c
index 3fa086bf62..5697c1d812 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -62,9 +62,10 @@ const char *node_names[] = {
"aaa", // AAA_NODE,
"keychain", // KEYCHAIN_NODE,
"keychain key", // KEYCHAIN_KEY_NODE,
- "logical-router", // LOGICALROUTER_NODE,
+ "logical-router", // LOGICALROUTER_NODE,
"vrf", // VRF_NODE,
"interface", // INTERFACE_NODE,
+ "nexthop-group", // NH_GROUP_NODE,
"zebra", // ZEBRA_NODE,
"table", // TABLE_NODE,
"rip", // RIP_NODE,
@@ -74,14 +75,14 @@ const char *node_names[] = {
"bgp", // BGP_NODE,
"bgp vpnv4", // BGP_VPNV4_NODE,
"bgp vpnv6", // BGP_VPNV6_NODE,
- "bgp ipv4 unicast", // BGP_IPV4_NODE,
+ "bgp ipv4 unicast", // BGP_IPV4_NODE,
"bgp ipv4 multicast", // BGP_IPV4M_NODE,
"bgp ipv4 labeled unicast", // BGP_IPV4L_NODE,
"bgp ipv6", // BGP_IPV6_NODE,
"bgp ipv6 multicast", // BGP_IPV6M_NODE,
"bgp ipv6 labeled unicast", // BGP_IPV6L_NODE,
- "bgp vrf policy", // BGP_VRF_POLICY_NODE,
- "bgp vnc defaults", // BGP_VNC_DEFAULTS_NODE,
+ "bgp vrf policy", // BGP_VRF_POLICY_NODE,
+ "bgp vnc defaults", // BGP_VNC_DEFAULTS_NODE,
"bgp vnc nve", // BGP_VNC_NVE_GROUP_NODE,
"bgp vnc l2", // BGP_VNC_L2_GROUP_NODE,
"rfp defaults", // RFP_DEFAULTS_NODE,
@@ -99,13 +100,13 @@ const char *node_names[] = {
"masc", // MASC_NODE,
"irdp", // IRDP_NODE,
"static ip", // IP_NODE,
- "ipv4 access list", // ACCESS_NODE,
- "ipv4 prefix list", // PREFIX_NODE,
- "ipv6 access list", // ACCESS_IPV6_NODE,
- "MAC access list", // ACCESS_MAC_NODE,
- "ipv6 prefix list", // PREFIX_IPV6_NODE,
+ "ipv4 access list", // ACCESS_NODE,
+ "ipv4 prefix list", // PREFIX_NODE,
+ "ipv6 access list", // ACCESS_IPV6_NODE,
+ "MAC access list", // ACCESS_MAC_NODE,
+ "ipv6 prefix list", // PREFIX_IPV6_NODE,
"as list", // AS_LIST_NODE,
- "community list", // COMMUNITY_LIST_NODE,
+ "community list", // COMMUNITY_LIST_NODE,
"routemap", // RMAP_NODE,
"smux", // SMUX_NODE,
"dump", // DUMP_NODE,
@@ -301,8 +302,7 @@ void install_node(struct cmd_node *node, int (*func)(struct vty *))
cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL);
graph_new_node(node->cmdgraph, token,
(void (*)(void *)) & cmd_token_del);
- node->cmd_hash = hash_create_size(16, cmd_hash_key,
- cmd_hash_cmp,
+ node->cmd_hash = hash_create_size(16, cmd_hash_key, cmd_hash_cmp,
"Command Hash");
}
@@ -1170,8 +1170,7 @@ int command_config_read_one_line(struct vty *vty,
if (!(use_daemon && ret == CMD_SUCCESS_DAEMON)
&& !(!use_daemon && ret == CMD_ERR_NOTHING_TODO)
&& ret != CMD_SUCCESS && ret != CMD_WARNING
- && ret != CMD_NOT_MY_INSTANCE
- && ret != CMD_WARNING_CONFIG_FAILED
+ && ret != CMD_NOT_MY_INSTANCE && ret != CMD_WARNING_CONFIG_FAILED
&& vty->node != CONFIG_NODE) {
saved_node = vty->node;
@@ -1296,6 +1295,7 @@ void cmd_exit(struct vty *vty)
case PW_NODE:
case LOGICALROUTER_NODE:
case VRF_NODE:
+ case NH_GROUP_NODE:
case ZEBRA_NODE:
case BGP_NODE:
case RIP_NODE:
@@ -1381,6 +1381,7 @@ DEFUN (config_end,
case PW_NODE:
case LOGICALROUTER_NODE:
case VRF_NODE:
+ case NH_GROUP_NODE:
case ZEBRA_NODE:
case RIP_NODE:
case RIPNG_NODE:
diff --git a/lib/command.h b/lib/command.h
index 269318989f..0febf903a3 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -85,9 +85,10 @@ enum node_type {
AAA_NODE, /* AAA node. */
KEYCHAIN_NODE, /* Key-chain node. */
KEYCHAIN_KEY_NODE, /* Key-chain key node. */
- LOGICALROUTER_NODE, /* Logical-Router node. */
+ LOGICALROUTER_NODE, /* Logical-Router node. */
VRF_NODE, /* VRF mode node. */
INTERFACE_NODE, /* Interface mode node. */
+ NH_GROUP_NODE, /* Nexthop-Group mode node. */
ZEBRA_NODE, /* zebra connection node. */
TABLE_NODE, /* rtm_table selection node. */
RIP_NODE, /* RIP protocol mode node. */
@@ -139,8 +140,9 @@ enum node_type {
VTY_NODE, /* Vty node. */
LINK_PARAMS_NODE, /* Link-parameters node */
BGP_EVPN_VNI_NODE, /* BGP EVPN VNI */
- RPKI_NODE, /* RPKI node for configuration of RPKI cache server connections.*/
- NODE_TYPE_MAX, /* maximum */
+ RPKI_NODE, /* RPKI node for configuration of RPKI cache server
+ connections.*/
+ NODE_TYPE_MAX, /* maximum */
};
extern vector cmdvec;
diff --git a/lib/compiler.h b/lib/compiler.h
index 49a2f2a422..773a52e742 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -21,25 +21,25 @@
* void prototype(void) __attribute__((_CONSTRUCTOR(100)));
*/
#if defined(__clang__)
-# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5)
+#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5)
# define _RET_NONNULL , returns_nonnull
-# endif
+#endif
# define _CONSTRUCTOR(x) constructor(x)
#elif defined(__GNUC__)
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
# define _RET_NONNULL , returns_nonnull
-# endif
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#endif
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
# define _CONSTRUCTOR(x) constructor(x)
# define _DESTRUCTOR(x) destructor(x)
# define _ALLOC_SIZE(x) alloc_size(x)
-# endif
+#endif
#endif
#ifdef __sun
/* Solaris doesn't do constructor priorities due to linker restrictions */
-# undef _CONSTRUCTOR
-# undef _DESTRUCTOR
+#undef _CONSTRUCTOR
+#undef _DESTRUCTOR
#endif
/* fallback versions */
diff --git a/lib/debug.c b/lib/debug.c
new file mode 100644
index 0000000000..0bacf9789c
--- /dev/null
+++ b/lib/debug.c
@@ -0,0 +1,46 @@
+/*
+ * Debugging utilities.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Quentin Young
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <zebra.h>
+#include "debug.h"
+#include "command.h"
+
+static const struct debug_callbacks *callbacks;
+
+/* All code in this section should be reentrant and MT-safe */
+
+DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
+ NO_STR DEBUG_STR "Toggle all debugging output\n")
+{
+ bool set = strmatch(argv[0]->text, "no");
+ uint32_t mode = DEBUG_NODE2MODE(vty->node);
+
+ if (callbacks->debug_set_all)
+ callbacks->debug_set_all(mode, set);
+ return CMD_SUCCESS;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void debug_init(const struct debug_callbacks *cb)
+{
+ callbacks = cb;
+ install_element(ENABLE_NODE, &debug_all_cmd);
+ install_element(CONFIG_NODE, &debug_all_cmd);
+}
diff --git a/lib/debug.h b/lib/debug.h
new file mode 100644
index 0000000000..3e6772aacf
--- /dev/null
+++ b/lib/debug.h
@@ -0,0 +1,216 @@
+/*
+ * Debugging utilities.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Quentin Young
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _FRRDEBUG_H
+#define _FRRDEBUG_H
+
+#include <zebra.h>
+#include "command.h"
+#include "frratomic.h"
+
+/*
+ * Debugging modes.
+ *
+ * FRR's convention is that a debug statement issued under the vty CONFIG_NODE
+ * persists to the config file, whereas the same debug statement issued from
+ * the ENABLE_NODE only persists for the current session. These are mapped to
+ * DEBUG_MODE_CONF and DEBUG_MODE_TERM respectively.
+ *
+ * They are not mutually exclusive and are placed in the MSB of the flags
+ * field in a debugging record.
+ */
+#define DEBUG_MODE_TERM 0x01000000
+#define DEBUG_MODE_CONF 0x02000000
+#define DEBUG_MODE_ALL (DEBUG_MODE_TERM | DEBUG_MODE_CONF)
+#define DEBUG_MODE_NONE 0x00000000
+#define DEBUG_OPT_ALL 0x00FFFFFF
+#define DEBUG_OPT_NONE 0x00000000
+
+
+/*
+ * Debugging record.
+ *
+ * All operations on this record exposed in this header are MT-safe.
+ *
+ * flags
+ * A bitfield with the following format (bytes high to low)
+ * - [0] Debugging mode field (MSB) | Mode
+ * - [1] Arbitrary flag field | Option
+ * - [2] Arbitrary flag field | Option
+ * - [3] Arbitrary flag field (LSB) | Option
+ *
+ * ALL THESE BYTES ARE YOURS - EXCEPT MODE.
+ * ATTEMPT NO BIT OPS THERE.
+ *
+ * The MSB of this field determines the debug mode, Use the DEBUG_MODE*
+ * macros to manipulate this byte.
+ *
+ * The low 3 bytes of this field may be used to store arbitrary information.
+ * Usually they are used to store flags that tune how detailed the logging
+ * for a particular debug record is. Use the DEBUG_OPT* macros to manipulate
+ * those bytes.
+ *
+ * All operations performed on this field should be done using the macros
+ * later in this header file. They are guaranteed to be atomic operations
+ * with respect to this field. Using anything except the macros to
+ * manipulate the flags field in a multithreaded environment results in
+ * undefined behavior.
+ *
+ * desc
+ * Human-readable description of this debugging record.
+ */
+struct debug {
+ _Atomic uint32_t flags;
+ const char *desc;
+};
+
+/*
+ * Callback set for debugging code.
+ *
+ * debug_set_all
+ * Function pointer to call when the user requests that all debugs have a
+ * mode set.
+ */
+struct debug_callbacks {
+ /*
+ * flags
+ * flags to set on debug flag fields
+ *
+ * set
+ * true: set flags
+ * false: unset flags
+ */
+ void (*debug_set_all)(uint32_t flags, bool set);
+};
+
+/*
+ * Check if a mode is set for a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_MODE_CHECK(name, type) \
+ CHECK_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_MODE_ALL)
+
+/*
+ * Check if an option bit is set for a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_OPT_CHECK(name, type) \
+ CHECK_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_OPT_ALL)
+
+/*
+ * Check if bits are set for a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_FLAGS_CHECK(name, type) CHECK_FLAG_ATOMIC(&(name)->flags, (type))
+
+/*
+ * Check if any mode is on for a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG(name) DEBUG_MODE_CHECK((name), DEBUG_MODE_ALL)
+
+/*
+ * Set modes on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_MODE_SET(name, type) \
+ SET_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_MODE_ALL)
+
+/*
+ * Unset modes on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_MODE_UNSET(name, type) \
+ UNSET_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_MODE_ALL)
+
+/*
+ * Set options on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_OPT_SET(name, type) \
+ SET_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_OPT_ALL)
+
+/*
+ * Unset options on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_OPT_UNSET(name, type) \
+ UNSET_FLAG_ATOMIC(&(name)->flags, (type)&DEBUG_OPT_ALL)
+
+/*
+ * Set bits on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_FLAGS_SET(name, type) SET_FLAG_ATOMIC(&(name)->flags, (type))
+
+/*
+ * Unset bits on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_FLAGS_UNSET(name, type) UNSET_FLAG_ATOMIC(&(name)->flags, (type))
+
+/*
+ * Unset all modes and options on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_CLEAR(name) RESET_FLAG_ATOMIC(&(name)->flags)
+
+/*
+ * Set all modes and options on a debug.
+ *
+ * MT-Safe
+ */
+#define DEBUG_ON(name) \
+ SET_FLAG_ATOMIC(&(name)->flags, DEBUG_MODE_ALL | DEBUG_OPT_ALL)
+
+/*
+ * Map a vty node to the correct debugging mode flags. FRR behaves such that a
+ * debug statement issued under the config node persists to the config file,
+ * whereas the same debug statement issued from the enable node only persists
+ * for the current session.
+ *
+ * MT-Safe
+ */
+#define DEBUG_NODE2MODE(vtynode) \
+ (((vtynode) == CONFIG_NODE) ? DEBUG_MODE_ALL : DEBUG_MODE_TERM)
+
+
+/*
+ * Optional initializer for debugging. Highly recommended.
+ *
+ * This function installs common debugging commands and allows the caller to
+ * specify callbacks to take when these commands are issued, allowing the
+ * caller to respond to events such as a request to turn off all debugs.
+ *
+ * MT-Safe
+ */
+void debug_init(const struct debug_callbacks *cb);
+
+#endif /* _FRRDEBUG_H */
diff --git a/lib/ferr.c b/lib/ferr.c
index 69aeb3db40..d315cf843c 100644
--- a/lib/ferr.c
+++ b/lib/ferr.c
@@ -63,8 +63,8 @@ ferr_r ferr_clear(void)
}
static ferr_r ferr_set_va(const char *file, int line, const char *func,
- enum ferr_kind kind, const char *pathname, int errno_val,
- const char *text, va_list va)
+ enum ferr_kind kind, const char *pathname,
+ int errno_val, const char *text, va_list va)
{
struct ferr *error = pthread_getspecific(errkey);
@@ -74,7 +74,8 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,
/* we're screwed */
zlog_err("out of memory while allocating error info");
raise(SIGSEGV);
- abort(); /* raise() can return, but raise(SIGSEGV) shall not */
+ abort(); /* raise() can return, but raise(SIGSEGV) shall
+ not */
}
pthread_setspecific(errkey, error);
@@ -86,12 +87,12 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,
error->kind = kind;
error->unique_id = jhash(text, strlen(text),
- jhash(file, strlen(file), 0xd4ed0298));
+ jhash(file, strlen(file), 0xd4ed0298));
error->errno_val = errno_val;
if (pathname)
- snprintf(error->pathname, sizeof(error->pathname),
- "%s", pathname);
+ snprintf(error->pathname, sizeof(error->pathname), "%s",
+ pathname);
else
error->pathname[0] = '\0';
@@ -100,7 +101,7 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,
}
ferr_r ferr_set_internal(const char *file, int line, const char *func,
- enum ferr_kind kind, const char *text, ...)
+ enum ferr_kind kind, const char *text, ...)
{
ferr_r rv;
va_list va;
@@ -111,8 +112,8 @@ ferr_r ferr_set_internal(const char *file, int line, const char *func,
}
ferr_r ferr_set_internal_ext(const char *file, int line, const char *func,
- enum ferr_kind kind, const char *pathname, int errno_val,
- const char *text, ...)
+ enum ferr_kind kind, const char *pathname,
+ int errno_val, const char *text, ...)
{
ferr_r rv;
va_list va;
@@ -139,10 +140,8 @@ void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...)
else {
replacepos[0] = '\0';
replacepos += sizeof(REPLACE) - 1;
- vty_out(vty, "%s%s%s\n",
- tmpmsg,
+ vty_out(vty, "%s%s%s\n", tmpmsg,
last_error ? last_error->message : "(no error?)",
replacepos);
}
}
-
diff --git a/lib/ferr.h b/lib/ferr.h
index c4f83f1710..2f100c1b01 100644
--- a/lib/ferr.h
+++ b/lib/ferr.h
@@ -107,13 +107,12 @@ ferr_r ferr_clear(void);
/* do NOT call these functions directly. only for macro use! */
ferr_r ferr_set_internal(const char *file, int line, const char *func,
- enum ferr_kind kind, const char *text, ...);
+ enum ferr_kind kind, const char *text, ...);
ferr_r ferr_set_internal_ext(const char *file, int line, const char *func,
- enum ferr_kind kind, const char *pathname, int errno_val,
- const char *text, ...);
+ enum ferr_kind kind, const char *pathname,
+ int errno_val, const char *text, ...);
-#define ferr_ok() \
- 0
+#define ferr_ok() 0
/* Report an error.
*
@@ -122,58 +121,60 @@ ferr_r ferr_set_internal_ext(const char *file, int line, const char *func,
*
* Don't put a \n at the end of the error message.
*/
-#define ferr_code_bug(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CODE_BUG, \
- __VA_ARGS__)
-#define ferr_cfg_invalid(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_INVALID, \
- __VA_ARGS__)
-#define ferr_cfg_reality(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_REALITY, \
- __VA_ARGS__)
-#define ferr_cfg_resource(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_RESOURCE, \
- __VA_ARGS__)
-#define ferr_system(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_SYSTEM, \
- __VA_ARGS__)
-#define ferr_library(...) \
- ferr_set_internal(__FILE__, __LINE__, __func__, FERR_LIBRARY, \
- __VA_ARGS__)
+#define ferr_code_bug(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CODE_BUG, \
+ __VA_ARGS__)
+#define ferr_cfg_invalid(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_INVALID, \
+ __VA_ARGS__)
+#define ferr_cfg_reality(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_REALITY, \
+ __VA_ARGS__)
+#define ferr_cfg_resource(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_RESOURCE, \
+ __VA_ARGS__)
+#define ferr_system(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_SYSTEM, \
+ __VA_ARGS__)
+#define ferr_library(...) \
+ ferr_set_internal(__FILE__, __LINE__, __func__, FERR_LIBRARY, \
+ __VA_ARGS__)
/* extended information variants */
-#define ferr_system_errno(...) \
- ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, \
- NULL, errno, __VA_ARGS__)
-#define ferr_system_path_errno(path, ...) \
- ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, \
- path, errno, __VA_ARGS__)
+#define ferr_system_errno(...) \
+ ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, NULL, \
+ errno, __VA_ARGS__)
+#define ferr_system_path_errno(path, ...) \
+ ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, path, \
+ errno, __VA_ARGS__)
#include "vty.h"
/* print error message to vty; $ERR is replaced by the error's message */
void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...);
-#define CMD_FERR_DO(func, action, ...) \
- do { ferr_r cmd_retval = func; \
- if (cmd_retval) { \
- vty_print_error(vty, cmd_retval, __VA_ARGS__); \
- action; \
- } \
+#define CMD_FERR_DO(func, action, ...) \
+ do { \
+ ferr_r cmd_retval = func; \
+ if (cmd_retval) { \
+ vty_print_error(vty, cmd_retval, __VA_ARGS__); \
+ action; \
+ } \
} while (0)
-#define CMD_FERR_RETURN(func, ...) \
+#define CMD_FERR_RETURN(func, ...) \
CMD_FERR_DO(func, return CMD_WARNING_CONFIG_FAILED, __VA_ARGS__)
-#define CMD_FERR_GOTO(func, label, ...) \
+#define CMD_FERR_GOTO(func, label, ...) \
CMD_FERR_DO(func, goto label, __VA_ARGS__)
-/* example:
-
+/* example: uses bogus #define to keep indent.py happy */
+#ifdef THIS_IS_AN_EXAMPLE
ferr_r foo_bar_set(struct object *obj, int bar)
{
if (bar < 1 || bar >= 100)
- return ferr_config_invalid("bar setting (%d) must be 0<x<100", bar);
+ return ferr_config_invalid("bar setting (%d) must be 0<x<100",
+ bar);
obj->bar = bar;
- if (ioctl (obj->fd, bar))
+ if (ioctl(obj->fd, bar))
return ferr_system_errno("couldn't set bar to %d", bar);
return ferr_ok();
@@ -182,10 +183,10 @@ ferr_r foo_bar_set(struct object *obj, int bar)
DEFUN("bla")
{
CMD_FERR_RETURN(foo_bar_set(obj, atoi(argv[1])),
- "command failed: $ERR\n");
+ "command failed: $ERR\n");
return CMD_SUCCESS;
}
-*/
+#endif /* THIS_IS_AN_EXAMPLE */
#endif /* _FERR_H */
diff --git a/lib/freebsd-queue.h b/lib/freebsd-queue.h
index d198f5674f..4fcfe85a68 100644
--- a/lib/freebsd-queue.h
+++ b/lib/freebsd-queue.h
@@ -302,8 +302,7 @@ struct qm_trace {
(STAILQ_EMPTY((head)) \
? NULL \
: ((struct type *)(void *)((char *)((head)->stqh_last) \
- - offsetof(struct type, \
- field))))
+ - offsetof(struct type, field))))
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
diff --git a/lib/frratomic.h b/lib/frratomic.h
index 4ae84c4018..689b25255d 100644
--- a/lib/frratomic.h
+++ b/lib/frratomic.h
@@ -46,6 +46,8 @@
#define atomic_exchange_explicit __atomic_exchange_n
#define atomic_fetch_add_explicit __atomic_fetch_add
#define atomic_fetch_sub_explicit __atomic_fetch_sub
+#define atomic_fetch_and_explicit __atomic_fetch_and
+#define atomic_fetch_or_explicit __atomic_fetch_or
#define atomic_compare_exchange_weak_explicit(atom, expect, desire, mem1, \
mem2) \
@@ -135,6 +137,20 @@
*_expect = rval; \
ret; \
})
+#define atomic_fetch_and_explicit(ptr, val, mem) \
+ ({ \
+ __sync_synchronize(); \
+ typeof(*ptr) rval = __sync_fetch_and_and(ptr, val); \
+ __sync_synchronize(); \
+ rval; \
+ })
+#define atomic_fetch_or_explicit(ptr, val, mem) \
+ ({ \
+ __sync_synchronize(); \
+ typeof(*ptr) rval = __sync_fetch_and_or(ptr, val); \
+ __sync_synchronize(); \
+ rval; \
+ })
#else /* !HAVE___ATOMIC && !HAVE_STDATOMIC_H */
#error no atomic functions...
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c
index 79c951dd69..41dd57b7f1 100644
--- a/lib/grammar_sandbox.c
+++ b/lib/grammar_sandbox.c
@@ -402,8 +402,8 @@ DEFUN (grammar_findambig,
nodegraph = cnode->cmdgraph;
if (!nodegraph)
continue;
- vty_out(vty, "scanning node %d (%s)\n",
- scannode - 1, node_names[scannode - 1]);
+ vty_out(vty, "scanning node %d (%s)\n", scannode - 1,
+ node_names[scannode - 1]);
}
commands = cmd_graph_permutations(nodegraph);
diff --git a/lib/hook.c b/lib/hook.c
index 1468c4d329..935064f4d2 100644
--- a/lib/hook.c
+++ b/lib/hook.c
@@ -38,9 +38,8 @@ void _hook_register(struct hook *hook, void *funcptr, void *arg, bool has_arg,
he->priority = priority;
for (pos = &hook->entries; *pos; pos = &(*pos)->next)
- if (hook->reverse
- ? (*pos)->priority < priority
- : (*pos)->priority >= priority)
+ if (hook->reverse ? (*pos)->priority < priority
+ : (*pos)->priority >= priority)
break;
he->next = *pos;
diff --git a/lib/hook.h b/lib/hook.h
index 5f45e113e7..ee496ab365 100644
--- a/lib/hook.h
+++ b/lib/hook.h
@@ -150,8 +150,8 @@ extern void _hook_register(struct hook *hook, void *funcptr, void *arg,
NULL, false, THIS_MODULE, #func, prio)
#define hook_register_arg_prio(hookname, prio, func, arg) \
_hook_register(&_hook_##hookname, \
- _hook_typecheck_arg_##hookname(func), \
- arg, true, THIS_MODULE, #func, prio)
+ _hook_typecheck_arg_##hookname(func), arg, true, \
+ THIS_MODULE, #func, prio)
extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
bool has_arg);
@@ -190,7 +190,7 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
{ \
return (void *)funcptr; \
}
-#define DECLARE_KOOH(hookname, arglist, passlist) \
+#define DECLARE_KOOH(hookname, arglist, passlist) \
DECLARE_HOOK(hookname, arglist, passlist)
/* use in source file - contains hook-related definitions.
@@ -220,9 +220,9 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
return hooksum; \
}
-#define DEFINE_HOOK(hookname, arglist, passlist) \
+#define DEFINE_HOOK(hookname, arglist, passlist) \
DEFINE_HOOK_INT(hookname, arglist, passlist, false)
-#define DEFINE_KOOH(hookname, arglist, passlist) \
+#define DEFINE_KOOH(hookname, arglist, passlist) \
DEFINE_HOOK_INT(hookname, arglist, passlist, true)
#endif /* _FRR_HOOK_H */
diff --git a/lib/if.c b/lib/if.c
index 3a83de46ae..2541e6e45a 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -48,8 +48,8 @@ RB_GENERATE(if_index_head, interface, index_entry, if_cmp_index_func);
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))
/* List of interfaces in only the default VRF */
int ptm_enable = 0;
@@ -152,7 +152,7 @@ struct interface *if_create(const char *name, vrf_id_t vrf_id)
SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
QOBJ_REG(ifp, interface);
- hook_call(if_add, ifp);
+ hook_call(if_add, ifp);
return ifp;
}
@@ -181,7 +181,7 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
/* Delete interface structure. */
void if_delete_retain(struct interface *ifp)
{
- hook_call(if_del, ifp);
+ hook_call(if_del, ifp);
QOBJ_UNREG(ifp);
/* Free connected address list */
@@ -225,7 +225,7 @@ struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
if (vrf_id == VRF_UNKNOWN) {
struct interface *ifp;
- RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) {
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
ifp = if_lookup_by_index(ifindex, vrf->vrf_id);
if (ifp)
return ifp;
@@ -404,8 +404,7 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, int vty)
* this should not be considered as an update
* then create the new interface
*/
- if (ifp->vrf_id != vrf_id &&
- vrf_is_mapped_on_netns(vrf_id))
+ if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(vrf_id))
return if_create(name, vrf_id);
/* If it came from the kernel
* or by way of zclient, believe it and update
@@ -477,6 +476,12 @@ int if_is_loopback(struct interface *ifp)
return (ifp->flags & (IFF_LOOPBACK | IFF_NOXMIT | IFF_VIRTUAL));
}
+/* Check interface is VRF */
+int if_is_vrf(struct interface *ifp)
+{
+ return CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK);
+}
+
/* Does this interface support broadcast ? */
int if_is_broadcast(struct interface *ifp)
{
diff --git a/lib/if.h b/lib/if.h
index 79f96a7c45..7e23932a16 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -288,6 +288,7 @@ struct interface {
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);
@@ -337,8 +338,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))
/* Connected address structure. */
struct connected {
@@ -460,7 +461,7 @@ extern int if_cmp_name_func(char *, char *);
* else think before you use VRF_UNKNOWN
*/
extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id);
-extern struct interface *if_create(const char *name, vrf_id_t vrf_id);
+extern struct interface *if_create(const char *name, vrf_id_t vrf_id);
extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);
extern struct interface *if_lookup_exact_address(void *matchaddr, int family,
vrf_id_t vrf_id);
@@ -491,6 +492,7 @@ extern int if_is_running(struct interface *);
extern int if_is_operative(struct interface *);
extern int if_is_no_ptm_operative(struct interface *);
extern int if_is_loopback(struct interface *);
+extern int if_is_vrf(struct interface *ifp);
extern int if_is_broadcast(struct interface *);
extern int if_is_pointopoint(struct interface *);
extern int if_is_multicast(struct interface *);
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 53c2824a99..2c686ecb85 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -294,9 +294,7 @@ void if_rmap_reset()
void if_rmap_init(int node)
{
- ifrmaphash = hash_create_size(4,
- if_rmap_hash_make,
- if_rmap_hash_cmp,
+ ifrmaphash = hash_create_size(4, if_rmap_hash_make, if_rmap_hash_cmp,
"Interface Route-Map Hash");
if (node == RIPNG_NODE) {
} else if (node == RIP_NODE) {
diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c
index ae660504e4..ba1e26820b 100644
--- a/lib/imsg-buffer.c
+++ b/lib/imsg-buffer.c
@@ -21,14 +21,13 @@
#include "queue.h"
#include "imsg.h"
-int ibuf_realloc(struct ibuf *, size_t);
-void ibuf_enqueue(struct msgbuf *, struct ibuf *);
-void ibuf_dequeue(struct msgbuf *, struct ibuf *);
+int ibuf_realloc(struct ibuf *, size_t);
+void ibuf_enqueue(struct msgbuf *, struct ibuf *);
+void ibuf_dequeue(struct msgbuf *, struct ibuf *);
-struct ibuf *
-ibuf_open(size_t len)
+struct ibuf *ibuf_open(size_t len)
{
- struct ibuf *buf;
+ struct ibuf *buf;
if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)
return (NULL);
@@ -42,10 +41,9 @@ ibuf_open(size_t len)
return (buf);
}
-struct ibuf *
-ibuf_dynamic(size_t len, size_t max)
+struct ibuf *ibuf_dynamic(size_t len, size_t max)
{
- struct ibuf *buf;
+ struct ibuf *buf;
if (max < len)
return (NULL);
@@ -59,10 +57,9 @@ ibuf_dynamic(size_t len, size_t max)
return (buf);
}
-int
-ibuf_realloc(struct ibuf *buf, size_t len)
+int ibuf_realloc(struct ibuf *buf, size_t len)
{
- u_char *b;
+ u_char *b;
/* on static buffers max is eq size and so the following fails */
if (buf->wpos + len > buf->max) {
@@ -79,8 +76,7 @@ ibuf_realloc(struct ibuf *buf, size_t len)
return (0);
}
-int
-ibuf_add(struct ibuf *buf, const void *data, size_t len)
+int ibuf_add(struct ibuf *buf, const void *data, size_t len)
{
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
@@ -91,10 +87,9 @@ ibuf_add(struct ibuf *buf, const void *data, size_t len)
return (0);
}
-void *
-ibuf_reserve(struct ibuf *buf, size_t len)
+void *ibuf_reserve(struct ibuf *buf, size_t len)
{
- void *b;
+ void *b;
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
@@ -105,8 +100,7 @@ ibuf_reserve(struct ibuf *buf, size_t len)
return (b);
}
-void *
-ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
+void *ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
{
/* only allowed to seek in already written parts */
if (pos + len > buf->wpos)
@@ -115,34 +109,30 @@ ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
return (buf->buf + pos);
}
-size_t
-ibuf_size(struct ibuf *buf)
+size_t ibuf_size(struct ibuf *buf)
{
return (buf->wpos);
}
-size_t
-ibuf_left(struct ibuf *buf)
+size_t ibuf_left(struct ibuf *buf)
{
return (buf->max - buf->wpos);
}
-void
-ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
+void ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
{
ibuf_enqueue(msgbuf, buf);
}
-int
-ibuf_write(struct msgbuf *msgbuf)
+int ibuf_write(struct msgbuf *msgbuf)
{
- struct iovec iov[IOV_MAX];
- struct ibuf *buf;
- unsigned int i = 0;
- ssize_t n;
+ struct iovec iov[IOV_MAX];
+ struct ibuf *buf;
+ unsigned int i = 0;
+ ssize_t n;
memset(&iov, 0, sizeof(iov));
- TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
+ TAILQ_FOREACH (buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
@@ -159,7 +149,7 @@ again:
return (-1);
}
- if (n == 0) { /* connection closed */
+ if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
@@ -169,8 +159,7 @@ again:
return (1);
}
-void
-ibuf_free(struct ibuf *buf)
+void ibuf_free(struct ibuf *buf)
{
if (buf == NULL)
return;
@@ -178,21 +167,19 @@ ibuf_free(struct ibuf *buf)
free(buf);
}
-void
-msgbuf_init(struct msgbuf *msgbuf)
+void msgbuf_init(struct msgbuf *msgbuf)
{
msgbuf->queued = 0;
msgbuf->fd = -1;
TAILQ_INIT(&msgbuf->bufs);
}
-void
-msgbuf_drain(struct msgbuf *msgbuf, size_t n)
+void msgbuf_drain(struct msgbuf *msgbuf, size_t n)
{
- struct ibuf *buf, *next;
+ struct ibuf *buf, *next;
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
- buf = next) {
+ buf = next) {
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos;
@@ -204,33 +191,31 @@ msgbuf_drain(struct msgbuf *msgbuf, size_t n)
}
}
-void
-msgbuf_clear(struct msgbuf *msgbuf)
+void msgbuf_clear(struct msgbuf *msgbuf)
{
- struct ibuf *buf;
+ struct ibuf *buf;
while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)
ibuf_dequeue(msgbuf, buf);
}
-int
-msgbuf_write(struct msgbuf *msgbuf)
+int msgbuf_write(struct msgbuf *msgbuf)
{
- struct iovec iov[IOV_MAX];
- struct ibuf *buf;
- unsigned int i = 0;
- ssize_t n;
- struct msghdr msg;
- struct cmsghdr *cmsg;
+ struct iovec iov[IOV_MAX];
+ struct ibuf *buf;
+ unsigned int i = 0;
+ ssize_t n;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
union {
- struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int))];
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int))];
} cmsgbuf;
memset(&iov, 0, sizeof(iov));
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
- TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
+ TAILQ_FOREACH (buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
@@ -262,7 +247,7 @@ again:
return (-1);
}
- if (n == 0) { /* connection closed */
+ if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
@@ -281,15 +266,13 @@ again:
return (1);
}
-void
-ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
+void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++;
}
-void
-ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
+void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
diff --git a/lib/imsg.c b/lib/imsg.c
index 999ab679b8..1c2f480aab 100644
--- a/lib/imsg.c
+++ b/lib/imsg.c
@@ -21,22 +21,21 @@
#include "queue.h"
#include "imsg.h"
-int imsg_fd_overhead = 0;
+int imsg_fd_overhead = 0;
-int imsg_get_fd(struct imsgbuf *);
+int imsg_get_fd(struct imsgbuf *);
#ifndef __OpenBSD__
/*
* The original code calls getdtablecount() which is OpenBSD specific. Use
* available_fds() from OpenSMTPD instead.
*/
-static int
-available_fds(unsigned int n)
+static int available_fds(unsigned int n)
{
- unsigned int i;
- int ret, fds[256];
+ unsigned int i;
+ int ret, fds[256];
- if (n > (sizeof(fds)/sizeof(fds[0])))
+ if (n > (sizeof(fds) / sizeof(fds[0])))
return (1);
ret = 0;
@@ -59,8 +58,7 @@ available_fds(unsigned int n)
}
#endif
-void
-imsg_init(struct imsgbuf *ibuf, int fd)
+void imsg_init(struct imsgbuf *ibuf, int fd)
{
msgbuf_init(&ibuf->w);
memset(&ibuf->r, 0, sizeof(ibuf->r));
@@ -70,19 +68,18 @@ imsg_init(struct imsgbuf *ibuf, int fd)
TAILQ_INIT(&ibuf->fds);
}
-ssize_t
-imsg_read(struct imsgbuf *ibuf)
+ssize_t imsg_read(struct imsgbuf *ibuf)
{
- struct msghdr msg;
- struct cmsghdr *cmsg;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int) * 1)];
+ char buf[CMSG_SPACE(sizeof(int) * 1)];
} cmsgbuf;
- struct iovec iov;
- ssize_t n = -1;
- int fd;
- struct imsg_fd *ifd;
+ struct iovec iov;
+ ssize_t n = -1;
+ int fd;
+ struct imsg_fd *ifd;
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
@@ -99,12 +96,14 @@ imsg_read(struct imsgbuf *ibuf)
again:
#ifdef __OpenBSD__
- if (getdtablecount() + imsg_fd_overhead +
- (int)((CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))
+ if (getdtablecount() + imsg_fd_overhead
+ + (int)((CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0))
+ / sizeof(int))
>= getdtablesize()) {
#else
- if (available_fds(imsg_fd_overhead +
- (CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))) {
+ if (available_fds(imsg_fd_overhead
+ + (CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0))
+ / sizeof(int))) {
#endif
errno = EAGAIN;
free(ifd);
@@ -120,9 +119,9 @@ again:
ibuf->r.wpos += n;
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_RIGHTS) {
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET
+ && cmsg->cmsg_type == SCM_RIGHTS) {
int i;
int j;
@@ -131,14 +130,15 @@ again:
* padding rules, our control buffer might contain
* more than one fd, and we must close them.
*/
- j = ((char *)cmsg + cmsg->cmsg_len -
- (char *)CMSG_DATA(cmsg)) / sizeof(int);
+ j = ((char *)cmsg + cmsg->cmsg_len
+ - (char *)CMSG_DATA(cmsg))
+ / sizeof(int);
for (i = 0; i < j; i++) {
fd = ((int *)CMSG_DATA(cmsg))[i];
if (ifd != NULL) {
ifd->fd = fd;
TAILQ_INSERT_TAIL(&ibuf->fds, ifd,
- entry);
+ entry);
ifd = NULL;
} else
close(fd);
@@ -152,10 +152,9 @@ fail:
return (n);
}
-ssize_t
-imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
+ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
{
- size_t av, left, datalen;
+ size_t av, left, datalen;
av = ibuf->r.wpos;
@@ -163,8 +162,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
return (0);
memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
- if (imsg->hdr.len < IMSG_HEADER_SIZE ||
- imsg->hdr.len > MAX_IMSGSIZE) {
+ if (imsg->hdr.len < IMSG_HEADER_SIZE || imsg->hdr.len > MAX_IMSGSIZE) {
errno = ERANGE;
return (-1);
}
@@ -183,7 +181,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
imsg->fd = -1;
if (imsg->data)
- memcpy(imsg->data, ibuf->r.rptr, datalen);
+ memcpy(imsg->data, ibuf->r.rptr, datalen);
if (imsg->hdr.len < av) {
left = av - imsg->hdr.len;
@@ -195,11 +193,10 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
return (datalen + IMSG_HEADER_SIZE);
}
-int
-imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, int fd, const void *data, u_int16_t datalen)
+int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, int fd, const void *data, u_int16_t datalen)
{
- struct ibuf *wbuf;
+ struct ibuf *wbuf;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
return (-1);
@@ -214,12 +211,11 @@ imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
return (1);
}
-int
-imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, int fd, const struct iovec *iov, int iovcnt)
+int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, int fd, const struct iovec *iov, int iovcnt)
{
- struct ibuf *wbuf;
- int i, datalen = 0;
+ struct ibuf *wbuf;
+ int i, datalen = 0;
for (i = 0; i < iovcnt; i++)
datalen += iov[i].iov_len;
@@ -239,12 +235,11 @@ imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
}
/* ARGSUSED */
-struct ibuf *
-imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, u_int16_t datalen)
+struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, u_int16_t datalen)
{
- struct ibuf *wbuf;
- struct imsg_hdr hdr;
+ struct ibuf *wbuf;
+ struct imsg_hdr hdr;
datalen += IMSG_HEADER_SIZE;
if (datalen > MAX_IMSGSIZE) {
@@ -266,8 +261,7 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
return (wbuf);
}
-int
-imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
+int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
{
if (datalen)
if (ibuf_add(msg, data, datalen) == -1) {
@@ -277,10 +271,9 @@ imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
return (datalen);
}
-void
-imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
+void imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
{
- struct imsg_hdr *hdr;
+ struct imsg_hdr *hdr;
hdr = (struct imsg_hdr *)msg->buf;
@@ -293,17 +286,15 @@ imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
ibuf_close(&ibuf->w, msg);
}
-void
-imsg_free(struct imsg *imsg)
+void imsg_free(struct imsg *imsg)
{
free(imsg->data);
}
-int
-imsg_get_fd(struct imsgbuf *ibuf)
+int imsg_get_fd(struct imsgbuf *ibuf)
{
- int fd;
- struct imsg_fd *ifd;
+ int fd;
+ struct imsg_fd *ifd;
if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)
return (-1);
@@ -315,8 +306,7 @@ imsg_get_fd(struct imsgbuf *ibuf)
return (fd);
}
-int
-imsg_flush(struct imsgbuf *ibuf)
+int imsg_flush(struct imsgbuf *ibuf)
{
while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) <= 0)
@@ -324,10 +314,9 @@ imsg_flush(struct imsgbuf *ibuf)
return (0);
}
-void
-imsg_clear(struct imsgbuf *ibuf)
+void imsg_clear(struct imsgbuf *ibuf)
{
- int fd;
+ int fd;
msgbuf_clear(&ibuf->w);
while ((fd = imsg_get_fd(ibuf)) != -1)
diff --git a/lib/imsg.h b/lib/imsg.h
index d053d01956..ddaf71344e 100644
--- a/lib/imsg.h
+++ b/lib/imsg.h
@@ -26,87 +26,87 @@
#define MAX_IMSGSIZE 16384
struct ibuf {
- TAILQ_ENTRY(ibuf) entry;
- u_char *buf;
- size_t size;
- size_t max;
- size_t wpos;
- size_t rpos;
- int fd;
+ TAILQ_ENTRY(ibuf) entry;
+ u_char *buf;
+ size_t size;
+ size_t max;
+ size_t wpos;
+ size_t rpos;
+ int fd;
};
struct msgbuf {
- TAILQ_HEAD(, ibuf) bufs;
- u_int32_t queued;
- int fd;
+ TAILQ_HEAD(, ibuf) bufs;
+ u_int32_t queued;
+ int fd;
};
struct ibuf_read {
- u_char buf[IBUF_READ_SIZE];
- u_char *rptr;
- size_t wpos;
+ u_char buf[IBUF_READ_SIZE];
+ u_char *rptr;
+ size_t wpos;
};
struct imsg_fd {
- TAILQ_ENTRY(imsg_fd) entry;
- int fd;
+ TAILQ_ENTRY(imsg_fd) entry;
+ int fd;
};
struct imsgbuf {
- TAILQ_HEAD(, imsg_fd) fds;
- struct ibuf_read r;
- struct msgbuf w;
- int fd;
- pid_t pid;
+ TAILQ_HEAD(, imsg_fd) fds;
+ struct ibuf_read r;
+ struct msgbuf w;
+ int fd;
+ pid_t pid;
};
#define IMSGF_HASFD 1
struct imsg_hdr {
- u_int32_t type;
- u_int16_t len;
- u_int16_t flags;
- u_int32_t peerid;
- u_int32_t pid;
+ u_int32_t type;
+ u_int16_t len;
+ u_int16_t flags;
+ u_int32_t peerid;
+ u_int32_t pid;
};
struct imsg {
- struct imsg_hdr hdr;
- int fd;
- void *data;
+ struct imsg_hdr hdr;
+ int fd;
+ void *data;
};
/* buffer.c */
-struct ibuf *ibuf_open(size_t);
-struct ibuf *ibuf_dynamic(size_t, size_t);
-int ibuf_add(struct ibuf *, const void *, size_t);
-void *ibuf_reserve(struct ibuf *, size_t);
-void *ibuf_seek(struct ibuf *, size_t, size_t);
-size_t ibuf_size(struct ibuf *);
-size_t ibuf_left(struct ibuf *);
-void ibuf_close(struct msgbuf *, struct ibuf *);
-int ibuf_write(struct msgbuf *);
-void ibuf_free(struct ibuf *);
-void msgbuf_init(struct msgbuf *);
-void msgbuf_clear(struct msgbuf *);
-int msgbuf_write(struct msgbuf *);
-void msgbuf_drain(struct msgbuf *, size_t);
+struct ibuf *ibuf_open(size_t);
+struct ibuf *ibuf_dynamic(size_t, size_t);
+int ibuf_add(struct ibuf *, const void *, size_t);
+void *ibuf_reserve(struct ibuf *, size_t);
+void *ibuf_seek(struct ibuf *, size_t, size_t);
+size_t ibuf_size(struct ibuf *);
+size_t ibuf_left(struct ibuf *);
+void ibuf_close(struct msgbuf *, struct ibuf *);
+int ibuf_write(struct msgbuf *);
+void ibuf_free(struct ibuf *);
+void msgbuf_init(struct msgbuf *);
+void msgbuf_clear(struct msgbuf *);
+int msgbuf_write(struct msgbuf *);
+void msgbuf_drain(struct msgbuf *, size_t);
/* imsg.c */
-void imsg_init(struct imsgbuf *, int);
-ssize_t imsg_read(struct imsgbuf *);
-ssize_t imsg_get(struct imsgbuf *, struct imsg *);
-int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
- int, const void *, u_int16_t);
-int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
- int, const struct iovec *, int);
+void imsg_init(struct imsgbuf *, int);
+ssize_t imsg_read(struct imsgbuf *);
+ssize_t imsg_get(struct imsgbuf *, struct imsg *);
+int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int,
+ const void *, u_int16_t);
+int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int,
+ const struct iovec *, int);
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
- u_int16_t);
-int imsg_add(struct ibuf *, const void *, u_int16_t);
-void imsg_close(struct imsgbuf *, struct ibuf *);
-void imsg_free(struct imsg *);
-int imsg_flush(struct imsgbuf *);
-void imsg_clear(struct imsgbuf *);
+ u_int16_t);
+int imsg_add(struct ibuf *, const void *, u_int16_t);
+void imsg_close(struct imsgbuf *, struct ibuf *);
+void imsg_free(struct imsg *);
+int imsg_flush(struct imsgbuf *);
+void imsg_clear(struct imsgbuf *);
#endif
diff --git a/lib/keychain.c b/lib/keychain.c
index d9a09a3e41..39807cc7ce 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -1083,8 +1083,7 @@ void keychain_init()
&accept_lifetime_duration_day_month_cmd);
install_element(KEYCHAIN_KEY_NODE,
&accept_lifetime_duration_month_day_cmd);
- install_element(KEYCHAIN_KEY_NODE,
- &no_accept_lifetime_cmd);
+ install_element(KEYCHAIN_KEY_NODE, &no_accept_lifetime_cmd);
install_element(KEYCHAIN_KEY_NODE,
&send_lifetime_day_month_day_month_cmd);
@@ -1102,6 +1101,5 @@ void keychain_init()
&send_lifetime_duration_day_month_cmd);
install_element(KEYCHAIN_KEY_NODE,
&send_lifetime_duration_month_day_cmd);
- install_element(KEYCHAIN_KEY_NODE,
- &no_send_lifetime_cmd);
+ install_element(KEYCHAIN_KEY_NODE, &no_send_lifetime_cmd);
}
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 6cb8711edf..8d4a3ff8df 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -168,7 +168,7 @@ bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
break;
case '6':
path++;
- /* fallthrough */
+ /* fallthrough */
default:
af = AF_INET6;
break;
@@ -629,7 +629,7 @@ static void frr_daemon_wait(int fd)
rcvd_signal = 0;
-#if defined(HAVE_PPOLL)
+#if defined(HAVE_PPOLL)
ret = ppoll(pfd, 1, NULL, &prevsigs);
#elif defined(HAVE_POLLTS)
ret = pollts(pfd, 1, NULL, &prevsigs);
@@ -811,18 +811,18 @@ static int frr_daemon_ctl(struct thread *t)
return 0;
switch (buf[0]) {
- case 'S': /* SIGTSTP */
+ case 'S': /* SIGTSTP */
vty_stdio_suspend();
send(daemon_ctl_sock, "s", 1, 0);
break;
- case 'R': /* SIGTCNT [implicit] */
+ case 'R': /* SIGTCNT [implicit] */
vty_stdio_resume();
break;
- case 'I': /* SIGINT */
+ case 'I': /* SIGINT */
di->daemon_mode = false;
raise(SIGINT);
break;
- case 'Q': /* SIGQUIT */
+ case 'Q': /* SIGQUIT */
di->daemon_mode = true;
vty_stdio_close();
break;
@@ -914,10 +914,8 @@ void frr_fini(void)
if (!have_leftovers)
return;
- snprintf(filename, sizeof(filename),
- "/tmp/frr-memstats-%s-%llu-%llu",
- di->name,
- (unsigned long long)getpid(),
+ snprintf(filename, sizeof(filename), "/tmp/frr-memstats-%s-%llu-%llu",
+ di->name, (unsigned long long)getpid(),
(unsigned long long)time(NULL));
fp = fopen(filename, "w");
diff --git a/lib/linklist.h b/lib/linklist.h
index 8a43fbe64b..46617b5f65 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -89,10 +89,12 @@ CPP_NOTICE("list_delete without double pointer is deprecated, please fixup")
#endif
extern void list_delete_and_null(struct list **);
extern void list_delete_original(struct list *);
-#define list_delete(X) list_delete_original((X)) \
- CPP_WARN("Please transition to using list_delete_and_null")
-#define list_free(X) list_delete_original((X)) \
- CPP_WARN("Please transition tousing list_delete_and_null")
+#define list_delete(X) \
+ list_delete_original((X)) \
+ CPP_WARN("Please transition to using list_delete_and_null")
+#define list_free(X) \
+ list_delete_original((X)) \
+ CPP_WARN("Please transition tousing list_delete_and_null")
extern void list_delete_all_node(struct list *);
diff --git a/lib/log.c b/lib/log.c
index 9fc19ff683..9e33ef9102 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -177,9 +177,8 @@ static void time_print(FILE *fp, struct timestamp_control *ctl)
static void vzlog_file(struct zlog *zl, struct timestamp_control *tsctl,
- const char *proto_str, int record_priority,
- int priority, FILE *fp, const char *format,
- va_list args)
+ const char *proto_str, int record_priority, int priority,
+ FILE *fp, const char *format, va_list args)
{
va_list ac;
@@ -237,8 +236,8 @@ void vzlog(int priority, const char *format, va_list args)
/* File output. */
if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
- vzlog_file(zl, &tsctl, proto_str, zl->record_priority,
- priority, zl->fp, format, args);
+ vzlog_file(zl, &tsctl, proto_str, zl->record_priority, priority,
+ zl->fp, format, args);
/* fixed-config logging to stderr while we're stating up & haven't
* daemonized / reached mainloop yet
@@ -246,11 +245,11 @@ void vzlog(int priority, const char *format, va_list args)
* note the "else" on stdout output -- we don't want to print the same
* message to both stderr and stdout. */
if (zlog_startup_stderr && priority <= LOG_WARNING)
- vzlog_file(zl, &tsctl, proto_str, 1,
- priority, stderr, format, args);
+ vzlog_file(zl, &tsctl, proto_str, 1, priority, stderr, format,
+ args);
else if (priority <= zl->maxlvl[ZLOG_DEST_STDOUT])
- vzlog_file(zl, &tsctl, proto_str, zl->record_priority,
- priority, stdout, format, args);
+ vzlog_file(zl, &tsctl, proto_str, zl->record_priority, priority,
+ stdout, format, args);
/* Terminal monitor. */
if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
@@ -962,6 +961,9 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_PW_SET),
DESC_ENTRY(ZEBRA_PW_UNSET),
DESC_ENTRY(ZEBRA_PW_STATUS_UPDATE),
+ DESC_ENTRY(ZEBRA_RULE_ADD),
+ DESC_ENTRY(ZEBRA_RULE_DELETE),
+ DESC_ENTRY(ZEBRA_RULE_NOTIFY_OWNER),
};
#undef DESC_ENTRY
@@ -1114,10 +1116,9 @@ void zlog_hexdump(const void *mem, unsigned int len)
printing */
s += sprintf(s, " ");
- else if (
- isprint((int)((const char *)mem)
- [j])) /* printable char
- */
+ else if (isprint((int)((const char *)mem)
+ [j])) /* printable char
+ */
s += sprintf(
s, "%c",
0xFF & ((const char *)mem)[j]);
diff --git a/lib/logicalrouter.c b/lib/logicalrouter.c
index 4dc99d304f..da69ae5312 100644
--- a/lib/logicalrouter.c
+++ b/lib/logicalrouter.c
@@ -35,8 +35,7 @@
DEFINE_MTYPE_STATIC(LIB, LOGICALROUTER_NAME, "Logical Router Name")
/* Logical Router node has no interface. */
-static struct cmd_node logicalrouter_node = {LOGICALROUTER_NODE, "",
- 1};
+static struct cmd_node logicalrouter_node = {LOGICALROUTER_NODE, "", 1};
static int logicalrouter_backend;
diff --git a/lib/memory.c b/lib/memory.c
index c684c7605c..90d7d420a9 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -132,7 +132,7 @@ static int qmem_exit_walker(void *arg, struct memgroup *mg, struct memtype *mt)
int log_memstats(FILE *fp, const char *prefix)
{
- struct exit_dump_args eda = { .fp = fp, .prefix = prefix, .error = 0 };
+ struct exit_dump_args eda = {.fp = fp, .prefix = prefix, .error = 0};
qmem_walk(qmem_exit_walker, &eda);
return eda.error;
}
diff --git a/lib/module.c b/lib/module.c
index b3ab91c4ea..3f13307d82 100644
--- a/lib/module.c
+++ b/lib/module.c
@@ -42,10 +42,11 @@ static struct frrmod_info frrmod_default_info = {
.description = "libfrr core module",
};
union _frrmod_runtime_u frrmod_default = {
- .r = {
- .info = &frrmod_default_info,
- .finished_loading = 1,
- },
+ .r =
+ {
+ .info = &frrmod_default_info,
+ .finished_loading = 1,
+ },
};
// if defined(HAVE_SYS_WEAK_ALIAS_ATTRIBUTE)
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 0e955bade9..01616be711 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -43,6 +43,9 @@
DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context")
DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name")
+/* default NS ID value used when VRF backend is not NETNS */
+#define NS_DEFAULT_INTERNAL 0
+
static inline int ns_compare(const struct ns *ns, const struct ns *ns2);
static struct ns *ns_lookup_name_internal(const char *name);
@@ -173,7 +176,7 @@ static struct ns *ns_get_created_internal(struct ns *ns, char *name,
zlog_info("NS %s is created.", ns->name);
}
if (ns_master.ns_new_hook)
- (*ns_master.ns_new_hook) (ns);
+ (*ns_master.ns_new_hook)(ns);
return ns;
}
@@ -247,8 +250,7 @@ static void ns_disable_internal(struct ns *ns)
{
if (ns_is_enabled(ns)) {
if (ns_debug)
- zlog_info("NS %u is to be disabled.",
- ns->ns_id);
+ zlog_info("NS %u is to be disabled.", ns->ns_id);
if (ns_master.ns_disable_hook)
(*ns_master.ns_disable_hook)(ns);
@@ -295,8 +297,7 @@ void ns_delete(struct ns *ns)
}
/* Look up the data pointer of the specified VRF. */
-void *
-ns_info_lookup(ns_id_t ns_id)
+void *ns_info_lookup(ns_id_t ns_id)
{
struct ns *ns = ns_lookup_internal(ns_id);
@@ -385,18 +386,17 @@ char *ns_netns_pathname(struct vty *vty, const char *name)
vty_out(vty, "Invalid pathname: %s\n",
safe_strerror(errno));
else
- zlog_warn("Invalid pathname: %s",
- safe_strerror(errno));
+ zlog_warn("Invalid pathname: %s", safe_strerror(errno));
return NULL;
}
check_base = basename(pathname);
if (check_base != NULL && strlen(check_base) + 1 > NS_NAMSIZ) {
if (vty)
vty_out(vty, "NS name (%s) invalid: too long (>%d)\n",
- check_base, NS_NAMSIZ-1);
+ check_base, NS_NAMSIZ - 1);
else
zlog_warn("NS name (%s) invalid: too long (>%d)",
- check_base, NS_NAMSIZ-1);
+ check_base, NS_NAMSIZ - 1);
return NULL;
}
return pathname;
@@ -414,8 +414,10 @@ void ns_init(void)
#ifdef HAVE_NETNS
if (have_netns_enabled < 0)
ns_default_ns_fd = open(NS_DEFAULT_NAME, O_RDONLY);
- else
+ else {
ns_default_ns_fd = -1;
+ default_ns = NULL;
+ }
#else
ns_default_ns_fd = -1;
default_ns = NULL;
@@ -435,8 +437,7 @@ void ns_init_management(ns_id_t default_ns_id)
ns_init();
default_ns = ns_get_created_internal(NULL, NULL, default_ns_id);
if (!default_ns) {
- zlog_err("%s: failed to create the default NS!",
- __func__);
+ zlog_err("%s: failed to create the default NS!", __func__);
exit(1);
}
if (have_netns()) {
@@ -446,13 +447,12 @@ void ns_init_management(ns_id_t default_ns_id)
/* Set the default NS name. */
default_ns->name = XSTRDUP(MTYPE_NS_NAME, NS_DEFAULT_NAME);
if (ns_debug)
- zlog_info("%s: default NSID is %u",
- __func__, default_ns->ns_id);
+ zlog_info("%s: default NSID is %u", __func__,
+ default_ns->ns_id);
/* Enable the default NS. */
if (!ns_enable(default_ns, NULL)) {
- zlog_err("%s: failed to enable the default NS!",
- __func__);
+ zlog_err("%s: failed to enable the default NS!", __func__);
exit(1);
}
}
@@ -534,6 +534,5 @@ ns_id_t ns_get_default_id(void)
{
if (default_ns)
return default_ns->ns_id;
- return NS_UNKNOWN;
+ return NS_DEFAULT_INTERNAL;
}
-
diff --git a/lib/nexthop.c b/lib/nexthop.c
index a094c0e38d..cee34e85c7 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -71,18 +71,16 @@ int nexthop_same_no_recurse(const struct nexthop *next1,
return 1;
}
-int
-nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2)
+int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2)
{
int type1 = NEXTHOP_FIRSTHOPTYPE(next1->type);
int type2 = NEXTHOP_FIRSTHOPTYPE(next2->type);
if (type1 != type2)
return 0;
- switch (type1)
- {
+ switch (type1) {
case NEXTHOP_TYPE_IPV4_IFINDEX:
- if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4))
+ if (!IPV4_ADDR_SAME(&next1->gate.ipv4, &next2->gate.ipv4))
return 0;
if (next1->ifindex != next2->ifindex)
return 0;
@@ -92,7 +90,7 @@ nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2)
return 0;
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
- if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6))
+ if (!IPV6_ADDR_SAME(&next1->gate.ipv6, &next2->gate.ipv6))
return 0;
if (next1->ifindex != next2->ifindex)
return 0;
@@ -145,48 +143,6 @@ struct nexthop *nexthop_new(void)
return XCALLOC(MTYPE_NEXTHOP, sizeof(struct nexthop));
}
-/* Add nexthop to the end of a nexthop list. */
-void nexthop_add(struct nexthop **target, struct nexthop *nexthop)
-{
- struct nexthop *last;
-
- for (last = *target; last && last->next; last = last->next)
- ;
- if (last)
- last->next = nexthop;
- else
- *target = nexthop;
- nexthop->prev = last;
-}
-
-void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
- struct nexthop *rparent)
-{
- struct nexthop *nexthop;
- struct nexthop *nh1;
-
- for (nh1 = nh; nh1; nh1 = nh1->next) {
- nexthop = nexthop_new();
- nexthop->vrf_id = nh1->vrf_id;
- nexthop->ifindex = nh1->ifindex;
- nexthop->type = nh1->type;
- nexthop->flags = nh1->flags;
- memcpy(&nexthop->gate, &nh1->gate, sizeof(nh1->gate));
- memcpy(&nexthop->src, &nh1->src, sizeof(nh1->src));
- memcpy(&nexthop->rmap_src, &nh1->rmap_src, sizeof(nh1->rmap_src));
- nexthop->rparent = rparent;
- if (nh1->nh_label)
- nexthop_add_labels(nexthop, nh1->nh_label_type,
- nh1->nh_label->num_labels,
- &nh1->nh_label->label[0]);
- nexthop_add(tnh, nexthop);
-
- if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE))
- copy_nexthops(&nexthop->resolved, nh1->resolved,
- nexthop);
- }
-}
-
/* Free nexthop. */
void nexthop_free(struct nexthop *nexthop)
{
diff --git a/lib/nexthop.h b/lib/nexthop.h
index b502f293bc..0ca8a0063a 100644
--- a/lib/nexthop.h
+++ b/lib/nexthop.h
@@ -51,9 +51,10 @@ enum blackhole_type {
};
/* IPV[46] -> IPV[46]_IFINDEX */
-#define NEXTHOP_FIRSTHOPTYPE(type) \
- ((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE) \
- ? (type) : ((type) | 1)
+#define NEXTHOP_FIRSTHOPTYPE(type) \
+ ((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE) \
+ ? (type) \
+ : ((type) | 1)
/* Nexthop structure. */
struct nexthop {
@@ -79,9 +80,9 @@ struct nexthop {
#define NEXTHOP_FLAG_FILTERED (1 << 5) /* rmap filtered, used by static only */
#define NEXTHOP_FLAG_DUPLICATE (1 << 6) /* nexthop duplicates another active one */
#define NEXTHOP_FLAG_EVPN_RVTEP (1 << 7) /* EVPN remote vtep nexthop */
-#define NEXTHOP_IS_ACTIVE(flags) \
- (CHECK_FLAG(flags, NEXTHOP_FLAG_ACTIVE) \
- && !CHECK_FLAG(flags, NEXTHOP_FLAG_DUPLICATE))
+#define NEXTHOP_IS_ACTIVE(flags) \
+ (CHECK_FLAG(flags, NEXTHOP_FLAG_ACTIVE) \
+ && !CHECK_FLAG(flags, NEXTHOP_FLAG_DUPLICATE))
/* Nexthop address */
union {
@@ -108,24 +109,8 @@ struct nexthop {
struct mpls_label_stack *nh_label;
};
-/* The following for loop allows to iterate over the nexthop
- * structure of routes.
- *
- * head: The pointer to the first nexthop in the chain.
- *
- * nexthop: The pointer to the current nexthop, either in the
- * top-level chain or in a resolved chain.
- */
-#define ALL_NEXTHOPS(head, nexthop) \
- (nexthop) = (head); \
- (nexthop); \
- (nexthop) = nexthop_next(nexthop)
-
struct nexthop *nexthop_new(void);
-void nexthop_add(struct nexthop **target, struct nexthop *nexthop);
-void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
- struct nexthop *rparent);
void nexthop_free(struct nexthop *nexthop);
void nexthops_free(struct nexthop *nexthop);
@@ -137,7 +122,7 @@ extern const char *nexthop_type_to_str(enum nexthop_types_t nh_type);
extern int nexthop_same_no_recurse(const struct nexthop *next1,
const struct nexthop *next2);
extern int nexthop_labels_match(struct nexthop *nh1, struct nexthop *nh2);
-extern int nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2);
+extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2);
extern const char *nexthop2str(struct nexthop *nexthop, char *str, int size);
extern struct nexthop *nexthop_next(struct nexthop *nexthop);
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
new file mode 100644
index 0000000000..e7f10487d1
--- /dev/null
+++ b/lib/nexthop_group.c
@@ -0,0 +1,100 @@
+/*
+ * Nexthop Group structure definition.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <zebra.h>
+
+#include <nexthop.h>
+#include <nexthop_group.h>
+#include <vty.h>
+#include <command.h>
+
+#ifndef VTYSH_EXTRACT_PL
+#include "lib/nexthop_group_clippy.c"
+#endif
+
+/* Add nexthop to the end of a nexthop list. */
+void nexthop_add(struct nexthop **target, struct nexthop *nexthop)
+{
+ struct nexthop *last;
+
+ for (last = *target; last && last->next; last = last->next)
+ ;
+ if (last)
+ last->next = nexthop;
+ else
+ *target = nexthop;
+ nexthop->prev = last;
+}
+
+void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
+ struct nexthop *rparent)
+{
+ struct nexthop *nexthop;
+ struct nexthop *nh1;
+
+ for (nh1 = nh; nh1; nh1 = nh1->next) {
+ nexthop = nexthop_new();
+ nexthop->vrf_id = nh1->vrf_id;
+ nexthop->ifindex = nh1->ifindex;
+ nexthop->type = nh1->type;
+ nexthop->flags = nh1->flags;
+ memcpy(&nexthop->gate, &nh1->gate, sizeof(nh1->gate));
+ memcpy(&nexthop->src, &nh1->src, sizeof(nh1->src));
+ memcpy(&nexthop->rmap_src, &nh1->rmap_src,
+ sizeof(nh1->rmap_src));
+ nexthop->rparent = rparent;
+ if (nh1->nh_label)
+ nexthop_add_labels(nexthop, nh1->nh_label_type,
+ nh1->nh_label->num_labels,
+ &nh1->nh_label->label[0]);
+ nexthop_add(tnh, nexthop);
+
+ if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE))
+ copy_nexthops(&nexthop->resolved, nh1->resolved,
+ nexthop);
+ }
+}
+
+DEFPY (nexthop_group,
+ nexthop_group_cmd,
+ "nexthop-group NAME",
+ "Enter into the nexthop-group submode\n"
+ "Specify the NAME of the nexthop-group\n")
+{
+ return CMD_SUCCESS;
+}
+
+struct cmd_node nexthop_group_node = {
+ NH_GROUP_NODE,
+ "%s(config-nh-group)# ",
+ 1
+};
+
+static int nexthop_group_write(struct vty *vty)
+{
+ vty_out(vty, "!\n");
+
+ return 1;
+}
+
+void nexthop_group_init(void)
+{
+ install_node(&nexthop_group_node, nexthop_group_write);
+ install_element(CONFIG_NODE, &nexthop_group_cmd);
+}
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
new file mode 100644
index 0000000000..561fe96425
--- /dev/null
+++ b/lib/nexthop_group.h
@@ -0,0 +1,54 @@
+/*
+ * Nexthop Group structure definition.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __NEXTHOP_GROUP__
+#define __NEXTHOP_GROUP__
+
+/*
+ * What is a nexthop group?
+ *
+ * A nexthop group is a collection of nexthops that make up
+ * the ECMP path for the route.
+ *
+ * This module provides a proper abstraction to this idea.
+ */
+struct nexthop_group {
+ struct nexthop *nexthop;
+};
+
+void nexthop_group_init(void);
+
+void nexthop_add(struct nexthop **target, struct nexthop *nexthop);
+void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
+ struct nexthop *rparent);
+
+/* The following for loop allows to iterate over the nexthop
+ * structure of routes.
+ *
+ * head: The pointer to the first nexthop in the chain.
+ *
+ * nexthop: The pointer to the current nexthop, either in the
+ * top-level chain or in a resolved chain.
+ */
+#define ALL_NEXTHOPS(head, nhop) \
+ (nhop) = (head.nexthop); \
+ (nhop); \
+ (nhop) = nexthop_next(nhop)
+#endif
diff --git a/lib/openbsd-tree.c b/lib/openbsd-tree.c
index d171e14d25..35bfce3a89 100644
--- a/lib/openbsd-tree.c
+++ b/lib/openbsd-tree.c
@@ -45,16 +45,14 @@
#include <lib/openbsd-tree.h>
-static inline struct rb_entry *
-rb_n2e(const struct rb_type *t, void *node)
+static inline struct rb_entry *rb_n2e(const struct rb_type *t, void *node)
{
unsigned long addr = (unsigned long)node;
return ((struct rb_entry *)(addr + t->t_offset));
}
-static inline void *
-rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
+static inline void *rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
{
unsigned long addr = (unsigned long)rbe;
@@ -68,37 +66,33 @@ rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
#define RBH_ROOT(_rbt) (_rbt)->rbt_root
-static inline void
-rbe_set(struct rb_entry *rbe, struct rb_entry *parent)
+static inline void rbe_set(struct rb_entry *rbe, struct rb_entry *parent)
{
RBE_PARENT(rbe) = parent;
RBE_LEFT(rbe) = RBE_RIGHT(rbe) = NULL;
RBE_COLOR(rbe) = RB_RED;
}
-static inline void
-rbe_set_blackred(struct rb_entry *black, struct rb_entry *red)
+static inline void rbe_set_blackred(struct rb_entry *black,
+ struct rb_entry *red)
{
RBE_COLOR(black) = RB_BLACK;
RBE_COLOR(red) = RB_RED;
}
-static inline void
-rbe_augment(const struct rb_type *t, struct rb_entry *rbe)
+static inline void rbe_augment(const struct rb_type *t, struct rb_entry *rbe)
{
(*t->t_augment)(rb_e2n(t, rbe));
}
-static inline void
-rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe)
+static inline void rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe)
{
if (t->t_augment != NULL)
rbe_augment(t, rbe);
}
-static inline void
-rbe_rotate_left(const struct rb_type *t, struct rbt_tree *rbt,
- struct rb_entry *rbe)
+static inline void rbe_rotate_left(const struct rb_type *t,
+ struct rbt_tree *rbt, struct rb_entry *rbe)
{
struct rb_entry *parent;
struct rb_entry *tmp;
@@ -130,9 +124,8 @@ rbe_rotate_left(const struct rb_type *t, struct rbt_tree *rbt,
}
}
-static inline void
-rbe_rotate_right(const struct rb_type *t, struct rbt_tree *rbt,
- struct rb_entry *rbe)
+static inline void rbe_rotate_right(const struct rb_type *t,
+ struct rbt_tree *rbt, struct rb_entry *rbe)
{
struct rb_entry *parent;
struct rb_entry *tmp;
@@ -164,14 +157,13 @@ rbe_rotate_right(const struct rb_type *t, struct rbt_tree *rbt,
}
}
-static inline void
-rbe_insert_color(const struct rb_type *t, struct rbt_tree *rbt,
- struct rb_entry *rbe)
+static inline void rbe_insert_color(const struct rb_type *t,
+ struct rbt_tree *rbt, struct rb_entry *rbe)
{
struct rb_entry *parent, *gparent, *tmp;
- while ((parent = RBE_PARENT(rbe)) != NULL &&
- RBE_COLOR(parent) == RB_RED) {
+ while ((parent = RBE_PARENT(rbe)) != NULL
+ && RBE_COLOR(parent) == RB_RED) {
gparent = RBE_PARENT(parent);
if (parent == RBE_LEFT(gparent)) {
@@ -216,14 +208,15 @@ rbe_insert_color(const struct rb_type *t, struct rbt_tree *rbt,
RBE_COLOR(RBH_ROOT(rbt)) = RB_BLACK;
}
-static inline void
-rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,
- struct rb_entry *parent, struct rb_entry *rbe)
+static inline void rbe_remove_color(const struct rb_type *t,
+ struct rbt_tree *rbt,
+ struct rb_entry *parent,
+ struct rb_entry *rbe)
{
struct rb_entry *tmp;
- while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) &&
- rbe != RBH_ROOT(rbt) && parent) {
+ while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK)
+ && rbe != RBH_ROOT(rbt) && parent) {
if (RBE_LEFT(parent) == rbe) {
tmp = RBE_RIGHT(parent);
if (RBE_COLOR(tmp) == RB_RED) {
@@ -231,16 +224,16 @@ rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,
rbe_rotate_left(t, rbt, parent);
tmp = RBE_RIGHT(parent);
}
- if ((RBE_LEFT(tmp) == NULL ||
- RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) &&
- (RBE_RIGHT(tmp) == NULL ||
- RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
+ if ((RBE_LEFT(tmp) == NULL
+ || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK)
+ && (RBE_RIGHT(tmp) == NULL
+ || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
RBE_COLOR(tmp) = RB_RED;
rbe = parent;
parent = RBE_PARENT(rbe);
} else {
- if (RBE_RIGHT(tmp) == NULL ||
- RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) {
+ if (RBE_RIGHT(tmp) == NULL
+ || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) {
struct rb_entry *oleft;
oleft = RBE_LEFT(tmp);
@@ -269,16 +262,16 @@ rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,
tmp = RBE_LEFT(parent);
}
- if ((RBE_LEFT(tmp) == NULL ||
- RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) &&
- (RBE_RIGHT(tmp) == NULL ||
- RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
+ if ((RBE_LEFT(tmp) == NULL
+ || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK)
+ && (RBE_RIGHT(tmp) == NULL
+ || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
RBE_COLOR(tmp) = RB_RED;
rbe = parent;
parent = RBE_PARENT(rbe);
} else {
- if (RBE_LEFT(tmp) == NULL ||
- RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) {
+ if (RBE_LEFT(tmp) == NULL
+ || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) {
struct rb_entry *oright;
oright = RBE_RIGHT(tmp);
@@ -388,8 +381,7 @@ color:
return (old);
}
-void *
-_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
+void *_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
struct rb_entry *old;
@@ -399,8 +391,7 @@ _rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
return (old == NULL ? NULL : rb_e2n(t, old));
}
-void *
-_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
+void *_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
struct rb_entry *tmp;
@@ -440,8 +431,7 @@ _rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
}
/* Finds the node with the same key as elm */
-void *
-_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
+void *_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
{
struct rb_entry *tmp = RBH_ROOT(rbt);
void *node;
@@ -462,8 +452,7 @@ _rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
}
/* Finds the first node greater than or equal to the search key */
-void *
-_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
+void *_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
{
struct rb_entry *tmp = RBH_ROOT(rbt);
void *node;
@@ -485,8 +474,7 @@ _rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
return (res);
}
-void *
-_rb_next(const struct rb_type *t, void *elm)
+void *_rb_next(const struct rb_type *t, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
@@ -495,12 +483,11 @@ _rb_next(const struct rb_type *t, void *elm)
while (RBE_LEFT(rbe) != NULL)
rbe = RBE_LEFT(rbe);
} else {
- if (RBE_PARENT(rbe) &&
- (rbe == RBE_LEFT(RBE_PARENT(rbe))))
+ if (RBE_PARENT(rbe) && (rbe == RBE_LEFT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
else {
- while (RBE_PARENT(rbe) &&
- (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
+ while (RBE_PARENT(rbe)
+ && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
rbe = RBE_PARENT(rbe);
}
@@ -509,8 +496,7 @@ _rb_next(const struct rb_type *t, void *elm)
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *
-_rb_prev(const struct rb_type *t, void *elm)
+void *_rb_prev(const struct rb_type *t, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
@@ -519,12 +505,11 @@ _rb_prev(const struct rb_type *t, void *elm)
while (RBE_RIGHT(rbe))
rbe = RBE_RIGHT(rbe);
} else {
- if (RBE_PARENT(rbe) &&
- (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
+ if (RBE_PARENT(rbe) && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
else {
- while (RBE_PARENT(rbe) &&
- (rbe == RBE_LEFT(RBE_PARENT(rbe))))
+ while (RBE_PARENT(rbe)
+ && (rbe == RBE_LEFT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
rbe = RBE_PARENT(rbe);
}
@@ -533,16 +518,14 @@ _rb_prev(const struct rb_type *t, void *elm)
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *
-_rb_root(const struct rb_type *t, struct rbt_tree *rbt)
+void *_rb_root(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
return (rbe == NULL ? rbe : rb_e2n(t, rbe));
}
-void *
-_rb_min(const struct rb_type *t, struct rbt_tree *rbt)
+void *_rb_min(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
struct rb_entry *parent = NULL;
@@ -555,8 +538,7 @@ _rb_min(const struct rb_type *t, struct rbt_tree *rbt)
return (parent == NULL ? NULL : rb_e2n(t, parent));
}
-void *
-_rb_max(const struct rb_type *t, struct rbt_tree *rbt)
+void *_rb_max(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
struct rb_entry *parent = NULL;
@@ -569,32 +551,28 @@ _rb_max(const struct rb_type *t, struct rbt_tree *rbt)
return (parent == NULL ? NULL : rb_e2n(t, parent));
}
-void *
-_rb_left(const struct rb_type *t, void *node)
+void *_rb_left(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_LEFT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *
-_rb_right(const struct rb_type *t, void *node)
+void *_rb_right(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_RIGHT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *
-_rb_parent(const struct rb_type *t, void *node)
+void *_rb_parent(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_PARENT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void
-_rb_set_left(const struct rb_type *t, void *node, void *left)
+void _rb_set_left(const struct rb_type *t, void *node, void *left)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbl = (left == NULL) ? NULL : rb_n2e(t, left);
@@ -602,8 +580,7 @@ _rb_set_left(const struct rb_type *t, void *node, void *left)
RBE_LEFT(rbe) = rbl;
}
-void
-_rb_set_right(const struct rb_type *t, void *node, void *right)
+void _rb_set_right(const struct rb_type *t, void *node, void *right)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbr = (right == NULL) ? NULL : rb_n2e(t, right);
@@ -611,8 +588,7 @@ _rb_set_right(const struct rb_type *t, void *node, void *right)
RBE_RIGHT(rbe) = rbr;
}
-void
-_rb_set_parent(const struct rb_type *t, void *node, void *parent)
+void _rb_set_parent(const struct rb_type *t, void *node, void *parent)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbp = (parent == NULL) ? NULL : rb_n2e(t, parent);
@@ -620,21 +596,19 @@ _rb_set_parent(const struct rb_type *t, void *node, void *parent)
RBE_PARENT(rbe) = rbp;
}
-void
-_rb_poison(const struct rb_type *t, void *node, unsigned long poison)
+void _rb_poison(const struct rb_type *t, void *node, unsigned long poison)
{
struct rb_entry *rbe = rb_n2e(t, node);
RBE_PARENT(rbe) = RBE_LEFT(rbe) = RBE_RIGHT(rbe) =
- (struct rb_entry *)poison;
+ (struct rb_entry *)poison;
}
-int
-_rb_check(const struct rb_type *t, void *node, unsigned long poison)
+int _rb_check(const struct rb_type *t, void *node, unsigned long poison)
{
struct rb_entry *rbe = rb_n2e(t, node);
- return ((unsigned long)RBE_PARENT(rbe) == poison &&
- (unsigned long)RBE_LEFT(rbe) == poison &&
- (unsigned long)RBE_RIGHT(rbe) == poison);
+ return ((unsigned long)RBE_PARENT(rbe) == poison
+ && (unsigned long)RBE_LEFT(rbe) == poison
+ && (unsigned long)RBE_RIGHT(rbe) == poison);
}
diff --git a/lib/openbsd-tree.h b/lib/openbsd-tree.h
index 22cb9252f5..859f751678 100644
--- a/lib/openbsd-tree.h
+++ b/lib/openbsd-tree.h
@@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _SYS_TREE_H_
+#ifndef _SYS_TREE_H_
#define _SYS_TREE_H_
/*
@@ -54,23 +54,26 @@
* The maximum height of a red-black tree is 2lg (n+1).
*/
-#define SPLAY_HEAD(name, type) \
-struct name { \
- struct type *sph_root; /* root of the tree */ \
-}
+#define SPLAY_HEAD(name, type) \
+ struct name { \
+ struct type *sph_root; /* root of the tree */ \
+ }
-#define SPLAY_INITIALIZER(root) \
- { NULL }
+#define SPLAY_INITIALIZER(root) \
+ { \
+ NULL \
+ }
-#define SPLAY_INIT(root) do { \
- (root)->sph_root = NULL; \
-} while (0)
+#define SPLAY_INIT(root) \
+ do { \
+ (root)->sph_root = NULL; \
+ } while (0)
-#define SPLAY_ENTRY(type) \
-struct { \
- struct type *spe_left; /* left element */ \
- struct type *spe_right; /* right element */ \
-}
+#define SPLAY_ENTRY(type) \
+ struct { \
+ struct type *spe_left; /* left element */ \
+ struct type *spe_right; /* right element */ \
+ }
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
@@ -78,197 +81,220 @@ struct { \
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
-#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
- SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
-} while (0)
-
-#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
- SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
-} while (0)
-
-#define SPLAY_LINKLEFT(head, tmp, field) do { \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
-} while (0)
-
-#define SPLAY_LINKRIGHT(head, tmp, field) do { \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
-} while (0)
-
-#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
- SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
- SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
- SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
- SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
-} while (0)
+#define SPLAY_ROTATE_RIGHT(head, tmp, field) \
+ do { \
+ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
+ (head)->sph_root = tmp; \
+ } while (0)
+
+#define SPLAY_ROTATE_LEFT(head, tmp, field) \
+ do { \
+ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
+ (head)->sph_root = tmp; \
+ } while (0)
+
+#define SPLAY_LINKLEFT(head, tmp, field) \
+ do { \
+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
+ tmp = (head)->sph_root; \
+ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
+ } while (0)
+
+#define SPLAY_LINKRIGHT(head, tmp, field) \
+ do { \
+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
+ tmp = (head)->sph_root; \
+ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
+ } while (0)
+
+#define SPLAY_ASSEMBLE(head, node, left, right, field) \
+ do { \
+ SPLAY_RIGHT(left, field) = \
+ SPLAY_LEFT((head)->sph_root, field); \
+ SPLAY_LEFT(right, field) = \
+ SPLAY_RIGHT((head)->sph_root, field); \
+ SPLAY_LEFT((head)->sph_root, field) = \
+ SPLAY_RIGHT(node, field); \
+ SPLAY_RIGHT((head)->sph_root, field) = \
+ SPLAY_LEFT(node, field); \
+ } while (0)
/* Generates prototypes and inline functions */
-#define SPLAY_PROTOTYPE(name, type, field, cmp) \
-void name##_SPLAY(struct name *, struct type *); \
-void name##_SPLAY_MINMAX(struct name *, int); \
-struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
-struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
- \
-/* Finds the node with the same key as elm */ \
-static __inline struct type * \
-name##_SPLAY_FIND(struct name *head, struct type *elm) \
-{ \
- if (SPLAY_EMPTY(head)) \
- return(NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) \
- return (head->sph_root); \
- return (NULL); \
-} \
- \
-static __inline struct type * \
-name##_SPLAY_NEXT(struct name *head, struct type *elm) \
-{ \
- name##_SPLAY(head, elm); \
- if (SPLAY_RIGHT(elm, field) != NULL) { \
- elm = SPLAY_RIGHT(elm, field); \
- while (SPLAY_LEFT(elm, field) != NULL) { \
- elm = SPLAY_LEFT(elm, field); \
- } \
- } else \
- elm = NULL; \
- return (elm); \
-} \
- \
-static __inline struct type * \
-name##_SPLAY_MIN_MAX(struct name *head, int val) \
-{ \
- name##_SPLAY_MINMAX(head, val); \
- return (SPLAY_ROOT(head)); \
-}
+#define SPLAY_PROTOTYPE(name, type, field, cmp) \
+ void name##_SPLAY(struct name *, struct type *); \
+ void name##_SPLAY_MINMAX(struct name *, int); \
+ struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
+ struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
+ \
+ /* Finds the node with the same key as elm */ \
+ static __inline struct type *name##_SPLAY_FIND(struct name *head, \
+ struct type *elm) \
+ { \
+ if (SPLAY_EMPTY(head)) \
+ return (NULL); \
+ name##_SPLAY(head, elm); \
+ if ((cmp)(elm, (head)->sph_root) == 0) \
+ return (head->sph_root); \
+ return (NULL); \
+ } \
+ \
+ static __inline struct type *name##_SPLAY_NEXT(struct name *head, \
+ struct type *elm) \
+ { \
+ name##_SPLAY(head, elm); \
+ if (SPLAY_RIGHT(elm, field) != NULL) { \
+ elm = SPLAY_RIGHT(elm, field); \
+ while (SPLAY_LEFT(elm, field) != NULL) { \
+ elm = SPLAY_LEFT(elm, field); \
+ } \
+ } else \
+ elm = NULL; \
+ return (elm); \
+ } \
+ \
+ static __inline struct type *name##_SPLAY_MIN_MAX(struct name *head, \
+ int val) \
+ { \
+ name##_SPLAY_MINMAX(head, val); \
+ return (SPLAY_ROOT(head)); \
+ }
/* Main splay operation.
* Moves node close to the key of elm to top
*/
-#define SPLAY_GENERATE(name, type, field, cmp) \
-struct type * \
-name##_SPLAY_INSERT(struct name *head, struct type *elm) \
-{ \
- if (SPLAY_EMPTY(head)) { \
- SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
- } else { \
- int __comp; \
- name##_SPLAY(head, elm); \
- __comp = (cmp)(elm, (head)->sph_root); \
- if(__comp < 0) { \
- SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
- SPLAY_RIGHT(elm, field) = (head)->sph_root; \
- SPLAY_LEFT((head)->sph_root, field) = NULL; \
- } else if (__comp > 0) { \
- SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
- SPLAY_LEFT(elm, field) = (head)->sph_root; \
- SPLAY_RIGHT((head)->sph_root, field) = NULL; \
- } else \
- return ((head)->sph_root); \
- } \
- (head)->sph_root = (elm); \
- return (NULL); \
-} \
- \
-struct type * \
-name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
-{ \
- struct type *__tmp; \
- if (SPLAY_EMPTY(head)) \
- return (NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) { \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
- (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
- } else { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
- name##_SPLAY(head, elm); \
- SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
- } \
- return (elm); \
- } \
- return (NULL); \
-} \
- \
-void \
-name##_SPLAY(struct name *head, struct type *elm) \
-{ \
- struct type __node, *__left, *__right, *__tmp; \
- int __comp; \
-\
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
- __left = __right = &__node; \
-\
- while ((__comp = (cmp)(elm, (head)->sph_root))) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) < 0){ \
- SPLAY_ROTATE_RIGHT(head, __tmp, field); \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) > 0){ \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
-} \
- \
-/* Splay with either the minimum or the maximum element \
- * Used to find minimum or maximum element in tree. \
- */ \
-void name##_SPLAY_MINMAX(struct name *head, int __comp) \
-{ \
- struct type __node, *__left, *__right, *__tmp; \
-\
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
- __left = __right = &__node; \
-\
- while (1) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp < 0){ \
- SPLAY_ROTATE_RIGHT(head, __tmp, field); \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp > 0) { \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
-}
+#define SPLAY_GENERATE(name, type, field, cmp) \
+ struct type *name##_SPLAY_INSERT(struct name *head, struct type *elm) \
+ { \
+ if (SPLAY_EMPTY(head)) { \
+ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = \
+ NULL; \
+ } else { \
+ int __comp; \
+ name##_SPLAY(head, elm); \
+ __comp = (cmp)(elm, (head)->sph_root); \
+ if (__comp < 0) { \
+ SPLAY_LEFT(elm, field) = \
+ SPLAY_LEFT((head)->sph_root, field); \
+ SPLAY_RIGHT(elm, field) = (head)->sph_root; \
+ SPLAY_LEFT((head)->sph_root, field) = NULL; \
+ } else if (__comp > 0) { \
+ SPLAY_RIGHT(elm, field) = \
+ SPLAY_RIGHT((head)->sph_root, field); \
+ SPLAY_LEFT(elm, field) = (head)->sph_root; \
+ SPLAY_RIGHT((head)->sph_root, field) = NULL; \
+ } else \
+ return ((head)->sph_root); \
+ } \
+ (head)->sph_root = (elm); \
+ return (NULL); \
+ } \
+ \
+ struct type *name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
+ { \
+ struct type *__tmp; \
+ if (SPLAY_EMPTY(head)) \
+ return (NULL); \
+ name##_SPLAY(head, elm); \
+ if ((cmp)(elm, (head)->sph_root) == 0) { \
+ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
+ (head)->sph_root = \
+ SPLAY_RIGHT((head)->sph_root, field); \
+ } else { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ (head)->sph_root = \
+ SPLAY_LEFT((head)->sph_root, field); \
+ name##_SPLAY(head, elm); \
+ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
+ } \
+ return (elm); \
+ } \
+ return (NULL); \
+ } \
+ \
+ void name##_SPLAY(struct name *head, struct type *elm) \
+ { \
+ struct type __node, *__left, *__right, *__tmp; \
+ int __comp; \
+ \
+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = \
+ NULL; \
+ __left = __right = &__node; \
+ \
+ while ((__comp = (cmp)(elm, (head)->sph_root))) { \
+ if (__comp < 0) { \
+ __tmp = SPLAY_LEFT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if ((cmp)(elm, __tmp) < 0) { \
+ SPLAY_ROTATE_RIGHT(head, __tmp, \
+ field); \
+ if (SPLAY_LEFT((head)->sph_root, \
+ field) \
+ == NULL) \
+ break; \
+ } \
+ SPLAY_LINKLEFT(head, __right, field); \
+ } else if (__comp > 0) { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if ((cmp)(elm, __tmp) > 0) { \
+ SPLAY_ROTATE_LEFT(head, __tmp, field); \
+ if (SPLAY_RIGHT((head)->sph_root, \
+ field) \
+ == NULL) \
+ break; \
+ } \
+ SPLAY_LINKRIGHT(head, __left, field); \
+ } \
+ } \
+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
+ } \
+ \
+ /* Splay with either the minimum or the maximum element \
+ * Used to find minimum or maximum element in tree. \
+ */ \
+ void name##_SPLAY_MINMAX(struct name *head, int __comp) \
+ { \
+ struct type __node, *__left, *__right, *__tmp; \
+ \
+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = \
+ NULL; \
+ __left = __right = &__node; \
+ \
+ while (1) { \
+ if (__comp < 0) { \
+ __tmp = SPLAY_LEFT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if (__comp < 0) { \
+ SPLAY_ROTATE_RIGHT(head, __tmp, \
+ field); \
+ if (SPLAY_LEFT((head)->sph_root, \
+ field) \
+ == NULL) \
+ break; \
+ } \
+ SPLAY_LINKLEFT(head, __right, field); \
+ } else if (__comp > 0) { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if (__comp > 0) { \
+ SPLAY_ROTATE_LEFT(head, __tmp, field); \
+ if (SPLAY_RIGHT((head)->sph_root, \
+ field) \
+ == NULL) \
+ break; \
+ } \
+ SPLAY_LINKRIGHT(head, __left, field); \
+ } \
+ } \
+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
+ }
#define SPLAY_NEGINF -1
#define SPLAY_INF 1
@@ -277,14 +303,13 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
-#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
- : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
-#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
- : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
-
-#define SPLAY_FOREACH(x, name, head) \
- for ((x) = SPLAY_MIN(name, head); \
- (x) != NULL; \
+#define SPLAY_MIN(name, x) \
+ (SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
+#define SPLAY_MAX(name, x) \
+ (SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
+
+#define SPLAY_FOREACH(x, name, head) \
+ for ((x) = SPLAY_MIN(name, head); (x) != NULL; \
(x) = SPLAY_NEXT(name, head, x))
/*
@@ -307,203 +332,197 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \
#define RB_RED 1
struct rb_type {
- int (*t_compare)(const void *, const void *);
- void (*t_augment)(void *);
- unsigned int t_offset; /* offset of rb_entry in type */
+ int (*t_compare)(const void *, const void *);
+ void (*t_augment)(void *);
+ unsigned int t_offset; /* offset of rb_entry in type */
};
struct rbt_tree {
- struct rb_entry *rbt_root;
+ struct rb_entry *rbt_root;
};
struct rb_entry {
- struct rb_entry *rbt_parent;
- struct rb_entry *rbt_left;
- struct rb_entry *rbt_right;
- unsigned int rbt_color;
+ struct rb_entry *rbt_parent;
+ struct rb_entry *rbt_left;
+ struct rb_entry *rbt_right;
+ unsigned int rbt_color;
};
-#define RB_HEAD(_name, _type) \
-struct _name { \
- struct rbt_tree rbh_root; \
-}
+#define RB_HEAD(_name, _type) \
+ struct _name { \
+ struct rbt_tree rbh_root; \
+ }
#define RB_ENTRY(_type) struct rb_entry
-static inline void
-_rb_init(struct rbt_tree *rbt)
+static inline void _rb_init(struct rbt_tree *rbt)
{
rbt->rbt_root = NULL;
}
-static inline int
-_rb_empty(struct rbt_tree *rbt)
+static inline int _rb_empty(struct rbt_tree *rbt)
{
return (rbt->rbt_root == NULL);
}
-void *_rb_insert(const struct rb_type *, struct rbt_tree *, void *);
-void *_rb_remove(const struct rb_type *, struct rbt_tree *, void *);
-void *_rb_find(const struct rb_type *, struct rbt_tree *, const void *);
-void *_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *);
-void *_rb_root(const struct rb_type *, struct rbt_tree *);
-void *_rb_min(const struct rb_type *, struct rbt_tree *);
-void *_rb_max(const struct rb_type *, struct rbt_tree *);
-void *_rb_next(const struct rb_type *, void *);
-void *_rb_prev(const struct rb_type *, void *);
-void *_rb_left(const struct rb_type *, void *);
-void *_rb_right(const struct rb_type *, void *);
-void *_rb_parent(const struct rb_type *, void *);
-void _rb_set_left(const struct rb_type *, void *, void *);
-void _rb_set_right(const struct rb_type *, void *, void *);
-void _rb_set_parent(const struct rb_type *, void *, void *);
-void _rb_poison(const struct rb_type *, void *, unsigned long);
-int _rb_check(const struct rb_type *, void *, unsigned long);
+void *_rb_insert(const struct rb_type *, struct rbt_tree *, void *);
+void *_rb_remove(const struct rb_type *, struct rbt_tree *, void *);
+void *_rb_find(const struct rb_type *, struct rbt_tree *, const void *);
+void *_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *);
+void *_rb_root(const struct rb_type *, struct rbt_tree *);
+void *_rb_min(const struct rb_type *, struct rbt_tree *);
+void *_rb_max(const struct rb_type *, struct rbt_tree *);
+void *_rb_next(const struct rb_type *, void *);
+void *_rb_prev(const struct rb_type *, void *);
+void *_rb_left(const struct rb_type *, void *);
+void *_rb_right(const struct rb_type *, void *);
+void *_rb_parent(const struct rb_type *, void *);
+void _rb_set_left(const struct rb_type *, void *, void *);
+void _rb_set_right(const struct rb_type *, void *, void *);
+void _rb_set_parent(const struct rb_type *, void *, void *);
+void _rb_poison(const struct rb_type *, void *, unsigned long);
+int _rb_check(const struct rb_type *, void *, unsigned long);
#define RB_INITIALIZER(_head) { { NULL } }
-#define RB_PROTOTYPE(_name, _type, _field, _cmp) \
-extern const struct rb_type *const _name##_RB_TYPE; \
- \
-__attribute__((__unused__)) static inline void \
-_name##_RB_INIT(struct _name *head) \
-{ \
- _rb_init(&head->rbh_root); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_INSERT(struct _name *head, struct _type *elm) \
-{ \
- return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_REMOVE(struct _name *head, struct _type *elm) \
-{ \
- return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_FIND(struct _name *head, const struct _type *key) \
-{ \
- return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_NFIND(struct _name *head, const struct _type *key) \
-{ \
- return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_ROOT(struct _name *head) \
-{ \
- return _rb_root(_name##_RB_TYPE, &head->rbh_root); \
-} \
- \
-__attribute__((__unused__)) static inline int \
-_name##_RB_EMPTY(struct _name *head) \
-{ \
- return _rb_empty(&head->rbh_root); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_MIN(struct _name *head) \
-{ \
- return _rb_min(_name##_RB_TYPE, &head->rbh_root); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_MAX(struct _name *head) \
-{ \
- return _rb_max(_name##_RB_TYPE, &head->rbh_root); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_NEXT(struct _type *elm) \
-{ \
- return _rb_next(_name##_RB_TYPE, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_PREV(struct _type *elm) \
-{ \
- return _rb_prev(_name##_RB_TYPE, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_LEFT(struct _type *elm) \
-{ \
- return _rb_left(_name##_RB_TYPE, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_RIGHT(struct _type *elm) \
-{ \
- return _rb_right(_name##_RB_TYPE, elm); \
-} \
- \
-__attribute__((__unused__)) static inline struct _type * \
-_name##_RB_PARENT(struct _type *elm) \
-{ \
- return _rb_parent(_name##_RB_TYPE, elm); \
-} \
- \
-__attribute__((__unused__)) static inline void \
-_name##_RB_SET_LEFT(struct _type *elm, struct _type *left) \
-{ \
- return _rb_set_left(_name##_RB_TYPE, elm, left); \
-} \
- \
-__attribute__((__unused__)) static inline void \
-_name##_RB_SET_RIGHT(struct _type *elm, struct _type *right) \
-{ \
- return _rb_set_right(_name##_RB_TYPE, elm, right); \
-} \
- \
-__attribute__((__unused__)) static inline void \
-_name##_RB_SET_PARENT(struct _type *elm, struct _type *parent) \
-{ \
- return _rb_set_parent(_name##_RB_TYPE, elm, parent); \
-} \
- \
-__attribute__((__unused__)) static inline void \
-_name##_RB_POISON(struct _type *elm, unsigned long poison) \
-{ \
- return _rb_poison(_name##_RB_TYPE, elm, poison); \
-} \
- \
-__attribute__((__unused__)) static inline int \
-_name##_RB_CHECK(struct _type *elm, unsigned long poison) \
-{ \
- return _rb_check(_name##_RB_TYPE, elm, poison); \
-}
-
-#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \
-static int \
-_name##_RB_COMPARE(const void *lptr, const void *rptr) \
-{ \
- const struct _type *l = lptr, *r = rptr; \
- return _cmp(l, r); \
-} \
-static const struct rb_type _name##_RB_INFO = { \
- _name##_RB_COMPARE, \
- _aug, \
- offsetof(struct _type, _field), \
-}; \
-const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO;
-
-#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \
-static void \
-_name##_RB_AUGMENT(void *ptr) \
-{ \
- struct _type *p = ptr; \
- return _aug(p); \
-} \
-RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)
-
-#define RB_GENERATE(_name, _type, _field, _cmp) \
- RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL)
+#define RB_PROTOTYPE(_name, _type, _field, _cmp) \
+ extern const struct rb_type *const _name##_RB_TYPE; \
+ \
+ __attribute__((__unused__)) static inline void _name##_RB_INIT( \
+ struct _name *head) \
+ { \
+ _rb_init(&head->rbh_root); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_INSERT(struct _name *head, struct _type *elm) \
+ { \
+ return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_REMOVE(struct _name *head, struct _type *elm) \
+ { \
+ return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_FIND(struct _name *head, const struct _type *key) \
+ { \
+ return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_NFIND(struct _name *head, const struct _type *key) \
+ { \
+ return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_ROOT(struct _name *head) \
+ { \
+ return _rb_root(_name##_RB_TYPE, &head->rbh_root); \
+ } \
+ \
+ __attribute__((__unused__)) static inline int _name##_RB_EMPTY( \
+ struct _name *head) \
+ { \
+ return _rb_empty(&head->rbh_root); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_MIN(struct _name *head) \
+ { \
+ return _rb_min(_name##_RB_TYPE, &head->rbh_root); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_MAX(struct _name *head) \
+ { \
+ return _rb_max(_name##_RB_TYPE, &head->rbh_root); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_NEXT(struct _type *elm) \
+ { \
+ return _rb_next(_name##_RB_TYPE, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_PREV(struct _type *elm) \
+ { \
+ return _rb_prev(_name##_RB_TYPE, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_LEFT(struct _type *elm) \
+ { \
+ return _rb_left(_name##_RB_TYPE, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_RIGHT(struct _type *elm) \
+ { \
+ return _rb_right(_name##_RB_TYPE, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline struct _type \
+ *_name##_RB_PARENT(struct _type *elm) \
+ { \
+ return _rb_parent(_name##_RB_TYPE, elm); \
+ } \
+ \
+ __attribute__((__unused__)) static inline void _name##_RB_SET_LEFT( \
+ struct _type *elm, struct _type *left) \
+ { \
+ return _rb_set_left(_name##_RB_TYPE, elm, left); \
+ } \
+ \
+ __attribute__((__unused__)) static inline void _name##_RB_SET_RIGHT( \
+ struct _type *elm, struct _type *right) \
+ { \
+ return _rb_set_right(_name##_RB_TYPE, elm, right); \
+ } \
+ \
+ __attribute__((__unused__)) static inline void _name##_RB_SET_PARENT( \
+ struct _type *elm, struct _type *parent) \
+ { \
+ return _rb_set_parent(_name##_RB_TYPE, elm, parent); \
+ } \
+ \
+ __attribute__((__unused__)) static inline void _name##_RB_POISON( \
+ struct _type *elm, unsigned long poison) \
+ { \
+ return _rb_poison(_name##_RB_TYPE, elm, poison); \
+ } \
+ \
+ __attribute__((__unused__)) static inline int _name##_RB_CHECK( \
+ struct _type *elm, unsigned long poison) \
+ { \
+ return _rb_check(_name##_RB_TYPE, elm, poison); \
+ }
+
+#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \
+ static int _name##_RB_COMPARE(const void *lptr, const void *rptr) \
+ { \
+ const struct _type *l = lptr, *r = rptr; \
+ return _cmp(l, r); \
+ } \
+ static const struct rb_type _name##_RB_INFO = { \
+ _name##_RB_COMPARE, _aug, offsetof(struct _type, _field), \
+ }; \
+ const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO;
+
+#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \
+ static void _name##_RB_AUGMENT(void *ptr) \
+ { \
+ struct _type *p = ptr; \
+ return _aug(p); \
+ } \
+ RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)
+
+#define RB_GENERATE(_name, _type, _field, _cmp) \
+ RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL)
#define RB_INIT(_name, _head) _name##_RB_INIT(_head)
#define RB_INSERT(_name, _head, _elm) _name##_RB_INSERT(_head, _elm)
@@ -525,24 +544,20 @@ RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)
#define RB_POISON(_name, _elm, _p) _name##_RB_POISON(_elm, _p)
#define RB_CHECK(_name, _elm, _p) _name##_RB_CHECK(_elm, _p)
-#define RB_FOREACH(_e, _name, _head) \
- for ((_e) = RB_MIN(_name, (_head)); \
- (_e) != NULL; \
+#define RB_FOREACH(_e, _name, _head) \
+ for ((_e) = RB_MIN(_name, (_head)); (_e) != NULL; \
(_e) = RB_NEXT(_name, (_e)))
-#define RB_FOREACH_SAFE(_e, _name, _head, _n) \
- for ((_e) = RB_MIN(_name, (_head)); \
- (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1); \
- (_e) = (_n))
+#define RB_FOREACH_SAFE(_e, _name, _head, _n) \
+ for ((_e) = RB_MIN(_name, (_head)); \
+ (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1); (_e) = (_n))
-#define RB_FOREACH_REVERSE(_e, _name, _head) \
- for ((_e) = RB_MAX(_name, (_head)); \
- (_e) != NULL; \
+#define RB_FOREACH_REVERSE(_e, _name, _head) \
+ for ((_e) = RB_MAX(_name, (_head)); (_e) != NULL; \
(_e) = RB_PREV(_name, (_e)))
-#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \
- for ((_e) = RB_MAX(_name, (_head)); \
- (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); \
- (_e) = (_n))
+#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \
+ for ((_e) = RB_MAX(_name, (_head)); \
+ (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); (_e) = (_n))
-#endif /* _SYS_TREE_H_ */
+#endif /* _SYS_TREE_H_ */
diff --git a/lib/plist.c b/lib/plist.c
index a95749cf0e..9dd5e561a7 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1230,8 +1230,8 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,
match = 1;
if (type == longer_display) {
- if ((p.family == pentry->prefix.family) &&
- (prefix_match(&p, &pentry->prefix)))
+ if ((p.family == pentry->prefix.family)
+ && (prefix_match(&p, &pentry->prefix)))
match = 1;
}
@@ -1310,8 +1310,8 @@ static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name,
for (pentry = plist->head; pentry; pentry = pentry->next) {
if (prefix) {
- if (pentry->prefix.family == p.family &&
- prefix_match(&pentry->prefix, &p))
+ if (pentry->prefix.family == p.family
+ && prefix_match(&pentry->prefix, &p))
pentry->hitcnt = 0;
} else
pentry->hitcnt = 0;
diff --git a/lib/plist.h b/lib/plist.h
index bf06e74d36..9662f0311b 100644
--- a/lib/plist.h
+++ b/lib/plist.h
@@ -60,10 +60,9 @@ extern struct prefix_list *prefix_list_lookup(afi_t, const char *);
* If no pointer is sent in, do not return anything.
* If it is a empty plist return a NULL pointer.
*/
-extern enum prefix_list_type prefix_list_apply_which_prefix(
- struct prefix_list *plist,
- struct prefix **which,
- void *object);
+extern enum prefix_list_type
+prefix_list_apply_which_prefix(struct prefix_list *plist, struct prefix **which,
+ void *object);
#define prefix_list_apply(A, B) prefix_list_apply_which_prefix((A), NULL, (B))
extern struct prefix_list *prefix_bgp_orf_lookup(afi_t, const char *);
diff --git a/lib/prefix.c b/lib/prefix.c
index 9f13cb8bb1..1344039498 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -37,262 +37,390 @@ static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
static const struct in6_addr maskbytes6[] = {
/* /0 */ {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /1 */ {{{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /2 */ {{{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /3 */ {{{0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /4 */ {{{0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /5 */ {{{0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /6 */ {{{0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /7 */ {{{0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /8 */ {{{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /9 */ {{{0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /10 */ {{{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /11 */ {{{0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /12 */ {{{0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /13 */ {{{0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /14 */ {{{0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /15 */ {{{0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /16 */ {{{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /17 */ {{{0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /18 */ {{{0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /19 */ {{{0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /20 */ {{{0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /21 */ {{{0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /22 */ {{{0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /23 */ {{{0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /24 */ {{{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /25 */ {{{0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /26 */ {{{0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /27 */ {{{0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /28 */ {{{0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /29 */ {{{0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /30 */ {{{0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /31 */ {{{0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /32 */ {{{0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /33 */ {{{0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /34 */ {{{0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /35 */ {{{0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /36 */ {{{0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /37 */ {{{0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /38 */ {{{0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /39 */ {{{0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /40 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /41 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /42 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /43 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /44 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /45 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /46 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /47 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /48 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /49 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /50 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /51 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /52 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /53 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /54 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /55 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /56 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /57 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /58 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /59 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /60 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /61 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /62 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /63 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /64 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /65 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /66 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /67 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /68 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /69 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /70 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /71 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /72 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /73 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /74 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /75 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /76 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /77 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /78 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /79 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /80 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /81 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /82 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /83 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /84 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /85 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /86 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /87 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /88 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- /* /89 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00}}},
- /* /90 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00}}},
- /* /91 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00}}},
- /* /92 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00}}},
- /* /93 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00}}},
- /* /94 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00}}},
- /* /95 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00}}},
- /* /96 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00}}},
- /* /97 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00}}},
- /* /98 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00}}},
- /* /99 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00}}},
- /* /100 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00}}},
- /* /101 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00}}},
- /* /102 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00}}},
- /* /103 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00}}},
- /* /104 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}}},
- /* /105 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00}}},
- /* /106 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00}}},
- /* /107 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00}}},
- /* /108 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00}}},
- /* /109 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00}}},
- /* /110 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00}}},
- /* /111 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00}}},
- /* /112 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00}}},
- /* /113 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00}}},
- /* /114 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00}}},
- /* /115 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00}}},
- /* /116 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00}}},
- /* /117 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00}}},
- /* /118 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00}}},
- /* /119 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00}}},
- /* /120 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}}},
- /* /121 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80}}},
- /* /122 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0}}},
- /* /123 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0}}},
- /* /124 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0}}},
- /* /125 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8}}},
- /* /126 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc}}},
- /* /127 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}}},
- /* /128 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}}};
+ /* /1 */
+ {{{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /2 */
+ {{{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /3 */
+ {{{0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /4 */
+ {{{0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /5 */
+ {{{0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /6 */
+ {{{0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /7 */
+ {{{0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /8 */
+ {{{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /9 */
+ {{{0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /10 */
+ {{{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /11 */
+ {{{0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /12 */
+ {{{0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /13 */
+ {{{0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /14 */
+ {{{0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /15 */
+ {{{0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /16 */
+ {{{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /17 */
+ {{{0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /18 */
+ {{{0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /19 */
+ {{{0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /20 */
+ {{{0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /21 */
+ {{{0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /22 */
+ {{{0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /23 */
+ {{{0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /24 */
+ {{{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /25 */
+ {{{0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /26 */
+ {{{0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /27 */
+ {{{0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /28 */
+ {{{0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /29 */
+ {{{0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /30 */
+ {{{0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /31 */
+ {{{0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /32 */
+ {{{0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /33 */
+ {{{0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /34 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /35 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /36 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /37 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /38 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /39 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /40 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /41 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /42 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /43 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /44 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /45 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /46 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /47 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /48 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /49 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /50 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /51 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /52 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /53 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /54 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /55 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /56 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /57 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /58 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /59 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /60 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /61 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /62 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /63 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /64 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /65 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /66 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /67 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /68 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /69 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /70 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /71 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /72 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /73 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /74 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /75 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /76 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /77 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /78 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /79 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /80 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /81 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /82 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /83 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /84 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /85 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /86 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /87 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /88 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00}}},
+ /* /89 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x80, 0x00, 0x00, 0x00, 0x00}}},
+ /* /90 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc0, 0x00, 0x00, 0x00, 0x00}}},
+ /* /91 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xe0, 0x00, 0x00, 0x00, 0x00}}},
+ /* /92 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf0, 0x00, 0x00, 0x00, 0x00}}},
+ /* /93 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf8, 0x00, 0x00, 0x00, 0x00}}},
+ /* /94 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xfc, 0x00, 0x00, 0x00, 0x00}}},
+ /* /95 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xfe, 0x00, 0x00, 0x00, 0x00}}},
+ /* /96 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00}}},
+ /* /97 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x80, 0x00, 0x00, 0x00}}},
+ /* /98 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc0, 0x00, 0x00, 0x00}}},
+ /* /99 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xe0, 0x00, 0x00, 0x00}}},
+ /* /100 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xf0, 0x00, 0x00, 0x00}}},
+ /* /101 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xf8, 0x00, 0x00, 0x00}}},
+ /* /102 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xfc, 0x00, 0x00, 0x00}}},
+ /* /103 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xfe, 0x00, 0x00, 0x00}}},
+ /* /104 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00}}},
+ /* /105 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x80, 0x00, 0x00}}},
+ /* /106 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xc0, 0x00, 0x00}}},
+ /* /107 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xe0, 0x00, 0x00}}},
+ /* /108 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf0, 0x00, 0x00}}},
+ /* /109 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf8, 0x00, 0x00}}},
+ /* /110 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xfc, 0x00, 0x00}}},
+ /* /111 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xfe, 0x00, 0x00}}},
+ /* /112 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0x00}}},
+ /* /113 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x80, 0x00}}},
+ /* /114 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xc0, 0x00}}},
+ /* /115 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xe0, 0x00}}},
+ /* /116 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xf0, 0x00}}},
+ /* /117 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xf8, 0x00}}},
+ /* /118 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xfc, 0x00}}},
+ /* /119 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xfe, 0x00}}},
+ /* /120 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00}}},
+ /* /121 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x80}}},
+ /* /122 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xc0}}},
+ /* /123 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xe0}}},
+ /* /124 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf0}}},
+ /* /125 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf8}}},
+ /* /126 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xfc}}},
+ /* /127 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xfe}}},
+ /* /128 */
+ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff}}}};
/* Number of bits in prefix type. */
#ifndef PNBBY
@@ -726,7 +854,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)
* a comparison to zero, let's assume
*/
if (!slash && is_zero_mac(&(p->eth_addr)))
- p->prefixlen = 0;
+ p->prefixlen = 0;
ret = 1;
@@ -1047,11 +1175,10 @@ static const char *prefixevpn2str(const struct prefix *p, char *str, int size)
p->u.prefix_evpn.route_type, p->u.prefix_evpn.eth_tag,
inet_ntop(family, &p->u.prefix_evpn.ip.ip.addr, buf,
PREFIX2STR_BUFFER),
- p->u.prefix_evpn.ip_prefix_length,
- p->prefixlen);
+ p->u.prefix_evpn.ip_prefix_length, p->prefixlen);
} else {
sprintf(str, "Unsupported EVPN route type %d",
- p->u.prefix_evpn.route_type);
+ p->u.prefix_evpn.route_type);
}
return str;
@@ -1264,6 +1391,7 @@ unsigned prefix_hash_key(void *pp)
* padding and unused prefix bytes. */
memset(&copy, 0, sizeof(copy));
prefix_copy(&copy, (struct prefix *)pp);
- return jhash(&copy, offsetof(struct prefix, u.prefix)
- + PSIZE(copy.prefixlen), 0x55aa5a5a);
+ return jhash(&copy,
+ offsetof(struct prefix, u.prefix) + PSIZE(copy.prefixlen),
+ 0x55aa5a5a);
}
diff --git a/lib/prefix.h b/lib/prefix.h
index 5bf7d498c1..1724225817 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -310,9 +310,9 @@ extern void prefix_ipv4_free(struct prefix_ipv4 *);
extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);
extern void apply_mask_ipv4(struct prefix_ipv4 *);
-#define PREFIX_COPY(DST, SRC) \
+#define PREFIX_COPY(DST, SRC) \
*((struct prefix *)(DST)) = *((const struct prefix *)(SRC))
-#define PREFIX_COPY_IPV4(DST, SRC) \
+#define PREFIX_COPY_IPV4(DST, SRC) \
*((struct prefix_ipv4 *)(DST)) = *((const struct prefix_ipv4 *)(SRC));
extern int prefix_ipv4_any(const struct prefix_ipv4 *);
@@ -380,15 +380,12 @@ static inline int is_default_prefix(const struct prefix *p)
if (!p)
return 0;
- if ((p->family == AF_INET) &&
- (p->u.prefix4.s_addr == INADDR_ANY) &&
- (p->prefixlen == 0))
+ if ((p->family == AF_INET) && (p->u.prefix4.s_addr == INADDR_ANY)
+ && (p->prefixlen == 0))
return 1;
- if ((p->family == AF_INET6) &&
- (p->prefixlen == 0) &&
- (!memcmp(&p->u.prefix6, &in6addr_any,
- sizeof(struct in6_addr))))
+ if ((p->family == AF_INET6) && (p->prefixlen == 0)
+ && (!memcmp(&p->u.prefix6, &in6addr_any, sizeof(struct in6_addr))))
return 1;
return 0;
diff --git a/lib/qobj.c b/lib/qobj.c
index c75002052e..c3f1a27c82 100644
--- a/lib/qobj.c
+++ b/lib/qobj.c
@@ -98,9 +98,7 @@ void qobj_init(void)
{
if (!nodes) {
pthread_rwlock_init(&nodes_lock, NULL);
- nodes = hash_create_size(16, qobj_key,
- qobj_cmp,
- "QOBJ Hash");
+ nodes = hash_create_size(16, qobj_key, qobj_cmp, "QOBJ Hash");
}
}
diff --git a/lib/queue.h b/lib/queue.h
index 29b67a26e6..04fbeee700 100644
--- a/lib/queue.h
+++ b/lib/queue.h
@@ -40,8 +40,7 @@
(SIMPLEQ_EMPTY((head)) \
? NULL \
: ((struct type *)(void *)((char *)((head)->sqh_last) \
- - offsetof(struct type, \
- field))))
+ - offsetof(struct type, field))))
#define STAILQ_NEXT(elm, field) SIMPLEQ_NEXT(elm, field)
#define STAILQ_REMOVE(head, elm, type, field) \
do { \
diff --git a/lib/ringbuf.c b/lib/ringbuf.c
index 11db502a94..1c3c3e9753 100644
--- a/lib/ringbuf.c
+++ b/lib/ringbuf.c
@@ -96,7 +96,7 @@ size_t ringbuf_peek(struct ringbuf *buf, size_t offset, void *data, size_t size)
size_t remain = ringbuf_remain(buf);
if (offset >= remain)
return 0;
- size_t copysize = MAX(MIN(remain - offset, size), (size_t) 0);
+ size_t copysize = MAX(MIN(remain - offset, size), (size_t)0);
size_t tocopy = copysize;
size_t cstart = (buf->start + offset) % buf->size;
if (tocopy >= buf->size - cstart) {
diff --git a/lib/routemap.c b/lib/routemap.c
index 175e099994..ea61043a8d 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -423,8 +423,7 @@ int generic_match_add(struct vty *vty, struct route_map_index *index,
}
break;
case RMAP_RULE_MISSING:
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
+ vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_ERROR:
@@ -464,8 +463,7 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
ret = route_map_delete_match(index, command, dep_name);
switch (ret) {
case RMAP_RULE_MISSING:
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
+ vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_ERROR:
@@ -496,8 +494,7 @@ int generic_set_add(struct vty *vty, struct route_map_index *index,
ret = route_map_add_set(index, command, arg);
switch (ret) {
case RMAP_RULE_MISSING:
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
+ vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_ERROR:
@@ -521,8 +518,7 @@ int generic_set_delete(struct vty *vty, struct route_map_index *index,
ret = route_map_delete_set(index, command, arg);
switch (ret) {
case RMAP_RULE_MISSING:
- vty_out(vty, "%% [%s] Can't find rule.\n",
- frr_protonameinst);
+ vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_ERROR:
@@ -1581,10 +1577,9 @@ static void *route_map_dep_hash_alloc(void *p)
dep_entry = XCALLOC(MTYPE_ROUTE_MAP_DEP, sizeof(struct route_map_dep));
dep_entry->dep_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, dep_name);
- dep_entry->dep_rmap_hash = hash_create_size(8,
- route_map_dep_hash_make_key,
- route_map_rmap_hash_cmp,
- "Route Map Dep Hash");
+ dep_entry->dep_rmap_hash =
+ hash_create_size(8, route_map_dep_hash_make_key,
+ route_map_rmap_hash_cmp, "Route Map Dep Hash");
dep_entry->this_hash = NULL;
return ((void *)dep_entry);
@@ -2786,15 +2781,13 @@ void route_map_init(void)
route_match_vec = vector_init(1);
route_set_vec = vector_init(1);
route_map_master_hash =
- hash_create_size(8, route_map_hash_key_make,
- route_map_hash_cmp,
+ hash_create_size(8, route_map_hash_key_make, route_map_hash_cmp,
"Route Map Master Hash");
for (i = 1; i < ROUTE_MAP_DEP_MAX; i++)
- route_map_dep_hash[i] =
- hash_create_size(8, route_map_dep_hash_make_key,
- route_map_dep_hash_cmp,
- "Route Map Dep Hash");
+ route_map_dep_hash[i] = hash_create_size(
+ 8, route_map_dep_hash_make_key, route_map_dep_hash_cmp,
+ "Route Map Dep Hash");
cmd_variable_handler_register(rmap_var_handlers);
diff --git a/lib/routemap.h b/lib/routemap.h
index 8c00e8104c..0046b77c46 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -98,15 +98,13 @@ struct route_map_rule_cmd {
};
/* Route map apply error. */
-enum {
- RMAP_COMPILE_SUCCESS,
+enum { RMAP_COMPILE_SUCCESS,
- /* Route map rule is missing. */
- RMAP_RULE_MISSING,
+ /* Route map rule is missing. */
+ RMAP_RULE_MISSING,
- /* Route map rule can't compile */
- RMAP_COMPILE_ERROR
-};
+ /* Route map rule can't compile */
+ RMAP_COMPILE_ERROR };
/* Route map rule list. */
struct route_map_rule_list {
diff --git a/lib/sbuf.h b/lib/sbuf.h
index 3e49ada6c2..c38e96912f 100644
--- a/lib/sbuf.h
+++ b/lib/sbuf.h
@@ -53,8 +53,10 @@
* return 1;
* }
*
- * In this case, sbuf_example uses a string buffer with undefined size, which will
- * be allocated on the heap by sbuf. The caller of sbuf_example is expected to free
+ * In this case, sbuf_example uses a string buffer with undefined size, which
+ * will
+ * be allocated on the heap by sbuf. The caller of sbuf_example is expected to
+ * free
* the string returned in parser_log.
*/
diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c
index d7907fafdf..c420c25f04 100644
--- a/lib/spf_backoff.c
+++ b/lib/spf_backoff.c
@@ -227,7 +227,8 @@ void spf_backoff_show(struct spf_backoff *backoff, struct vty *vty,
struct timeval remain =
thread_timer_remain(backoff->t_holddown);
vty_out(vty, "%s Still runs for %lld msec\n",
- prefix, (long long)remain.tv_sec * 1000
+ prefix,
+ (long long)remain.tv_sec * 1000
+ remain.tv_usec / 1000);
} else {
vty_out(vty, "%s Inactive\n", prefix);
@@ -239,7 +240,8 @@ void spf_backoff_show(struct spf_backoff *backoff, struct vty *vty,
struct timeval remain =
thread_timer_remain(backoff->t_timetolearn);
vty_out(vty, "%s Still runs for %lld msec\n",
- prefix, (long long)remain.tv_sec * 1000
+ prefix,
+ (long long)remain.tv_sec * 1000
+ remain.tv_usec / 1000);
} else {
vty_out(vty, "%s Inactive\n", prefix);
diff --git a/lib/stream.c b/lib/stream.c
index 0eb790b753..3c08d4454b 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -65,19 +65,19 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
assert(ENDP_VALID(S, (S)->endp)); \
} while (0)
-#define STREAM_BOUND_WARN(S, WHAT) \
- do { \
- zlog_warn("%s: Attempt to %s out of bounds", __func__, \
- (WHAT)); \
- STREAM_WARN_OFFSETS(S); \
- assert(0); \
+#define STREAM_BOUND_WARN(S, WHAT) \
+ do { \
+ zlog_warn("%s: Attempt to %s out of bounds", __func__, \
+ (WHAT)); \
+ STREAM_WARN_OFFSETS(S); \
+ assert(0); \
} while (0)
-#define STREAM_BOUND_WARN2(S, WHAT) \
- do { \
- zlog_warn("%s: Attempt to %s out of bounds", __func__, \
- (WHAT)); \
- STREAM_WARN_OFFSETS(S); \
+#define STREAM_BOUND_WARN2(S, WHAT) \
+ do { \
+ zlog_warn("%s: Attempt to %s out of bounds", __func__, \
+ (WHAT)); \
+ STREAM_WARN_OFFSETS(S); \
} while (0)
/* XXX: Deprecated macro: do not use */
@@ -353,7 +353,7 @@ inline bool stream_getw2(struct stream *s, uint16_t *word)
return false;
}
- *word = s->data[s->getp++] << 8;
+ *word = s->data[s->getp++] << 8;
*word |= s->data[s->getp++];
return true;
@@ -474,13 +474,12 @@ inline bool stream_getl2(struct stream *s, uint32_t *l)
return false;
}
- *l = (unsigned int)(s->data[s->getp++]) << 24;
+ *l = (unsigned int)(s->data[s->getp++]) << 24;
*l |= s->data[s->getp++] << 16;
*l |= s->data[s->getp++] << 8;
*l |= s->data[s->getp++];
return true;
-
}
u_int32_t stream_getl(struct stream *s)
diff --git a/lib/stream.h b/lib/stream.h
index 4d387f9564..e738040d34 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -281,34 +281,34 @@ static inline uint8_t *ptr_get_be32(uint8_t *ptr, uint32_t *out)
* the stream functions but we need a transition
* plan.
*/
-#define STREAM_GETC(S, P) \
- do { \
- uint8_t _pval; \
- if (!stream_getc2((S), &_pval)) \
- goto stream_failure; \
- (P) = _pval; \
+#define STREAM_GETC(S, P) \
+ do { \
+ uint8_t _pval; \
+ if (!stream_getc2((S), &_pval)) \
+ goto stream_failure; \
+ (P) = _pval; \
} while (0)
-#define STREAM_GETW(S, P) \
- do { \
- uint16_t _pval; \
- if (!stream_getw2((S), &_pval)) \
- goto stream_failure; \
- (P) = _pval; \
+#define STREAM_GETW(S, P) \
+ do { \
+ uint16_t _pval; \
+ if (!stream_getw2((S), &_pval)) \
+ goto stream_failure; \
+ (P) = _pval; \
} while (0)
-#define STREAM_GETL(S, P) \
- do { \
- uint32_t _pval; \
- if (!stream_getl2((S), &_pval)) \
- goto stream_failure; \
- (P) = _pval; \
+#define STREAM_GETL(S, P) \
+ do { \
+ uint32_t _pval; \
+ if (!stream_getl2((S), &_pval)) \
+ goto stream_failure; \
+ (P) = _pval; \
} while (0)
-#define STREAM_GET(P, STR, SIZE) \
- do { \
- if (!stream_get2((P), (STR), (SIZE))) \
- goto stream_failure; \
+#define STREAM_GET(P, STR, SIZE) \
+ do { \
+ if (!stream_get2((P), (STR), (SIZE))) \
+ goto stream_failure; \
} while (0)
#endif /* _ZEBRA_STREAM_H */
diff --git a/lib/subdir.am b/lib/subdir.am
index e292d7a342..7d85b7a24d 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -15,6 +15,7 @@ lib_libfrr_la_SOURCES = \
lib/command_match.c \
lib/command_parse.y \
lib/csv.c \
+ lib/debug.c \
lib/distribute.c \
lib/event_counter.c \
lib/ferr.c \
@@ -44,6 +45,7 @@ lib_libfrr_la_SOURCES = \
lib/nexthop.c \
lib/netns_linux.c \
lib/netns_other.c \
+ lib/nexthop_group.c \
lib/openbsd-tree.c \
lib/pid_output.c \
lib/plist.c \
@@ -80,6 +82,8 @@ lib_libfrr_la_SOURCES = \
lib/plist_clippy.c: $(CLIPPY_DEPS)
lib/plist.lo: lib/plist_clippy.c
+lib/nexthop_group_clippy.c: $(CLIPPY_DEPS)
+lib/nexthop_group.lo: lib/nexthop_group_clippy.c
pkginclude_HEADERS += \
lib/bfd.h \
@@ -91,6 +95,7 @@ pkginclude_HEADERS += \
lib/command_match.h \
lib/compiler.h \
lib/csv.h \
+ lib/debug.h \
lib/distribute.h \
lib/event_counter.h \
lib/ferr.h \
@@ -122,6 +127,7 @@ pkginclude_HEADERS += \
lib/mpls.h \
lib/network.h \
lib/nexthop.h \
+ lib/nexthop_group.h \
lib/ns.h \
lib/openbsd-queue.h \
lib/openbsd-tree.h \
diff --git a/lib/thread.c b/lib/thread.c
index 9d64663d9c..a221c77628 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -59,7 +59,7 @@ static struct list *masters;
/* CLI start ---------------------------------------------------------------- */
static unsigned int cpu_record_hash_key(struct cpu_thread_history *a)
{
- int size = sizeof (&a->func);
+ int size = sizeof(&a->func);
return jhash(&a->func, size, 0);
}
@@ -380,8 +380,7 @@ struct thread_master *thread_master_create(const char *name)
}
rv->cpu_record = hash_create_size(
- 8,
- (unsigned int (*)(void *))cpu_record_hash_key,
+ 8, (unsigned int (*)(void *))cpu_record_hash_key,
(int (*)(const void *, const void *))cpu_record_hash_cmp,
"Thread Hash");
@@ -937,7 +936,7 @@ static void thread_cancel_rw(struct thread_master *master, int fd, short state)
zlog_debug(
"[!] Received cancellation request for nonexistent rw job");
zlog_debug("[!] threadmaster: %s | fd: %d",
- master->name ? master->name : "", fd);
+ master->name ? master->name : "", fd);
return;
}
diff --git a/lib/vrf.c b/lib/vrf.c
index ea106b90a2..f8e5a97904 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -150,8 +150,8 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name)
int new = 0;
if (debug_vrf)
- zlog_debug("VRF_GET: %s(%u)",
- name == NULL ? "(NULL)" : name, vrf_id);
+ zlog_debug("VRF_GET: %s(%u)", name == NULL ? "(NULL)" : name,
+ vrf_id);
/* Nothing to see, move along here */
if (!name && vrf_id == VRF_UNKNOWN)
@@ -500,14 +500,14 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- zlog_err("%s: Can't switch to VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
+ safe_strerror(errno));
ret = socket(domain, type, protocol);
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- zlog_err("%s: Can't switchback from VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
if (ret <= 0)
return ret;
@@ -541,12 +541,12 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, struct vrf **vrf)
if (strlen(vrfname) > VRF_NAMSIZ) {
if (vty)
vty_out(vty,
- "%% VRF name %s invalid: length exceeds %d bytes\n",
- vrfname, VRF_NAMSIZ);
+ "%% VRF name %s invalid: length exceeds %d bytes\n",
+ vrfname, VRF_NAMSIZ);
else
zlog_warn(
- "%% VRF name %s invalid: length exceeds %d bytes\n",
- vrfname, VRF_NAMSIZ);
+ "%% VRF name %s invalid: length exceeds %d bytes\n",
+ vrfname, VRF_NAMSIZ);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -560,8 +560,8 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, struct vrf **vrf)
return CMD_SUCCESS;
}
-int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
- char *pathname, ns_id_t ns_id)
+int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
+ ns_id_t ns_id)
{
struct ns *ns = NULL;
@@ -578,16 +578,16 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
return CMD_WARNING_CONFIG_FAILED;
}
if (vrf->ns_ctxt != NULL) {
- ns = (struct ns *) vrf->ns_ctxt;
+ ns = (struct ns *)vrf->ns_ctxt;
if (ns && 0 != strcmp(ns->name, pathname)) {
if (vty)
vty_out(vty,
- "VRF %u already configured with NETNS %s\n",
- vrf->vrf_id, ns->name);
+ "VRF %u already configured with NETNS %s\n",
+ vrf->vrf_id, ns->name);
else
zlog_warn(
- "VRF %u already configured with NETNS %s",
- vrf->vrf_id, ns->name);
+ "VRF %u already configured with NETNS %s",
+ vrf->vrf_id, ns->name);
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -598,9 +598,10 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
if (vrf2 == vrf)
return CMD_SUCCESS;
if (vty)
- vty_out(vty, "NS %s is already configured"
+ vty_out(vty,
+ "NS %s is already configured"
" with VRF %u(%s)\n",
- ns->name, vrf2->vrf_id, vrf2->name);
+ ns->name, vrf2->vrf_id, vrf2->name);
else
zlog_warn("NS %s is already configured with VRF %u(%s)",
ns->name, vrf2->vrf_id, vrf2->name);
@@ -616,7 +617,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
if (!ns_enable(ns, vrf_update_vrf_id)) {
if (vty)
vty_out(vty, "Can not associate NS %u with NETNS %s\n",
- ns->ns_id, ns->name);
+ ns->ns_id, ns->name);
else
zlog_warn("Can not associate NS %u with NETNS %s",
ns->ns_id, ns->name);
@@ -812,30 +813,29 @@ int vrf_bind(vrf_id_t vrf_id, int fd, char *name)
if (vrf_is_mapped_on_netns(vrf_id))
return fd;
#ifdef SO_BINDTODEVICE
- ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name,
- strlen(name));
+ ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name));
if (ret < 0)
- zlog_debug("bind to interface %s failed, errno=%d",
- name, errno);
+ zlog_debug("bind to interface %s failed, errno=%d", name,
+ errno);
#endif /* SO_BINDTODEVICE */
return ret;
}
int vrf_getaddrinfo(const char *node, const char *service,
- const struct addrinfo *hints,
- struct addrinfo **res, vrf_id_t vrf_id)
+ const struct addrinfo *hints, struct addrinfo **res,
+ vrf_id_t vrf_id)
{
int ret, ret2, save_errno;
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- zlog_err("%s: Can't switch to VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
+ safe_strerror(errno));
ret = getaddrinfo(node, service, hints, res);
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- zlog_err("%s: Can't switchback from VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
return ret;
}
@@ -846,16 +846,16 @@ int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *params)
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0) {
- zlog_err("%s: Can't switch to VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
+ safe_strerror(errno));
return 0;
}
rc = ioctl(d, request, params);
saved_errno = errno;
ret = vrf_switchback_to_initial();
if (ret < 0)
- zlog_err("%s: Can't switchback from VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = saved_errno;
return rc;
}
@@ -867,14 +867,14 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id,
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- zlog_err("%s: Can't switch to VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
+ safe_strerror(errno));
ret = sockunion_socket(su);
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- zlog_err("%s: Can't switchback from VRF %u (%s)",
- __func__, vrf_id, safe_strerror(errno));
+ zlog_err("%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
if (ret <= 0)
diff --git a/lib/vrf.h b/lib/vrf.h
index 062e6f3d8d..6482740aa1 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -206,19 +206,18 @@ extern void vrf_terminate(void);
*/
/* Create a socket serving for the given VRF */
-extern int vrf_socket(int domain, int type,
- int protocol, vrf_id_t vrf_id,
+extern int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,
char *name);
-extern int vrf_sockunion_socket(const union sockunion *su,
- vrf_id_t vrf_id, char *name);
+extern int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id,
+ char *name);
extern int vrf_bind(vrf_id_t vrf_id, int fd, char *name);
/* VRF ioctl operations */
extern int vrf_getaddrinfo(const char *node, const char *service,
- const struct addrinfo *hints,
- struct addrinfo **res, vrf_id_t vrf_id);
+ const struct addrinfo *hints, struct addrinfo **res,
+ vrf_id_t vrf_id);
extern int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *args);
@@ -264,8 +263,7 @@ extern int vrf_is_backend_netns(void);
/* API to create a VRF. either from vty
* or through discovery
*/
-extern int vrf_handler_create(struct vty *vty,
- const char *name,
+extern int vrf_handler_create(struct vty *vty, const char *name,
struct vrf **vrf);
/* API to associate a VRF with a NETNS.
@@ -273,7 +271,7 @@ extern int vrf_handler_create(struct vty *vty,
* should be called from zebra only
*/
extern int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,
- char *pathname, ns_id_t ns_id);
+ char *pathname, ns_id_t ns_id);
/* used internally to enable or disable VRF.
* Notify a change in the VRF ID of the VRF
diff --git a/lib/vty.c b/lib/vty.c
index 43a53b7732..4a703f12ba 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2287,7 +2287,8 @@ static void vty_read_file(FILE *confp)
message = "Command returned Incomplete";
break;
case CMD_ERR_EXEED_ARGC_MAX:
- message = "Command exceeded maximum number of Arguments";
+ message =
+ "Command exceeded maximum number of Arguments";
break;
default:
message = "Command returned unhandled error message";
@@ -2297,8 +2298,8 @@ static void vty_read_file(FILE *confp)
nl = strchr(vty->error_buf, '\n');
if (nl)
*nl = '\0';
- zlog_err("ERROR: %s on config line %u: %s",
- message, line_num, vty->error_buf);
+ zlog_err("ERROR: %s on config line %u: %s", message, line_num,
+ vty->error_buf);
}
vty_close(vty);
@@ -2370,7 +2371,8 @@ void vty_read_config(const char *config_file, char *config_default_dir)
if (config_file != NULL) {
if (!IS_DIRECTORY_SEP(config_file[0])) {
if (getcwd(cwd, MAXPATHLEN) == NULL) {
- zlog_err("Failure to determine Current Working Directory %d!",
+ zlog_err(
+ "Failure to determine Current Working Directory %d!",
errno);
exit(1);
}
@@ -2385,14 +2387,15 @@ void vty_read_config(const char *config_file, char *config_default_dir)
if (confp == NULL) {
zlog_err("%s: failed to open configuration file %s: %s",
- __func__, fullpath, safe_strerror(errno));
+ __func__, fullpath, safe_strerror(errno));
confp = vty_use_backup_config(fullpath);
if (confp)
- zlog_warn("WARNING: using backup configuration file!");
+ zlog_warn(
+ "WARNING: using backup configuration file!");
else {
zlog_err("can't open configuration file [%s]",
- config_file);
+ config_file);
exit(1);
}
}
@@ -2427,16 +2430,17 @@ void vty_read_config(const char *config_file, char *config_default_dir)
confp = fopen(config_default_dir, "r");
if (confp == NULL) {
zlog_err("%s: failed to open configuration file %s: %s",
- __func__, config_default_dir,
- safe_strerror(errno));
+ __func__, config_default_dir,
+ safe_strerror(errno));
confp = vty_use_backup_config(config_default_dir);
if (confp) {
- zlog_warn("WARNING: using backup configuration file!");
+ zlog_warn(
+ "WARNING: using backup configuration file!");
fullpath = config_default_dir;
} else {
zlog_err("can't open configuration file [%s]",
- config_default_dir);
+ config_default_dir);
goto tmp_free_and_out;
}
} else
@@ -2946,12 +2950,11 @@ static void vty_save_cwd(void)
*/
if (!chdir(SYSCONFDIR)) {
zlog_err("Failure to chdir to %s, errno: %d",
- SYSCONFDIR, errno);
+ SYSCONFDIR, errno);
exit(-1);
}
if (getcwd(cwd, MAXPATHLEN) == NULL) {
- zlog_err("Failure to getcwd, errno: %d",
- errno);
+ zlog_err("Failure to getcwd, errno: %d", errno);
exit(-1);
}
}
diff --git a/lib/vty.h b/lib/vty.h
index 3b75afb02c..3ea9cce388 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -174,8 +174,8 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
struct structname *ptr = VTY_GET_CONTEXT_SUB(structname); \
VTY_CHECK_CONTEXT(ptr);
#define VTY_DECLVAR_INSTANCE_CONTEXT(structname, ptr) \
- if (vty->qobj_index == 0) \
- return CMD_NOT_MY_INSTANCE; \
+ if (vty->qobj_index == 0) \
+ return CMD_NOT_MY_INSTANCE; \
struct structname *ptr = VTY_GET_CONTEXT(structname); \
VTY_CHECK_CONTEXT(ptr);
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 952012a006..1af51c06c1 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -101,7 +101,7 @@ struct work_queue *work_queue_new(struct thread_master *m,
return new;
}
-void work_queue_free(struct work_queue *wq)
+void work_queue_free_original(struct work_queue *wq)
{
if (wq->thread != NULL)
thread_cancel(wq->thread);
@@ -119,6 +119,12 @@ void work_queue_free(struct work_queue *wq)
return;
}
+void work_queue_free_and_null(struct work_queue **wq)
+{
+ work_queue_free_original(*wq);
+ *wq = NULL;
+}
+
bool work_queue_is_scheduled(struct work_queue *wq)
{
return (wq->thread != NULL);
@@ -127,8 +133,8 @@ bool work_queue_is_scheduled(struct work_queue *wq)
static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
{
/* if appropriate, schedule work queue thread */
- if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL) &&
- !work_queue_empty(wq)) {
+ if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL)
+ && !work_queue_empty(wq)) {
wq->thread = NULL;
thread_add_timer_msec(wq->master, work_queue_run, wq, delay,
&wq->thread);
@@ -159,7 +165,8 @@ void work_queue_add(struct work_queue *wq, void *data)
return;
}
-static void work_queue_item_requeue(struct work_queue *wq, struct work_queue_item *item)
+static void work_queue_item_requeue(struct work_queue *wq,
+ struct work_queue_item *item)
{
work_queue_item_dequeue(wq, item);
diff --git a/lib/workqueue.h b/lib/workqueue.h
index df35d44fbc..c9785de09a 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -28,7 +28,7 @@
DECLARE_MTYPE(WORK_QUEUE)
/* Hold time for the initial schedule of a queue run, in millisec */
-#define WORK_QUEUE_DEFAULT_HOLD 50
+#define WORK_QUEUE_DEFAULT_HOLD 50
/* action value, for use by item processor and item error handlers */
typedef enum {
@@ -93,8 +93,9 @@ struct work_queue {
} spec;
/* remaining fields should be opaque to users */
- STAILQ_HEAD(work_queue_items, work_queue_item) items; /* queue item list */
- int item_count; /* queued items */
+ STAILQ_HEAD(work_queue_items, work_queue_item)
+ items; /* queue item list */
+ int item_count; /* queued items */
unsigned long runs; /* runs count */
unsigned long yields; /* yields count */
@@ -120,7 +121,8 @@ static inline bool work_queue_empty(struct work_queue *wq)
return (wq->item_count == 0) ? true : false;
}
-static inline struct work_queue_item *work_queue_last_item(struct work_queue *wq)
+static inline struct work_queue_item *
+work_queue_last_item(struct work_queue *wq)
{
return STAILQ_LAST(&wq->items, work_queue_item, wq);
}
@@ -146,8 +148,22 @@ static inline void work_queue_item_dequeue(struct work_queue *wq,
* anything to it
*/
extern struct work_queue *work_queue_new(struct thread_master *, const char *);
+
/* destroy work queue */
-extern void work_queue_free(struct work_queue *);
+/*
+ * The usage of work_queue_free is being transitioned to pass
+ * in the double pointer to remove use after free's.
+ */
+#if CONFDATE > 20190205
+CPP_NOTICE("work_queue_free without double pointer is deprecated, please fixup")
+#endif
+extern void work_queue_free_and_null(struct work_queue **);
+extern void work_queue_free_original(struct work_queue *);
+#define work_queue_free(X) \
+ do { \
+ work_queue_free_original((X)); \
+ CPP_WARN("Please use work_queue_free_and_null"); \
+ } while (0)
/* Add the supplied data as an item onto the workqueue */
extern void work_queue_add(struct work_queue *, void *);
diff --git a/lib/zclient.c b/lib/zclient.c
index 8535c3b5f5..fa3a5f6691 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -52,7 +52,7 @@ socklen_t zclient_addr_len;
/* This file local debug flag. */
int zclient_debug = 0;
-struct zclient_options zclient_options_default = { .receive_notify = false };
+struct zclient_options zclient_options_default = {.receive_notify = false};
/* Allocate zclient structure. */
struct zclient *zclient_new_notify(struct thread_master *master,
@@ -186,8 +186,8 @@ void zclient_reset(struct zclient *zclient)
&zclient->mi_redist[afi][zclient->redist_default],
zclient->instance);
- zclient_init(zclient, zclient->redist_default,
- zclient->instance, zclient->privs);
+ zclient_init(zclient, zclient->redist_default, zclient->instance,
+ zclient->privs);
}
/**
@@ -214,8 +214,7 @@ int zclient_socket_connect(struct zclient *zclient)
zclient->privs->change(ZPRIVS_LOWER);
/* Connect to zebra. */
- ret = connect(sock, (struct sockaddr *)&zclient_addr,
- zclient_addr_len);
+ ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
if (ret < 0) {
if (zclient_debug)
zlog_warn("%s connect failure: %d(%s)",
@@ -416,13 +415,13 @@ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id)
for (ALL_LIST_ELEMENTS_RO(
zclient->mi_redist[afi][i]
- .instances, node, id))
+ .instances,
+ node, id))
if (!(i == zclient->redist_default
&& *id == zclient->instance))
zebra_redistribute_send(
ZEBRA_REDISTRIBUTE_ADD,
- zclient, afi, i,
- *id,
+ zclient, afi, i, *id,
VRF_DEFAULT);
}
}
@@ -481,13 +480,13 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)
for (ALL_LIST_ELEMENTS_RO(
zclient->mi_redist[afi][i]
- .instances, node, id))
+ .instances,
+ node, id))
if (!(i == zclient->redist_default
&& *id == zclient->instance))
zebra_redistribute_send(
ZEBRA_REDISTRIBUTE_DELETE,
- zclient, afi, i,
- *id,
+ zclient, afi, i, *id,
VRF_DEFAULT);
}
}
@@ -583,8 +582,8 @@ int zclient_start(struct zclient *zclient)
/* Initialize zebra client. Argument redist_default is unwanted
redistribute route type. */
-void zclient_init(struct zclient *zclient, int redist_default,
- u_short instance, struct zebra_privs_t *privs)
+void zclient_init(struct zclient *zclient, int redist_default, u_short instance,
+ struct zebra_privs_t *privs)
{
int afi, i;
@@ -1021,8 +1020,9 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
stream_putl(s, api_nh->ifindex);
break;
default:
- zlog_warn("%s: Specified Nexthop type %d does not exist",
- __PRETTY_FUNCTION__, api_nh->type);
+ zlog_warn(
+ "%s: Specified Nexthop type %d does not exist",
+ __PRETTY_FUNCTION__, api_nh->type);
return -1;
}
@@ -1058,6 +1058,8 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
stream_putl(s, api->tag);
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
stream_putl(s, api->mtu);
+ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+ stream_putl(s, api->tableid);
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
@@ -1076,7 +1078,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api->type);
if (api->type > ZEBRA_ROUTE_MAX) {
zlog_warn("%s: Specified route type: %d is not a legal value\n",
- __PRETTY_FUNCTION__, api->type);
+ __PRETTY_FUNCTION__, api->type);
return -1;
}
@@ -1093,15 +1095,17 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
switch (api->prefix.family) {
case AF_INET:
if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) {
- zlog_warn("%s: V4 prefixlen is %d which should not be more than 32",
- __PRETTY_FUNCTION__, api->prefix.prefixlen);
+ zlog_warn(
+ "%s: V4 prefixlen is %d which should not be more than 32",
+ __PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
}
break;
case AF_INET6:
if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn("%s: v6 prefixlen is %d which should not be more than 128",
- __PRETTY_FUNCTION__, api->prefix.prefixlen);
+ zlog_warn(
+ "%s: v6 prefixlen is %d which should not be more than 128",
+ __PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
}
break;
@@ -1116,9 +1120,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
api->src_prefix.family = AF_INET6;
STREAM_GETC(s, api->src_prefix.prefixlen);
if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn("%s: SRC Prefix prefixlen received: %d is too large",
- __PRETTY_FUNCTION__,
- api->src_prefix.prefixlen);
+ zlog_warn(
+ "%s: SRC Prefix prefixlen received: %d is too large",
+ __PRETTY_FUNCTION__, api->src_prefix.prefixlen);
return -1;
}
STREAM_GET(&api->src_prefix.prefix, s,
@@ -1126,8 +1130,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (api->prefix.family != AF_INET6
|| api->src_prefix.prefixlen == 0) {
- zlog_warn("%s: SRC prefix specified in some manner that makes no sense",
- __PRETTY_FUNCTION__);
+ zlog_warn(
+ "%s: SRC prefix specified in some manner that makes no sense",
+ __PRETTY_FUNCTION__);
return -1;
}
}
@@ -1170,9 +1175,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETL(s, api_nh->ifindex);
break;
default:
- zlog_warn("%s: Specified nexthop type %d does not exist",
- __PRETTY_FUNCTION__,
- api_nh->type);
+ zlog_warn(
+ "%s: Specified nexthop type %d does not exist",
+ __PRETTY_FUNCTION__, api_nh->type);
return -1;
}
@@ -1204,6 +1209,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETL(s, api->tag);
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
STREAM_GETL(s, api->mtu);
+ if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+ STREAM_GETL(s, api->tableid);
stream_failure:
return 0;
@@ -1219,8 +1226,7 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
STREAM_GETC(s, p->family);
STREAM_GETC(s, p->prefixlen);
- STREAM_GET(&p->u.prefix, s,
- prefix_blen(p));
+ STREAM_GET(&p->u.prefix, s, prefix_blen(p));
STREAM_GETL(s, t);
*tableid = t;
@@ -1231,6 +1237,35 @@ stream_failure:
return false;
}
+bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
+ uint32_t *priority, uint32_t *unique,
+ ifindex_t *ifindex,
+ enum zapi_rule_notify_owner *note)
+{
+ uint32_t prio, seq, uni;
+ ifindex_t ifi;
+
+ STREAM_GET(note, s, sizeof(*note));
+
+ STREAM_GETL(s, seq);
+ STREAM_GETL(s, prio);
+ STREAM_GETL(s, uni);
+ STREAM_GETL(s, ifi);
+
+ if (zclient_debug)
+ zlog_debug("%s: %u %u %u %u", __PRETTY_FUNCTION__,
+ seq, prio, uni, ifi);
+ *seqno = seq;
+ *priority = prio;
+ *unique = uni;
+ *ifindex = ifi;
+
+ return true;
+
+stream_failure:
+ return false;
+}
+
struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh)
{
struct nexthop *n = nexthop_new();
@@ -1255,7 +1290,7 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
STREAM_GETW(s, nhr->prefix.family);
STREAM_GETC(s, nhr->prefix.prefixlen);
- switch(nhr->prefix.family) {
+ switch (nhr->prefix.family) {
case AF_INET:
STREAM_GET(&nhr->prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);
break;
@@ -1272,13 +1307,13 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
STREAM_GETL(s, nhr->metric);
STREAM_GETC(s, nhr->nexthop_num);
- for (i = 0; i < nhr->nexthop_num ; i++) {
+ for (i = 0; i < nhr->nexthop_num; i++) {
STREAM_GETC(s, nhr->nexthops[i].type);
switch (nhr->nexthops[i].type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr,
- s, IPV4_MAX_BYTELEN);
+ STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr, s,
+ IPV4_MAX_BYTELEN);
STREAM_GETL(s, nhr->nexthops[i].ifindex);
break;
case NEXTHOP_TYPE_IFINDEX:
@@ -1286,8 +1321,8 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
- STREAM_GET(&nhr->nexthops[i].gate.ipv6,
- s, IPV6_MAX_BYTELEN);
+ STREAM_GET(&nhr->nexthops[i].gate.ipv6, s,
+ IPV6_MAX_BYTELEN);
STREAM_GETL(s, nhr->nexthops[i].ifindex);
break;
case NEXTHOP_TYPE_BLACKHOLE:
@@ -2375,6 +2410,10 @@ static int zclient_read(struct thread *thread)
(*zclient->route_notify_owner)(command, zclient, length,
vrf_id);
break;
+ case ZEBRA_RULE_NOTIFY_OWNER:
+ if (zclient->rule_notify_owner)
+ (*zclient->rule_notify_owner)(command, zclient, length,
+ vrf_id);
default:
break;
}
diff --git a/lib/zclient.h b/lib/zclient.h
index 4c84af1f61..1aa94b641c 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -37,7 +37,7 @@
#include "pw.h"
/* For input/output buffer to zebra. */
-#define ZEBRA_MAX_PACKET_SIZ 4096
+#define ZEBRA_MAX_PACKET_SIZ 16384
/* Zebra header size. */
#define ZEBRA_HEADER_SIZE 10
@@ -129,6 +129,9 @@ typedef enum {
ZEBRA_PW_SET,
ZEBRA_PW_UNSET,
ZEBRA_PW_STATUS_UPDATE,
+ ZEBRA_RULE_ADD,
+ ZEBRA_RULE_DELETE,
+ ZEBRA_RULE_NOTIFY_OWNER,
} zebra_message_types_t;
struct redist_proto {
@@ -215,6 +218,8 @@ struct zclient {
int (*pw_status_update)(int, struct zclient *, uint16_t, vrf_id_t);
int (*route_notify_owner)(int command, struct zclient *zclient,
uint16_t length, vrf_id_t vrf_id);
+ int (*rule_notify_owner)(int command, struct zclient *zclient,
+ uint16_t length, vrf_id_t vrf_id);
};
/* Zebra API message flag. */
@@ -225,6 +230,12 @@ struct zclient {
#define ZAPI_MESSAGE_MTU 0x10
#define ZAPI_MESSAGE_SRCPFX 0x20
#define ZAPI_MESSAGE_LABEL 0x40
+/*
+ * This should only be used by a DAEMON that needs to communicate
+ * the table being used is not in the VRF. You must pass the
+ * default vrf, else this will be ignored.
+ */
+#define ZAPI_MESSAGE_TABLEID 0x80
/* Zserv protocol message header */
struct zserv_header {
@@ -289,6 +300,8 @@ struct zapi_route {
vrf_id_t vrf_id;
+ uint32_t tableid;
+
struct ethaddr rmac;
};
@@ -346,6 +359,14 @@ enum zapi_route_notify_owner {
ZAPI_ROUTE_FAIL_INSTALL,
ZAPI_ROUTE_BETTER_ADMIN_WON,
ZAPI_ROUTE_INSTALLED,
+ ZAPI_ROUTE_REMOVED,
+ ZAPI_ROUTE_REMOVE_FAIL,
+};
+
+enum zapi_rule_notify_owner {
+ ZAPI_RULE_FAIL_INSTALL,
+ ZAPI_RULE_INSTALLED,
+ ZAPI_RULE_REMOVED,
};
/* Zebra MAC types */
@@ -368,10 +389,12 @@ extern struct zclient_options zclient_options_default;
extern struct zclient *zclient_new_notify(struct thread_master *m,
struct zclient_options *opt);
-#define zclient_new(A) zclient_new_notify((A), &zclient_options_default); \
+#define zclient_new(A) \
+ zclient_new_notify((A), &zclient_options_default); \
CPP_WARN("Please transition to using zclient_new_notify");
-extern void zclient_init(struct zclient *, int, u_short, struct zebra_privs_t *privs);
+extern void zclient_init(struct zclient *, int, u_short,
+ struct zebra_privs_t *privs);
extern int zclient_start(struct zclient *);
extern void zclient_stop(struct zclient *);
extern void zclient_reset(struct zclient *);
@@ -446,7 +469,8 @@ extern void zebra_interface_if_set_value(struct stream *, struct interface *);
extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);
#if CONFDATE > 20180823
-CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");
+CPP_NOTICE(
+ "zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");
#endif
extern int zapi_ipv4_route(u_char, struct zclient *, struct prefix_ipv4 *,
@@ -515,6 +539,10 @@ extern int zapi_route_decode(struct stream *, struct zapi_route *);
bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
uint32_t *tableid,
enum zapi_route_notify_owner *note);
+bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
+ uint32_t *priority, uint32_t *unique,
+ ifindex_t *ifindex,
+ enum zapi_rule_notify_owner *note);
extern struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh);
extern bool zapi_nexthop_update_decode(struct stream *s,
struct zapi_route *nhr);
diff --git a/lib/zebra.h b/lib/zebra.h
index 11bf764b63..262ad2e43d 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -127,10 +127,10 @@ typedef unsigned char u_int8_t;
#endif
#ifndef HAVE_LIBCRYPT
-# ifdef HAVE_LIBCRYPTO
-# include <openssl/des.h>
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/des.h>
# define crypt DES_crypt
-# endif
+#endif
#endif
#include "openbsd-tree.h"
@@ -481,6 +481,16 @@ typedef enum {
#define UNSET_FLAG(V,F) (V) &= ~(F)
#define RESET_FLAG(V) (V) = 0
+/* Atomic flag manipulation macros. */
+#define CHECK_FLAG_ATOMIC(PV, F) \
+ ((atomic_load_explicit(PV, memory_order_seq_cst)) & (F))
+#define SET_FLAG_ATOMIC(PV, F) \
+ ((atomic_fetch_or_explicit(PV, (F), memory_order_seq_cst)))
+#define UNSET_FLAG_ATOMIC(PV, F) \
+ ((atomic_fetch_and_explicit(PV, ~(F), memory_order_seq_cst)))
+#define RESET_FLAG_ATOMIC(PV) \
+ ((atomic_store_explicit(PV, 0, memory_order_seq_cst)))
+
/* Zebra types. Used in Zserv message header. */
typedef u_int16_t zebra_size_t;
typedef u_int16_t zebra_command_t;