summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/filter.c5
-rw-r--r--lib/northbound_cli.c16
-rw-r--r--lib/northbound_grpc.cpp5
-rw-r--r--lib/pbr.h2
-rw-r--r--lib/prefix.c47
-rw-r--r--lib/prefix.h2
-rw-r--r--lib/thread.c12
-rw-r--r--lib/yang.c16
-rw-r--r--lib/yang.h8
9 files changed, 106 insertions, 7 deletions
diff --git a/lib/filter.c b/lib/filter.c
index fe62ca1c13..8c210bd7ad 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1915,6 +1915,7 @@ DEFUN (mac_access_list,
argv_find(argv, argc, "X:X:X:X:X:X", &idx);
if (idx)
mac = argv[idx]->arg;
+ assert(mac);
return filter_set_zebra(vty, argv[2]->arg, seq, permit_deny, AFI_L2VPN,
mac, 0, 1);
@@ -1952,6 +1953,7 @@ DEFUN (no_mac_access_list,
argv_find(argv, argc, "X:X:X:X:X:X", &idx);
if (idx)
mac = argv[idx]->arg;
+ assert(mac);
return filter_set_zebra(vty, argv[2]->arg, seq, permit_deny, AFI_L2VPN,
mac, 0, 0);
@@ -2050,6 +2052,7 @@ DEFUN (access_list_exact,
argv_find(argv, argc, "A.B.C.D/M", &idx);
if (idx)
prefix = argv[idx]->arg;
+ assert(prefix);
idx = 0;
if (argv_find(argv, argc, "exact-match", &idx))
@@ -2122,6 +2125,7 @@ DEFUN (no_access_list_exact,
argv_find(argv, argc, "A.B.C.D/M", &idx);
if (idx)
prefix = argv[idx]->arg;
+ assert(prefix);
idx = 0;
if (argv_find(argv, argc, "exact-match", &idx))
@@ -2367,6 +2371,7 @@ DEFUN (no_ipv6_access_list_exact,
argv_find(argv, argc, "X:X::X:X/M", &idx);
if (idx)
prefix = argv[idx]->arg;
+ assert(prefix);
idx = 0;
if (argv_find(argv, argc, "exact-match", &idx))
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 61919f0229..d3e788d5d3 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -40,6 +40,7 @@ struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"};
struct debug nb_dbg_notif = {0, "Northbound notifications"};
struct debug nb_dbg_events = {0, "Northbound events"};
+struct debug nb_dbg_libyang = {0, "libyang debugging"};
struct nb_config *vty_shared_candidate_config;
static struct thread_master *master;
@@ -1581,7 +1582,7 @@ DEFPY (rollback_config,
/* Debug CLI commands. */
static struct debug *nb_debugs[] = {
&nb_dbg_cbs_config, &nb_dbg_cbs_state, &nb_dbg_cbs_rpc,
- &nb_dbg_notif, &nb_dbg_events,
+ &nb_dbg_notif, &nb_dbg_events, &nb_dbg_libyang,
};
static const char *const nb_debugs_conflines[] = {
@@ -1590,6 +1591,7 @@ static const char *const nb_debugs_conflines[] = {
"debug northbound callbacks rpc",
"debug northbound notifications",
"debug northbound events",
+ "debug northbound libyang",
};
DEFINE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
@@ -1614,6 +1616,7 @@ DEFPY (debug_nb,
callbacks$cbs [{configuration$cbs_cfg|state$cbs_state|rpc$cbs_rpc}]\
|notifications$notifications\
|events$events\
+ |libyang$libyang\
>]",
NO_STR
DEBUG_STR
@@ -1623,7 +1626,8 @@ DEFPY (debug_nb,
"State\n"
"RPC\n"
"Notifications\n"
- "Events\n")
+ "Events\n"
+ "libyang debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
@@ -1641,10 +1645,16 @@ DEFPY (debug_nb,
DEBUG_MODE_SET(&nb_dbg_notif, mode, !no);
if (events)
DEBUG_MODE_SET(&nb_dbg_events, mode, !no);
+ if (libyang) {
+ DEBUG_MODE_SET(&nb_dbg_libyang, mode, !no);
+ yang_debugging_set(!no);
+ }
/* no specific debug --> act on all of them */
- if (strmatch(argv[argc - 1]->text, "northbound"))
+ if (strmatch(argv[argc - 1]->text, "northbound")) {
nb_debug_set_all(mode, !no);
+ yang_debugging_set(!no);
+ }
return CMD_SUCCESS;
}
diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp
index 218cae4e74..089899368d 100644
--- a/lib/northbound_grpc.cpp
+++ b/lib/northbound_grpc.cpp
@@ -616,6 +616,11 @@ class NorthboundImpl final : public frr::Northbound::Service
return LYD_JSON;
case frr::XML:
return LYD_XML;
+ default:
+ flog_err(EC_LIB_DEVELOPMENT,
+ "%s: unknown data encoding format (%u)",
+ __func__, encoding);
+ exit(1);
}
}
diff --git a/lib/pbr.h b/lib/pbr.h
index ecd50447e5..cf6ac41d32 100644
--- a/lib/pbr.h
+++ b/lib/pbr.h
@@ -90,7 +90,7 @@ struct pbr_rule {
uint32_t unique;
struct pbr_filter filter;
struct pbr_action action;
- uint32_t ifindex;
+ ifindex_t ifindex;
};
/* TCP flags value shared
diff --git a/lib/prefix.c b/lib/prefix.c
index aa6661d7fb..5071ca8201 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -601,6 +601,53 @@ int prefix_match(const struct prefix *n, const struct prefix *p)
if (np[offset] != pp[offset])
return 0;
return 1;
+
+}
+
+/*
+ * n is a type5 evpn prefix. This function tries to see if there is an
+ * ip-prefix within n which matches prefix p
+ * If n includes p prefix then return 1 else return 0.
+ */
+int evpn_type5_prefix_match(const struct prefix *n, const struct prefix *p)
+{
+ int offset;
+ int shift;
+ int prefixlen;
+ const uint8_t *np, *pp;
+ struct prefix_evpn *evp;
+
+ if (n->family != AF_EVPN)
+ return 0;
+
+ evp = (struct prefix_evpn *)n;
+ pp = p->u.val;
+
+ if ((evp->prefix.route_type != 5) ||
+ (p->family == AF_INET6 && !is_evpn_prefix_ipaddr_v6(evp)) ||
+ (p->family == AF_INET && !is_evpn_prefix_ipaddr_v4(evp)) ||
+ (is_evpn_prefix_ipaddr_none(evp)))
+ return 0;
+
+ prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
+ np = &evp->prefix.prefix_addr.ip.ip.addr;
+
+ /* If n's prefix is longer than p's one return 0. */
+ if (prefixlen > p->prefixlen)
+ return 0;
+
+ offset = prefixlen / PNBBY;
+ shift = prefixlen % PNBBY;
+
+ if (shift)
+ if (maskbit[shift] & (np[offset] ^ pp[offset]))
+ return 0;
+
+ while (offset--)
+ if (np[offset] != pp[offset])
+ return 0;
+ return 1;
+
}
/* If n includes p then return 1 else return 0. Prefix mask is not considered */
diff --git a/lib/prefix.h b/lib/prefix.h
index 24c146e022..784927616a 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -407,6 +407,8 @@ extern void prefix_mcast_inet4_dump(const char *onfail, struct in_addr addr,
char *buf, int buf_size);
extern const char *prefix_sg2str(const struct prefix_sg *sg, char *str);
extern const char *prefix2str(union prefixconstptr, char *, int);
+extern int evpn_type5_prefix_match(const struct prefix *evpn_pfx,
+ const struct prefix *match_pfx);
extern int prefix_match(const struct prefix *, const struct prefix *);
extern int prefix_match_network_statement(const struct prefix *,
const struct prefix *);
diff --git a/lib/thread.c b/lib/thread.c
index 6669952ff4..649fe500cd 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -109,6 +109,7 @@ static void cpu_record_hash_free(void *a)
XFREE(MTYPE_THREAD_STATS, hist);
}
+#ifndef EXCLUDE_CPU_TIME
static void vty_out_cpu_thread_history(struct vty *vty,
struct cpu_thread_history *a)
{
@@ -219,6 +220,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
if (tmp.total_calls > 0)
vty_out_cpu_thread_history(vty, &tmp);
}
+#endif
static void cpu_record_hash_clear(struct hash_bucket *bucket, void *args[])
{
@@ -288,6 +290,7 @@ static uint8_t parse_filter(const char *filterstr)
return filter;
}
+#ifndef EXCLUDE_CPU_TIME
DEFUN (show_thread_cpu,
show_thread_cpu_cmd,
"show thread cpu [FILTER]",
@@ -313,6 +316,7 @@ DEFUN (show_thread_cpu,
cpu_record_print(vty, filter);
return CMD_SUCCESS;
}
+#endif
static void show_thread_poll_helper(struct vty *vty, struct thread_master *m)
{
@@ -403,7 +407,9 @@ DEFUN (clear_thread_cpu,
void thread_cmd_init(void)
{
+#ifndef EXCLUDE_CPU_TIME
install_element(VIEW_NODE, &show_thread_cpu_cmd);
+#endif
install_element(VIEW_NODE, &show_thread_poll_cmd);
install_element(ENABLE_NODE, &clear_thread_cpu_cmd);
}
@@ -1511,7 +1517,9 @@ void thread_getrusage(RUSAGE_T *r)
#define FRR_RUSAGE RUSAGE_SELF
#endif
monotime(&r->real);
+#ifndef EXCLUDE_CPU_TIME
getrusage(FRR_RUSAGE, &(r->cpu));
+#endif
}
/*
@@ -1527,9 +1535,11 @@ void thread_getrusage(RUSAGE_T *r)
*/
void thread_call(struct thread *thread)
{
+#ifndef EXCLUDE_CPU_TIME
_Atomic unsigned long realtime, cputime;
unsigned long exp;
unsigned long helper;
+#endif
RUSAGE_T before, after;
GETRUSAGE(&before);
@@ -1541,6 +1551,7 @@ void thread_call(struct thread *thread)
GETRUSAGE(&after);
+#ifndef EXCLUDE_CPU_TIME
realtime = thread_consumed_time(&after, &before, &helper);
cputime = helper;
@@ -1585,6 +1596,7 @@ void thread_call(struct thread *thread)
realtime / 1000, cputime / 1000);
}
#endif /* CONSUMED_TIME_CHECK */
+#endif /* Exclude CPU Time */
}
/* Execute thread */
diff --git a/lib/yang.c b/lib/yang.c
index 674f3610d6..d153f75530 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -595,7 +595,7 @@ struct yang_data *yang_data_list_find(const struct list *list,
/* Make libyang log its errors using FRR logging infrastructure. */
static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
{
- int priority;
+ int priority = LOG_ERR;
switch (level) {
case LY_LLERR:
@@ -605,10 +605,9 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
priority = LOG_WARNING;
break;
case LY_LLVRB:
+ case LY_LLDBG:
priority = LOG_DEBUG;
break;
- default:
- return;
}
if (path)
@@ -617,6 +616,17 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
zlog(priority, "libyang: %s", msg);
}
+void yang_debugging_set(bool enable)
+{
+ if (enable) {
+ ly_verb(LY_LLDBG);
+ ly_verb_dbg(0xFF);
+ } else {
+ ly_verb(LY_LLERR);
+ ly_verb_dbg(0);
+ }
+}
+
struct ly_ctx *yang_ctx_new_setup(void)
{
struct ly_ctx *ctx;
diff --git a/lib/yang.h b/lib/yang.h
index 322c74c76a..6892e36019 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -486,6 +486,14 @@ extern struct yang_data *yang_data_list_find(const struct list *list,
extern struct ly_ctx *yang_ctx_new_setup(void);
/*
+ * Enable or disable libyang verbose debugging.
+ *
+ * enable
+ * When set to true, enable libyang verbose debugging, otherwise disable it.
+ */
+extern void yang_debugging_set(bool enable);
+
+/*
* Initialize the YANG subsystem. Should be called only once during the
* daemon initialization process.
*/