summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_btoa.c38
-rw-r--r--bgpd/bgp_rd.c1
-rw-r--r--bgpd/bgp_routemap.c11
-rw-r--r--bgpd/bgp_vty.c1
-rw-r--r--doc/user/pbr.rst27
-rw-r--r--doc/user/pim.rst10
-rw-r--r--isisd/isis_lsp.c17
-rw-r--r--ldpd/ldpd.c30
-rw-r--r--lib/frrstr.c8
-rw-r--r--lib/frrstr.h11
-rw-r--r--lib/pbr.h6
-rw-r--r--lib/prefix.c11
-rw-r--r--lib/prefix.h1
-rw-r--r--lib/routemap.c6
-rw-r--r--lib/routemap.h5
-rw-r--r--ospfd/ospf_ri.c11
-rw-r--r--ospfd/ospf_routemap.c1
-rw-r--r--pbrd/pbr_nht.c38
-rw-r--r--pbrd/pbr_nht.h8
-rw-r--r--pbrd/pbr_vty.c58
-rw-r--r--pimd/pim_routemap.c16
-rw-r--r--zebra/zebra_netns_notify.c5
-rw-r--r--zebra/zebra_rib.c10
-rw-r--r--zebra/zebra_routemap.c27
24 files changed, 231 insertions, 126 deletions
diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c
index bf2607f2e7..cc37e352ef 100644
--- a/bgpd/bgp_btoa.c
+++ b/bgpd/bgp_btoa.c
@@ -122,7 +122,7 @@ static int attr_parse(struct stream *s, uint16_t len)
int main(int argc, char **argv)
{
int ret;
- FILE *fp;
+ int fd;
struct stream *s;
time_t now;
int type;
@@ -143,8 +143,8 @@ int main(int argc, char **argv)
fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
exit(1);
}
- fp = fopen(argv[1], "r");
- if (!fp) {
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
fprintf(stdout,
"%% Can't open configuration file %s due to '%s'.\n",
argv[1], safe_strerror(errno));
@@ -154,13 +154,14 @@ int main(int argc, char **argv)
while (1) {
stream_reset(s);
- ret = fread(s->data, 12, 1, fp);
- if (!ret || feof(fp)) {
- printf("END OF FILE\n");
- break;
- }
- if (ferror(fp)) {
- printf("ERROR OF FREAD\n");
+ ret = stream_read(s, fd, 12);
+ if (ret != 12) {
+ if (!ret)
+ printf("END OF FILE\n");
+ else if (ret < 0)
+ printf("ERROR OF READ\n");
+ else
+ printf("UNDERFLOW\n");
break;
}
@@ -217,13 +218,14 @@ int main(int argc, char **argv)
printf("len: %zd\n", len);
- fread(s->data + 12, len, 1, fp);
- if (feof(fp)) {
- printf("ENDOF FILE 2\n");
- break;
- }
- if (ferror(fp)) {
- printf("ERROR OF FREAD 2\n");
+ ret = stream_read(s, fd, len);
+ if (ret != (int)len) {
+ if (!ret)
+ printf("END OF FILE 2\n");
+ else if (ret < 0)
+ printf("ERROR OF READ 2\n");
+ else
+ printf("UNDERFLOW 2\n");
break;
}
@@ -284,6 +286,6 @@ int main(int argc, char **argv)
printf("\n");
}
}
- fclose(fp);
+ close(fd);
return 0;
}
diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c
index 356a949d69..77f5aade5f 100644
--- a/bgpd/bgp_rd.c
+++ b/bgpd/bgp_rd.c
@@ -27,6 +27,7 @@
#include "memory.h"
#include "stream.h"
#include "filter.h"
+#include "frrstr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_rd.h"
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index cbacd6b4f2..f7c79f873d 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -37,6 +37,7 @@
#include "sockunion.h"
#include "hash.h"
#include "queue.h"
+#include "frrstr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
@@ -3112,7 +3113,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
}
}
-static int bgp_route_map_process_update_cb(char *rmap_name)
+static void bgp_route_map_process_update_cb(char *rmap_name)
{
struct listnode *node, *nnode;
struct bgp *bgp;
@@ -3127,8 +3128,6 @@ static int bgp_route_map_process_update_cb(char *rmap_name)
}
vpn_policy_routemap_event(rmap_name);
-
- return 0;
}
int bgp_route_map_update_timer(struct thread *thread)
@@ -3172,7 +3171,7 @@ static void bgp_route_map_mark_update(const char *rmap_name)
static void bgp_route_map_add(const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 0) == 0)
+ if (route_map_mark_updated(rmap_name) == 0)
bgp_route_map_mark_update(rmap_name);
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
@@ -3180,7 +3179,7 @@ static void bgp_route_map_add(const char *rmap_name)
static void bgp_route_map_delete(const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 1) == 0)
+ if (route_map_mark_updated(rmap_name) == 0)
bgp_route_map_mark_update(rmap_name);
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
@@ -3188,7 +3187,7 @@ static void bgp_route_map_delete(const char *rmap_name)
static void bgp_route_map_event(route_map_event_t event, const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 0) == 0)
+ if (route_map_mark_updated(rmap_name) == 0)
bgp_route_map_mark_update(rmap_name);
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index f0fc3a89e9..4e0f7155ba 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -34,6 +34,7 @@
#include "hash.h"
#include "queue.h"
#include "filter.h"
+#include "frrstr.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_advertise.h"
diff --git a/doc/user/pbr.rst b/doc/user/pbr.rst
index aa48a3cd4f..638767c557 100644
--- a/doc/user/pbr.rst
+++ b/doc/user/pbr.rst
@@ -33,7 +33,6 @@ Nexthop Groups
Nexthop groups are a way to encapsulate ECMP information together. It's a
listing of ECMP nexthops used to forward packets for when a pbr-map is matched.
-.. index:: nexthop-group
.. clicmd:: nexthop-group NAME
Create a nexthop-group with an associated NAME. This will put you into a
@@ -46,24 +45,38 @@ listing of ECMP nexthops used to forward packets for when a pbr-map is matched.
are used to are allowed here. The syntax was intentionally kept the same as
creating nexthops as you would for static routes.
+.. clicmd:: [no] pbr table range (10000-4294966272) (10000-4294966272)
+
+ Set or unset the range used to assign numeric table ID's to new
+ nexthop-group tables. Existing tables will not be modified to fit in this
+ range, so it is recommended to configure this before adding nexthop groups.
+
+ .. seealso:: :ref:`pbr-details`
+
+Showing Nexthop Group Information
+---------------------------------
+
+.. clicmd:: show pbr nexthop-groups [NAME]
+
+ Display information on a PBR nexthop-group. If ``NAME`` is omitted, all
+ nexthop groups are shown.
+
.. _pbr-maps:
PBR Maps
========
-PBR maps are a way to group policies that we would like to apply
-to individual interfaces. These policies when applied are matched
-against incoming packets. If matched the nexthop-group or nexthop
-is used to forward the packets to the end destination
+PBR maps are a way to group policies that we would like to apply to individual
+interfaces. These policies when applied are matched against incoming packets.
+If matched the nexthop-group or nexthop is used to forward the packets to the
+end destination.
-.. index:: pbr-map
.. clicmd:: pbr-map NAME seq (1-700)
Create a pbr-map with NAME and sequence number specified. This command puts
you into a new submode for pbr-map specification. To exit this mode type
exit or end as per normal conventions for leaving a sub-mode.
-.. index:: match
.. clicmd:: match src-ip PREFIX
When a incoming packet matches the source prefix specified, take the packet
diff --git a/doc/user/pim.rst b/doc/user/pim.rst
index 04bda5f236..feb77db1e1 100644
--- a/doc/user/pim.rst
+++ b/doc/user/pim.rst
@@ -189,8 +189,8 @@ is in a vrf, enter the interface command with the vrf keyword at the end.
Tell pim to receive IGMP reports and Query on this interface. The default
version is v3. This command is useful on the LHR.
-.. index:: ip igmp join
-.. clicmd:: ip igmp join
+.. index:: ip igmp join A.B.C.D A.B.C.D
+.. clicmd:: ip igmp join A.B.C.D A.B.C.D
Join multicast source-group on an interface.
@@ -404,10 +404,10 @@ cause great confusion.
Display the multicast RIB created in zebra.
-.. index:: mtrace
-.. clicmd:: mtrace
+.. index:: mtrace A.B.C.D [A.B.C.D]
+.. clicmd:: mtrace A.B.C.D [A.B.C.D]
- Display multicast traceroute towards source.
+ Display multicast traceroute towards source, optionally for particular group.
PIM Debug Commands
==================
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 95fa38223e..bba86d4c1f 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -55,9 +55,6 @@
#include "isisd/isis_mt.h"
#include "isisd/isis_tlvs.h"
-/* staticly assigned vars for printing purposes */
-char lsp_bits_string[200]; /* FIXME: enough ? */
-
static int lsp_l1_refresh(struct thread *thread);
static int lsp_l2_refresh(struct thread *thread);
static int lsp_l1_refresh_pseudo(struct thread *thread);
@@ -608,13 +605,16 @@ static void lspid_print(uint8_t *lsp_id, uint8_t *trg, char dynhost, char frag)
}
/* Convert the lsp attribute bits to attribute string */
-static const char *lsp_bits2string(uint8_t lsp_bits)
+static const char *lsp_bits2string(uint8_t lsp_bits, char *buf, size_t buf_size)
{
- char *pos = lsp_bits_string;
+ char *pos = buf;
if (!lsp_bits)
return " none";
+ if (buf_size < 2 * 3)
+ return " error";
+
/* we only focus on the default metric */
pos += sprintf(pos, "%d/",
ISIS_MASK_LSP_ATT_DEFAULT_BIT(lsp_bits) ? 1 : 0);
@@ -624,9 +624,7 @@ static const char *lsp_bits2string(uint8_t lsp_bits)
pos += sprintf(pos, "%d", ISIS_MASK_LSP_OL_BIT(lsp_bits) ? 1 : 0);
- *(pos) = '\0';
-
- return lsp_bits_string;
+ return buf;
}
/* this function prints the lsp on show isis database */
@@ -634,6 +632,7 @@ void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost)
{
uint8_t LSPid[255];
char age_out[8];
+ char b[200];
lspid_print(lsp->hdr.lsp_id, LSPid, dynhost, 1);
vty_out(vty, "%-21s%c ", LSPid, lsp->own_lsp ? '*' : ' ');
@@ -646,7 +645,7 @@ void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost)
vty_out(vty, "%7s ", age_out);
} else
vty_out(vty, " %5" PRIu16 " ", lsp->hdr.rem_lifetime);
- vty_out(vty, "%s\n", lsp_bits2string(lsp->hdr.lsp_bits));
+ vty_out(vty, "%s\n", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b)));
}
void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost)
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 255febeb60..b265c98dae 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -406,16 +406,32 @@ ldpd_shutdown(void)
free(vty_conf);
log_debug("waiting for children to terminate");
- do {
+
+ while (true) {
+ /* Wait for child process. */
pid = wait(&status);
if (pid == -1) {
- if (errno != EINTR && errno != ECHILD)
- fatal("wait");
- } else if (WIFSIGNALED(status))
+ /* We got interrupted, try again. */
+ if (errno == EINTR)
+ continue;
+ /* No more processes were found. */
+ if (errno != ECHILD)
+ break;
+
+ /* Unhandled errno condition. */
+ fatal("wait");
+ /* UNREACHABLE */
+ }
+
+ /* We found something, lets announce it. */
+ if (WIFSIGNALED(status))
log_warnx("%s terminated; signal %d",
- (pid == lde_pid) ? "label decision engine" :
- "ldp engine", WTERMSIG(status));
- } while (pid != -1 || (pid == -1 && errno == EINTR));
+ (pid == lde_pid ? "label decision engine"
+ : "ldp engine"),
+ WTERMSIG(status));
+
+ /* Repeat until there are no more child processes. */
+ }
free(iev_ldpe);
free(iev_lde);
diff --git a/lib/frrstr.c b/lib/frrstr.c
index 82c0ad7730..715e67b868 100644
--- a/lib/frrstr.c
+++ b/lib/frrstr.c
@@ -161,3 +161,11 @@ bool begins_with(const char *str, const char *prefix)
return strncmp(str, prefix, lenprefix) == 0;
}
+
+int all_digit(const char *str)
+{
+ for (; *str != '\0'; str++)
+ if (!isdigit((int)*str))
+ return 0;
+ return 1;
+}
diff --git a/lib/frrstr.h b/lib/frrstr.h
index 2454771122..891a3f337c 100644
--- a/lib/frrstr.h
+++ b/lib/frrstr.h
@@ -97,4 +97,15 @@ void frrstr_strvec_free(vector v);
*/
bool begins_with(const char *str, const char *prefix);
+/*
+ * Check the string only contains digit characters.
+ *
+ * str
+ * string to check for digits
+ *
+ * Returns:
+ * 1 str only contains digit characters, 0 otherwise
+ */
+int all_digit(const char *str);
+
#endif /* _FRRSTR_H_ */
diff --git a/lib/pbr.h b/lib/pbr.h
index 401cfb0813..1704d8d37e 100644
--- a/lib/pbr.h
+++ b/lib/pbr.h
@@ -20,6 +20,12 @@
#ifndef _PBR_H
#define _PBR_H
+#include <zebra.h>
+#include "stream.h"
+#include "prefix.h"
+
+#define PBR_STR "Policy Based Routing\n"
+
/*
* A PBR filter
*
diff --git a/lib/prefix.c b/lib/prefix.c
index b129665e7b..751f20cb83 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1373,17 +1373,6 @@ void prefix_free(struct prefix *p)
XFREE(MTYPE_PREFIX, p);
}
-/* Utility function. Check the string only contains digit
- * character.
- * FIXME str.[c|h] would be better place for this function. */
-int all_digit(const char *str)
-{
- for (; *str != '\0'; str++)
- if (!isdigit((int)*str))
- return 0;
- return 1;
-}
-
/* Utility function to convert ipv4 prefixes to Classful prefixes */
void apply_classful_mask_ipv4(struct prefix_ipv4 *p)
{
diff --git a/lib/prefix.h b/lib/prefix.h
index f5dbb22f79..4247569137 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -458,7 +458,6 @@ static inline int ipv6_martian(struct in6_addr *addr)
return 0;
}
-extern int all_digit(const char *);
extern int macstr2prefix_evpn(const char *str, struct prefix_evpn *p);
/* NOTE: This routine expects the address argument in network byte order. */
diff --git a/lib/routemap.c b/lib/routemap.c
index 892b19dac5..056c793454 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -751,7 +751,7 @@ struct route_map *route_map_lookup_by_name(const char *name)
return map;
}
-int route_map_mark_updated(const char *name, int del_later)
+int route_map_mark_updated(const char *name)
{
struct route_map *map;
int ret = -1;
@@ -781,7 +781,7 @@ int route_map_mark_updated(const char *name, int del_later)
return (ret);
}
-int route_map_clear_updated(struct route_map *map)
+static int route_map_clear_updated(struct route_map *map)
{
int ret = -1;
@@ -807,7 +807,7 @@ static struct route_map *route_map_get(const char *name)
return map;
}
-void route_map_walk_update_list(int (*route_map_update_fn)(char *name))
+void route_map_walk_update_list(void (*route_map_update_fn)(char *name))
{
struct route_map *node;
struct route_map *nnode = NULL;
diff --git a/lib/routemap.h b/lib/routemap.h
index 990c7fa72f..0aeba7e1f6 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -215,9 +215,8 @@ extern route_map_result_t route_map_apply(struct route_map *map,
extern void route_map_add_hook(void (*func)(const char *));
extern void route_map_delete_hook(void (*func)(const char *));
extern void route_map_event_hook(void (*func)(route_map_event_t, const char *));
-extern int route_map_mark_updated(const char *name, int deleted);
-extern int route_map_clear_updated(struct route_map *rmap);
-extern void route_map_walk_update_list(int (*update_fn)(char *name));
+extern int route_map_mark_updated(const char *name);
+extern void route_map_walk_update_list(void (*update_fn)(char *name));
extern void route_map_upd8_dependency(route_map_event_t type, const char *arg,
const char *rmap_name);
extern void route_map_notify_dependencies(const char *affected_name,
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index 786b199029..93267156f2 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -516,12 +516,13 @@ static void unset_sr_node_msd(void)
TLV_LEN(OspfRI.sr_info.msd) = htons(0);
}
-static void unset_param(struct tlv_header *tlv)
+static void unset_param(void *tlv_buffer)
{
+ struct tlv_header *tlv = (struct tlv_header *)tlv_buffer;
tlv->type = 0;
/* Fill the Value to 0 */
- memset(TLV_DATA(tlv), 0, TLV_BODY_SIZE(tlv));
+ memset(TLV_DATA(tlv_buffer), 0, TLV_BODY_SIZE(tlv));
tlv->length = 0;
return;
@@ -1571,7 +1572,7 @@ DEFUN (no_pce_address,
"PCE address in IPv4 address format\n")
{
- unset_param(&OspfRI.pce_info.pce_address.header);
+ unset_param(&OspfRI.pce_info.pce_address);
/* Refresh RI LSA if already engaged */
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
@@ -1621,7 +1622,7 @@ DEFUN (no_pce_path_scope,
"32-bit Hexadecimal value\n")
{
- unset_param(&OspfRI.pce_info.pce_address.header);
+ unset_param(&OspfRI.pce_info.pce_address);
/* Refresh RI LSA if already engaged */
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
@@ -1810,7 +1811,7 @@ DEFUN (no_pce_cap_flag,
"Disable PCE capabilities\n")
{
- unset_param(&OspfRI.pce_info.pce_cap_flag.header);
+ unset_param(&OspfRI.pce_info.pce_cap_flag);
/* Refresh RI LSA if already engaged */
if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED))
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index ca711aa42f..f3271acfa2 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -32,6 +32,7 @@
#include "log.h"
#include "plist.h"
#include "vrf.h"
+#include "frrstr.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_asbr.h"
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index a4a9233f72..a8cefce84f 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -192,7 +192,7 @@ static void *pbr_nhgc_alloc(void *p)
new = XCALLOC(MTYPE_PBR_NHG, sizeof(*new));
strcpy(new->name, pnhgc->name);
- new->table_id = pbr_nht_get_next_tableid();
+ new->table_id = pbr_nht_get_next_tableid(false);
DEBUGD(&pbr_dbg_nht, "%s: NHT: %s assigned Table ID: %u",
__PRETTY_FUNCTION__, new->name, new->table_id);
@@ -218,6 +218,9 @@ void pbr_nhgroup_add_cb(const char *name)
pnhgc = pbr_nht_add_group(name);
+ if (!pnhgc)
+ return;
+
DEBUGD(&pbr_dbg_nht, "%s: Added nexthop-group %s", __PRETTY_FUNCTION__,
name);
@@ -234,6 +237,13 @@ void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,
struct pbr_nexthop_cache pnhc_find = {};
struct pbr_nexthop_cache *pnhc;
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, nhgc->name);
+ return;
+ }
+
/* find pnhgc by name */
strlcpy(pnhgc_find.name, nhgc->name, sizeof(pnhgc_find.name));
pnhgc = hash_get(pbr_nhg_hash, &pnhgc_find, pbr_nhgc_alloc);
@@ -268,7 +278,7 @@ void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc,
/* find pnhgc by name */
strlcpy(pnhgc_find.name, nhgc->name, sizeof(pnhgc_find.name));
- pnhgc = hash_get(pbr_nhg_hash, &pnhgc_find, pbr_nhgc_alloc);
+ pnhgc = hash_lookup(pbr_nhg_hash, &pnhgc_find);
/* delete pnhc from pnhgc->nhh */
pnhc_find.nexthop = (struct nexthop *)nhop;
@@ -487,6 +497,14 @@ void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms)
memset(&find, 0, sizeof(find));
pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_NHC_NAMELEN,
pbrms->seqno, find.name);
+
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, find.name);
+ return;
+ }
+
if (!pbrms->internal_nhg_name)
pbrms->internal_nhg_name = XSTRDUP(MTYPE_TMP, find.name);
@@ -547,11 +565,18 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name)
struct pbr_nexthop_group_cache *pnhgc;
struct pbr_nexthop_group_cache lookup;
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, name);
+ return NULL;
+ }
+
nhgc = nhgc_find(name);
if (!nhgc) {
- zlog_warn("%s: Could not find group %s to add",
- __PRETTY_FUNCTION__, name);
+ DEBUGD(&pbr_dbg_nht, "%s: Could not find nhgc with name: %s\n",
+ __PRETTY_FUNCTION__, name);
return NULL;
}
@@ -709,8 +734,7 @@ static int pbr_nhg_hash_equal(const void *arg1, const void *arg2)
return !strcmp(nhgc1->name, nhgc2->name);
}
-
-uint32_t pbr_nht_get_next_tableid(void)
+uint32_t pbr_nht_get_next_tableid(bool peek)
{
uint32_t i;
bool found = false;
@@ -723,7 +747,7 @@ uint32_t pbr_nht_get_next_tableid(void)
}
if (found) {
- nhg_tableid[i] = true;
+ nhg_tableid[i] = !peek;
return i;
} else
return 0;
diff --git a/pbrd/pbr_nht.h b/pbrd/pbr_nht.h
index e6fdbfd04c..d37803fbe3 100644
--- a/pbrd/pbr_nht.h
+++ b/pbrd/pbr_nht.h
@@ -56,9 +56,13 @@ extern void pbr_nht_write_table_range(struct vty *vty);
extern void pbr_nht_set_tableid_range(uint32_t low, uint32_t high);
/*
- * Get the next tableid to use for installation
+ * Get the next tableid to use for installation.
+ *
+ * peek
+ * If set to true, retrieves the next ID without marking it used. The next
+ * call will return the same ID.
*/
-extern uint32_t pbr_nht_get_next_tableid(void);
+extern uint32_t pbr_nht_get_next_tableid(bool peek);
/*
* Get the next rule number to use for installation
*/
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index 7e0e8d632b..44e14c5477 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -26,8 +26,8 @@
#include "nexthop.h"
#include "nexthop_group.h"
#include "log.h"
-#include "json.h"
#include "debug.h"
+#include "pbr.h"
#include "pbrd/pbr_nht.h"
#include "pbrd/pbr_map.h"
@@ -85,6 +85,34 @@ DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]",
return CMD_SUCCESS;
}
+DEFPY(pbr_set_table_range,
+ pbr_set_table_range_cmd,
+ "[no] pbr table range (10000-4294966272)$lb (10000-4294966272)$ub",
+ NO_STR
+ PBR_STR
+ "Set table ID range\n"
+ "Set table ID range\n"
+ "Lower bound for table ID range\n"
+ "Upper bound for table ID range\n")
+{
+ /* upper bound is 2^32 - 2^10 */
+ int ret = CMD_WARNING;
+ const int minrange = 1000;
+
+ /* validate given bounds */
+ if (lb > ub)
+ vty_out(vty, "%% Lower bound must be less than upper bound\n");
+ else if (ub - lb < minrange)
+ vty_out(vty, "%% Range breadth must be at least %d\n", minrange);
+ else {
+ ret = CMD_SUCCESS;
+ pbr_nht_set_tableid_range((uint32_t) lb, (uint32_t) ub);
+ }
+
+ return ret;
+}
+
+
DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
"[no] match src-ip <A.B.C.D/M|X:X::X:X/M>$prefix",
NO_STR
@@ -355,10 +383,9 @@ DEFPY (pbr_policy,
DEFPY (show_pbr,
show_pbr_cmd,
- "show pbr [json$json]",
+ "show pbr",
SHOW_STR
- "Policy Based Routing\n"
- JSON_STR)
+ PBR_STR)
{
pbr_nht_write_table_range(vty);
pbr_nht_write_rule_range(vty);
@@ -368,13 +395,12 @@ DEFPY (show_pbr,
DEFPY (show_pbr_map,
show_pbr_map_cmd,
- "show pbr map [NAME$name] [detail$detail] [json$json]",
+ "show pbr map [NAME$name] [detail$detail]",
SHOW_STR
- "Policy Based Routing\n"
+ PBR_STR
"PBR Map\n"
"PBR Map Name\n"
- "Detailed information\n"
- JSON_STR)
+ "Detailed information\n")
{
struct pbr_map_sequence *pbrms;
struct pbr_map *pbrm;
@@ -439,7 +465,7 @@ DEFPY(show_pbr_nexthop_group,
show_pbr_nexthop_group_cmd,
"show pbr nexthop-groups [WORD$word]",
SHOW_STR
- "Policy Based Routing\n"
+ PBR_STR
"Nexthop Groups\n"
"Optional Name of the nexthop group\n")
{
@@ -450,12 +476,11 @@ DEFPY(show_pbr_nexthop_group,
DEFPY (show_pbr_interface,
show_pbr_interface_cmd,
- "show pbr interface [NAME$name] [json$json]",
+ "show pbr interface [NAME$name]",
SHOW_STR
- "Policy Based Routing\n"
+ PBR_STR
"PBR Interface\n"
- "PBR Interface Name\n"
- JSON_STR)
+ "PBR Interface Name\n")
{
struct interface *ifp;
struct vrf *vrf;
@@ -489,7 +514,6 @@ DEFPY (show_pbr_interface,
}
/* PBR debugging CLI ------------------------------------------------------- */
-/* clang-format off */
static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
@@ -498,7 +522,7 @@ DEFPY(debug_pbr,
"[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]",
NO_STR
DEBUG_STR
- "Policy Based Routing\n"
+ PBR_STR
"Policy maps\n"
"PBRD <-> Zebra communications\n"
"Nexthop tracking\n"
@@ -527,7 +551,7 @@ DEFUN_NOSH(show_debugging_pbr,
"show debugging [pbr]",
SHOW_STR
DEBUG_STR
- "Policy Based Routing\n")
+ PBR_STR)
{
vty_out(vty, "PBR debugging status:\n");
@@ -536,7 +560,6 @@ DEFUN_NOSH(show_debugging_pbr,
return CMD_SUCCESS;
}
-/* clang-format on */
/* ------------------------------------------------------------------------- */
@@ -634,6 +657,7 @@ void pbr_vty_init(void)
install_element(CONFIG_NODE, &pbr_map_cmd);
install_element(CONFIG_NODE, &no_pbr_map_cmd);
+ install_element(CONFIG_NODE, &pbr_set_table_range_cmd);
install_element(INTERFACE_NODE, &pbr_policy_cmd);
install_element(PBRMAP_NODE, &pbr_map_match_src_cmd);
install_element(PBRMAP_NODE, &pbr_map_match_dst_cmd);
diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c
index 6d06229b98..b41124376f 100644
--- a/pimd/pim_routemap.c
+++ b/pimd/pim_routemap.c
@@ -26,34 +26,18 @@
#include "pimd.h"
-
-static void pim_route_map_mark_update(const char *rmap_name)
-{
- // placeholder
- return;
-}
-
static void pim_route_map_add(const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 0) == 0)
- pim_route_map_mark_update(rmap_name);
-
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
static void pim_route_map_delete(const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 1) == 0)
- pim_route_map_mark_update(rmap_name);
-
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
}
static void pim_route_map_event(route_map_event_t event, const char *rmap_name)
{
- if (route_map_mark_updated(rmap_name, 0) == 0)
- pim_route_map_mark_update(rmap_name);
-
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c
index 30f850597c..bb6a565211 100644
--- a/zebra/zebra_netns_notify.c
+++ b/zebra/zebra_netns_notify.c
@@ -212,6 +212,11 @@ static int zebra_ns_notify_read(struct thread *t)
continue;
if (event->mask & IN_DELETE)
return zebra_ns_delete(event->name);
+ if (&event->name[event->len] >= &buf[sizeof(buf)]) {
+ zlog_err("NS notify read: buffer underflow");
+ break;
+ }
+ event->name[event->len] = 0;
netnspath = ns_netns_pathname(NULL, event->name);
if (!netnspath)
continue;
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 879e7e8317..bd00823ed8 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2542,12 +2542,10 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
rn, vrf_id,
"via %s ifindex %d type %d "
"doesn't exist in rib",
- inet_ntop(
- family2afi(afi),
- &nh->gate, buf2,
- INET_ADDRSTRLEN), /* FIXME
- */
- nh->ifindex, type);
+ inet_ntop(afi2family(afi),
+ &nh->gate, buf2,
+ sizeof(buf2)),
+ nh->ifindex, type);
else
rnode_debug(
rn, vrf_id,
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 10ba88880a..ce51f54a65 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -31,6 +31,7 @@
#include "plist.h"
#include "nexthop.h"
#include "vrf.h"
+#include "frrstr.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
@@ -1282,6 +1283,13 @@ static struct route_map_rule_cmd route_set_src_cmd = {
"src", route_set_src, route_set_src_compile, route_set_src_free,
};
+static void zebra_route_map_process_update_cb(char *rmap_name)
+{
+ if (IS_ZEBRA_DEBUG_EVENT)
+ zlog_debug("Event handler for route-map: %s",
+ rmap_name);
+}
+
static int zebra_route_map_update_timer(struct thread *thread)
{
zebra_t_rmap_update = NULL;
@@ -1294,6 +1302,13 @@ static int zebra_route_map_update_timer(struct thread *thread)
"%u: Routemap update-timer fired, scheduling RIB processing",
VRF_DEFAULT);
+ route_map_walk_update_list(zebra_route_map_process_update_cb);
+
+ /*
+ * This code needs to be updated to be:
+ * 1) VRF Aware <sigh>
+ * 2) Route-map aware
+ */
zebra_import_table_rm_update();
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
@@ -1433,20 +1448,26 @@ static void zebra_route_map_mark_update(const char *rmap_name)
static void zebra_route_map_add(const char *rmap_name)
{
- zebra_route_map_mark_update(rmap_name);
+ if (route_map_mark_updated(rmap_name) == 0)
+ zebra_route_map_mark_update(rmap_name);
+
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
static void zebra_route_map_delete(const char *rmap_name)
{
- zebra_route_map_mark_update(rmap_name);
+ if (route_map_mark_updated(rmap_name) == 0)
+ zebra_route_map_mark_update(rmap_name);
+
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
}
static void zebra_route_map_event(route_map_event_t event,
const char *rmap_name)
{
- zebra_route_map_mark_update(rmap_name);
+ if (route_map_mark_updated(rmap_name) == 0)
+ zebra_route_map_mark_update(rmap_name);
+
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}