summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.h2
-rw-r--r--lib/defun_lex.l3
-rw-r--r--lib/netns_linux.c2
-rw-r--r--lib/ntop.c13
-rw-r--r--lib/ptm_lib.c26
-rw-r--r--lib/routemap.h1
-rw-r--r--lib/routemap_cli.c44
-rw-r--r--lib/routemap_northbound.c42
-rw-r--r--lib/zclient.c2
-rw-r--r--lib/zclient.h61
-rw-r--r--lib/zlog_5424_cli.c1
11 files changed, 122 insertions, 75 deletions
diff --git a/lib/command.h b/lib/command.h
index f369a35243..c60751789f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -84,6 +84,7 @@ enum node_type {
CONFIG_NODE, /* Config node. Default mode of config file. */
PREFIX_NODE, /* ip prefix-list node. */
PREFIX_IPV6_NODE, /* ipv6 prefix-list node. */
+ RMAP_NODE, /* Route map node. */
LIB_DEBUG_NODE, /* frrlib debug node. */
DEBUG_NODE, /* Debug node. */
VRF_DEBUG_NODE, /* Vrf Debug node. */
@@ -136,7 +137,6 @@ enum node_type {
AS_LIST_NODE, /* AS list node. */
COMMUNITY_LIST_NODE, /* Community list node. */
COMMUNITY_ALIAS_NODE, /* Community alias node. */
- RMAP_NODE, /* Route map node. */
PBRMAP_NODE, /* PBR map node. */
SMUX_NODE, /* SNMP configuration node. */
DUMP_NODE, /* Packet dump node. */
diff --git a/lib/defun_lex.l b/lib/defun_lex.l
index 3104e48063..9528e44852 100644
--- a/lib/defun_lex.l
+++ b/lib/defun_lex.l
@@ -157,6 +157,9 @@ SPECIAL [(),]
%%
+#else
+extern int def_yylex(void);
+extern int def_yylex_destroy(void);
#endif /* __clang_analyzer__ */
static int yylex_clr(char **retbuf)
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 8fa4bc6fe0..82162abfd4 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -258,7 +258,7 @@ static void ns_disable_internal(struct ns *ns)
if (ns_master.ns_disable_hook)
(*ns_master.ns_disable_hook)(ns);
- if (have_netns())
+ if (have_netns() && ns->fd >= 0)
close(ns->fd);
ns->fd = -1;
diff --git a/lib/ntop.c b/lib/ntop.c
index 89b4d5ecdc..edf03cd076 100644
--- a/lib/ntop.c
+++ b/lib/ntop.c
@@ -116,7 +116,18 @@ inet4:
best = i - curlen;
bestlen = curlen;
}
- /* do we want ::ffff:A.B.C.D? */
+ if (best == 0 && bestlen == 5 && b[10] == 0xff && b[11] == 0xff) {
+ /* ::ffff:A.B.C.D */
+ *o++ = ':';
+ *o++ = ':';
+ *o++ = 'f';
+ *o++ = 'f';
+ *o++ = 'f';
+ *o++ = 'f';
+ *o++ = ':';
+ b += 12;
+ goto inet4;
+ }
if (best == 0 && bestlen == 6) {
*o++ = ':';
*o++ = ':';
diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c
index ac800be0a5..737c60775f 100644
--- a/lib/ptm_lib.c
+++ b/lib/ptm_lib.c
@@ -308,22 +308,18 @@ static int _ptm_lib_read_ptm_socket(int fd, char *buf, int len)
while (bytes_read != len) {
rc = recv(fd, (void *)(buf + bytes_read), (len - bytes_read),
MSG_DONTWAIT);
- if (rc <= 0) {
- if (errno && (errno != EAGAIN)
- && (errno != EWOULDBLOCK)) {
- ERRLOG("fatal recv error(%s), closing connection, rc %d\n",
- strerror(errno), rc);
- return (rc);
- } else {
- if (retries++ < 2) {
- usleep(10000);
- continue;
- }
- DLOG("max retries - recv error(%d - %s) bytes read %d (%d)\n",
- errno, strerror(errno), bytes_read, len);
- return (bytes_read);
+ if (rc < 0 && (errno != EAGAIN) && (errno != EWOULDBLOCK)) {
+ ERRLOG("fatal recv error(%s), closing connection, rc %d\n", strerror(errno),
+ rc);
+ return (rc);
+ } else if (rc <= 0) {
+ if (retries++ < 2) {
+ usleep(10000);
+ continue;
}
- break;
+ DLOG("max retries - recv error(%d - %s) bytes read %d (%d)\n", errno,
+ strerror(errno), bytes_read, len);
+ return (bytes_read);
} else {
bytes_read += rc;
}
diff --git a/lib/routemap.h b/lib/routemap.h
index dfb84ced5b..ef9b3cb160 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -278,6 +278,7 @@ DECLARE_QOBJ_TYPE(route_map);
#define IS_MATCH_SRC_VRF(C) \
(strmatch(C, "frr-bgp-route-map:source-vrf"))
#define IS_MATCH_PEER(C) (strmatch(C, "frr-bgp-route-map:peer"))
+#define IS_MATCH_SRC_PEER(C) (strmatch(C, "frr-bgp-route-map:src-peer"))
#define IS_MATCH_AS_LIST(C) \
(strmatch(C, "frr-bgp-route-map:as-path-list"))
#define IS_MATCH_MAC_LIST(C) \
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c
index f64c3c2376..69b942064b 100644
--- a/lib/routemap_cli.c
+++ b/lib/routemap_cli.c
@@ -756,6 +756,18 @@ void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
acl = "local";
vty_out(vty, " match peer %s\n", acl);
+ } else if (IS_MATCH_SRC_PEER(condition)) {
+ acl = NULL;
+ ln = yang_dnode_get(dnode,
+ "./rmap-match-condition/frr-bgp-route-map:src-peer-ipv4-address");
+ if (!ln)
+ ln = yang_dnode_get(dnode,
+ "./rmap-match-condition/frr-bgp-route-map:src-peer-ipv6-address");
+ if (!ln)
+ ln = yang_dnode_get(dnode,
+ "./rmap-match-condition/frr-bgp-route-map:src-peer-interface");
+ acl = yang_dnode_get_string(ln, NULL);
+ vty_out(vty, " match src-peer %s\n", acl);
} else if (IS_MATCH_AS_LIST(condition)) {
vty_out(vty, " match as-path %s\n",
yang_dnode_get_string(
@@ -922,13 +934,15 @@ DEFPY_YANG(
DEFPY_YANG(
set_metric, set_metric_cmd,
- "set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt>",
+ "set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt|igp$igp|aigp$aigp>",
SET_STR
"Metric value for destination routing protocol\n"
"Metric value (use +/- for additions or subtractions)\n"
"Assign round trip time\n"
"Add round trip time\n"
- "Subtract round trip time\n")
+ "Subtract round trip time\n"
+ "Metric value from IGP protocol\n"
+ "Metric value from AIGP (Accumulated IGP)\n")
{
const char *xpath = "./set-action[action='frr-route-map:set-metric']";
char xpath_value[XPATH_MAXLEN];
@@ -939,6 +953,12 @@ DEFPY_YANG(
snprintf(xpath_value, sizeof(xpath_value),
"%s/rmap-set-action/use-round-trip-time", xpath);
snprintf(value, sizeof(value), "true");
+ } else if (igp) {
+ snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-igp", xpath);
+ snprintf(value, sizeof(value), "true");
+ } else if (aigp) {
+ snprintf(xpath_value, sizeof(xpath_value), "%s/rmap-set-action/use-aigp", xpath);
+ snprintf(value, sizeof(value), "true");
} else if (artt) {
snprintf(xpath_value, sizeof(xpath_value),
"%s/rmap-set-action/add-round-trip-time", xpath);
@@ -1148,23 +1168,19 @@ void route_map_action_show(struct vty *vty, const struct lyd_node *dnode,
if (yang_dnode_get(dnode,
"./rmap-set-action/use-round-trip-time")) {
vty_out(vty, " set metric rtt\n");
- } else if (yang_dnode_get(
- dnode,
- "./rmap-set-action/add-round-trip-time")) {
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/use-igp")) {
+ vty_out(vty, " set metric igp\n");
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/use-aigp")) {
+ vty_out(vty, " set metric aigp\n");
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/add-round-trip-time")) {
vty_out(vty, " set metric +rtt\n");
- } else if (
- yang_dnode_get(
- dnode,
- "./rmap-set-action/subtract-round-trip-time")) {
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-round-trip-time")) {
vty_out(vty, " set metric -rtt\n");
- } else if (yang_dnode_get(dnode,
- "./rmap-set-action/add-metric")) {
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/add-metric")) {
vty_out(vty, " set metric +%s\n",
yang_dnode_get_string(
dnode, "./rmap-set-action/add-metric"));
- } else if (yang_dnode_get(
- dnode,
- "./rmap-set-action/subtract-metric")) {
+ } else if (yang_dnode_get(dnode, "./rmap-set-action/subtract-metric")) {
vty_out(vty, " set metric -%s\n",
yang_dnode_get_string(
dnode,
diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c
index 1bba4dad47..0ee055e653 100644
--- a/lib/routemap_northbound.c
+++ b/lib/routemap_northbound.c
@@ -1214,6 +1214,34 @@ static int lib_route_map_entry_set_action_use_round_trip_time_destroy(
}
/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/use-igp
+ */
+static int lib_route_map_entry_set_action_use_igp_modify(struct nb_cb_modify_args *args)
+{
+ return set_action_modify(args->event, args->dnode, args->resource, "igp", args->errmsg,
+ args->errmsg_len);
+}
+
+static int lib_route_map_entry_set_action_use_igp_destroy(struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_action_value_destroy(args);
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/use-aigp
+ */
+static int lib_route_map_entry_set_action_use_aigp_modify(struct nb_cb_modify_args *args)
+{
+ return set_action_modify(args->event, args->dnode, args->resource, "aigp", args->errmsg,
+ args->errmsg_len);
+}
+
+static int lib_route_map_entry_set_action_use_aigp_destroy(struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_action_value_destroy(args);
+}
+
+/*
* XPath: /frr-route-map:lib/route-map/entry/set-action/add-round-trip-time
*/
static int lib_route_map_entry_set_action_add_round_trip_time_modify(
@@ -1517,6 +1545,20 @@ const struct frr_yang_module_info frr_route_map_info = {
}
},
{
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-igp",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_use_igp_modify,
+ .destroy = lib_route_map_entry_set_action_use_igp_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-aigp",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_use_aigp_modify,
+ .destroy = lib_route_map_entry_set_action_use_aigp_destroy,
+ }
+ },
+ {
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
.cbs = {
.modify = lib_route_map_entry_set_action_add_round_trip_time_modify,
diff --git a/lib/zclient.c b/lib/zclient.c
index 0e832f0d8f..557d9c3eb9 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2374,7 +2374,7 @@ static bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
STREAM_GETW(s, nhr->instance);
STREAM_GETC(s, nhr->distance);
STREAM_GETL(s, nhr->metric);
- STREAM_GETC(s, nhr->nexthop_num);
+ STREAM_GETW(s, nhr->nexthop_num);
for (i = 0; i < nhr->nexthop_num; i++) {
if (zapi_nexthop_decode(s, &(nhr->nexthops[i]), 0, 0) != 0)
diff --git a/lib/zclient.h b/lib/zclient.h
index 91c0c9ed6d..6da9558aa5 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -251,21 +251,16 @@ enum zebra_error_types {
static inline const char *zebra_error_type2str(enum zebra_error_types type)
{
- const char *ret = "UNKNOWN";
-
switch (type) {
case ZEBRA_UNKNOWN_ERROR:
- ret = "ZEBRA_UNKNOWN_ERROR";
- break;
+ return "ZEBRA_UNKNOWN_ERROR";
case ZEBRA_NO_VRF:
- ret = "ZEBRA_NO_VRF";
- break;
+ return "ZEBRA_NO_VRF";
case ZEBRA_INVALID_MSG_TYPE:
- ret = "ZEBRA_INVALID_MSG_TYPE";
- break;
+ return "ZEBRA_INVALID_MSG_TYPE";
}
- return ret;
+ return "UNKNOWN";
}
struct redist_proto {
@@ -780,69 +775,51 @@ enum zclient_send_status {
static inline const char *
zapi_nhg_notify_owner2str(enum zapi_nhg_notify_owner note)
{
- const char *ret = "UNKNOWN";
-
switch (note) {
case ZAPI_NHG_FAIL_INSTALL:
- ret = "ZAPI_NHG_FAIL_INSTALL";
- break;
+ return "ZAPI_NHG_FAIL_INSTALL";
case ZAPI_NHG_INSTALLED:
- ret = "ZAPI_NHG_INSTALLED";
- break;
+ return "ZAPI_NHG_INSTALLED";
case ZAPI_NHG_REMOVE_FAIL:
- ret = "ZAPI_NHG_REMOVE_FAIL";
- break;
+ return "ZAPI_NHG_REMOVE_FAIL";
case ZAPI_NHG_REMOVED:
- ret = "ZAPI_NHG_REMOVED";
- break;
+ return "ZAPI_NHG_REMOVED";
}
- return ret;
+ return "UNKNOWN";
}
static inline const char *
zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note)
{
- const char *ret = "UNKNOWN";
-
switch (note) {
case ZAPI_RULE_FAIL_INSTALL:
- ret = "ZAPI_RULE_FAIL_INSTALL";
- break;
+ return "ZAPI_RULE_FAIL_INSTALL";
case ZAPI_RULE_INSTALLED:
- ret = "ZAPI_RULE_INSTALLED";
- break;
+ return "ZAPI_RULE_INSTALLED";
case ZAPI_RULE_FAIL_REMOVE:
- ret = "ZAPI_RULE_FAIL_REMOVE";
- break;
+ return "ZAPI_RULE_FAIL_REMOVE";
case ZAPI_RULE_REMOVED:
- ret = "ZAPI_RULE_REMOVED";
- break;
+ return "ZAPI_RULE_REMOVED";
}
- return ret;
+ return "UNKNOWN";
}
static inline const char *zapi_srv6_sid_notify2str(enum zapi_srv6_sid_notify note)
{
- const char *ret = "UNKNOWN";
-
switch (note) {
case ZAPI_SRV6_SID_FAIL_ALLOC:
- ret = "ZAPI_SRV6_SID_FAIL_ALLOC";
- break;
+ return "ZAPI_SRV6_SID_FAIL_ALLOC";
case ZAPI_SRV6_SID_ALLOCATED:
- ret = "ZAPI_SRV6_SID_ALLOCATED";
- break;
+ return "ZAPI_SRV6_SID_ALLOCATED";
case ZAPI_SRV6_SID_FAIL_RELEASE:
- ret = "ZAPI_SRV6_SID_FAIL_RELEASE";
- break;
+ return "ZAPI_SRV6_SID_FAIL_RELEASE";
case ZAPI_SRV6_SID_RELEASED:
- ret = "ZAPI_SRV6_SID_RELEASED";
- break;
+ return "ZAPI_SRV6_SID_RELEASED";
}
- return ret;
+ return "UNKNOWN";
}
/* Zebra MAC types */
diff --git a/lib/zlog_5424_cli.c b/lib/zlog_5424_cli.c
index 3003df542f..f97c426463 100644
--- a/lib/zlog_5424_cli.c
+++ b/lib/zlog_5424_cli.c
@@ -674,6 +674,7 @@ static int log_5424_config_write(struct vty *vty)
vty_out(vty, "log extended %s\n", cfg->name);
+ (void)fmt_str; /* clang-SA */
switch (cfg->cfg.fmt) {
case ZLOG_FMT_5424:
fmt_str = " format rfc5424";