summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/stale.yml20
-rw-r--r--babeld/message.c217
-rw-r--r--babeld/message.h1
-rw-r--r--bgpd/bgp_label.c41
-rw-r--r--bgpd/bgp_label.h19
-rw-r--r--bgpd/bgp_route.c23
-rw-r--r--bgpd/bgp_zebra.c9
-rw-r--r--bgpd/bgpd.h2
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog4
-rw-r--r--lib/northbound_sysrepo.c14
-rw-r--r--lib/workqueue.c21
-rw-r--r--lib/workqueue.h7
-rw-r--r--ospfd/ospf_zebra.c2
-rw-r--r--ospfd/ospfd.h112
-rw-r--r--pimd/pim6_cmd.c247
-rw-r--r--pimd/pim_cmd.c265
-rw-r--r--pimd/pim_cmd_common.c298
-rw-r--r--pimd/pim_cmd_common.h17
-rw-r--r--pimd/pim_oil.c22
-rw-r--r--pimd/pim_oil.h7
-rw-r--r--redhat/frr.spec.in6
-rw-r--r--tests/topotests/lib/common_config.py14
-rwxr-xr-xtests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_static_routes_topo1.py14
24 files changed, 665 insertions, 719 deletions
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 0000000000..df9f5ce5b3
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,20 @@
+name: Mark stale issues
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: "30 1 * * *"
+
+jobs:
+ stale:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/stale@v5
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Comment or remove the `autoclose` label in order to avoid having this issue closed.'
+ stale-issue-label: autoclose
+ days-before-stale: 180
+ days-before-close: -1
+ days-before-pr-stale: -1
+ days-before-pr-close: -1
diff --git a/babeld/message.c b/babeld/message.c
index 0ddfda8d7b..c2ea2a2683 100644
--- a/babeld/message.c
+++ b/babeld/message.c
@@ -127,9 +127,8 @@ network_prefix(int ae, int plen, unsigned int omitted,
return ret;
}
-static void
-parse_update_subtlv(const unsigned char *a, int alen,
- unsigned char *channels)
+static bool parse_update_subtlv(const unsigned char *a, int alen,
+ unsigned char *channels)
{
int type, len, i = 0;
@@ -142,37 +141,51 @@ parse_update_subtlv(const unsigned char *a, int alen,
if(i + 1 >= alen) {
flog_err(EC_BABEL_PACKET, "Received truncated attributes.");
- return;
- }
+ return false;
+ }
len = a[i + 1];
if(i + len + 2 > alen) {
flog_err(EC_BABEL_PACKET, "Received truncated attributes.");
- return;
- }
+ return false;
+ }
- if(type == SUBTLV_PADN) {
- /* Nothing. */
- } else if(type == SUBTLV_DIVERSITY) {
- if(len > DIVERSITY_HOPS) {
- flog_err(EC_BABEL_PACKET,
- "Received overlong channel information (%d > %d).n",
- len, DIVERSITY_HOPS);
- len = DIVERSITY_HOPS;
- }
- if(memchr(a + i + 2, 0, len) != NULL) {
- /* 0 is reserved. */
- flog_err(EC_BABEL_PACKET, "Channel information contains 0!");
- return;
- }
- memset(channels, 0, DIVERSITY_HOPS);
- memcpy(channels, a + i + 2, len);
- } else {
- debugf(BABEL_DEBUG_COMMON,
- "Received unknown route attribute %d.", type);
- }
+ if (type & SUBTLV_MANDATORY) {
+ /*
+ * RFC 8966 - 4.4
+ * If the mandatory bit is set, then the whole enclosing
+ * TLV MUST be silently ignored (except for updating the
+ * parser state by a Router-Id, Next Hop, or Update TLV,
+ * as described in the next section).
+ */
+ debugf(BABEL_DEBUG_COMMON,
+ "Received Mandatory bit set but this FRR version is not prepared to handle it at this point");
+ return true;
+ } else if (type == SUBTLV_PADN) {
+ /* Nothing. */
+ } else if (type == SUBTLV_DIVERSITY) {
+ if (len > DIVERSITY_HOPS) {
+ flog_err(
+ EC_BABEL_PACKET,
+ "Received overlong channel information (%d > %d).n",
+ len, DIVERSITY_HOPS);
+ len = DIVERSITY_HOPS;
+ }
+ if (memchr(a + i + 2, 0, len) != NULL) {
+ /* 0 is reserved. */
+ flog_err(EC_BABEL_PACKET,
+ "Channel information contains 0!");
+ return false;
+ }
+ memset(channels, 0, DIVERSITY_HOPS);
+ memcpy(channels, a + i + 2, len);
+ } else {
+ debugf(BABEL_DEBUG_COMMON,
+ "Received unknown route attribute %d.", type);
+ }
- i += len + 2;
+ i += len + 2;
}
+ return false;
}
static int
@@ -200,22 +213,34 @@ parse_hello_subtlv(const unsigned char *a, int alen,
return -1;
}
- if(type == SUBTLV_PADN) {
- /* Nothing to do. */
- } else if(type == SUBTLV_TIMESTAMP) {
- if(len >= 4) {
- DO_NTOHL(*hello_send_us, a + i + 2);
- ret = 1;
- } else {
- flog_err(EC_BABEL_PACKET,
- "Received incorrect RTT sub-TLV on Hello message.");
- }
- } else {
- debugf(BABEL_DEBUG_COMMON,
- "Received unknown Hello sub-TLV type %d.", type);
- }
+ if (type & SUBTLV_MANDATORY) {
+ /*
+ * RFC 8966 4.4
+ * If the mandatory bit is set, then the whole enclosing
+ * TLV MUST be silently ignored (except for updating the
+ * parser state by a Router-Id, Next Hop, or Update TLV, as
+ * described in the next section).
+ */
+ debugf(BABEL_DEBUG_COMMON,
+ "Received subtlv with Mandatory bit, this version of FRR is not prepared to handle this currently");
+ return -2;
+ } else if (type == SUBTLV_PADN) {
+ /* Nothing to do. */
+ } else if (type == SUBTLV_TIMESTAMP) {
+ if (len >= 4) {
+ DO_NTOHL(*hello_send_us, a + i + 2);
+ ret = 1;
+ } else {
+ flog_err(
+ EC_BABEL_PACKET,
+ "Received incorrect RTT sub-TLV on Hello message.");
+ }
+ } else {
+ debugf(BABEL_DEBUG_COMMON,
+ "Received unknown Hello sub-TLV type %d.", type);
+ }
- i += len + 2;
+ i += len + 2;
}
return ret;
}
@@ -398,27 +423,69 @@ parse_packet(const unsigned char *from, struct interface *ifp,
format_address(from), ifp->name);
/* Nothing right now */
} else if(type == MESSAGE_HELLO) {
- unsigned short seqno, interval;
- int changed;
- unsigned int timestamp = 0;
- DO_NTOHS(seqno, message + 4);
- DO_NTOHS(interval, message + 6);
- debugf(BABEL_DEBUG_COMMON,"Received hello %d (%d) from %s on %s.",
- seqno, interval,
- format_address(from), ifp->name);
- changed = update_neighbour(neigh, seqno, interval);
- update_neighbour_metric(neigh, changed);
- if(interval > 0)
- /* Multiply by 3/2 to allow hellos to expire. */
- schedule_neighbours_check(interval * 15, 0);
- /* Sub-TLV handling. */
- if(len > 8) {
- if(parse_hello_subtlv(message + 8, len - 6, &timestamp) > 0) {
- neigh->hello_send_us = timestamp;
- neigh->hello_rtt_receive_time = babel_now;
- have_hello_rtt = 1;
- }
- }
+ unsigned short seqno, interval, flags;
+ int changed;
+ unsigned int timestamp = 0;
+
+#define BABEL_UNICAST_HELLO 0x8000
+ DO_NTOHS(flags, message + 2);
+
+ /*
+ * RFC 8966 4.6.5
+ * All other bits MUST be sent as a 0 and silently
+ * ignored on reception
+ */
+ if (CHECK_FLAG(flags, ~BABEL_UNICAST_HELLO)) {
+ debugf(BABEL_DEBUG_COMMON,
+ "Received Hello from %s on %s that does not have all 0's in the unused section of flags, ignoring",
+ format_address(from), ifp->name);
+ continue;
+ }
+
+ /*
+ * RFC 8966 Appendix F
+ * TL;DR -> Please ignore Unicast hellos until FRR's
+ * BABEL is brought up to date
+ */
+ if (CHECK_FLAG(flags, BABEL_UNICAST_HELLO)) {
+ debugf(BABEL_DEBUG_COMMON,
+ "Received Unicast Hello from %s on %s that FRR is not prepared to understand yet",
+ format_address(from), ifp->name);
+ continue;
+ }
+
+ DO_NTOHS(seqno, message + 4);
+ DO_NTOHS(interval, message + 6);
+ debugf(BABEL_DEBUG_COMMON,
+ "Received hello %d (%d) from %s on %s.", seqno, interval,
+ format_address(from), ifp->name);
+
+ /*
+ * RFC 8966 Appendix F
+ * TL;DR -> Please ignore any Hello packets with the interval
+ * field set to 0
+ */
+ if (interval == 0) {
+ debugf(BABEL_DEBUG_COMMON,
+ "Received hello from %s on %s should be ignored as that this version of FRR does not know how to properly handle interval == 0",
+ format_address(from), ifp->name);
+ continue;
+ }
+
+ changed = update_neighbour(neigh, seqno, interval);
+ update_neighbour_metric(neigh, changed);
+ if (interval > 0)
+ /* Multiply by 3/2 to allow hellos to expire. */
+ schedule_neighbours_check(interval * 15, 0);
+ /* Sub-TLV handling. */
+ if (len > 8) {
+ if (parse_hello_subtlv(message + 8, len - 6,
+ &timestamp) > 0) {
+ neigh->hello_send_us = timestamp;
+ neigh->hello_rtt_receive_time = babel_now;
+ have_hello_rtt = 1;
+ }
+ }
} else if(type == MESSAGE_IHU) {
unsigned short txcost, interval;
unsigned char address[16];
@@ -476,7 +543,9 @@ parse_packet(const unsigned char *from, struct interface *ifp,
unsigned char channels[DIVERSITY_HOPS];
unsigned short interval, seqno, metric;
int rc, parsed_len;
- DO_NTOHS(interval, message + 6);
+ bool ignore_update = false;
+
+ DO_NTOHS(interval, message + 6);
DO_NTOHS(seqno, message + 8);
DO_NTOHS(metric, message + 10);
if(message[5] == 0 ||
@@ -562,14 +631,16 @@ parse_packet(const unsigned char *from, struct interface *ifp,
}
if(parsed_len < len)
- parse_update_subtlv(message + 2 + parsed_len,
- len - parsed_len, channels);
- }
-
- update_route(router_id, prefix, plen, seqno, metric, interval,
- neigh, nh,
- channels, channels_len(channels));
- } else if(type == MESSAGE_REQUEST) {
+ ignore_update =
+ parse_update_subtlv(message + 2 + parsed_len,
+ len - parsed_len, channels);
+ }
+
+ if (ignore_update)
+ update_route(router_id, prefix, plen, seqno, metric,
+ interval, neigh, nh, channels,
+ channels_len(channels));
+ } else if(type == MESSAGE_REQUEST) {
unsigned char prefix[16], plen;
int rc;
rc = network_prefix(message[2], message[3], 0,
diff --git a/babeld/message.h b/babeld/message.h
index 2410a8c308..22db35e2a0 100644
--- a/babeld/message.h
+++ b/babeld/message.h
@@ -51,6 +51,7 @@ THE SOFTWARE.
#define SUBTLV_PADN 1
#define SUBTLV_DIVERSITY 2 /* Also known as babelz. */
#define SUBTLV_TIMESTAMP 3 /* Used to compute RTT. */
+#define SUBTLV_MANDATORY 0x80
extern unsigned short myseqno;
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index a9c4b4c678..38f34a8927 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -85,7 +85,7 @@ int bgp_parse_fec_update(void)
if (label == MPLS_INVALID_LABEL)
bgp_unset_valid_label(&dest->local_label);
else {
- label_ntop(label, 1, &dest->local_label);
+ dest->local_label = mpls_lse_encode(label, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
}
SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
@@ -129,9 +129,16 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
uint16_t flags = 0;
size_t flags_pos = 0;
mpls_label_t *local_label = &(dest->local_label);
- bool have_label_to_reg =
- bgp_is_valid_label(local_label)
- && label_pton(local_label) != MPLS_LABEL_IMPLICIT_NULL;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
+ bool have_label_to_reg;
+
+ mpls_lse_decode(*local_label, &label, &ttl, &exp, &bos);
+
+ have_label_to_reg = bgp_is_valid_label(local_label) &&
+ label != MPLS_LABEL_IMPLICIT_NULL;
p = bgp_dest_get_prefix(dest);
@@ -142,7 +149,7 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
if (BGP_DEBUG(labelpool, LABELPOOL))
zlog_debug("%s: FEC %sregister %pRN label_index=%u label=%u",
__func__, reg ? "" : "un", bgp_dest_to_rnode(dest),
- label_index, label_pton(local_label));
+ label_index, label);
/* If the route node has a local_label assigned or the
* path node has an MPLS SR label index allowing zebra to
* derive the label, proceed with registration. */
@@ -161,7 +168,7 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
stream_putl(s, label_index);
} else if (have_label_to_reg) {
flags |= ZEBRA_FEC_REGISTER_LABEL;
- stream_putl(s, label_pton(local_label));
+ stream_putl(s, label);
}
SET_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL);
} else
@@ -216,13 +223,13 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
*/
if (CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
UNSET_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED);
- label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
- &dest->local_label);
+ dest->local_label = mpls_lse_encode(
+ MPLS_LABEL_IMPLICIT_NULL, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
}
}
- label_ntop(new_label, 1, &dest->local_label);
+ dest->local_label = mpls_lse_encode(new_label, 0, 0, 1);
bgp_set_valid_label(&dest->local_label);
/*
@@ -238,9 +245,16 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
{
bool with_label_index = false;
const struct prefix *p;
- bool have_label_to_reg =
- bgp_is_valid_label(&dest->local_label)
- && label_pton(&dest->local_label) != MPLS_LABEL_IMPLICIT_NULL;
+ bool have_label_to_reg;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
+
+ mpls_lse_decode(dest->local_label, &label, &ttl, &exp, &bos);
+
+ have_label_to_reg = bgp_is_valid_label(&dest->local_label) &&
+ label != MPLS_LABEL_IMPLICIT_NULL;
p = bgp_dest_get_prefix(dest);
@@ -283,8 +297,7 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
}
} else {
UNSET_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED);
- bgp_lp_release(LP_TYPE_BGP_LU, dest,
- label_pton(&dest->local_label));
+ bgp_lp_release(LP_TYPE_BGP_LU, dest, label);
}
bgp_send_fec_register_label_msg(
diff --git a/bgpd/bgp_label.h b/bgpd/bgp_label.h
index cafcc8e9c7..4061e8719b 100644
--- a/bgpd/bgp_label.h
+++ b/bgpd/bgp_label.h
@@ -98,25 +98,6 @@ static inline void bgp_unregister_for_label(struct bgp_dest *dest)
bgp_reg_dereg_for_label(dest, NULL, false);
}
-/* Label stream to value */
-static inline uint32_t label_pton(const mpls_label_t *label)
-{
- uint8_t *t = (uint8_t *)label;
- return ((((unsigned int)t[0]) << 12) | (((unsigned int)t[1]) << 4)
- | ((unsigned int)((t[2] & 0xF0) >> 4)));
-}
-
-/* Encode label values */
-static inline void label_ntop(uint32_t l, int bos, mpls_label_t *label)
-{
- uint8_t *t = (uint8_t *)label;
- t[0] = ((l & 0x000FF000) >> 12);
- t[1] = ((l & 0x00000FF0) >> 4);
- t[2] = ((l & 0x0000000F) << 4);
- if (bos)
- t[2] |= 0x01;
-}
-
/* Return BOS value of label stream */
static inline uint8_t label_bos(mpls_label_t *label)
{
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5df45aa315..84037675ec 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2958,8 +2958,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
dest->flags,
BGP_NODE_LABEL_REQUESTED))
bgp_unregister_for_label(dest);
- label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
- &dest->local_label);
+ dest->local_label = mpls_lse_encode(
+ MPLS_LABEL_IMPLICIT_NULL, 0, 0,
+ 1);
bgp_set_valid_label(&dest->local_label);
} else
bgp_register_for_label(dest,
@@ -9846,7 +9847,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
char buf[INET6_ADDRSTRLEN];
char buf1[BUFSIZ];
struct attr *attr = path->attr;
- int sockunion_vty_out(struct vty *, union sockunion *);
time_t tbuf;
json_object *json_bestpath = NULL;
json_object *json_cluster_list = NULL;
@@ -9872,6 +9872,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
int i;
char *nexthop_hostname =
bgp_nexthop_hostname(path->peer, path->nexthop);
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
+ mpls_label_t label = MPLS_INVALID_LABEL;
if (json_paths) {
json_path = json_object_new_object();
@@ -10614,7 +10618,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
/* Remote Label */
if (path->extra && bgp_is_valid_label(&path->extra->label[0])
&& (safi != SAFI_EVPN && !is_route_parent_evpn(path))) {
- mpls_label_t label = label_pton(&path->extra->label[0]);
+ mpls_lse_decode(path->extra->label[0], &label, &ttl, &exp,
+ &bos);
if (json_paths)
json_object_int_add(json_path, "remoteLabel", label);
@@ -11433,12 +11438,14 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
int has_valid_label = 0;
mpls_label_t label = 0;
json_object *json_adv_to = NULL;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
- p = bgp_dest_get_prefix(dest);
- has_valid_label = bgp_is_valid_label(&dest->local_label);
+ mpls_lse_decode(dest->local_label, &label, &ttl, &exp, &bos);
- if (has_valid_label)
- label = label_pton(&dest->local_label);
+ p = bgp_dest_get_prefix(dest);
+ has_valid_label = bgp_is_valid_label(&label);
if (safi == SAFI_EVPN) {
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 2c1d561721..c1b388b05d 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1274,6 +1274,9 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
uint64_t cum_bw = 0;
uint32_t nhg_id = 0;
bool is_add;
+ uint32_t ttl = 0;
+ uint32_t bos = 0;
+ uint32_t exp = 0;
/* Don't try to install if we're not connected to Zebra or Zebra doesn't
* know of this instance.
@@ -1465,7 +1468,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
if (mpinfo->extra
&& bgp_is_valid_label(&mpinfo->extra->label[0])
&& !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) {
- label = label_pton(&mpinfo->extra->label[0]);
+ mpls_lse_decode(mpinfo->extra->label[0], &label, &ttl,
+ &exp, &bos);
SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_LABEL);
@@ -1493,7 +1497,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
&mpinfo->extra->label[0]))
continue;
- label = label_pton(&mpinfo->extra->label[0]);
+ mpls_lse_decode(mpinfo->extra->label[0], &label,
+ &ttl, &exp, &bos);
transpose_sid(&api_nh->seg6_segs, label,
sid_info->transposition_offset,
sid_info->transposition_len);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index bf26bdc5b0..98e59bcc85 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1637,7 +1637,7 @@ struct peer {
* a new value to the last_reset reason
*/
- size_t last_reset_cause_size;
+ uint16_t last_reset_cause_size;
uint8_t last_reset_cause[BGP_MAX_PACKET_SIZE];
/* The kind of route-map Flags.*/
diff --git a/configure.ac b/configure.ac
index 4fc5a334bb..ff53e1224f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1970,7 +1970,7 @@ dnl ---------------
dnl sysrepo
dnl ---------------
if test "$enable_sysrepo" = "yes"; then
- PKG_CHECK_MODULES([SYSREPO], [sysrepo],
+ PKG_CHECK_MODULES([SYSREPO], [sysrepo >= 2.1.42],
[AC_DEFINE([HAVE_SYSREPO], [1], [Enable sysrepo integration])
SYSREPO=true],
[SYSREPO=false
diff --git a/debian/changelog b/debian/changelog
index 0661ffbb97..feaf92d073 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,8 @@
-frr (8.3~dev-1) UNRELEASED; urgency=medium
+frr (8.4~dev-1) UNRELEASED; urgency=medium
* New upstream release...
- -- Donatas Abraitis <donatas.abraitis@gmail.com> Tue, 01 Feb 2022 11:00:00 +0200
+ -- Donatas Abraitis <donatas@opensourcerouting.org> Tue, 07 May 2022 23:00:00 +0300
frr (8.2-0) UNRELEASED; urgency=medium
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index 8a64347871..f035ac8611 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -515,7 +515,7 @@ static int frr_sr_notification_send(const char *xpath, struct list *arguments)
}
}
- ret = sr_event_notif_send(session, xpath, values, values_cnt, 0, 0);
+ ret = sr_notif_send(session, xpath, values, values_cnt, 0, 0);
if (ret != SR_ERR_OK) {
flog_err(EC_LIB_LIBSYSREPO,
"%s: sr_event_notif_send() failed for xpath %s",
@@ -532,7 +532,8 @@ static void frr_sr_read_cb(struct thread *thread)
int fd = THREAD_FD(thread);
int ret;
- ret = sr_process_events(module->sr_subscription, session, NULL);
+ ret = sr_subscription_process_events(module->sr_subscription, session,
+ NULL);
if (ret != SR_ERR_OK) {
flog_err(EC_LIB_LIBSYSREPO, "%s: sr_fd_event_process(): %s",
__func__, sr_strerror(ret));
@@ -578,9 +579,9 @@ static int frr_sr_subscribe_state(const struct lysc_node *snode, void *arg)
DEBUGD(&nb_dbg_client_sysrepo, "sysrepo: providing data to '%s'",
nb_node->xpath);
- ret = sr_oper_get_items_subscribe(
- session, snode->module->name, nb_node->xpath, frr_sr_state_cb,
- NULL, SR_SUBSCR_CTX_REUSE, &module->sr_subscription);
+ ret = sr_oper_get_subscribe(session, snode->module->name,
+ nb_node->xpath, frr_sr_state_cb, NULL, 0,
+ &module->sr_subscription);
if (ret != SR_ERR_OK)
flog_err(EC_LIB_LIBSYSREPO, "sr_oper_get_items_subscribe(): %s",
sr_strerror(ret));
@@ -605,8 +606,7 @@ static int frr_sr_subscribe_rpc(const struct lysc_node *snode, void *arg)
nb_node->xpath);
ret = sr_rpc_subscribe(session, nb_node->xpath, frr_sr_config_rpc_cb,
- NULL, 0, SR_SUBSCR_CTX_REUSE,
- &module->sr_subscription);
+ NULL, 0, 0, &module->sr_subscription);
if (ret != SR_ERR_OK)
flog_err(EC_LIB_LIBSYSREPO, "sr_rpc_subscribe(): %s",
sr_strerror(ret));
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 92869594dd..c703de90b3 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -103,8 +103,7 @@ void work_queue_free_and_null(struct work_queue **wqp)
{
struct work_queue *wq = *wqp;
- if (wq->thread != NULL)
- thread_cancel(&(wq->thread));
+ THREAD_OFF(wq->thread);
while (!work_queue_empty(wq)) {
struct work_queue_item *item = work_queue_last_item(wq);
@@ -122,16 +121,14 @@ void work_queue_free_and_null(struct work_queue **wqp)
bool work_queue_is_scheduled(struct work_queue *wq)
{
- return (wq->thread != NULL);
+ return thread_is_scheduled(wq->thread);
}
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)) {
- wq->thread = NULL;
-
+ if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) &&
+ !thread_is_scheduled(wq->thread) && !work_queue_empty(wq)) {
/* Schedule timer if there's a delay, otherwise just schedule
* as an 'event'
*/
@@ -144,7 +141,8 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
&wq->thread);
/* set thread yield time, if needed */
- if (wq->thread && wq->spec.yield != THREAD_YIELD_TIME_SLOT)
+ if (thread_is_scheduled(wq->thread) &&
+ wq->spec.yield != THREAD_YIELD_TIME_SLOT)
thread_set_yield_time(wq->thread, wq->spec.yield);
return 1;
} else
@@ -215,10 +213,7 @@ void workqueue_cmd_init(void)
*/
void work_queue_plug(struct work_queue *wq)
{
- if (wq->thread)
- thread_cancel(&(wq->thread));
-
- wq->thread = NULL;
+ THREAD_OFF(wq->thread);
UNSET_FLAG(wq->flags, WQ_UNPLUGGED);
}
@@ -250,8 +245,6 @@ void work_queue_run(struct thread *thread)
assert(wq);
- wq->thread = NULL;
-
/* calculate cycle granularity:
* list iteration == 1 run
* listnode processing == 1 cycle
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 39202dcda7..27fb1383eb 100644
--- a/lib/workqueue.h
+++ b/lib/workqueue.h
@@ -157,7 +157,8 @@ static inline void work_queue_item_dequeue(struct work_queue *wq,
* user must fill in the spec of the returned work queue before adding
* anything to it
*/
-extern struct work_queue *work_queue_new(struct thread_master *, const char *);
+extern struct work_queue *work_queue_new(struct thread_master *m,
+ const char *queue_name);
/* destroy work queue */
/*
@@ -174,10 +175,10 @@ extern void work_queue_plug(struct work_queue *wq);
/* unplug the queue, allow it to be drained again */
extern void work_queue_unplug(struct work_queue *wq);
-bool work_queue_is_scheduled(struct work_queue *);
+bool work_queue_is_scheduled(struct work_queue *wq);
/* Helpers, exported for thread.c and command.c */
-extern void work_queue_run(struct thread *);
+extern void work_queue_run(struct thread *thread);
extern void workqueue_cmd_init(void);
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 46eb625383..1754512b5b 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1747,7 +1747,7 @@ static void ospf_filter_update(struct access_list *access)
}
/* If prefix-list is updated, do some updates. */
-void ospf_prefix_list_update(struct prefix_list *plist)
+static void ospf_prefix_list_update(struct prefix_list *plist)
{
struct ospf *ospf = NULL;
int type;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 76501dd6bb..401a89fa38 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -661,7 +661,7 @@ extern struct zebra_privs_t ospfd_privs;
/* Prototypes. */
extern const char *ospf_redist_string(unsigned int route_type);
-extern struct ospf *ospf_lookup_instance(unsigned short);
+extern struct ospf *ospf_lookup_instance(unsigned short instance);
extern struct ospf *ospf_lookup(unsigned short instance, const char *name);
extern struct ospf *ospf_get(unsigned short instance, const char *name,
bool *created);
@@ -670,68 +670,82 @@ extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance,
const char *name);
extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
extern uint32_t ospf_count_area_params(struct ospf *ospf);
-extern void ospf_finish(struct ospf *);
+extern void ospf_finish(struct ospf *ospf);
extern void ospf_process_refresh_data(struct ospf *ospf, bool reset);
extern void ospf_router_id_update(struct ospf *ospf);
extern void ospf_process_reset(struct ospf *ospf);
extern void ospf_neighbor_reset(struct ospf *ospf, struct in_addr nbr_id,
const char *nbr_str);
-extern int ospf_network_set(struct ospf *, struct prefix_ipv4 *, struct in_addr,
- int);
-extern int ospf_network_unset(struct ospf *, struct prefix_ipv4 *,
- struct in_addr);
-extern int ospf_area_display_format_set(struct ospf *, struct ospf_area *area,
- int df);
-extern int ospf_area_stub_set(struct ospf *, struct in_addr);
-extern int ospf_area_stub_unset(struct ospf *, struct in_addr);
-extern int ospf_area_no_summary_set(struct ospf *, struct in_addr);
-extern int ospf_area_no_summary_unset(struct ospf *, struct in_addr);
-extern int ospf_area_nssa_set(struct ospf *, struct in_addr);
-extern int ospf_area_nssa_unset(struct ospf *, struct in_addr, int);
+extern int ospf_network_set(struct ospf *ospf, struct prefix_ipv4 *p,
+ struct in_addr area_id, int df);
+extern int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
+ struct in_addr aread_id);
+extern int ospf_area_display_format_set(struct ospf *ospf,
+ struct ospf_area *area, int df);
+extern int ospf_area_stub_set(struct ospf *ospf, struct in_addr area_id);
+extern int ospf_area_stub_unset(struct ospf *ospf, struct in_addr area_id);
+extern int ospf_area_no_summary_set(struct ospf *ospf, struct in_addr area_id);
+extern int ospf_area_no_summary_unset(struct ospf *ospf,
+ struct in_addr area_id);
+extern int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id);
+extern int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id,
+ int argc);
extern int ospf_area_nssa_suppress_fa_set(struct ospf *ospf,
struct in_addr area_id);
extern int ospf_area_nssa_suppress_fa_unset(struct ospf *ospf,
struct in_addr area_id);
-extern int ospf_area_nssa_translator_role_set(struct ospf *, struct in_addr,
- int);
-extern int ospf_area_export_list_set(struct ospf *, struct ospf_area *,
- const char *);
-extern int ospf_area_export_list_unset(struct ospf *, struct ospf_area *);
-extern int ospf_area_import_list_set(struct ospf *, struct ospf_area *,
- const char *);
-extern int ospf_area_import_list_unset(struct ospf *, struct ospf_area *);
-extern int ospf_area_shortcut_set(struct ospf *, struct ospf_area *, int);
-extern int ospf_area_shortcut_unset(struct ospf *, struct ospf_area *);
-extern int ospf_timers_refresh_set(struct ospf *, int);
-extern int ospf_timers_refresh_unset(struct ospf *);
+extern int ospf_area_nssa_translator_role_set(struct ospf *ospf,
+ struct in_addr area_id, int role);
+extern int ospf_area_export_list_set(struct ospf *ospf,
+ struct ospf_area *area_id,
+ const char *list_name);
+extern int ospf_area_export_list_unset(struct ospf *ospf,
+ struct ospf_area *area_id);
+extern int ospf_area_import_list_set(struct ospf *ospf,
+ struct ospf_area *area_id,
+ const char *name);
+extern int ospf_area_import_list_unset(struct ospf *ospf,
+ struct ospf_area *area_id);
+extern int ospf_area_shortcut_set(struct ospf *ospf, struct ospf_area *area_id,
+ int mode);
+extern int ospf_area_shortcut_unset(struct ospf *ospf,
+ struct ospf_area *area_id);
+extern int ospf_timers_refresh_set(struct ospf *ospf, int interval);
+extern int ospf_timers_refresh_unset(struct ospf *ospf);
void ospf_area_lsdb_discard_delete(struct ospf_area *area);
-extern int ospf_nbr_nbma_set(struct ospf *, struct in_addr);
-extern int ospf_nbr_nbma_unset(struct ospf *, struct in_addr);
-extern int ospf_nbr_nbma_priority_set(struct ospf *, struct in_addr, uint8_t);
-extern int ospf_nbr_nbma_priority_unset(struct ospf *, struct in_addr);
-extern int ospf_nbr_nbma_poll_interval_set(struct ospf *, struct in_addr,
- unsigned int);
-extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *, struct in_addr);
-extern void ospf_prefix_list_update(struct prefix_list *);
-extern void ospf_if_update(struct ospf *, struct interface *);
-extern void ospf_ls_upd_queue_empty(struct ospf_interface *);
+extern int ospf_nbr_nbma_set(struct ospf *ospf, struct in_addr nbr_addr);
+extern int ospf_nbr_nbma_unset(struct ospf *ospf, struct in_addr nbr_addr);
+extern int ospf_nbr_nbma_priority_set(struct ospf *ospf,
+ struct in_addr nbr_addr,
+ uint8_t priority);
+extern int ospf_nbr_nbma_priority_unset(struct ospf *ospf,
+ struct in_addr nbr_addr);
+extern int ospf_nbr_nbma_poll_interval_set(struct ospf *ospf,
+ struct in_addr nbr_addr,
+ unsigned int interval);
+extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *ospf,
+ struct in_addr addr);
+extern void ospf_if_update(struct ospf *ospf, struct interface *ifp);
+extern void ospf_ls_upd_queue_empty(struct ospf_interface *oi);
extern void ospf_terminate(void);
-extern void ospf_nbr_nbma_if_update(struct ospf *, struct ospf_interface *);
-extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup(struct ospf *,
- struct in_addr);
-extern int ospf_oi_count(struct interface *);
+extern void ospf_nbr_nbma_if_update(struct ospf *ospf,
+ struct ospf_interface *oi);
+extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup(struct ospf *ospf,
+ struct in_addr nbr_addr);
+extern int ospf_oi_count(struct interface *ifp);
extern struct ospf_area *ospf_area_new(struct ospf *ospf,
struct in_addr area_id);
-extern struct ospf_area *ospf_area_get(struct ospf *, struct in_addr);
-extern void ospf_area_check_free(struct ospf *, struct in_addr);
-extern struct ospf_area *ospf_area_lookup_by_area_id(struct ospf *,
- struct in_addr);
-extern void ospf_area_add_if(struct ospf_area *, struct ospf_interface *);
-extern void ospf_area_del_if(struct ospf_area *, struct ospf_interface *);
+extern struct ospf_area *ospf_area_get(struct ospf *ospf,
+ struct in_addr area_id);
+extern void ospf_area_check_free(struct ospf *ospf, struct in_addr area_id);
+extern struct ospf_area *ospf_area_lookup_by_area_id(struct ospf *ospf,
+ struct in_addr area_id);
+extern void ospf_area_add_if(struct ospf_area *oa, struct ospf_interface *oi);
+extern void ospf_area_del_if(struct ospf_area *oa, struct ospf_interface *oi);
-extern void ospf_interface_area_set(struct ospf *, struct interface *);
-extern void ospf_interface_area_unset(struct ospf *, struct interface *);
+extern void ospf_interface_area_set(struct ospf *ospf, struct interface *ifp);
+extern void ospf_interface_area_unset(struct ospf *ospf, struct interface *ifp);
extern void ospf_route_map_init(void);
@@ -741,7 +755,7 @@ extern void ospf_vrf_terminate(void);
extern void ospf_vrf_link(struct ospf *ospf, struct vrf *vrf);
extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf);
const char *ospf_vrf_id_to_name(vrf_id_t vrf_id);
-int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr);
+int ospf_area_nssa_no_summary_set(struct ospf *ospf, struct in_addr area_id);
const char *ospf_get_name(const struct ospf *ospf);
extern struct ospf_interface *add_ospf_interface(struct connected *co,
diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c
index 0cf7a2f347..fea83f37b6 100644
--- a/pimd/pim6_cmd.c
+++ b/pimd/pim6_cmd.c
@@ -956,17 +956,7 @@ DEFPY (show_ipv6_pim_channel,
"PIM downstream channel info\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_channel(v->info, vty, uj);
-
- return CMD_SUCCESS;
+ return pim_show_channel_cmd_helper(vrf, vty, !!json);
}
DEFPY (show_ipv6_pim_interface,
@@ -981,28 +971,8 @@ DEFPY (show_ipv6_pim_interface,
"interface name\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (uj)
- json_parent = json_object_new_object();
-
- if (interface)
- pim_show_interfaces_single(v->info, vty, interface, false,
- json_parent);
- else
- pim_show_interfaces(v->info, vty, false, json_parent);
-
- if (uj)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_interface_cmd_helper(vrf, vty, !!json, false,
+ interface);
}
DEFPY (show_ipv6_pim_interface_vrf_all,
@@ -1017,33 +987,8 @@ DEFPY (show_ipv6_pim_interface_vrf_all,
"interface name\n"
JSON_STR)
{
- bool uj = !!json;
- struct vrf *v;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (uj)
- json_parent = json_object_new_object();
-
- RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
- if (!uj)
- vty_out(vty, "VRF: %s\n", v->name);
- else
- json_vrf = json_object_new_object();
-
- if (interface)
- pim_show_interfaces_single(v->info, vty, interface,
- false, json_vrf);
- else
- pim_show_interfaces(v->info, vty, false, json_vrf);
-
- if (uj)
- json_object_object_add(json_parent, v->name, json_vrf);
- }
- if (uj)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_interface_vrf_all_cmd_helper(vty, !!json, false,
+ interface);
}
DEFPY (show_ipv6_pim_join,
@@ -1058,41 +1003,7 @@ DEFPY (show_ipv6_pim_join,
"The Group\n"
JSON_STR)
{
- pim_sgaddr sg = {};
- struct vrf *v;
- struct pim_instance *pim;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v) {
- vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
- return CMD_WARNING;
- }
- pim = pim_get_pim_instance(v->vrf_id);
-
- if (!pim) {
- vty_out(vty, "%% Unable to find pim instance\n");
- return CMD_WARNING;
- }
-
- if (!pim_addr_is_any(s_or_g)) {
- if (!pim_addr_is_any(g)) {
- sg.src = s_or_g;
- sg.grp = g;
- } else
- sg.grp = s_or_g;
- }
-
- if (json)
- json_parent = json_object_new_object();
-
- pim_show_join(pim, vty, &sg, json_parent);
-
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_join_cmd_helper(vrf, vty, s_or_g, g, json);
}
DEFPY (show_ipv6_pim_join_vrf_all,
@@ -1105,29 +1016,7 @@ DEFPY (show_ipv6_pim_join_vrf_all,
"PIM interface join information\n"
JSON_STR)
{
- pim_sgaddr sg = {0};
- struct vrf *vrf_struct;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (json)
- json_parent = json_object_new_object();
-
- RB_FOREACH (vrf_struct, vrf_name_head, &vrfs_by_name) {
- if (!json_parent)
- vty_out(vty, "VRF: %s\n", vrf_struct->name);
- else
- json_vrf = json_object_new_object();
- pim_show_join(vrf_struct->info, vty, &sg, json_vrf);
-
- if (json)
- json_object_object_add(json_parent, vrf_struct->name,
- json_vrf);
- }
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_WARNING;
+ return pim_show_join_vrf_all_cmd_helper(vty, json);
}
DEFPY (show_ipv6_pim_jp_agg,
@@ -1139,25 +1028,7 @@ DEFPY (show_ipv6_pim_jp_agg,
VRF_CMD_HELP_STR
"join prune aggregation list\n")
{
- struct vrf *v;
- struct pim_instance *pim;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v) {
- vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
- return CMD_WARNING;
- }
- pim = pim_get_pim_instance(v->vrf_id);
-
- if (!pim) {
- vty_out(vty, "%% Unable to find pim instance\n");
- return CMD_WARNING;
- }
-
- pim_show_jp_agg_list(pim, vty);
-
- return CMD_SUCCESS;
+ return pim_show_jp_agg_list_cmd_helper(vrf, vty);
}
DEFPY (show_ipv6_pim_local_membership,
@@ -1170,17 +1041,7 @@ DEFPY (show_ipv6_pim_local_membership,
"PIM interface local-membership\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_membership(v->info, vty, uj);
-
- return CMD_SUCCESS;
+ return pim_show_membership_cmd_helper(vrf, vty, !!json);
}
DEFPY (show_ipv6_pim_neighbor,
@@ -1195,26 +1056,7 @@ DEFPY (show_ipv6_pim_neighbor,
"Name of interface or neighbor\n"
JSON_STR)
{
- struct vrf *v;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (json)
- json_parent = json_object_new_object();
-
- if (interface)
- pim_show_neighbors_single(v->info, vty, interface, json_parent);
- else
- pim_show_neighbors(v->info, vty, json_parent);
-
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_neighbors_cmd_helper(vrf, vty, json, interface);
}
DEFPY (show_ipv6_pim_neighbor_vrf_all,
@@ -1229,31 +1071,7 @@ DEFPY (show_ipv6_pim_neighbor_vrf_all,
"Name of interface or neighbor\n"
JSON_STR)
{
- struct vrf *v;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (json)
- json_parent = json_object_new_object();
- RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
- if (!json)
- vty_out(vty, "VRF: %s\n", v->name);
- else
- json_vrf = json_object_new_object();
-
- if (interface)
- pim_show_neighbors_single(v->info, vty, interface,
- json_vrf);
- else
- pim_show_neighbors(v->info, vty, json_vrf);
-
- if (json)
- json_object_object_add(json_parent, v->name, json_vrf);
- }
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface);
}
DEFPY (show_ipv6_pim_nexthop,
@@ -1265,16 +1083,7 @@ DEFPY (show_ipv6_pim_nexthop,
VRF_CMD_HELP_STR
"PIM cached nexthop rpf information\n")
{
- struct vrf *v;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_nexthop(v->info, vty);
-
- return CMD_SUCCESS;
+ return pim_show_nexthop_cmd_helper(vrf, vty);
}
DEFPY (show_ipv6_pim_nexthop_lookup,
@@ -1288,37 +1097,7 @@ DEFPY (show_ipv6_pim_nexthop_lookup,
"Source/RP address\n"
"Multicast Group address\n")
{
- struct prefix nht_p;
- int result = 0;
- pim_addr vif_source;
- struct prefix grp;
- struct pim_nexthop nexthop;
- struct vrf *v;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
- return CMD_SUCCESS;
-
- pim_addr_to_prefix(&nht_p, vif_source);
- pim_addr_to_prefix(&grp, group);
- memset(&nexthop, 0, sizeof(nexthop));
-
- result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
-
- if (!result) {
- vty_out(vty,
- "Nexthop Lookup failed, no usable routes returned.\n");
- return CMD_SUCCESS;
- }
-
- vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s\n", group_str,
- &nexthop.mrib_nexthop_addr, nexthop.interface->name);
-
- return CMD_SUCCESS;
+ return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
}
DEFPY (show_ipv6_multicast,
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 9abd5a3b76..b387783e85 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -867,8 +867,6 @@ static void pim_show_interface_traffic(struct pim_instance *pim,
if (!pim_ifp)
continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
if (uj) {
json_row = json_object_new_object();
json_object_pim_ifp_add(json_row, ifp);
@@ -958,9 +956,6 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,
if (!pim_ifp)
continue;
- if (pim_ifp->pim_sock_fd < 0)
- continue;
-
found_ifname = 1;
if (uj) {
json_row = json_object_new_object();
@@ -2427,29 +2422,8 @@ DEFPY (show_ip_pim_interface,
"interface name\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
- bool is_mlag = !!mlag;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (uj)
- json_parent = json_object_new_object();
-
- if (interface)
- pim_show_interfaces_single(v->info, vty, interface, is_mlag,
- json_parent);
- else
- pim_show_interfaces(v->info, vty, is_mlag, json_parent);
-
- if (uj)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_interface_cmd_helper(vrf, vty, !!json, !!mlag,
+ interface);
}
DEFPY (show_ip_pim_interface_vrf_all,
@@ -2465,34 +2439,8 @@ DEFPY (show_ip_pim_interface_vrf_all,
"interface name\n"
JSON_STR)
{
- bool uj = !!json;
- bool is_mlag = !!mlag;
- struct vrf *v;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (uj)
- json_parent = json_object_new_object();
-
- RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
- if (!uj)
- vty_out(vty, "VRF: %s\n", v->name);
- else
- json_vrf = json_object_new_object();
-
- if (interface)
- pim_show_interfaces_single(v->info, vty, interface,
- is_mlag, json_vrf);
- else
- pim_show_interfaces(v->info, vty, is_mlag, json_vrf);
-
- if (uj)
- json_object_object_add(json_parent, v->name, json_vrf);
- }
- if (uj)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_interface_vrf_all_cmd_helper(vty, !!json, !!mlag,
+ interface);
}
DEFPY (show_ip_pim_join,
@@ -2507,41 +2455,7 @@ DEFPY (show_ip_pim_join,
"The Group\n"
JSON_STR)
{
- pim_sgaddr sg = {0};
- struct vrf *v;
- struct pim_instance *pim;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v) {
- vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
- return CMD_WARNING;
- }
- pim = pim_get_pim_instance(v->vrf_id);
-
- if (!pim) {
- vty_out(vty, "%% Unable to find pim instance\n");
- return CMD_WARNING;
- }
-
- if (s_or_g.s_addr != INADDR_ANY) {
- if (g.s_addr != INADDR_ANY) {
- sg.src = s_or_g;
- sg.grp = g;
- } else
- sg.grp = s_or_g;
- }
-
- if (json)
- json_parent = json_object_new_object();
-
- pim_show_join(pim, vty, &sg, json_parent);
-
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_join_cmd_helper(vrf, vty, s_or_g, g, json);
}
DEFPY (show_ip_pim_join_vrf_all,
@@ -2554,28 +2468,7 @@ DEFPY (show_ip_pim_join_vrf_all,
"PIM interface join information\n"
JSON_STR)
{
- pim_sgaddr sg = {0};
- struct vrf *vrf_struct;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (json)
- json_parent = json_object_new_object();
- RB_FOREACH (vrf_struct, vrf_name_head, &vrfs_by_name) {
- if (!json)
- vty_out(vty, "VRF: %s\n", vrf_struct->name);
- else
- json_vrf = json_object_new_object();
- pim_show_join(vrf_struct->info, vty, &sg, json_vrf);
-
- if (json)
- json_object_object_add(json_parent, vrf_struct->name,
- json_vrf);
- }
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_WARNING;
+ return pim_show_join_vrf_all_cmd_helper(vty, json);
}
DEFPY (show_ip_pim_jp_agg,
@@ -2587,25 +2480,7 @@ DEFPY (show_ip_pim_jp_agg,
VRF_CMD_HELP_STR
"join prune aggregation list\n")
{
- struct vrf *v;
- struct pim_instance *pim;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v) {
- vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
- return CMD_WARNING;
- }
- pim = pim_get_pim_instance(v->vrf_id);
-
- if (!pim) {
- vty_out(vty, "%% Unable to find pim instance\n");
- return CMD_WARNING;
- }
-
- pim_show_jp_agg_list(pim, vty);
-
- return CMD_SUCCESS;
+ return pim_show_jp_agg_list_cmd_helper(vrf, vty);
}
DEFPY (show_ip_pim_local_membership,
@@ -2618,17 +2493,7 @@ DEFPY (show_ip_pim_local_membership,
"PIM interface local-membership\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_membership(v->info, vty, uj);
-
- return CMD_SUCCESS;
+ return pim_show_membership_cmd_helper(vrf, vty, !!json);
}
static void pim_show_mlag_up_entry_detail(struct vrf *vrf,
@@ -2910,26 +2775,7 @@ DEFPY (show_ip_pim_neighbor,
"Name of interface or neighbor\n"
JSON_STR)
{
- struct vrf *v;
- json_object *json_parent = NULL;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (json)
- json_parent = json_object_new_object();
-
- if (interface)
- pim_show_neighbors_single(v->info, vty, interface, json_parent);
- else
- pim_show_neighbors(v->info, vty, json_parent);
-
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_neighbors_cmd_helper(vrf, vty, json, interface);
}
DEFPY (show_ip_pim_neighbor_vrf_all,
@@ -2944,31 +2790,7 @@ DEFPY (show_ip_pim_neighbor_vrf_all,
"Name of interface or neighbor\n"
JSON_STR)
{
- struct vrf *v;
- json_object *json_parent = NULL;
- json_object *json_vrf = NULL;
-
- if (json)
- json_parent = json_object_new_object();
- RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
- if (!json)
- vty_out(vty, "VRF: %s\n", v->name);
- else
- json_vrf = json_object_new_object();
-
- if (interface)
- pim_show_neighbors_single(v->info, vty, interface,
- json_vrf);
- else
- pim_show_neighbors(v->info, vty, json_vrf);
-
- if (json)
- json_object_object_add(json_parent, v->name, json_vrf);
- }
- if (json)
- vty_json(vty, json_parent);
-
- return CMD_SUCCESS;
+ return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface);
}
DEFPY (show_ip_pim_secondary,
@@ -3051,17 +2873,7 @@ DEFPY (show_ip_pim_channel,
"PIM downstream channel info\n"
JSON_STR)
{
- struct vrf *v;
- bool uj = !!json;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_channel(v->info, vty, uj);
-
- return CMD_SUCCESS;
+ return pim_show_channel_cmd_helper(vrf, vty, !!json);
}
DEFPY (show_ip_pim_upstream_join_desired,
@@ -3155,16 +2967,7 @@ DEFPY (show_ip_pim_nexthop,
VRF_CMD_HELP_STR
"PIM cached nexthop rpf information\n")
{
- struct vrf *v;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- pim_show_nexthop(v->info, vty);
-
- return CMD_SUCCESS;
+ return pim_show_nexthop_cmd_helper(vrf, vty);
}
DEFPY (show_ip_pim_nexthop_lookup,
@@ -3178,49 +2981,7 @@ DEFPY (show_ip_pim_nexthop_lookup,
"Source/RP address\n"
"Multicast Group address\n")
{
- struct prefix nht_p;
- int result = 0;
- pim_addr vif_source;
- struct prefix grp;
- struct pim_nexthop nexthop;
- struct vrf *v;
-
- v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
- if (!v)
- return CMD_WARNING;
-
- if (pim_is_group_224_4(source)) {
- vty_out(vty,
- "Invalid argument. Expected Valid Source Address.\n");
- return CMD_WARNING;
- }
-
- if (!pim_is_group_224_4(group)) {
- vty_out(vty,
- "Invalid argument. Expected Valid Multicast Group Address.\n");
- return CMD_WARNING;
- }
-
- if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
- return CMD_SUCCESS;
-
- pim_addr_to_prefix(&nht_p, vif_source);
- pim_addr_to_prefix(&grp, group);
- memset(&nexthop, 0, sizeof(nexthop));
-
- result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
-
- if (!result) {
- vty_out(vty,
- "Nexthop Lookup failed, no usable routes returned.\n");
- return CMD_SUCCESS;
- }
-
- vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s \n", group_str,
- &nexthop.mrib_nexthop_addr, nexthop.interface->name);
-
- return CMD_SUCCESS;
+ return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
}
DEFUN (show_ip_pim_interface_traffic,
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index bc3d8d0fca..559aa7ec03 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -55,6 +55,7 @@
#include "pim_static.h"
#include "pim_addr.h"
#include "pim_static.h"
+#include "pim_util.h"
/**
* Get current node VRF name.
@@ -1664,6 +1665,73 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
}
}
+int pim_show_join_cmd_helper(const char *vrf, struct vty *vty, pim_addr s_or_g,
+ pim_addr g, const char *json)
+{
+ pim_sgaddr sg = {};
+ struct vrf *v;
+ struct pim_instance *pim;
+ json_object *json_parent = NULL;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v) {
+ vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
+ return CMD_WARNING;
+ }
+ pim = pim_get_pim_instance(v->vrf_id);
+
+ if (!pim) {
+ vty_out(vty, "%% Unable to find pim instance\n");
+ return CMD_WARNING;
+ }
+
+ if (!pim_addr_is_any(s_or_g)) {
+ if (!pim_addr_is_any(g)) {
+ sg.src = s_or_g;
+ sg.grp = g;
+ } else
+ sg.grp = s_or_g;
+ }
+
+ if (json)
+ json_parent = json_object_new_object();
+
+ pim_show_join(pim, vty, &sg, json_parent);
+
+ if (json)
+ vty_json(vty, json_parent);
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_join_vrf_all_cmd_helper(struct vty *vty, const char *json)
+{
+ pim_sgaddr sg = {0};
+ struct vrf *vrf_struct;
+ json_object *json_parent = NULL;
+ json_object *json_vrf = NULL;
+
+ if (json)
+ json_parent = json_object_new_object();
+
+ RB_FOREACH (vrf_struct, vrf_name_head, &vrfs_by_name) {
+ if (!json_parent)
+ vty_out(vty, "VRF: %s\n", vrf_struct->name);
+ else
+ json_vrf = json_object_new_object();
+ pim_show_join(vrf_struct->info, vty, &sg, json_vrf);
+
+ if (json)
+ json_object_object_add(json_parent, vrf_struct->name,
+ json_vrf);
+ }
+ if (json)
+ vty_json(vty, json_parent);
+
+ return CMD_WARNING;
+}
+
void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
json_object *json)
{
@@ -1701,6 +1769,29 @@ static void pim_show_jp_agg_helper(struct vty *vty, struct interface *ifp,
is_join ? "J" : "P");
}
+int pim_show_jp_agg_list_cmd_helper(const char *vrf, struct vty *vty)
+{
+ struct vrf *v;
+ struct pim_instance *pim;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v) {
+ vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf);
+ return CMD_WARNING;
+ }
+ pim = pim_get_pim_instance(v->vrf_id);
+
+ if (!pim) {
+ vty_out(vty, "%% Unable to find pim instance\n");
+ return CMD_WARNING;
+ }
+
+ pim_show_jp_agg_list(pim, vty);
+
+ return CMD_SUCCESS;
+}
+
void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
{
struct interface *ifp;
@@ -1735,6 +1826,20 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
}
}
+int pim_show_membership_cmd_helper(const char *vrf, struct vty *vty, bool uj)
+{
+ struct vrf *v;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+ pim_show_membership(v->info, vty, uj);
+
+ return CMD_SUCCESS;
+}
+
static void pim_show_membership_helper(struct vty *vty,
struct pim_interface *pim_ifp,
struct pim_ifchannel *ch,
@@ -1945,6 +2050,77 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
vty_json(vty, json);
}
+int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj)
+{
+ struct vrf *v;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+ pim_show_channel(v->info, vty, uj);
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_interface_cmd_helper(const char *vrf, struct vty *vty, bool uj,
+ bool mlag, const char *interface)
+{
+ struct vrf *v;
+ json_object *json_parent = NULL;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+ if (uj)
+ json_parent = json_object_new_object();
+
+ if (interface)
+ pim_show_interfaces_single(v->info, vty, interface, mlag,
+ json_parent);
+ else
+ pim_show_interfaces(v->info, vty, mlag, json_parent);
+
+ if (uj)
+ vty_json(vty, json_parent);
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_interface_vrf_all_cmd_helper(struct vty *vty, bool uj, bool mlag,
+ const char *interface)
+{
+ struct vrf *v;
+ json_object *json_parent = NULL;
+ json_object *json_vrf = NULL;
+
+ if (uj)
+ json_parent = json_object_new_object();
+
+ RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
+ if (!uj)
+ vty_out(vty, "VRF: %s\n", v->name);
+ else
+ json_vrf = json_object_new_object();
+
+ if (interface)
+ pim_show_interfaces_single(v->info, vty, interface,
+ mlag, json_vrf);
+ else
+ pim_show_interfaces(v->info, vty, mlag, json_vrf);
+
+ if (uj)
+ json_object_object_add(json_parent, v->name, json_vrf);
+ }
+ if (uj)
+ vty_json(vty, json_parent);
+
+ return CMD_SUCCESS;
+}
+
void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
json_object *json)
{
@@ -2489,6 +2665,73 @@ static int pim_print_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
return CMD_SUCCESS;
}
+int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty,
+ pim_addr source, pim_addr group)
+{
+ struct prefix nht_p;
+ int result = 0;
+ pim_addr vif_source;
+ struct prefix grp;
+ struct pim_nexthop nexthop;
+ struct vrf *v;
+ char grp_str[PREFIX_STRLEN];
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+#if PIM_IPV == 4
+ if (pim_is_group_224_4(source)) {
+ vty_out(vty,
+ "Invalid argument. Expected Valid Source Address.\n");
+ return CMD_WARNING;
+ }
+
+ if (!pim_is_group_224_4(group)) {
+ vty_out(vty,
+ "Invalid argument. Expected Valid Multicast Group Address.\n");
+ return CMD_WARNING;
+ }
+#endif
+
+ if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
+ return CMD_SUCCESS;
+
+ pim_addr_to_prefix(&nht_p, vif_source);
+ pim_addr_to_prefix(&grp, group);
+ memset(&nexthop, 0, sizeof(nexthop));
+
+ result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
+
+ if (!result) {
+ vty_out(vty,
+ "Nexthop Lookup failed, no usable routes returned.\n");
+ return CMD_SUCCESS;
+ }
+
+ pim_addr_dump("<grp?>", &grp, grp_str, sizeof(grp_str));
+
+ vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s\n", grp_str,
+ &nexthop.mrib_nexthop_addr, nexthop.interface->name);
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_nexthop_cmd_helper(const char *vrf, struct vty *vty)
+{
+ struct vrf *v;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+ pim_show_nexthop(v->info, vty);
+
+ return CMD_SUCCESS;
+}
+
void pim_show_nexthop(struct pim_instance *pim, struct vty *vty)
{
struct pnc_cache_walk_data cwd;
@@ -2503,6 +2746,61 @@ void pim_show_nexthop(struct pim_instance *pim, struct vty *vty)
hash_walk(pim->rpf_hash, pim_print_pnc_cache_walkcb, &cwd);
}
+int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,
+ const char *json, const char *interface)
+{
+ struct vrf *v;
+ json_object *json_parent = NULL;
+
+ v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+ if (!v)
+ return CMD_WARNING;
+
+ if (json)
+ json_parent = json_object_new_object();
+
+ if (interface)
+ pim_show_neighbors_single(v->info, vty, interface, json_parent);
+ else
+ pim_show_neighbors(v->info, vty, json_parent);
+
+ if (json)
+ vty_json(vty, json_parent);
+
+ return CMD_SUCCESS;
+}
+
+int pim_show_neighbors_vrf_all_cmd_helper(struct vty *vty, const char *json,
+ const char *interface)
+{
+ struct vrf *v;
+ json_object *json_parent = NULL;
+ json_object *json_vrf = NULL;
+
+ if (json)
+ json_parent = json_object_new_object();
+ RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
+ if (!json)
+ vty_out(vty, "VRF: %s\n", v->name);
+ else
+ json_vrf = json_object_new_object();
+
+ if (interface)
+ pim_show_neighbors_single(v->info, vty, interface,
+ json_vrf);
+ else
+ pim_show_neighbors(v->info, vty, json_vrf);
+
+ if (json)
+ json_object_object_add(json_parent, v->name, json_vrf);
+ }
+ if (json)
+ vty_json(vty, json_parent);
+
+ return CMD_SUCCESS;
+}
+
void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
const char *neighbor, json_object *json)
{
diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h
index 437d92897f..e1e48dd24a 100644
--- a/pimd/pim_cmd_common.h
+++ b/pimd/pim_cmd_common.h
@@ -83,11 +83,21 @@ bool pim_sgaddr_match(pim_sgaddr item, pim_sgaddr match);
void json_object_pim_ifp_add(struct json_object *json, struct interface *ifp);
void pim_print_ifp_flags(struct vty *vty, struct interface *ifp);
void json_object_pim_upstream_add(json_object *json, struct pim_upstream *up);
+int pim_show_join_cmd_helper(const char *vrf, struct vty *vty, pim_addr s_or_g,
+ pim_addr g, const char *json);
+int pim_show_join_vrf_all_cmd_helper(struct vty *vty, const char *json);
void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
json_object *json);
+int pim_show_jp_agg_list_cmd_helper(const char *vrf, struct vty *vty);
void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty);
+int pim_show_membership_cmd_helper(const char *vrf, struct vty *vty, bool uj);
void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj);
void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj);
+int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj);
+int pim_show_interface_cmd_helper(const char *vrf, struct vty *vty, bool uj,
+ bool mlag, const char *interface);
+int pim_show_interface_vrf_all_cmd_helper(struct vty *vty, bool uj, bool mlag,
+ const char *interface);
void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
json_object *json);
void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty,
@@ -95,7 +105,14 @@ void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty,
json_object *json);
void ip_pim_ssm_show_group_range(struct pim_instance *pim, struct vty *vty,
bool uj);
+int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty,
+ pim_addr source, pim_addr group);
+int pim_show_nexthop_cmd_helper(const char *vrf, struct vty *vty);
void pim_show_nexthop(struct pim_instance *pim, struct vty *vty);
+int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,
+ const char *json, const char *interface);
+int pim_show_neighbors_vrf_all_cmd_helper(struct vty *vty, const char *json,
+ const char *interface);
void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
const char *neighbor, json_object *json);
void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index 5b5cc2c103..8fa2c96034 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -255,7 +255,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
return 0;
}
- oil_if_set(channel_oil, pim_ifp->mroute_vif_index, false);
+ oil_if_set(channel_oil, pim_ifp->mroute_vif_index, 0);
/* clear mute; will be re-evaluated when the OIF becomes valid again */
channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~PIM_OIF_FLAG_MUTE;
@@ -544,27 +544,19 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
int pim_channel_oil_empty(struct channel_oil *c_oil)
{
-#if PIM_IPV == 4
- static struct mfcctl null_oil;
-#else
- static struct mf6cctl null_oil;
-#endif
+ static struct channel_oil null_oil;
if (!c_oil)
return 1;
-
/* exclude pimreg from the OIL when checking if the inherited_oil is
* non-NULL.
* pimreg device (in all vrfs) uses a vifi of
* 0 (PIM_OIF_PIM_REGISTER_VIF) so we simply mfcc_ttls[0] */
- if (oil_if_has(c_oil, 0)) {
-#if PIM_IPV == 4
- null_oil.mfcc_ttls[0] = 1;
-#else
- IF_SET(0, &null_oil.mf6cc_ifset);
-#endif
- }
+ if (oil_if_has(c_oil, 0))
+ oil_if_set(&null_oil, 0, 1);
+ else
+ oil_if_set(&null_oil, 0, 0);
- return !oil_if_cmp(&c_oil->oil, &null_oil);
+ return !oil_if_cmp(&c_oil->oil, &null_oil.oil);
}
diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h
index eed4b203cd..d0c4921d07 100644
--- a/pimd/pim_oil.h
+++ b/pimd/pim_oil.h
@@ -130,9 +130,9 @@ static inline vifi_t *oil_parent(struct channel_oil *c_oil)
return &c_oil->oil.mfcc_parent;
}
-static inline uint8_t oil_if_has(struct channel_oil *c_oil, vifi_t ifi)
+static inline bool oil_if_has(struct channel_oil *c_oil, vifi_t ifi)
{
- return c_oil->oil.mfcc_ttls[ifi];
+ return !!c_oil->oil.mfcc_ttls[ifi];
}
static inline void oil_if_set(struct channel_oil *c_oil, vifi_t ifi, uint8_t set)
@@ -166,7 +166,8 @@ static inline bool oil_if_has(struct channel_oil *c_oil, mifi_t ifi)
return !!IF_ISSET(ifi, &c_oil->oil.mf6cc_ifset);
}
-static inline void oil_if_set(struct channel_oil *c_oil, mifi_t ifi, bool set)
+static inline void oil_if_set(struct channel_oil *c_oil, mifi_t ifi,
+ uint8_t set)
{
if (set)
IF_SET(ifi, &c_oil->oil.mf6cc_ifset);
diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in
index 91829122ee..9d3d2b0643 100644
--- a/redhat/frr.spec.in
+++ b/redhat/frr.spec.in
@@ -779,11 +779,7 @@ sed -i 's/ -M rpki//' %{_sysconfdir}/frr/daemons
%changelog
-* Sun May 29 2022 Christian Hopps <chopps@labn.net> - %{version}
-- ospfclient:
-- Add OSPF API python client ospfclient.py
-
-* Tue Mar 1 2022 Martin Winter <mwinter@opensourcerouting.org> - %{version}
+* Tue Jun 7 2022 Donatas Abraitis <donatas@opensourcerouting.org> - %{version}
* Tue Mar 1 2022 Jafar Al-Gharaibeh <jafar@atcorp.com> - 8.2
- The FRRouting community would like to announce FRR Release 8.2.
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index 3f70dbddf7..a7d8b2c9b5 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -225,17 +225,9 @@ def run_frr_cmd(rnode, cmd, isjson=False):
if cmd:
ret_data = rnode.vtysh_cmd(cmd, isjson=isjson)
- if True:
- if isjson:
- print_data = json.dumps(ret_data)
- else:
- print_data = ret_data
- logger.info(
- "Output for command [%s] on router %s:\n%s",
- cmd,
- rnode.name,
- print_data,
- )
+ if isjson:
+ rnode.vtysh_cmd(cmd.rstrip("json"), isjson=False)
+
return ret_data
else:
diff --git a/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_static_routes_topo1.py b/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_static_routes_topo1.py
index afc91dd7ac..4d17da5f61 100755
--- a/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_static_routes_topo1.py
+++ b/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_static_routes_topo1.py
@@ -720,7 +720,7 @@ def test_pim_source_dr_functionality_while_rebooting_dr_non_dr_nodes_p1(request)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
- "R2 is transit router for R3 to reach R4, mroute should have (s, g) mroute with "
+ "R2 is transit router for I1 to reach R4, mroute should have (s, g) mroute with "
"OIL towards R4, using 'show ip mroute json'"
)
step(
@@ -787,7 +787,9 @@ def test_pim_source_dr_functionality_while_rebooting_dr_non_dr_nodes_p1(request)
step("Reboot R3 node")
stop_router(tgen, "r3")
- step("After reboot of R3 verify R1 became DR, using 'show ip pim interface json'")
+ step(
+ "After reboot of R3 verify R1 continues to be DR, using 'show ip pim interface json'"
+ )
result = verify_pim_config(tgen, input_dict_dr)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
@@ -834,7 +836,9 @@ def test_pim_source_dr_functionality_while_rebooting_dr_non_dr_nodes_p1(request)
step("Reboot R2 node")
stop_router(tgen, "r2")
- step("After reboot of R2, R1 became DR verify using 'show ip pim interface json'")
+ step(
+ "After reboot of R2, R1 continues to be DR verify using 'show ip pim interface json'"
+ )
result = verify_pim_config(tgen, input_dict_dr)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
@@ -843,9 +847,9 @@ def test_pim_source_dr_functionality_while_rebooting_dr_non_dr_nodes_p1(request)
"R3 and R2 should not have any mroute and upstream , verify using "
"'show ip mroute json' 'show ip pim upstream json'"
)
- step("R1 has mroute created with OIL towards R4 , using 'show ip mroute json'")
+ step("R1 has mroute created with empty OIL, using 'show ip mroute json'")
step(
- "R1 has upstream with Join Rej Prune , verify using 'show ip pim upstream json'"
+ "R1 has upstream with Not Join, Rej Prune , verify using 'show ip pim upstream json'"
)
for data in input_dict_r1_r2: