summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--babeld/babeld.c2
-rw-r--r--babeld/util.h2
-rw-r--r--bgpd/bgp_aspath.c83
-rw-r--r--bgpd/bgp_aspath.h16
-rw-r--r--bgpd/bgp_attr.c108
-rw-r--r--bgpd/bgp_attr_evpn.h1
-rw-r--r--bgpd/bgp_bfd.c19
-rw-r--r--bgpd/bgp_bfd.h2
-rw-r--r--bgpd/bgp_clist.c2
-rw-r--r--bgpd/bgp_debug.c22
-rw-r--r--bgpd/bgp_fsm.c37
-rw-r--r--bgpd/bgp_fsm.h1
-rw-r--r--bgpd/bgp_mplsvpn.c10
-rw-r--r--bgpd/bgp_network.c21
-rw-r--r--bgpd/bgp_network.h1
-rw-r--r--bgpd/bgp_nexthop.c13
-rw-r--r--bgpd/bgp_nexthop.h6
-rw-r--r--bgpd/bgp_packet.c15
-rw-r--r--bgpd/bgp_route.c31
-rw-r--r--bgpd/bgp_rpki.c58
-rw-r--r--bgpd/bgp_snmp.c4
-rw-r--r--bgpd/bgp_vty.c28
-rw-r--r--bgpd/bgpd.c26
-rw-r--r--bgpd/bgpd.h14
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c4
-rw-r--r--bgpd/rfapi/rfapi.c2
-rw-r--r--bgpd/rfapi/rfapi_import.c62
-rw-r--r--bgpd/rfapi/rfapi_rib.c16
-rw-r--r--bgpd/rfapi/rfapi_vty.c4
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c2
-rwxr-xr-xconfigure.ac296
-rw-r--r--doc/developer/cli.rst2
-rw-r--r--doc/manpages/conf.py2
-rw-r--r--doc/user/bgp.rst6
-rw-r--r--doc/user/overview.rst4
-rw-r--r--doc/user/pim.rst25
-rw-r--r--doc/user/sharp.rst17
-rw-r--r--eigrpd/eigrp_packet.c2
-rw-r--r--eigrpd/eigrp_routemap.c10
-rw-r--r--fpm/fpm.h2
-rw-r--r--isisd/isis_misc.c18
-rw-r--r--isisd/isis_pdu.c2
-rw-r--r--isisd/isis_tlvs.c4
-rw-r--r--isisd/isis_vty_fabricd.c16
-rw-r--r--ldpd/hello.c2
-rw-r--r--ldpd/interface.c2
-rw-r--r--ldpd/lde.c3
-rw-r--r--ldpd/ldpd.c2
-rw-r--r--ldpd/ldpd.h23
-rw-r--r--ldpd/ldpe.c11
-rw-r--r--ldpd/ldpe.h8
-rw-r--r--ldpd/logmsg.c2
-rw-r--r--ldpd/socket.c2
-rw-r--r--lib/agentx.c2
-rw-r--r--lib/buffer.c4
-rw-r--r--lib/getopt.h2
-rw-r--r--lib/if.c7
-rw-r--r--lib/md5.c4
-rw-r--r--lib/mlag.c28
-rw-r--r--lib/mlag.h9
-rw-r--r--lib/monotime.h20
-rw-r--r--lib/prefix.c2
-rw-r--r--lib/printf/printf-pos.c2
-rw-r--r--lib/routemap_northbound.c3
-rw-r--r--lib/seqlock.c4
-rw-r--r--lib/skiplist.c12
-rw-r--r--lib/sockopt.c2
-rw-r--r--lib/sockopt.h10
-rw-r--r--lib/sockunion.c10
-rw-r--r--lib/stream.h2
-rw-r--r--lib/systemd.c4
-rw-r--r--lib/thread.c2
-rw-r--r--lib/wheel.c4
-rw-r--r--lib/zclient.c2
-rw-r--r--m4/ax_python.m42
-rw-r--r--nhrpd/netlink_arp.c41
-rw-r--r--nhrpd/nhrp_cache.c88
-rw-r--r--nhrpd/nhrp_interface.c10
-rw-r--r--nhrpd/nhrp_nhs.c4
-rw-r--r--nhrpd/nhrp_peer.c166
-rw-r--r--nhrpd/nhrp_route.c12
-rw-r--r--nhrpd/nhrp_shortcut.c105
-rw-r--r--nhrpd/nhrp_vc.c4
-rw-r--r--nhrpd/nhrp_vty.c28
-rw-r--r--nhrpd/vici.c6
-rw-r--r--ospf6d/ospf6_abr.c96
-rw-r--r--ospf6d/ospf6_asbr.c64
-rw-r--r--ospf6d/ospf6_flood.c2
-rw-r--r--ospf6d/ospf6_intra.c65
-rw-r--r--ospf6d/ospf6_proto.h2
-rw-r--r--ospf6d/ospf6_snmp.c4
-rw-r--r--ospf6d/ospf6_spf.c2
-rw-r--r--ospf6d/ospf6_zebra.c2
-rw-r--r--ospfd/ospf_dump.c2
-rw-r--r--ospfd/ospf_lsa.c2
-rw-r--r--ospfd/ospf_nsm.c2
-rw-r--r--ospfd/ospf_packet.c6
-rw-r--r--ospfd/ospf_snmp.c8
-rw-r--r--ospfd/ospf_spf.c2
-rw-r--r--ospfd/ospf_vty.c5
-rw-r--r--ospfd/ospf_zebra.c4
-rw-r--r--ospfd/ospfd.c7
-rw-r--r--pbrd/pbr_map.c16
-rw-r--r--pbrd/pbr_nht.c17
-rw-r--r--pimd/pim_bfd.c15
-rw-r--r--pimd/pim_bsm.c26
-rw-r--r--pimd/pim_cmd.c361
-rw-r--r--pimd/pim_iface.c20
-rw-r--r--pimd/pim_iface.h1
-rw-r--r--pimd/pim_ifchannel.c105
-rw-r--r--pimd/pim_ifchannel.h19
-rw-r--r--pimd/pim_igmpv3.c8
-rw-r--r--pimd/pim_instance.c2
-rw-r--r--pimd/pim_instance.h3
-rw-r--r--pimd/pim_join.c24
-rw-r--r--pimd/pim_jp_agg.c4
-rw-r--r--pimd/pim_macro.c15
-rw-r--r--pimd/pim_memory.c2
-rw-r--r--pimd/pim_memory.h2
-rw-r--r--pimd/pim_mlag.c143
-rw-r--r--pimd/pim_mlag.h17
-rw-r--r--pimd/pim_mroute.c58
-rw-r--r--pimd/pim_msdp_socket.c4
-rw-r--r--pimd/pim_msg.c17
-rw-r--r--pimd/pim_neighbor.c11
-rw-r--r--pimd/pim_nht.c2
-rw-r--r--pimd/pim_oil.c22
-rw-r--r--pimd/pim_oil.h4
-rw-r--r--pimd/pim_register.c56
-rw-r--r--pimd/pim_rp.c12
-rw-r--r--pimd/pim_sock.c3
-rw-r--r--pimd/pim_static.c42
-rw-r--r--pimd/pim_tlv.c2
-rw-r--r--pimd/pim_upstream.c159
-rw-r--r--pimd/pim_upstream.h2
-rw-r--r--pimd/pim_vty.c10
-rw-r--r--pimd/pim_vxlan.c49
-rw-r--r--pimd/pim_vxlan.h2
-rw-r--r--pimd/pim_zebra.c14
-rw-r--r--pimd/pim_zpthread.c225
-rw-r--r--pimd/pimd.c4
-rw-r--r--pimd/subdir.am5
-rw-r--r--ripd/rip_interface.c2
-rw-r--r--ripd/rip_peer.c15
-rw-r--r--ripd/rip_snmp.c2
-rw-r--r--ripd/ripd.c2
-rw-r--r--ripngd/ripng_peer.c15
-rw-r--r--ripngd/ripngd.c4
-rw-r--r--sharpd/sharp_vty.c122
-rw-r--r--sharpd/sharp_zebra.c92
-rw-r--r--sharpd/sharp_zebra.h4
-rw-r--r--staticd/static_debug.h2
-rw-r--r--staticd/static_main.c2
-rw-r--r--staticd/static_vrf.c6
-rw-r--r--staticd/static_vrf.h1
-rw-r--r--staticd/static_vty.c2
-rw-r--r--tests/bgpd/test_aspath.c29
-rw-r--r--tests/bgpd/test_aspath.py2
-rw-r--r--tests/bgpd/test_mpath.c2
-rw-r--r--tests/isisd/test_fuzz_isis_tlv_tests.h.gzbin206007 -> 182891 bytes
-rwxr-xr-xtests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py9
-rw-r--r--tests/topotests/lib/bgp.py4
-rw-r--r--tests/topotests/pim-basic/r1/pimd.conf4
-rw-r--r--tests/topotests/pim-basic/r1/zebra.conf3
-rw-r--r--tests/topotests/pim-basic/r3/pimd.conf1
-rw-r--r--tests/topotests/pim-basic/r3/zebra.conf8
-rw-r--r--tests/topotests/pim-basic/rp/pimd.conf3
-rw-r--r--tests/topotests/pim-basic/test_pim.py13
-rw-r--r--tools/coccinelle/__func__.cocci (renamed from scripts/coccinelle/__func__.cocci)0
-rw-r--r--tools/coccinelle/bool_assignment.cocci (renamed from scripts/coccinelle/bool_assignment.cocci)0
-rw-r--r--tools/coccinelle/bool_expression.cocci (renamed from scripts/coccinelle/bool_expression.cocci)0
-rw-r--r--tools/coccinelle/bool_function.cocci (renamed from scripts/coccinelle/bool_function.cocci)0
-rw-r--r--tools/coccinelle/bool_function_type.cocci (renamed from scripts/coccinelle/bool_function_type.cocci)0
-rw-r--r--tools/coccinelle/replace_bgp_flag_functions.cocci (renamed from scripts/coccinelle/replace_bgp_flag_functions.cocci)0
-rw-r--r--tools/coccinelle/return_without_parenthesis.cocci (renamed from scripts/coccinelle/return_without_parenthesis.cocci)0
-rw-r--r--tools/coccinelle/s_addr_0_to_INADDR_ANY.cocci (renamed from scripts/coccinelle/s_addr_0_to_INADDR_ANY.cocci)0
-rw-r--r--tools/coccinelle/shorthand_operator.cocci (renamed from scripts/coccinelle/shorthand_operator.cocci)0
-rw-r--r--tools/coccinelle/test_after_assert.cocci (renamed from scripts/coccinelle/test_after_assert.cocci)0
-rw-r--r--tools/coccinelle/void_no_return.cocci (renamed from scripts/coccinelle/void_no_return.cocci)0
-rw-r--r--vrrpd/vrrp.c56
-rw-r--r--vrrpd/vrrp_debug.h14
-rwxr-xr-xvtysh/extract.pl.in4
-rw-r--r--vtysh/vtysh.c2
-rw-r--r--vtysh/vtysh_main.c2
-rw-r--r--zebra/if_netlink.c30
-rw-r--r--zebra/ipforward_sysctl.c12
-rw-r--r--zebra/irdp_main.c2
-rw-r--r--zebra/irdp_packet.c2
-rw-r--r--zebra/kernel_netlink.c26
-rw-r--r--zebra/kernel_socket.c2
-rw-r--r--zebra/main.c9
-rw-r--r--zebra/redistribute.c4
-rw-r--r--zebra/rt_netlink.c143
-rw-r--r--zebra/rtadv.c23
-rw-r--r--zebra/rtread_getmsg.c2
-rw-r--r--zebra/zapi_msg.c37
-rw-r--r--zebra/zebra_dplane.c4
-rw-r--r--zebra/zebra_fpm_netlink.c3
-rw-r--r--zebra/zebra_gr.c3
-rw-r--r--zebra/zebra_mlag.c85
-rw-r--r--zebra/zebra_mlag.h1
-rw-r--r--zebra/zebra_mlag_private.c7
-rw-r--r--zebra/zebra_nhg.c35
-rw-r--r--zebra/zebra_pbr.c2
-rw-r--r--zebra/zebra_rnh.c4
-rw-r--r--zebra/zebra_routemap.c9
-rw-r--r--zebra/zebra_routemap.h1
-rw-r--r--zebra/zebra_vty.c71
-rw-r--r--zebra/zebra_vxlan.c81
-rw-r--r--zebra/zebra_vxlan.h2
-rw-r--r--zebra/zserv.c42
212 files changed, 2980 insertions, 1548 deletions
diff --git a/.gitignore b/.gitignore
index 226dca09d0..8c61aeb9c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,12 @@
*.pb.cc
*_clippy.c
+### gcov outputs
+
+*.gcno
+*.gcov
+*.gcda
+
### dist
*.tar.?z
@@ -96,3 +102,4 @@ compile_commands.json
.dirstamp
refix
.vscode
+.kitchen
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 83a2a3137c..a7a3481998 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -138,7 +138,7 @@ babel_create_routing_process (void)
assert (babel_routing_process == NULL);
/* Allocaste Babel instance. */
- babel_routing_process = XCALLOC (MTYPE_BABEL, sizeof (struct babel));
+ babel_routing_process = XCALLOC(MTYPE_BABEL, sizeof(struct babel));
/* Initialize timeouts */
gettime(&babel_now);
diff --git a/babeld/util.h b/babeld/util.h
index 00a025ff93..9310040571 100644
--- a/babeld/util.h
+++ b/babeld/util.h
@@ -122,7 +122,7 @@ void uchar_to_inaddr(struct in_addr *dest, const unsigned char *src);
void in6addr_to_uchar(unsigned char *dest, const struct in6_addr *src);
void uchar_to_in6addr(struct in6_addr *dest, const unsigned char *src);
int daemonise(void);
-const unsigned char v4prefix[16];
+extern const unsigned char v4prefix[16];
/* If debugging is disabled, we want to avoid calling format_address
for every omitted debugging message. So debug is a macro. But
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 7b8b8d94a6..44962f5af3 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -41,9 +41,9 @@
#define AS_HEADER_SIZE 2
/* Now FOUR octets are used for AS value. */
-#define AS_VALUE_SIZE sizeof (as_t)
+#define AS_VALUE_SIZE sizeof(as_t)
/* This is the old one */
-#define AS16_VALUE_SIZE sizeof (as16_t)
+#define AS16_VALUE_SIZE sizeof(as16_t)
/* Maximum protocol segment length value */
#define AS_SEGMENT_MAX 255
@@ -132,8 +132,7 @@ static void assegment_free(struct assegment *seg)
if (!seg)
return;
- if (seg->as)
- assegment_data_free(seg->as);
+ assegment_data_free(seg->as);
memset(seg, 0xfe, sizeof(struct assegment));
XFREE(MTYPE_AS_SEG, seg);
@@ -429,6 +428,22 @@ bool aspath_check_as_sets(struct aspath *aspath)
return false;
}
+/* Check if aspath has BGP_AS_ZERO */
+bool aspath_check_as_zero(struct aspath *aspath)
+{
+ struct assegment *seg = aspath->segments;
+ unsigned int i;
+
+ while (seg) {
+ for (i = 0; i < seg->length; i++)
+ if (seg->as[i] == BGP_AS_ZERO)
+ return true;
+ seg = seg->next;
+ }
+
+ return false;
+}
+
/* Estimate size aspath /might/ take if encoded into an
* ASPATH attribute.
*
@@ -477,7 +492,7 @@ as_t aspath_leftmost(struct aspath *aspath)
}
/* Return 1 if there are any 4-byte ASes in the path */
-unsigned int aspath_has_as4(struct aspath *aspath)
+bool aspath_has_as4(struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
unsigned int i;
@@ -485,10 +500,10 @@ unsigned int aspath_has_as4(struct aspath *aspath)
while (seg) {
for (i = 0; i < seg->length; i++)
if (seg->as[i] > BGP_AS_MAX)
- return 1;
+ return true;
seg = seg->next;
}
- return 0;
+ return false;
}
/* Convert aspath structure to string expression. */
@@ -768,7 +783,7 @@ static int assegments_parse(struct stream *s, size_t length,
* on more, than 8 bits (otherwise it's a warning, bug
* #564).
*/
- || ((sizeof segh.length > 1)
+ || ((sizeof(segh.length) > 1)
&& (0x10 + segh.length > 0x10 + AS_SEGMENT_MAX))) {
if (head)
assegment_free_all(head);
@@ -1114,16 +1129,16 @@ struct aspath *aspath_aggregate(struct aspath *as1, struct aspath *as2)
/* When a BGP router receives an UPDATE with an MP_REACH_NLRI
attribute, check the leftmost AS number in the AS_PATH attribute is
or not the peer's AS number. */
-int aspath_firstas_check(struct aspath *aspath, as_t asno)
+bool aspath_firstas_check(struct aspath *aspath, as_t asno)
{
if ((aspath == NULL) || (aspath->segments == NULL))
- return 0;
+ return false;
if (aspath->segments && (aspath->segments->type == AS_SEQUENCE)
&& (aspath->segments->as[0] == asno))
- return 1;
+ return true;
- return 0;
+ return false;
}
unsigned int aspath_get_first_as(struct aspath *aspath)
@@ -1179,12 +1194,12 @@ int aspath_loop_check(struct aspath *aspath, as_t asno)
}
/* When all of AS path is private AS return 1. */
-int aspath_private_as_check(struct aspath *aspath)
+bool aspath_private_as_check(struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
@@ -1193,20 +1208,20 @@ int aspath_private_as_check(struct aspath *aspath)
for (i = 0; i < seg->length; i++) {
if (!BGP_AS_IS_PRIVATE(seg->as[i]))
- return 0;
+ return false;
}
seg = seg->next;
}
- return 1;
+ return true;
}
/* Return True if the entire ASPATH consist of the specified ASN */
-int aspath_single_asn_check(struct aspath *aspath, as_t asn)
+bool aspath_single_asn_check(struct aspath *aspath, as_t asn)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
@@ -1215,11 +1230,11 @@ int aspath_single_asn_check(struct aspath *aspath, as_t asn)
for (i = 0; i < seg->length; i++) {
if (seg->as[i] != asn)
- return 0;
+ return false;
}
seg = seg->next;
}
- return 1;
+ return true;
}
/* Replace all instances of the target ASN with our own ASN */
@@ -1338,37 +1353,37 @@ struct aspath *aspath_remove_private_asns(struct aspath *aspath, as_t peer_asn)
/* AS path confed check. If aspath contains confed set or sequence then return
* 1. */
-int aspath_confed_check(struct aspath *aspath)
+bool aspath_confed_check(struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
- return 0;
+ return false;
seg = aspath->segments;
while (seg) {
if (seg->type == AS_CONFED_SET
|| seg->type == AS_CONFED_SEQUENCE)
- return 1;
+ return true;
seg = seg->next;
}
- return 0;
+ return false;
}
/* Leftmost AS path segment confed check. If leftmost AS segment is of type
AS_CONFED_SEQUENCE or AS_CONFED_SET then return 1. */
-int aspath_left_confed_check(struct aspath *aspath)
+bool aspath_left_confed_check(struct aspath *aspath)
{
if (!(aspath && aspath->segments))
- return 0;
+ return false;
if ((aspath->segments->type == AS_CONFED_SEQUENCE)
|| (aspath->segments->type == AS_CONFED_SET))
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Merge as1 to as2. as2 should be uninterned aspath. */
@@ -1605,13 +1620,13 @@ struct aspath *aspath_add_seq(struct aspath *aspath, as_t asno)
/* Compare leftmost AS value for MED check. If as1's leftmost AS and
as2's leftmost AS is same return 1. */
-int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
+bool aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
{
const struct assegment *seg1;
const struct assegment *seg2;
if (!(aspath1 && aspath2))
- return 0;
+ return false;
seg1 = aspath1->segments;
seg2 = aspath2->segments;
@@ -1619,7 +1634,7 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
/* If both paths are originated in this AS then we do want to compare
* MED */
if (!seg1 && !seg2)
- return 1;
+ return true;
/* find first non-confed segments for each */
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
@@ -1633,12 +1648,12 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
/* Check as1's */
if (!(seg1 && seg2 && (seg1->type == AS_SEQUENCE)
&& (seg2->type == AS_SEQUENCE)))
- return 0;
+ return false;
if (seg1->as[0] == seg2->as[0])
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Truncate an aspath after a number of hops, and put the hops remaining
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index a4427714ba..9df352fcd6 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -39,6 +39,7 @@
#define BGP_PRIVATE_AS4_MAX 4294967294U
/* we leave BGP_AS_MAX as the 16bit AS MAX number. */
+#define BGP_AS_ZERO 0
#define BGP_AS_MAX 65535U
#define BGP_AS4_MAX 4294967295U
/* Transition 16Bit AS as defined by IANA */
@@ -87,7 +88,7 @@ extern struct aspath *aspath_add_seq_n(struct aspath *, as_t, unsigned);
extern struct aspath *aspath_add_seq(struct aspath *, as_t);
extern struct aspath *aspath_add_confed_seq(struct aspath *, as_t);
extern bool aspath_cmp(const void *as1, const void *as2);
-extern int aspath_cmp_left(const struct aspath *, const struct aspath *);
+extern bool aspath_cmp_left(const struct aspath *, const struct aspath *);
extern bool aspath_cmp_left_confed(const struct aspath *as1,
const struct aspath *as2xs);
extern struct aspath *aspath_delete_confed_seq(struct aspath *);
@@ -106,8 +107,8 @@ extern unsigned int aspath_key_make(const void *);
extern unsigned int aspath_get_first_as(struct aspath *);
extern unsigned int aspath_get_last_as(struct aspath *);
extern int aspath_loop_check(struct aspath *, as_t);
-extern int aspath_private_as_check(struct aspath *);
-extern int aspath_single_asn_check(struct aspath *, as_t asn);
+extern bool aspath_private_as_check(struct aspath *);
+extern bool aspath_single_asn_check(struct aspath *, as_t asn);
extern struct aspath *aspath_replace_specific_asn(struct aspath *aspath,
as_t target_asn,
as_t our_asn);
@@ -115,12 +116,13 @@ extern struct aspath *aspath_replace_private_asns(struct aspath *aspath,
as_t asn, as_t peer_asn);
extern struct aspath *aspath_remove_private_asns(struct aspath *aspath,
as_t peer_asn);
-extern int aspath_firstas_check(struct aspath *, as_t);
-extern int aspath_confed_check(struct aspath *);
-extern int aspath_left_confed_check(struct aspath *);
+extern bool aspath_firstas_check(struct aspath *, as_t);
+extern bool aspath_confed_check(struct aspath *);
+extern bool aspath_left_confed_check(struct aspath *);
extern unsigned long aspath_count(void);
extern unsigned int aspath_count_hops(const struct aspath *);
extern bool aspath_check_as_sets(struct aspath *aspath);
+extern bool aspath_check_as_zero(struct aspath *aspath);
extern unsigned int aspath_count_confeds(struct aspath *);
extern unsigned int aspath_size(struct aspath *);
extern as_t aspath_highest(struct aspath *);
@@ -128,7 +130,7 @@ extern as_t aspath_leftmost(struct aspath *);
extern size_t aspath_put(struct stream *, struct aspath *, int);
extern struct aspath *aspath_reconcile_as4(struct aspath *, struct aspath *);
-extern unsigned int aspath_has_as4(struct aspath *);
+extern bool aspath_has_as4(struct aspath *);
/* For SNMP BGP4PATHATTRASPATHSEGMENT, might be useful for debug */
extern uint8_t *aspath_snmp_pathseg(struct aspath *, size_t *);
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index f00bb2b3cd..7c15fd3711 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -47,7 +47,7 @@
#include "bgpd/bgp_lcommunity.h"
#include "bgpd/bgp_updgrp.h"
#include "bgpd/bgp_encap_types.h"
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
#include "bgpd/rfapi/bgp_rfapi_cfg.h"
#include "bgp_encap_types.h"
#include "bgp_vnc_types.h"
@@ -79,7 +79,7 @@ static const struct message attr_str[] = {
{BGP_ATTR_AS_PATHLIMIT, "AS_PATHLIMIT"},
{BGP_ATTR_PMSI_TUNNEL, "PMSI_TUNNEL_ATTRIBUTE"},
{BGP_ATTR_ENCAP, "ENCAP"},
-#if ENABLE_BGP_VNC_ATTR
+#ifdef ENABLE_BGP_VNC_ATTR
{BGP_ATTR_VNC, "VNC"},
#endif
{BGP_ATTR_LARGE_COMMUNITIES, "LARGE_COMMUNITY"},
@@ -199,7 +199,7 @@ static void cluster_finish(void)
}
static struct hash *encap_hash = NULL;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
static struct hash *vnc_hash = NULL;
#endif
static struct hash *srv6_l3vpn_hash;
@@ -247,7 +247,7 @@ void bgp_attr_flush_encap(struct attr *attr)
encap_free(attr->encap_subtlvs);
attr->encap_subtlvs = NULL;
}
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs) {
encap_free(attr->vnc_subtlvs);
attr->vnc_subtlvs = NULL;
@@ -309,7 +309,7 @@ static void *encap_hash_alloc(void *p)
typedef enum {
ENCAP_SUBTLV_TYPE,
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
VNC_SUBTLV_TYPE
#endif
} encap_subtlv_type;
@@ -319,7 +319,7 @@ encap_intern(struct bgp_attr_encap_subtlv *encap, encap_subtlv_type type)
{
struct bgp_attr_encap_subtlv *find;
struct hash *hash = encap_hash;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (type == VNC_SUBTLV_TYPE)
hash = vnc_hash;
#endif
@@ -341,7 +341,7 @@ static void encap_unintern(struct bgp_attr_encap_subtlv **encapp,
if (encap->refcnt == 0) {
struct hash *hash = encap_hash;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (type == VNC_SUBTLV_TYPE)
hash = vnc_hash;
#endif
@@ -368,7 +368,7 @@ static void encap_init(void)
{
encap_hash = hash_create(encap_hash_key_make, encap_hash_cmp,
"BGP Encap Hash");
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
vnc_hash = hash_create(encap_hash_key_make, encap_hash_cmp,
"BGP VNC Hash");
#endif
@@ -379,7 +379,7 @@ static void encap_finish(void)
hash_clean(encap_hash, (void (*)(void *))encap_free);
hash_free(encap_hash);
encap_hash = NULL;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
hash_clean(vnc_hash, (void (*)(void *))encap_free);
hash_free(vnc_hash);
vnc_hash = NULL;
@@ -660,7 +660,7 @@ unsigned int attrhash_key_make(const void *p)
MIX(transit_hash_key_make(attr->transit));
if (attr->encap_subtlvs)
MIX(encap_hash_key_make(attr->encap_subtlvs));
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs)
MIX(encap_hash_key_make(attr->vnc_subtlvs));
#endif
@@ -698,7 +698,7 @@ bool attrhash_cmp(const void *p1, const void *p2)
&& attr1->rmap_table_id == attr2->rmap_table_id
&& (attr1->encap_tunneltype == attr2->encap_tunneltype)
&& encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs)
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
&& encap_same(attr1->vnc_subtlvs, attr2->vnc_subtlvs)
#endif
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_global,
@@ -780,7 +780,7 @@ static void *bgp_attr_hash_alloc(void *p)
if (val->encap_subtlvs) {
val->encap_subtlvs = NULL;
}
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (val->vnc_subtlvs) {
val->vnc_subtlvs = NULL;
}
@@ -856,7 +856,7 @@ struct attr *bgp_attr_intern(struct attr *attr)
else
attr->srv6_vpn->refcnt++;
}
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs) {
if (!attr->vnc_subtlvs->refcnt)
attr->vnc_subtlvs = encap_intern(attr->vnc_subtlvs,
@@ -1041,7 +1041,7 @@ void bgp_attr_unintern_sub(struct attr *attr)
if (attr->encap_subtlvs)
encap_unintern(&attr->encap_subtlvs, ENCAP_SUBTLV_TYPE);
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs)
encap_unintern(&attr->vnc_subtlvs, VNC_SUBTLV_TYPE);
#endif
@@ -1125,7 +1125,7 @@ void bgp_attr_flush(struct attr *attr)
encap_free(attr->encap_subtlvs);
attr->encap_subtlvs = NULL;
}
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs && !attr->vnc_subtlvs->refcnt) {
encap_free(attr->vnc_subtlvs);
attr->vnc_subtlvs = NULL;
@@ -1398,6 +1398,15 @@ static int bgp_attr_aspath(struct bgp_attr_parser_args *args)
0);
}
+ /* Codification of AS 0 Processing */
+ if (aspath_check_as_zero(attr->aspath)) {
+ flog_err(EC_BGP_ATTR_MAL_AS_PATH,
+ "Malformed AS path, contains BGP_AS_ZERO(0) from %s",
+ peer->host);
+ return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
+ 0);
+ }
+
/* Set aspath attribute flag. */
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AS_PATH);
@@ -1469,6 +1478,15 @@ static int bgp_attr_as4_path(struct bgp_attr_parser_args *args,
0);
}
+ /* Codification of AS 0 Processing */
+ if (aspath_check_as_zero(*as4_path)) {
+ flog_err(EC_BGP_ATTR_MAL_AS_PATH,
+ "Malformed AS4 path, contains BGP_AS_ZERO(0) from %s",
+ peer->host);
+ return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
+ 0);
+ }
+
/* Set aspath attribute flag. */
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AS4_PATH);
@@ -1615,6 +1633,7 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args)
struct peer *const peer = args->peer;
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
+ as_t aggregator_as;
int wantedlen = 6;
@@ -1632,9 +1651,19 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args)
}
if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV))
- attr->aggregator_as = stream_getl(peer->curr);
+ aggregator_as = stream_getl(peer->curr);
else
- attr->aggregator_as = stream_getw(peer->curr);
+ aggregator_as = stream_getw(peer->curr);
+
+ /* Codification of AS 0 Processing */
+ if (aggregator_as == BGP_AS_ZERO) {
+ flog_err(EC_BGP_ATTR_LEN,
+ "AGGREGATOR attribute is BGP_AS_ZERO(0)");
+ return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
+ args->total);
+ }
+
+ attr->aggregator_as = aggregator_as;
attr->aggregator_addr.s_addr = stream_get_ipv4(peer->curr);
/* Set atomic aggregate flag. */
@@ -1652,6 +1681,7 @@ bgp_attr_as4_aggregator(struct bgp_attr_parser_args *args,
struct peer *const peer = args->peer;
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
+ as_t aggregator_as;
if (length != 8) {
flog_err(EC_BGP_ATTR_LEN, "New Aggregator length is not 8 [%d]",
@@ -1660,7 +1690,16 @@ bgp_attr_as4_aggregator(struct bgp_attr_parser_args *args,
0);
}
- *as4_aggregator_as = stream_getl(peer->curr);
+ /* Codification of AS 0 Processing */
+ aggregator_as = stream_getl(peer->curr);
+ if (aggregator_as == BGP_AS_ZERO) {
+ flog_err(EC_BGP_ATTR_LEN,
+ "AS4_AGGREGATOR attribute is BGP_AS_ZERO(0)");
+ return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
+ 0);
+ }
+
+ *as4_aggregator_as = aggregator_as;
as4_aggregator_addr->s_addr = stream_get_ipv4(peer->curr);
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AS4_AGGREGATOR);
@@ -2265,7 +2304,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
subtype = stream_getc(BGP_INPUT(peer));
sublength = stream_getc(BGP_INPUT(peer));
length -= 2;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
} else {
subtype = stream_getw(BGP_INPUT(peer));
sublength = stream_getw(BGP_INPUT(peer));
@@ -2304,7 +2343,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
} else {
attr->encap_subtlvs = tlv;
}
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
} else {
struct bgp_attr_encap_subtlv *stlv_last;
for (stlv_last = attr->vnc_subtlvs;
@@ -2506,9 +2545,14 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,
}
/* Configure from Info */
- attr->srv6_vpn = XMALLOC(MTYPE_BGP_SRV6_VPN,
+ if (attr->srv6_vpn) {
+ flog_err(EC_BGP_ATTRIBUTE_REPEATED,
+ "Prefix SID SRv6 VPN field repeated");
+ return bgp_attr_malformed(
+ args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total);
+ }
+ attr->srv6_vpn = XCALLOC(MTYPE_BGP_SRV6_VPN,
sizeof(struct bgp_attr_srv6_vpn));
- attr->srv6_vpn->refcnt = 0;
attr->srv6_vpn->sid_flags = sid_flags;
sid_copy(&attr->srv6_vpn->sid, &ipv6_sid);
}
@@ -2543,7 +2587,13 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,
}
/* Configure from Info */
- attr->srv6_l3vpn = XMALLOC(MTYPE_BGP_SRV6_L3VPN,
+ if (attr->srv6_l3vpn) {
+ flog_err(EC_BGP_ATTRIBUTE_REPEATED,
+ "Prefix SID SRv6 L3VPN field repeated");
+ return bgp_attr_malformed(
+ args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total);
+ }
+ attr->srv6_l3vpn = XCALLOC(MTYPE_BGP_SRV6_L3VPN,
sizeof(struct bgp_attr_srv6_l3vpn));
attr->srv6_l3vpn->sid_flags = sid_flags;
attr->srv6_l3vpn->endpoint_behavior = endpoint_behavior;
@@ -3008,7 +3058,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
case BGP_ATTR_EXT_COMMUNITIES:
ret = bgp_attr_ext_communities(&attr_args);
break;
-#if ENABLE_BGP_VNC_ATTR
+#ifdef ENABLE_BGP_VNC_ATTR
case BGP_ATTR_VNC:
#endif
case BGP_ATTR_ENCAP:
@@ -3160,7 +3210,7 @@ done:
if (attr->encap_subtlvs)
attr->encap_subtlvs = encap_intern(attr->encap_subtlvs,
ENCAP_SUBTLV_TYPE);
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs)
attr->vnc_subtlvs = encap_intern(attr->vnc_subtlvs,
VNC_SUBTLV_TYPE);
@@ -3179,7 +3229,7 @@ done:
assert(attr->transit->refcnt > 0);
if (attr->encap_subtlvs)
assert(attr->encap_subtlvs->refcnt > 0);
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
if (attr->vnc_subtlvs)
assert(attr->vnc_subtlvs->refcnt > 0);
#endif
@@ -3429,7 +3479,7 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
attrhdrlen = 1 + 1; /* subTLV T + L */
break;
-#if ENABLE_BGP_VNC_ATTR
+#ifdef ENABLE_BGP_VNC_ATTR
case BGP_ATTR_VNC:
attrname = "VNC";
subtlvs = attr->vnc_subtlvs;
@@ -3480,7 +3530,7 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
if (attrtype == BGP_ATTR_ENCAP) {
stream_putc(s, st->type);
stream_putc(s, st->length);
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
} else {
stream_putw(s, st->type);
stream_putw(s, st->length);
@@ -3965,7 +4015,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
/* Tunnel Encap attribute */
bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_ENCAP);
-#if ENABLE_BGP_VNC_ATTR
+#ifdef ENABLE_BGP_VNC_ATTR
/* VNC attribute */
bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_VNC);
#endif
diff --git a/bgpd/bgp_attr_evpn.h b/bgpd/bgp_attr_evpn.h
index a8a35e8174..25654ba709 100644
--- a/bgpd/bgp_attr_evpn.h
+++ b/bgpd/bgp_attr_evpn.h
@@ -34,7 +34,6 @@
#define MAX_ET 0xffffffff
-unsigned long eth_tag_id;
struct attr;
/* EVPN ESI */
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 1f650aaeb7..5f4db3dfa8 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -200,6 +200,25 @@ static void bgp_bfd_update_peer(struct peer *peer)
bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_UPDATE);
}
+/**
+ * bgp_bfd_reset_peer - reinitialise bfd
+ * ensures that bfd state machine is restarted
+ * to be synced with remote bfd
+ */
+void bgp_bfd_reset_peer(struct peer *peer)
+{
+ struct bfd_info *bfd_info;
+
+ if (!peer->bfd_info)
+ return;
+ bfd_info = (struct bfd_info *)peer->bfd_info;
+
+ /* if status is not down, reset bfd */
+ if (bfd_info->status != BFD_STATUS_DOWN)
+ bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
+ bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
+}
+
/*
* bgp_bfd_update_type - update session type with BFD through zebra.
*/
diff --git a/bgpd/bgp_bfd.h b/bgpd/bgp_bfd.h
index caa5651e3a..b96ebb6c96 100644
--- a/bgpd/bgp_bfd.h
+++ b/bgpd/bgp_bfd.h
@@ -31,6 +31,8 @@ extern void bgp_bfd_register_peer(struct peer *peer);
extern void bgp_bfd_deregister_peer(struct peer *peer);
+extern void bgp_bfd_reset_peer(struct peer *peer);
+
extern void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer,
char *addr);
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index 18369002b8..5c461dbe77 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -654,7 +654,7 @@ community_regexp_delete (struct community *com, regex_t * reg)
i = 0;
while (i < com->size)
{
- memcpy (&comval, com_nthval (com, i), sizeof (uint32_t));
+ memcpy (&comval, com_nthval (com, i), sizeof(uint32_t));
comval = ntohl (comval);
switch (comval) {
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index c69bc52e47..2e21c7222c 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -170,6 +170,16 @@ static const struct message bgp_notify_capability_msg[] = {
{BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
{0}};
+static const struct message bgp_notify_fsm_msg[] = {
+ {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC, "/Unspecific"},
+ {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT,
+ "/Receive Unexpected Message in OpenSent State"},
+ {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM,
+ "/Receive Unexpected Message in OpenConfirm State"},
+ {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED,
+ "/Receive Unexpected Message in Established State"},
+ {0}};
+
/* Origin strings. */
const char *const bgp_origin_str[] = {"i", "e", "?"};
const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"};
@@ -209,13 +219,8 @@ static void bgp_debug_list_free(struct list *list)
if (list)
for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) {
listnode_delete(list, filter);
-
- if (filter->p)
- prefix_free(&filter->p);
-
- if (filter->host)
- XFREE(MTYPE_BGP_DEBUG_STR, filter->host);
-
+ prefix_free(&filter->p);
+ XFREE(MTYPE_BGP_DEBUG_STR, filter->host);
XFREE(MTYPE_BGP_DEBUG_FILTER, filter);
}
}
@@ -476,7 +481,8 @@ const char *bgp_notify_subcode_str(char code, char subcode)
case BGP_NOTIFY_HOLD_ERR:
break;
case BGP_NOTIFY_FSM_ERR:
- break;
+ return lookup_msg(bgp_notify_fsm_msg, subcode,
+ "Unrecognized Error Subcode");
case BGP_NOTIFY_CEASE:
return lookup_msg(bgp_notify_cease_msg, subcode,
"Unrecognized Error Subcode");
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index a44effaac5..f4fbfe4c60 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -885,6 +885,27 @@ void bgp_maxmed_update(struct bgp *bgp)
}
}
+int bgp_fsm_error_subcode(int status)
+{
+ int fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC;
+
+ switch (status) {
+ case OpenSent:
+ fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT;
+ break;
+ case OpenConfirm:
+ fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM;
+ break;
+ case Established:
+ fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED;
+ break;
+ default:
+ break;
+ }
+
+ return fsm_err_subcode;
+}
+
/* The maxmed onstartup timer expiry callback. */
static int bgp_maxmed_onstartup_timer(struct thread *thread)
{
@@ -1128,6 +1149,10 @@ int bgp_stop(struct peer *peer)
peer->nsf_af_count = 0;
+ /* deregister peer */
+ if (peer->last_reset == PEER_DOWN_UPDATE_SOURCE_CHANGE)
+ bgp_bfd_deregister_peer(peer);
+
if (peer_dynamic_neighbor(peer)
&& !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) {
if (bgp_debug_neighbor_events(peer))
@@ -1451,9 +1476,8 @@ static int bgp_connect_success(struct peer *peer)
flog_err_sys(EC_LIB_SOCKET,
"%s: bgp_getsockname(): failed for peer %s, fd %d",
__func__, peer->host, peer->fd);
- bgp_notify_send(
- peer, BGP_NOTIFY_FSM_ERR,
- BGP_NOTIFY_SUBCODE_UNSPECIFIC); /* internal error */
+ bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
+ bgp_fsm_error_subcode(peer->status));
bgp_writes_on(peer);
return -1;
}
@@ -1653,7 +1677,8 @@ static int bgp_fsm_event_error(struct peer *peer)
flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s",
peer->host, lookup_msg(bgp_status_msg, peer->status, NULL));
- return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR, 0);
+ return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR,
+ bgp_fsm_error_subcode(peer->status));
}
/* Hold timer expire. This is error of BGP connection. So cut the
@@ -1931,7 +1956,7 @@ static int bgp_establish(struct peer *peer)
hash_release(peer->bgp->peerhash, peer);
hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
- bgp_bfd_register_peer(peer);
+ bgp_bfd_reset_peer(peer);
return ret;
}
@@ -2512,7 +2537,7 @@ int bgp_neighbor_graceful_restart(struct peer *peer, int peer_gr_cmd)
peer->peer_gr_present_state = peer_new_state;
if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
zlog_debug(
- "[BGP_GR] Succesfully change the state of the peer to : %s : !",
+ "[BGP_GR] Successfully change the state of the peer to : %s : !",
print_peer_gr_mode(peer_new_state));
return BGP_GR_SUCCESS;
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index 6feabbf570..4b8db161d7 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -121,6 +121,7 @@ extern void bgp_update_delay_end(struct bgp *);
extern void bgp_maxmed_update(struct bgp *);
extern int bgp_maxmed_onstartup_configured(struct bgp *);
extern int bgp_maxmed_onstartup_active(struct bgp *);
+extern int bgp_fsm_error_subcode(int status);
/**
* Start the route advertisement timer (that honors MRAI) for all the
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 86c04b71f0..8758d0ca78 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1532,7 +1532,10 @@ void vpn_handle_router_id_update(struct bgp *bgp, bool withdraw,
ecom = bgp->vpn_policy[afi].rtlist[edir];
for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].
export_vrf, node, vname)) {
- bgp_import = bgp_lookup_by_name(vname);
+ if (strcmp(vname, VRF_DEFAULT_NAME) == 0)
+ bgp_import = bgp_get_default();
+ else
+ bgp_import = bgp_lookup_by_name(vname);
if (!bgp_import)
continue;
@@ -1572,7 +1575,10 @@ void vpn_handle_router_id_update(struct bgp *bgp, bool withdraw,
ecom = bgp->vpn_policy[afi].rtlist[edir];
for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].
export_vrf, node, vname)) {
- bgp_import = bgp_lookup_by_name(vname);
+ if (strcmp(vname, VRF_DEFAULT_NAME) == 0)
+ bgp_import = bgp_get_default();
+ else
+ bgp_import = bgp_lookup_by_name(vname);
if (!bgp_import)
continue;
if (bgp_import->vpn_policy[afi].rtlist[idir])
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 8759a88444..037aeec288 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -57,8 +57,26 @@ struct bgp_listener {
union sockunion su;
struct thread *thread;
struct bgp *bgp;
+ char *name;
};
+void bgp_dump_listener_info(struct vty *vty)
+{
+ struct listnode *node;
+ struct bgp_listener *listener;
+
+ vty_out(vty, "Name fd Address\n");
+ vty_out(vty, "---------------------------\n");
+ for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) {
+ char buf[SU_ADDRSTRLEN];
+
+ vty_out(vty, "%-16s %d %s\n",
+ listener->name ? listener->name : VRF_DEFAULT_NAME,
+ listener->fd,
+ sockunion2str(&listener->su, buf, sizeof(buf)));
+ }
+}
+
/*
* Set MD5 key for the socket, for the given IPv4 peer address.
* If the password is NULL or zero-length, the option will be disabled.
@@ -762,6 +780,7 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
listener = XCALLOC(MTYPE_BGP_LISTENER, sizeof(*listener));
listener->fd = sock;
+ listener->name = XSTRDUP(MTYPE_BGP_LISTENER, bgp->name);
/* this socket needs a change of ns. record bgp back pointer */
if (bgp->vrf_id != VRF_DEFAULT && vrf_is_backend_netns())
@@ -871,6 +890,7 @@ void bgp_close_vrf_socket(struct bgp *bgp)
thread_cancel(listener->thread);
close(listener->fd);
listnode_delete(bm->listen_sockets, listener);
+ XFREE(MTYPE_BGP_LISTENER, listener->name);
XFREE(MTYPE_BGP_LISTENER, listener);
}
}
@@ -892,6 +912,7 @@ void bgp_close(void)
thread_cancel(listener->thread);
close(listener->fd);
listnode_delete(bm->listen_sockets, listener);
+ XFREE(MTYPE_BGP_LISTENER, listener->name);
XFREE(MTYPE_BGP_LISTENER, listener);
}
}
diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h
index 59b18f9376..018efbc08e 100644
--- a/bgpd/bgp_network.h
+++ b/bgpd/bgp_network.h
@@ -23,6 +23,7 @@
#define BGP_SOCKET_SNDBUF_SIZE 65536
+extern void bgp_dump_listener_info(struct vty *vty);
extern int bgp_socket(struct bgp *bgp, unsigned short port,
const char *address);
extern void bgp_close_vrf_socket(struct bgp *bgp);
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index ab0c3a3f11..8e43801d2d 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -612,7 +612,8 @@ int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
}
int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
- struct update_subgroup *subgrp)
+ struct update_subgroup *subgrp,
+ struct peer *exclude)
{
struct bgp_node *rn1 = NULL, *rn2 = NULL;
struct peer_af *paf = NULL;
@@ -632,6 +633,9 @@ int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
return 0;
SUBGRP_FOREACH_PEER (subgrp, paf) {
+ /* Skip peer we're told to exclude - e.g., source of route. */
+ if (paf->peer == exclude)
+ continue;
p.u.prefix6 = paf->peer->su.sin6.sin6_addr;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p);
@@ -650,7 +654,8 @@ int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
}
int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
- struct update_subgroup *subgrp)
+ struct update_subgroup *subgrp,
+ struct peer *exclude)
{
struct bgp_node *rn1, *rn2;
struct peer_af *paf;
@@ -670,6 +675,10 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
return 0;
SUBGRP_FOREACH_PEER (subgrp, paf) {
+ /* Skip peer we're told to exclude - e.g., source of route. */
+ if (paf->peer == exclude)
+ continue;
+
p.u.prefix4 = paf->peer->su.sin.sin_addr;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP], &p);
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index af4c0bc047..4a25c83cd5 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -82,9 +82,11 @@ struct bgp_addrv6 {
extern void bgp_connected_add(struct bgp *bgp, struct connected *c);
extern void bgp_connected_delete(struct bgp *bgp, struct connected *c);
extern int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
- struct update_subgroup *subgrp);
+ struct update_subgroup *subgrp,
+ struct peer *exclude);
extern int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
- struct update_subgroup *subgrp);
+ struct update_subgroup *subgrp,
+ struct peer *exclude);
extern int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer);
extern int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer);
extern int bgp_config_write_scan_time(struct vty *);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 0e251dced8..9649de464e 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1142,6 +1142,15 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
return BGP_Stop;
}
+ /* Codification of AS 0 Processing */
+ if (remote_as == BGP_AS_ZERO) {
+ flog_err(EC_BGP_PKT_OPEN, "%s bad OPEN, got AS set to 0",
+ peer->host);
+ bgp_notify_send(peer, BGP_NOTIFY_OPEN_ERR,
+ BGP_NOTIFY_OPEN_BAD_PEER_AS);
+ return BGP_Stop;
+ }
+
if (remote_as == BGP_AS_TRANS) {
/* Take the AS4 from the capability. We must have received the
* capability now! Otherwise we have a asn16 peer who uses
@@ -1447,7 +1456,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- BGP_NOTIFY_SUBCODE_UNSPECIFIC);
+ bgp_fsm_error_subcode(peer->status));
return BGP_Stop;
}
@@ -1859,7 +1868,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- BGP_NOTIFY_SUBCODE_UNSPECIFIC);
+ bgp_fsm_error_subcode(peer->status));
return BGP_Stop;
}
@@ -2251,7 +2260,7 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size)
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- BGP_NOTIFY_SUBCODE_UNSPECIFIC);
+ bgp_fsm_error_subcode(peer->status));
return BGP_Stop;
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index bcd87eb01b..0fdf2d3a8e 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -69,6 +69,7 @@
#include "bgpd/bgp_label.h"
#include "bgpd/bgp_addpath.h"
#include "bgpd/bgp_mac.h"
+#include "bgpd/bgp_network.h"
#if ENABLE_BGP_VNC
#include "bgpd/rfapi/rfapi_backend.h"
@@ -1944,6 +1945,10 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (aspath_check_as_sets(attr->aspath))
return 0;
+ /* Codification of AS 0 Processing */
+ if (aspath_check_as_zero(attr->aspath))
+ return 0;
+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
if (peer->sort == BGP_PEER_IBGP
|| peer->sort == BGP_PEER_CONFED) {
@@ -2001,7 +2006,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if ((p->family == AF_INET) &&
(!bgp_subgrp_multiaccess_check_v4(
piattr->nexthop,
- subgrp)))
+ subgrp, from)))
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
@@ -2011,7 +2016,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if ((p->family == AF_INET6) &&
(!bgp_subgrp_multiaccess_check_v6(
piattr->mp_nexthop_global,
- subgrp)))
+ subgrp, from)))
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
@@ -2102,6 +2107,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
if (debug)
prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
+ rn->reason = bgp_path_selection_none;
/* bgp deterministic-med */
new_select = NULL;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
@@ -2181,6 +2187,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
new_select = NULL;
for (pi = bgp_node_get_bgp_path_info(rn);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
+ enum bgp_path_selection_reason reason;
+
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
old_select = pi;
@@ -2221,8 +2229,12 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK);
+ reason = rn->reason;
if (bgp_path_info_cmp(bgp, pi, new_select, &paths_eq, mpath_cfg,
debug, pfx_buf, afi, safi, &rn->reason)) {
+ if (new_select == NULL &&
+ reason != bgp_path_selection_none)
+ rn->reason = reason;
new_select = pi;
}
}
@@ -2485,7 +2497,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
*/
if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
if (BGP_DEBUG(update, UPDATE_OUT))
- zlog_debug("SELECT_DEFER falg set for route %p", rn);
+ zlog_debug("SELECT_DEFER flag set for route %p", rn);
return;
}
@@ -12766,6 +12778,18 @@ static void show_bgp_peerhash_entry(struct hash_bucket *bucket, void *arg)
sockunion2str(&peer->su, buf, sizeof(buf)));
}
+DEFUN (show_bgp_listeners,
+ show_bgp_listeners_cmd,
+ "show bgp listeners",
+ SHOW_STR
+ BGP_STR
+ "Display Listen Sockets and who created them\n")
+{
+ bgp_dump_listener_info(vty);
+
+ return CMD_SUCCESS;
+}
+
DEFUN (show_bgp_peerhash,
show_bgp_peerhash_cmd,
"show bgp peerhash",
@@ -13155,6 +13179,7 @@ void bgp_route_init(void)
/* show bgp ipv4 flowspec detailed */
install_element(VIEW_NODE, &show_ip_bgp_flowspec_routes_detailed_cmd);
+ install_element(VIEW_NODE, &show_bgp_listeners_cmd);
install_element(VIEW_NODE, &show_bgp_peerhash_cmd);
}
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 2ca0c7b96d..ee1c49666b 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -94,6 +94,7 @@ enum return_values { SUCCESS = 0, ERROR = -1 };
struct rpki_for_each_record_arg {
struct vty *vty;
unsigned int *prefix_amount;
+ as_t as;
};
static int start(void);
@@ -273,6 +274,17 @@ static void print_record(const struct pfx_record *record, struct vty *vty)
record->max_len, record->asn);
}
+static void print_record_by_asn(const struct pfx_record *record, void *data)
+{
+ struct rpki_for_each_record_arg *arg = data;
+ struct vty *vty = arg->vty;
+
+ if (record->asn == arg->as) {
+ (*arg->prefix_amount)++;
+ print_record(record, vty);
+ }
+}
+
static void print_record_cb(const struct pfx_record *record, void *data)
{
struct rpki_for_each_record_arg *arg = data;
@@ -621,6 +633,36 @@ static struct rtr_mgr_group *get_connected_group(void)
return rtr_mgr_get_first_group(rtr_config);
}
+static void print_prefix_table_by_asn(struct vty *vty, as_t as)
+{
+ unsigned int number_of_ipv4_prefixes = 0;
+ unsigned int number_of_ipv6_prefixes = 0;
+ struct rtr_mgr_group *group = get_connected_group();
+ struct rpki_for_each_record_arg arg;
+
+ arg.vty = vty;
+ arg.as = as;
+
+ if (!group) {
+ vty_out(vty, "Cannot find a connected group.\n");
+ return;
+ }
+
+ struct pfx_table *pfx_table = group->sockets[0]->pfx_table;
+
+ vty_out(vty, "RPKI/RTR prefix table\n");
+ vty_out(vty, "%-40s %s %s\n", "Prefix", "Prefix Length", "Origin-AS");
+
+ arg.prefix_amount = &number_of_ipv4_prefixes;
+ pfx_table_for_each_ipv4_record(pfx_table, print_record_by_asn, &arg);
+
+ arg.prefix_amount = &number_of_ipv6_prefixes;
+ pfx_table_for_each_ipv6_record(pfx_table, print_record_by_asn, &arg);
+
+ vty_out(vty, "Number of IPv4 Prefixes: %u\n", number_of_ipv4_prefixes);
+ vty_out(vty, "Number of IPv6 Prefixes: %u\n", number_of_ipv6_prefixes);
+}
+
static void print_prefix_table(struct vty *vty)
{
struct rpki_for_each_record_arg arg;
@@ -1190,6 +1232,21 @@ DEFUN (show_rpki_prefix_table,
return CMD_SUCCESS;
}
+DEFPY(show_rpki_as_number, show_rpki_as_number_cmd,
+ "show rpki as-number (1-4294967295)$by_asn",
+ SHOW_STR RPKI_OUTPUT_STRING
+ "Lookup by ASN in prefix table\n"
+ "AS Number\n")
+{
+ if (!is_synchronized()) {
+ vty_out(vty, "No Connection to RPKI cache server.\n");
+ return CMD_WARNING;
+ }
+
+ print_prefix_table_by_asn(vty, by_asn);
+ return CMD_SUCCESS;
+}
+
DEFPY (show_rpki_prefix,
show_rpki_prefix_cmd,
"show rpki prefix <A.B.C.D/M|X:X::X:X/M> [(1-4294967295)$asn]",
@@ -1523,6 +1580,7 @@ static void install_cli_commands(void)
install_element(VIEW_NODE, &show_rpki_cache_connection_cmd);
install_element(VIEW_NODE, &show_rpki_cache_server_cmd);
install_element(VIEW_NODE, &show_rpki_prefix_cmd);
+ install_element(VIEW_NODE, &show_rpki_as_number_cmd);
/* Install debug commands */
install_element(CONFIG_NODE, &debug_rpki_cmd);
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 70e4a3fa00..d507161052 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -869,7 +869,7 @@ static int bgpTrapEstablished(struct peer *peer)
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
array_size(bgp_trap_oid), bgp_oid,
- sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
+ sizeof(bgp_oid) / sizeof(oid), index, IN_ADDR_SIZE,
bgpTrapList, array_size(bgpTrapList), BGPESTABLISHED);
return 0;
}
@@ -888,7 +888,7 @@ static int bgpTrapBackwardTransition(struct peer *peer)
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
array_size(bgp_trap_oid), bgp_oid,
- sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
+ sizeof(bgp_oid) / sizeof(oid), index, IN_ADDR_SIZE,
bgpTrapList, array_size(bgpTrapList), BGPBACKWARDTRANSITION);
return 0;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index fc841c6c1b..8c751e4f19 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -7304,7 +7304,7 @@ ALIAS (af_label_vpn_export,
DEFPY (af_nexthop_vpn_export,
af_nexthop_vpn_export_cmd,
- "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
+ "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
NO_STR
"Specify next hop to use for VRF advertised prefixes\n"
"Between current address-family and vpn\n"
@@ -7315,14 +7315,14 @@ DEFPY (af_nexthop_vpn_export,
VTY_DECLVAR_CONTEXT(bgp, bgp);
afi_t afi;
struct prefix p;
- int idx = 0;
- int yes = 1;
- if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ if (!no) {
+ if (!nexthop_su) {
+ vty_out(vty, "%% Nexthop required\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
- if (yes) {
- if (!sockunion2hostprefix(nexthop_str, &p))
+ if (!sockunion2hostprefix(nexthop_su, &p))
return CMD_WARNING_CONFIG_FAILED;
}
@@ -7336,7 +7336,7 @@ DEFPY (af_nexthop_vpn_export,
vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi,
bgp_get_default(), bgp);
- if (yes) {
+ if (!no) {
bgp->vpn_policy[afi].tovpn_nexthop = p;
SET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_NEXTHOP_SET);
@@ -7352,14 +7352,6 @@ DEFPY (af_nexthop_vpn_export,
return CMD_SUCCESS;
}
-ALIAS (af_nexthop_vpn_export,
- af_no_nexthop_vpn_export_cmd,
- "no nexthop vpn export",
- NO_STR
- "Specify next hop to use for VRF advertised prefixes\n"
- "Between current address-family and vpn\n"
- "For routes leaked from current address-family to vpn\n")
-
static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir)
{
if (!strcmp(dstr, "import")) {
@@ -11635,7 +11627,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
json_object_object_add(
json_neigh, "gracefulRestartInfo", json_grace);
} else {
- vty_out(vty, " Graceful restart informations:\n");
+ vty_out(vty, " Graceful restart information:\n");
if ((p->status == Established)
&& CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
@@ -16613,8 +16605,6 @@ void bgp_vty_init(void)
install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd);
install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd);
install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd);
- install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd);
- install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd);
install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd);
install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd);
install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 0e1278b1df..267d67e46e 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2102,8 +2102,8 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi,
if (peer_af_delete(peer, afi, safi) != 0) {
flog_err(EC_BGP_PEER_DELETE,
- "couldn't delete af structure for peer %s",
- peer->host);
+ "couldn't delete af structure for peer %s(%s, %s)",
+ peer->host, afi2str(afi), safi2str(safi));
return 1;
}
@@ -2152,9 +2152,10 @@ int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi)
group = peer->group;
if (peer_af_delete(peer, afi, safi) != 0) {
- flog_err(EC_BGP_PEER_DELETE,
- "couldn't delete af structure for peer %s",
- peer->host);
+ flog_err(
+ EC_BGP_PEER_DELETE,
+ "couldn't delete af structure for peer %s(%s, %s)",
+ peer->host, afi2str(afi), safi2str(safi));
}
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, tmp_peer)) {
@@ -3398,8 +3399,9 @@ int bgp_delete(struct bgp *bgp)
/* Deregister from Zebra, if needed */
if (IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("%s: deregistering this bgp %s instance from zebra",
- __PRETTY_FUNCTION__, bgp->name);
+ zlog_debug(
+ "%s: deregistering this bgp %s instance from zebra",
+ __func__, bgp->name);
bgp_zebra_instance_deregister(bgp);
}
@@ -4030,7 +4032,7 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set)
struct peer_flag_action action;
memset(&action, 0, sizeof(struct peer_flag_action));
- size = sizeof peer_flag_action_list / sizeof(struct peer_flag_action);
+ size = sizeof(peer_flag_action_list) / sizeof(struct peer_flag_action);
invert = CHECK_FLAG(peer->flags_invert, flag);
found = peer_flag_action_set(peer_flag_action_list, size, &action,
@@ -4069,6 +4071,9 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set)
/* Update flag override state accordingly. */
COND_FLAG(peer->flags_override, flag, set != invert);
+ if (set && flag == PEER_FLAG_CAPABILITY_ENHE)
+ bgp_nht_register_enhe_capability_interfaces(peer);
+
/* Execute flag action on peer. */
if (action.type == peer_change_reset)
peer_flag_modify_action(peer, flag);
@@ -4077,9 +4082,6 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set)
return 0;
}
- if (set && flag == PEER_FLAG_CAPABILITY_ENHE)
- bgp_nht_register_enhe_capability_interfaces(peer);
-
/*
* Update peer-group members, unless they are explicitely overriding
* peer-group configuration.
@@ -4136,7 +4138,7 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,
bgp_peer_sort_t ptype;
memset(&action, 0, sizeof(struct peer_flag_action));
- size = sizeof peer_af_flag_action_list
+ size = sizeof(peer_af_flag_action_list)
/ sizeof(struct peer_flag_action);
invert = CHECK_FLAG(peer->af_flags_invert[afi][safi], flag);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 03d33130fe..769ac32653 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -555,7 +555,7 @@ struct bgp {
struct bgp_addpath_bgp_data tx_addpath;
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
struct rfapi_cfg *rfapi_cfg;
struct rfapi *rfapi;
#endif
@@ -1281,9 +1281,7 @@ struct peer {
* - This does *not* contain the filter values, rather it contains
* whether the filter in filter (struct bgp_filter) is peer-specific.
*/
- uint8_t filter_override[AFI_MAX][SAFI_MAX][(FILTER_MAX > RMAP_MAX)
- ? FILTER_MAX
- : RMAP_MAX];
+ uint8_t filter_override[AFI_MAX][SAFI_MAX][FILTER_MAX];
#define PEER_FT_DISTRIBUTE_LIST (1 << 0) /* distribute-list */
#define PEER_FT_FILTER_LIST (1 << 1) /* filter-list */
#define PEER_FT_PREFIX_LIST (1 << 2) /* prefix-list */
@@ -1482,7 +1480,7 @@ struct bgp_nlri {
#define BGP_ATTR_ENCAP 23
#define BGP_ATTR_LARGE_COMMUNITIES 32
#define BGP_ATTR_PREFIX_SID 40
-#if ENABLE_BGP_VNC_ATTR
+#ifdef ENABLE_BGP_VNC_ATTR
#define BGP_ATTR_VNC 255
#endif
@@ -1501,6 +1499,12 @@ struct bgp_nlri {
#define BGP_NOTIFY_CEASE 6
#define BGP_NOTIFY_CAPABILITY_ERR 7
+/* Subcodes for BGP Finite State Machine Error */
+#define BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC 0
+#define BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT 1
+#define BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM 2
+#define BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED 3
+
#define BGP_NOTIFY_SUBCODE_UNSPECIFIC 0
/* BGP_NOTIFY_HEADER_ERR sub codes. */
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index cad33404fa..acfab53d2b 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -47,7 +47,7 @@
#include "bgpd/rfapi/vnc_import_bgp.h"
#include "bgpd/rfapi/vnc_debug.h"
-#if ENABLE_BGP_VNC
+#ifdef ENABLE_BGP_VNC
#undef BGP_VNC_DEBUG_MATCH_GROUP
@@ -168,7 +168,7 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
agg_unlock_node(rn_un);
}
-#if BGP_VNC_DEBUG_MATCH_GROUP
+#ifdef BGP_VNC_DEBUG_MATCH_GROUP
{
char buf[PREFIX_STRLEN];
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 4701d2e1fa..d87292f652 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -2150,7 +2150,7 @@ int rfapi_close(void *handle)
vnc_zlog_debug_verbose("%s: rfd=%p", __func__, rfd);
-#if RFAPI_WHO_IS_CALLING_ME
+#ifdef RFAPI_WHO_IS_CALLING_ME
#ifdef HAVE_GLIBC_BACKTRACE
#define RFAPI_DEBUG_BACKTRACE_NENTRIES 5
{
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 8fbc4d9d15..2f274015fc 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -200,7 +200,7 @@ void rfapiCheckRouteCount(void)
}
}
-#if DEBUG_ROUTE_COUNTERS
+#ifdef DEBUG_ROUTE_COUNTERS
#define VNC_ITRCCK do {rfapiCheckRouteCount();} while (0)
#else
#define VNC_ITRCCK
@@ -458,7 +458,7 @@ int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bpi, struct prefix *p)
default:
if (p)
p->family = 0;
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose(
"%s: bpi->extra->vnc.import.un_family is 0, no UN addr",
__func__);
@@ -609,7 +609,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
RFAPI_CHECK_REFCOUNT(original_vpn_node, SAFI_MPLS_VPN, lockoffset);
-#if DEBUG_MONITOR_MOVE_SHORTER
+#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
char buf[PREFIX_STRLEN];
@@ -628,7 +628,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
struct prefix pfx;
if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx)) {
-#if DEBUG_MONITOR_MOVE_SHORTER
+#ifdef DEBUG_MONITOR_MOVE_SHORTER
vnc_zlog_debug_verbose(
"%s: have valid UN at original node, no change",
__func__);
@@ -744,7 +744,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
agg_unlock_node(original_vpn_node);
}
-#if DEBUG_MONITOR_MOVE_SHORTER
+#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
char buf[PREFIX_STRLEN];
@@ -953,7 +953,7 @@ void rfapiImportTableRefDelByIt(struct bgp *bgp,
}
}
-#if RFAPI_REQUIRE_ENCAP_BEEC
+#ifdef RFAPI_REQUIRE_ENCAP_BEEC
/*
* Look for magic BGP Encapsulation Extended Community value
* Format in RFC 5512 Sect. 4.5
@@ -1267,7 +1267,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
struct rfapi_next_hop_entry *new;
int have_vnc_tunnel_un = 0;
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: entry, bpi %p, rn %p", __func__, bpi, rn);
#endif
@@ -1401,7 +1401,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
new->un_options = rfapi_encap_tlv_to_un_option(bpi->attr);
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: line %d: have_vnc_tunnel_un=%d", __func__,
__LINE__, have_vnc_tunnel_un);
#endif
@@ -1448,7 +1448,7 @@ int rfapiHasNonRemovedRoutes(struct agg_node *rn)
return 0;
}
-#if DEBUG_IT_NODES
+#ifdef DEBUG_IT_NODES
/*
* DEBUG FUNCTION
*/
@@ -1517,7 +1517,7 @@ static int rfapiNhlAddNodeRoutes(
struct prefix *newpfx;
if (removed && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
vnc_zlog_debug_verbose(
"%s: want holddown, this route not holddown, skip",
__func__);
@@ -1549,7 +1549,7 @@ static int rfapiNhlAddNodeRoutes(
rfapiNexthop2Prefix(bpi->attr, &pfx_vn);
}
if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) {
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
char buf[PREFIX_STRLEN];
prefix2str(&pfx_vn, buf, sizeof(buf));
@@ -1561,7 +1561,7 @@ static int rfapiNhlAddNodeRoutes(
}
if (rfapiGetUnAddrOfVpnBi(bpi, &pfx_un)) {
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose(
"%s: failed to get UN address of this VPN bpi",
__func__);
@@ -1715,7 +1715,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
int count = 0;
struct agg_node *rib_rn;
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
{
char buf[PREFIX_STRLEN];
@@ -1746,7 +1746,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
pfx_target_original);
vnc_zlog_debug_verbose("%s: %d nexthops, answer=%p", __func__,
count, answer);
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
rfapiPrintNhl(NULL, answer);
#endif
if (rib_rn)
@@ -1806,7 +1806,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
vnc_zlog_debug_verbose("%s: %d nexthops, answer=%p", __func__, count,
answer);
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
rfapiPrintNhl(NULL, answer);
#endif
return answer;
@@ -1868,7 +1868,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last,
NULL, rib_rn, pfx_target_original);
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: node %p: %d non-holddown routes", __func__,
rn, count);
#endif
@@ -1884,7 +1884,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
if (rib_rn)
agg_unlock_node(rib_rn);
-#if DEBUG_RETURNED_NHL
+#ifdef DEBUG_RETURNED_NHL
rfapiPrintNhl(NULL, answer);
#endif
@@ -2164,7 +2164,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
if (!sl)
return NULL;
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
{
char buf[RD_ADDRSTRLEN];
char buf_aux_pfx[PREFIX_STRLEN];
@@ -2185,13 +2185,13 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
/* threshold is a WAG */
if (sl->count < 3) {
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
vnc_zlog_debug_verbose("%s: short list algorithm", __func__);
#endif
/* if short list, linear search might be faster */
for (bpi_result = rn->info; bpi_result;
bpi_result = bpi_result->next) {
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
{
char buf[RD_ADDRSTRLEN];
@@ -2208,7 +2208,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
->vnc.import.rd,
(struct prefix *)prd)) {
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
vnc_zlog_debug_verbose(
"%s: peer and RD same, doing aux_prefix check",
__func__);
@@ -2219,7 +2219,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
&bpi_result->extra->vnc.import
.aux_prefix)) {
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
vnc_zlog_debug_verbose("%s: match",
__func__);
#endif
@@ -2244,13 +2244,13 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
rc = skiplist_search(sl, (void *)&bpi_fake, (void *)&bpi_result);
if (rc) {
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
vnc_zlog_debug_verbose("%s: no match", __func__);
#endif
return NULL;
}
-#if DEBUG_BI_SEARCH
+#ifdef DEBUG_BI_SEARCH
vnc_zlog_debug_verbose("%s: matched bpi=%p", __func__, bpi_result);
#endif
@@ -2958,7 +2958,7 @@ static void rfapiBgpInfoFilteredImportEncap(
__func__);
return;
}
-#if RFAPI_REQUIRE_ENCAP_BEEC
+#ifdef RFAPI_REQUIRE_ENCAP_BEEC
if (!rfapiEcommunitiesMatchBeec(attr->ecommunity)) {
vnc_zlog_debug_verbose(
"%s: it=%p: no match for BGP Encapsulation ecommunity",
@@ -3007,7 +3007,7 @@ static void rfapiBgpInfoFilteredImportEncap(
*/
rn = agg_node_lookup(rt, p);
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: initial encap lookup(it=%p) rn=%p",
__func__, import_table, rn);
#endif
@@ -3241,7 +3241,7 @@ static void rfapiBgpInfoFilteredImportEncap(
/*
* iterate over the set of monitors at this ENCAP node.
*/
-#if DEBUG_ENCAP_MONITOR
+#ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: examining monitors at rn=%p",
__func__, rn);
#endif
@@ -3997,7 +3997,7 @@ void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p,
rc == 0; rc = skiplist_next(h->import_mac, NULL,
(void **)&it, &cursor)) {
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
vnc_zlog_debug_verbose(
"%s: calling rfapiBgpInfoFilteredImportVPN(it=%p, afi=AFI_L2VPN)",
__func__, it);
@@ -4408,7 +4408,7 @@ static void rfapiDeleteRemotePrefixesIt(
{
afi_t afi;
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
{
char buf_pfx[PREFIX_STRLEN];
@@ -4487,7 +4487,7 @@ static void rfapiDeleteRemotePrefixesIt(
if (vn) {
if (!qpt_valid
|| !prefix_match(vn, &qpt)) {
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
vnc_zlog_debug_verbose(
"%s: continue at vn && !qpt_valid || !prefix_match(vn, &qpt)",
__func__);
@@ -4502,7 +4502,7 @@ static void rfapiDeleteRemotePrefixesIt(
if (un) {
if (!qct_valid
|| !prefix_match(un, &qct)) {
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
vnc_zlog_debug_verbose(
"%s: continue at un && !qct_valid || !prefix_match(un, &qct)",
__func__);
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index b7ec35c661..3d4bdef75a 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -479,7 +479,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
bgp = rfd->bgp;
else
bgp = bgp_get_default();
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
vnc_zlog_debug_verbose("%s: rfd=%p", __func__, rfd);
#endif
@@ -1487,7 +1487,7 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi)
struct rfapi_next_hop_entry *tail = NULL;
struct agg_node *rn;
-#if DEBUG_L2_EXTRA
+#ifdef DEBUG_L2_EXTRA
vnc_zlog_debug_verbose("%s: rfd=%p, afi=%d", __func__, rfd, afi);
#endif
@@ -1812,7 +1812,7 @@ int rfapiRibFTDFilterRecentPrefix(
if (it_rn->p.family == AF_ETHERNET)
return 0;
-#if DEBUG_FTD_FILTER_RECENT
+#ifdef DEBUG_FTD_FILTER_RECENT
{
char buf_pfx[PREFIX_STRLEN];
@@ -1825,7 +1825,7 @@ int rfapiRibFTDFilterRecentPrefix(
* prefix covers target address, so allow prefix
*/
if (prefix_match(&it_rn->p, pfx_target_original)) {
-#if DEBUG_FTD_FILTER_RECENT
+#ifdef DEBUG_FTD_FILTER_RECENT
vnc_zlog_debug_verbose("%s: prefix covers target, allowed",
__func__);
#endif
@@ -1840,7 +1840,7 @@ int rfapiRibFTDFilterRecentPrefix(
if (trn->lock > 1)
agg_unlock_node(trn);
-#if DEBUG_FTD_FILTER_RECENT
+#ifdef DEBUG_FTD_FILTER_RECENT
vnc_zlog_debug_verbose("%s: last sent time %lu, last allowed time %lu",
__func__, prefix_time,
rfd->ftd_last_allowed_time);
@@ -2311,7 +2311,7 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty,
*p = 0;
rfapiFormatSeconds(ri->lifetime, str_lifetime, BUFSIZ);
-#if RFAPI_REGISTRATIONS_REPORT_AGE
+#ifdef RFAPI_REGISTRATIONS_REPORT_AGE
rfapiFormatAge(ri->last_sent_time, str_age, BUFSIZ);
#else
{
@@ -2451,12 +2451,12 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
" %-20s %-15s %-15s %4s %-8s %-8s\n",
"Prefix", "Registered VN",
"Registered UN", "Cost", "Lifetime",
-#if RFAPI_REGISTRATIONS_REPORT_AGE
+#ifdef RFAPI_REGISTRATIONS_REPORT_AGE
"Age"
#else
"Remaining"
#endif
- );
+ );
}
if (!printednve) {
char str_vn[BUFSIZ];
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index 77fcf909c8..58fdc7c130 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -1123,7 +1123,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
(struct thread *)bpi->extra->vnc.import.timer;
remaining = thread_timer_remain_second(t);
-#if RFAPI_REGISTRATIONS_REPORT_AGE
+#ifdef RFAPI_REGISTRATIONS_REPORT_AGE
/*
* Calculate when the timer started. Doing so here saves
* us a timestamp field in "struct bgp_path_info".
@@ -1311,7 +1311,7 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream,
}
fp(out, "%s", HVTYNL);
if (show_expiring) {
-#if RFAPI_REGISTRATIONS_REPORT_AGE
+#ifdef RFAPI_REGISTRATIONS_REPORT_AGE
agetype = "Age";
#else
agetype = "Remaining";
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index 352f5e8328..3d34d696b5 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -1189,7 +1189,7 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
}
if (rfg->label > MPLS_LABEL_MAX) {
vnc_zlog_debug_verbose(
- "%s: VRF \"%s\" is missing defaul label configuration.\n",
+ "%s: VRF \"%s\" is missing default label configuration.\n",
__func__, rfg->name);
return;
}
diff --git a/configure.ac b/configure.ac
index 901cac2318..0d56b60e72 100755
--- a/configure.ac
+++ b/configure.ac
@@ -122,7 +122,7 @@ AC_ARG_ENABLE([pkgsrcrcdir],
pkgsrcrcdir="$enableval",)
dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow
AC_SUBST([pkgsrcrcdir])
-AM_CONDITIONAL([PKGSRC], [test "x$pkgsrcrcdir" != "x"])
+AM_CONDITIONAL([PKGSRC], [test "$pkgsrcrcdir" != ""])
AC_ARG_WITH([moduledir], [AS_HELP_STRING([--with-moduledir=DIR], [module directory (${libdir}/frr/modules)])], [
moduledir="$withval"
@@ -197,7 +197,7 @@ AC_DEFUN([AC_C_FLAG], [{
CFLAGS="$ac_c_flag_save"
AC_LANG_POP([C])
])
- if test "${cachename}" = yes; then
+ if test "$cachename" = "yes"; then
m4_if([$3], [], [CFLAGS="$CFLAGS $1"], [$3])
else
:
@@ -242,8 +242,8 @@ CC="${CC% -std=c99}"
AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"])
dnl if the user has specified any CFLAGS, override our settings
-if test "x${enable_gcov}" = "xyes"; then
- if test "z$orig_cflags" = "z"; then
+if test "$enable_gcov" = "yes"; then
+ if test "$orig_cflags" = ""; then
AC_C_FLAG([-coverage])
AC_C_FLAG([-O0])
fi
@@ -251,7 +251,7 @@ if test "x${enable_gcov}" = "xyes"; then
LDFLAGS="${LDFLAGS} -lgcov"
fi
-if test "x${enable_clang_coverage}" = "xyes"; then
+if test "$enable_clang_coverage" = "yes"; then
AC_C_FLAG([-fprofile-instr-generate], [
AC_MSG_ERROR([$CC does not support -fprofile-instr-generate.])
])
@@ -260,13 +260,13 @@ if test "x${enable_clang_coverage}" = "xyes"; then
])
fi
-if test "x${enable_dev_build}" = "xyes"; then
+if test "$enable_dev_build" = "yes"; then
AC_DEFINE([DEV_BUILD], [1], [Build for development])
- if test "z$orig_cflags" = "z"; then
+ if test "$orig_cflags" = ""; then
AC_C_FLAG([-g3])
AC_C_FLAG([-O0])
fi
- if test "x${enable_lua}" = "xyes"; then
+ if test "$enable_lua" = "yes"; then
AX_PROG_LUA([5.3])
AX_LUA_HEADERS
AX_LUA_LIBS([
@@ -275,15 +275,15 @@ if test "x${enable_dev_build}" = "xyes"; then
])
fi
else
- if test "x${enable_lua}" = "xyes"; then
+ if test "$enable_lua" = "yes"; then
AC_MSG_ERROR([Lua is not meant to be built/used outside of development at this time])
fi
- if test "z$orig_cflags" = "z"; then
+ if test "$orig_cflags" = ""; then
AC_C_FLAG([-g])
AC_C_FLAG([-O2])
fi
fi
-AM_CONDITIONAL([DEV_BUILD], [test "x$enable_dev_build" = "xyes"])
+AM_CONDITIONAL([DEV_BUILD], [test "$enable_dev_build" = "yes"])
dnl always want these CFLAGS
AC_C_FLAG([-fno-omit-frame-pointer])
@@ -295,7 +295,7 @@ AC_C_FLAG([-Wmissing-declarations])
AC_C_FLAG([-Wpointer-arith])
AC_C_FLAG([-Wbad-function-cast])
AC_C_FLAG([-Wwrite-strings])
-if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
+if test "$enable_gcc_ultra_verbose" = "yes" ; then
AC_C_FLAG([-Wcast-qual])
AC_C_FLAG([-Wstrict-prototypes])
AC_C_FLAG([-Wmissing-noreturn])
@@ -318,7 +318,7 @@ dnl for some reason the string consts get 'promoted' to char *,
dnl triggering a const to non-const conversion warning.
AC_C_FLAG([-diag-disable 3179])
-if test x"${enable_werror}" = x"yes" ; then
+if test "$enable_werror" = "yes" ; then
WERROR="-Werror"
fi
AC_SUBST([WERROR])
@@ -369,7 +369,7 @@ AX_PTHREAD([
AC_SEARCH_LIBS([pthread_condattr_setclock], [],
[frr_cv_pthread_condattr_setclock=yes],
[frr_cv_pthread_condattr_setclock=no])
-if test "$frr_cv_pthread_condattr_setclock" = yes; then
+if test "$frr_cv_pthread_condattr_setclock" = "yes"; then
AC_DEFINE([HAVE_PTHREAD_CONDATTR_SETCLOCK], [1], [Have pthread.h pthread_condattr_setclock])
fi
@@ -400,7 +400,7 @@ if test "$enable_shared" != "yes"; then
AC_MSG_ERROR([FRR cannot be built with --disable-shared. If you want statically linked daemons, use --enable-shared --enable-static --enable-static-bin])
fi
AC_SUBST([AC_LDFLAGS])
-AM_CONDITIONAL([STATIC_BIN], [test "x$enable_static_bin" = "xyes"])
+AM_CONDITIONAL([STATIC_BIN], [test "$enable_static_bin" = "yes"])
dnl $AR and $RANLIB are set by LT_INIT above
AC_MSG_CHECKING([whether $AR supports D option])
@@ -451,7 +451,7 @@ AC_ARG_WITH([pkg-extra-version],
], [])
AC_ARG_WITH([pkg-git-version],
AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]),
- [ test "x$withval" != "xno" && with_pkg_git_version="yes" ])
+ [ test "$withval" != "no" && with_pkg_git_version="yes" ])
AC_ARG_WITH([clippy],
AS_HELP_STRING([--with-clippy=PATH], [use external clippy helper program]))
AC_ARG_WITH([vtysh_pager],
@@ -602,23 +602,23 @@ AC_ARG_WITH([crypto],
AS_HELP_STRING([--with-crypto=<internal|openssl>], [choose between different implementations of cryptographic functions(default value is --with-crypto=internal)]))
#if openssl, else use the internal
-AS_IF([test x"${with_crypto}" = x"openssl"], [
+AS_IF([test "$with_crypto" = "openssl"], [
AC_CHECK_LIB([crypto], [EVP_DigestInit], [LIBS="$LIBS -lcrypto"], [], [])
-if test $ac_cv_lib_crypto_EVP_DigestInit = no; then
+if test "$ac_cv_lib_crypto_EVP_DigestInit" = "no"; then
AC_MSG_ERROR([build with openssl has been specified but openssl library was not found on your system])
else
AC_DEFINE([CRYPTO_OPENSSL], [1], [Compile with openssl support])
fi
-], [test x"${with_crypto}" = x"internal" || test x"${with_crypto}" = x"" ], [AC_DEFINE([CRYPTO_INTERNAL], [1], [Compile with internal cryptographic implementation])
+], [test "$with_crypto" = "internal" || test "$with_crypto" = "" ], [AC_DEFINE([CRYPTO_INTERNAL], [1], [Compile with internal cryptographic implementation])
], [AC_MSG_ERROR([Unknown value for --with-crypto])]
)
-AS_IF([test "${enable_clippy_only}" != "yes"], [
+AS_IF([test "$enable_clippy_only" != "yes"], [
AC_CHECK_HEADERS([json-c/json.h])
AC_CHECK_LIB([json-c], [json_object_get], [LIBS="$LIBS -ljson-c"], [], [-lm])
-if test "$ac_cv_lib_json_c_json_object_get" = no; then
+if test "$ac_cv_lib_json_c_json_object_get" = "no"; then
AC_CHECK_LIB([json], [json_object_get], [LIBS="$LIBS -ljson"])
- if test "$ac_cv_lib_json_json_object_get" = no; then
+ if test "$ac_cv_lib_json_json_object_get" = "no"; then
AC_MSG_ERROR([libjson is needed to compile])
fi
fi
@@ -630,8 +630,8 @@ AC_ARG_ENABLE([dev_build],
AC_ARG_ENABLE([lua],
AS_HELP_STRING([--enable-lua], [Build Lua scripting]))
-if test x"${enable_time_check}" != x"no" ; then
- if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
+if test "$enable_time_check" != "no" ; then
+ if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then
AC_DEFINE([CONSUMED_TIME_CHECK], [5000000], [Consumed Time Check])
else
AC_DEFINE_UNQUOTED([CONSUMED_TIME_CHECK], [$enable_time_check], [Consumed Time Check])
@@ -650,7 +650,7 @@ case "${enable_systemd}" in
"no") ;;
"yes")
AC_CHECK_LIB([systemd], [sd_notify], [LIBS="$LIBS -lsystemd"])
- if test $ac_cv_lib_systemd_sd_notify = no; then
+ if test "$ac_cv_lib_systemd_sd_notify" = "no"; then
AC_MSG_ERROR([enable systemd has been specified but systemd development env not found on your system])
else
AC_DEFINE([HAVE_SYSTEMD], [1], [Compile systemd support in])
@@ -659,11 +659,11 @@ case "${enable_systemd}" in
"*") ;;
esac
-if test "${enable_rr_semantics}" != "no" ; then
+if test "$enable_rr_semantics" != "no" ; then
AC_DEFINE([HAVE_V6_RR_SEMANTICS], [1], [Compile in v6 Route Replacement Semantics])
fi
-if test "${enable_datacenter}" = "yes" ; then
+if test "$enable_datacenter" = "yes" ; then
AC_DEFINE([HAVE_DATACENTER], [1], [Compile extensions for a DataCenter])
AC_MSG_WARN([The --enable-datacenter compile time option is deprecated. Please modify the init script to pass -F datacenter to the daemons instead.])
DFLT_NAME="datacenter"
@@ -671,22 +671,22 @@ else
DFLT_NAME="traditional"
fi
-if test "${enable_fuzzing}" = "yes" ; then
+if test "$enable_fuzzing" = "yes" ; then
AC_DEFINE([HANDLE_ZAPI_FUZZING], [1], [Compile extensions to use with a fuzzer])
fi
-if test "${enable_netlink_fuzzing}" = "yes" ; then
+if test "$enable_netlink_fuzzing" = "yes" ; then
AC_DEFINE([HANDLE_NETLINK_FUZZING], [1], [Compile extensions to use with a fuzzer for netlink])
fi
-if test "${enable_cumulus}" = "yes" ; then
+if test "$enable_cumulus" = "yes" ; then
AC_DEFINE([HAVE_CUMULUS], [1], [Compile Special Cumulus Code in])
fi
AC_SUBST([DFLT_NAME])
AC_DEFINE_UNQUOTED([DFLT_NAME], ["$DFLT_NAME"], [Name of the configuration default set])
-if test "${enable_shell_access}" = "yes"; then
+if test "$enable_shell_access" = "yes"; then
AC_DEFINE([HAVE_SHELL_ACCESS], [1], [Allow user to use ssh/telnet/bash, be aware this is considered insecure])
fi
@@ -702,15 +702,15 @@ AS_IF([test "$host" = "$build"], [
FRR_PYTHON_MODULES([pytest])
-if test "${enable_doc}" != "no"; then
+if test "$enable_doc" != "no"; then
FRR_PYTHON_MODULES([sphinx], , [
- if test "${enable_doc}" = "yes"; then
+ if test "$enable_doc" = "yes"; then
AC_MSG_ERROR([Documentation was explicitly requested with --enable-doc but sphinx is not available for $PYTHON. Please disable docs or install sphinx.])
fi
])
fi
-AM_CONDITIONAL([DOC], [test "${enable_doc}" != "no" -a "$frr_py_mod_sphinx" != "false"])
-AM_CONDITIONAL([DOC_HTML], [test "${enable_doc_html}" = "yes"])
+AM_CONDITIONAL([DOC], [test "$enable_doc" != "no" -a "$frr_py_mod_sphinx" != "false"])
+AM_CONDITIONAL([DOC_HTML], [test "$enable_doc_html" = "yes"])
FRR_PYTHON_MOD_EXEC([sphinx], [--version], [
PYSPHINX="-m sphinx"
@@ -731,35 +731,35 @@ fi
#
AC_MSG_CHECKING([if zebra should be configurable to send Route Advertisements])
-if test "${enable_rtadv}" != "no"; then
+if test "$enable_rtadv" != "no"; then
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_RTADV], [1], [Enable IPv6 Routing Advertisement support])
else
AC_MSG_RESULT([no])
fi
-if test x"${enable_user}" = x"no"; then
+if test "$enable_user" = "no"; then
enable_user=""
else
- if test x"${enable_user}" = x"yes" || test x"${enable_user}" = x""; then
+ if test "$enable_user" = "yes" || test "$enable_user" = ""; then
enable_user="frr"
fi
AC_DEFINE_UNQUOTED([FRR_USER], ["${enable_user}"], [frr User])
fi
-if test x"${enable_group}" = x"no"; then
+if test "$enable_group" = "no"; then
enable_group=""
else
- if test x"${enable_group}" = x"yes" || test x"${enable_group}" = x""; then
+ if test "$enable_group" = "yes" || test "$enable_group" = ""; then
enable_group="frr"
fi
AC_DEFINE_UNQUOTED([FRR_GROUP], ["${enable_group}"], [frr Group])
fi
-if test x"${enable_vty_group}" = x"yes" ; then
+if test "$enable_vty_group" = "yes" ; then
AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes])
-elif test x"${enable_vty_group}" != x""; then
- if test x"${enable_vty_group}" != x"no"; then
+elif test "$enable_vty_group" != ""; then
+ if test "$enable_vty_group" != "no"; then
AC_DEFINE_UNQUOTED([VTY_GROUP], ["${enable_vty_group}"], [VTY Sockets Group])
fi
fi
@@ -784,7 +784,7 @@ case "${enable_multipath}" in
;;
"")
;;
- *)
+ *)
AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
;;
esac
@@ -796,12 +796,12 @@ AC_DEFINE_UNQUOTED([VTYSH_PAGER], ["$VTYSH_PAGER"], [What pager to use])
dnl --------------------
dnl Enable code coverage
dnl --------------------
-AM_CONDITIONAL([HAVE_GCOV], [test '!' "$enable_gcov" = no])
+AM_CONDITIONAL([HAVE_GCOV], [test "$enable_gcov" != "no"])
dnl ------------------------------------
dnl Alpine only accepts numeric versions
dnl ------------------------------------
-if test "x${enable_numeric_version}" != "x" ; then
+if test "$enable_numeric_version" != "" ; then
VERSION="`echo ${VERSION} | tr -c -d '[[.0-9]]'`"
PACKAGE_VERSION="`echo ${PACKAGE_VERSION} | tr -c -d '[[.0-9]]'`"
fi
@@ -810,7 +810,7 @@ dnl -----------------------------------
dnl Add extra version string to package
dnl name, string and version fields.
dnl -----------------------------------
-if test "x${EXTRAVERSION}" != "x" ; then
+if test "$EXTRAVERSION" != "" ; then
VERSION="${VERSION}${EXTRAVERSION}"
PACKAGE_VERSION="${PACKAGE_VERSION}${EXTRAVERSION}"
AC_SUBST(PACKAGE_EXTRAVERSION, ["${EXTRAVERSION}"])
@@ -818,17 +818,17 @@ if test "x${EXTRAVERSION}" != "x" ; then
fi
AC_SUBST([EXTRAVERSION])
-if test "x$with_pkg_git_version" = "xyes"; then
+if test "$with_pkg_git_version" = "yes"; then
if test -d "${srcdir}/.git"; then
AC_DEFINE([GIT_VERSION], [1], [include git version info])
else with_pkg_git_version="no"
AC_MSG_WARN([--with-pkg-git-version given, but this is not a git checkout])
fi
fi
-AM_CONDITIONAL([GIT_VERSION], [test "x$with_pkg_git_version" = "xyes"])
+AM_CONDITIONAL([GIT_VERSION], [test "$with_pkg_git_version" = "yes"])
AC_CHECK_TOOL([OBJCOPY], [objcopy], [:])
-if test "x${OBJCOPY}" != "x:"; then
+if test "$OBJCOPY" != ":"; then
AC_CACHE_CHECK([for .interp value to use], [frr_cv_interp], [
frr_cv_interp=""
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], [
@@ -1026,7 +1026,7 @@ AC_CHECK_HEADERS([net/if_var.h], [], [], [FRR_INCLUDES])
m4_define([FRR_INCLUDES],
FRR_INCLUDES
-[#if HAVE_NET_IF_VAR_H
+[#ifdef HAVE_NET_IF_VAR_H
# include <net/if_var.h>
#endif
])dnl
@@ -1061,22 +1061,22 @@ FRR_INCLUDES
[
#include <sys/un.h>
#include <netinet/in_systm.h>
-#if HAVE_NETINET_IN_VAR_H
+#ifdef HAVE_NETINET_IN_VAR_H
# include <netinet/in_var.h>
#endif
-#if HAVE_NET_IF_DL_H
+#ifdef HAVE_NET_IF_DL_H
# include <net/if_dl.h>
#endif
-#if HAVE_NET_NETOPT_H
+#ifdef HAVE_NET_NETOPT_H
# include <net/netopt.h>
#endif
#include <net/route.h>
-#if HAVE_INET_ND_H
+#ifdef HAVE_INET_ND_H
# include <inet/nd.h>
#endif
#include <arpa/inet.h>
/* Required for IDRP */
-#if HAVE_NETINET_IP_ICMP_H
+#ifdef HAVE_NETINET_IP_ICMP_H
# include <netinet/ip_icmp.h>
#endif
])dnl
@@ -1123,7 +1123,7 @@ case "$host_os" in
AC_DEFINE([KAME], [1], [KAME IPv6])
AC_DEFINE([BSD_V6_SYSCTL], [1], [BSD v6 sysctl to turn on and off forwarding])
- if test "x${enable_pimd}" != "xno"; then
+ if test "$enable_pimd" != "no"; then
case "$host_os" in
openbsd6.0)
;;
@@ -1141,7 +1141,7 @@ case "$host_os" in
AC_DEFINE([BSD_V6_SYSCTL], [1], [BSD v6 sysctl to turn on and off forwarding])
;;
esac
-AM_CONDITIONAL([SOLARIS], [test "${SOLARIS}" = "solaris"])
+AM_CONDITIONAL([SOLARIS], [test "$SOLARIS" = "solaris"])
AM_CONDITIONAL([LINUX], [${is_linux}])
AC_SYS_LARGEFILE
@@ -1149,7 +1149,7 @@ AC_SYS_LARGEFILE
dnl ------------------------
dnl Integrated REALMS option
dnl ------------------------
-if test "${enable_realms}" = "yes"; then
+if test "$enable_realms" = "yes"; then
case "$host_os" in
linux*)
AC_DEFINE([SUPPORT_REALMS], [1], [Realms support])
@@ -1175,7 +1175,7 @@ AC_CHECK_FUNCS([ \
dnl ##########################################################################
dnl LARGE if block spans a lot of "configure"!
-if test "${enable_clippy_only}" != "yes"; then
+if test "$enable_clippy_only" != "yes"; then
dnl ##########################################################################
#
@@ -1243,15 +1243,15 @@ case "${enable_vtysh}" in
LIBS="$prev_libs"
AC_CHECK_HEADER([readline/history.h])
- if test $ac_cv_header_readline_history_h = no;then
+ if test "$ac_cv_header_readline_history_h" = "no"; then
AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
fi
AC_CHECK_LIB([readline], [rl_completion_matches], [true], [], [$LIBREADLINE])
- if test $ac_cv_lib_readline_rl_completion_matches = no; then
+ if test "$ac_cv_lib_readline_rl_completion_matches" = "no"; then
AC_DEFINE([rl_completion_matches], [completion_matches], [Old readline])
fi
AC_CHECK_LIB([readline], [append_history], [frr_cv_append_history=yes], [frr_cv_append_history=no], [$LIBREADLINE])
- if test "$frr_cv_append_history" = yes; then
+ if test "$frr_cv_append_history" = "yes"; then
AC_DEFINE([HAVE_APPEND_HISTORY], [1], [Have history.h append_history])
fi
;;
@@ -1366,10 +1366,10 @@ case "$host_os" in
ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
;;
*)
- if test $ac_cv_header_net_bpf_h = no; then
- if test $ac_cv_header_sys_dlpi_h = no; then
+ if test "$ac_cv_header_net_bpf_h" = "no"; then
+ if test "$ac_cv_header_sys_dlpi_h" = "no"; then
AC_MSG_RESULT([none])
- if test "${enable_isisd}" = yes -o "${enable_fabricd}" = yes; then
+ if test "$enable_isisd" = "yes" -o "$enable_fabricd" = "yes"; then
AC_MSG_FAILURE([IS-IS support requested but no packet backend found])
fi
AC_MSG_WARN([*** IS-IS support will not be built ***])
@@ -1401,7 +1401,7 @@ AC_CHECK_HEADERS([linux/mroute.h], [], [],[
m4_define([FRR_INCLUDES],
FRR_INCLUDES
-[#if HAVE_LINUX_MROUTE_H
+[#ifdef HAVE_LINUX_MROUTE_H
# include <linux/mroute.h>
#endif
])dnl
@@ -1415,7 +1415,7 @@ AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[
m4_define([FRR_INCLUDES],
FRR_INCLUDES
-[#if HAVE_NETINET_IP_MROUTE_H
+[#ifdef HAVE_NETINET_IP_MROUTE_H
# include <netinet/ip_mroute.h>
#endif
])dnl
@@ -1473,7 +1473,7 @@ AC_CHECK_HEADER([netinet/tcp.h],
AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
[],
FRR_INCLUDES)
-if test $ac_cv_have_decl_TCP_MD5SIG = no; then
+if test "$ac_cv_have_decl_TCP_MD5SIG" = "no"; then
AC_CHECK_HEADER([linux/tcp.h],
[m4_define([MD5_INCLUDES],
FRR_INCLUDES
@@ -1490,7 +1490,7 @@ AC_CHECK_LIB([resolv], [res_init])
dnl ---------------------------
dnl check system has PCRE regexp
dnl ---------------------------
-if test "x$enable_pcreposix" = "xyes"; then
+if test "$enable_pcreposix" = "yes"; then
AC_CHECK_LIB([pcreposix], [regexec], [], [
AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix])
])
@@ -1498,7 +1498,7 @@ fi
AC_SUBST([HAVE_LIBPCREPOSIX])
dnl ##########################################################################
-dnl test "${enable_clippy_only}" != "yes"
+dnl test "$enable_clippy_only" != "yes"
fi
dnl END OF LARGE if block
dnl ##########################################################################
@@ -1528,17 +1528,17 @@ AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h \
m4_define([FRR_INCLUDES],dnl
FRR_INCLUDES
-[#if HAVE_NETINET6_IN6_H
+[#ifdef HAVE_NETINET6_IN6_H
#include <netinet6/in6.h>
#endif
-#if HAVE_NETINET_IN6_VAR_H
+#ifdef HAVE_NETINET_IN6_VAR_H
#include <netinet/in6_var.h>
#endif
#include <netinet/icmp6.h>
-#if HAVE_NETINET6_IN6_VAR_H
+#ifdef HAVE_NETINET6_IN6_VAR_H
# include <netinet6/in6_var.h>
#endif
-#if HAVE_NETINET6_ND6_H
+#ifdef HAVE_NETINET6_ND6_H
# include <netinet6/nd6.h>
#endif
])dnl
@@ -1547,7 +1547,7 @@ dnl --------------------
dnl Daemon disable check
dnl --------------------
-AS_IF([test "${enable_ldpd}" != "no"], [
+AS_IF([test "$enable_ldpd" != "no"], [
AC_DEFINE([HAVE_LDPD], [1], [ldpd])
])
@@ -1569,7 +1569,7 @@ else
esac
fi
-if test "$ac_cv_lib_json_c_json_object_get" = no -a "x$BFDD" = "xbfdd"; then
+if test "$ac_cv_lib_json_c_json_object_get" = "no" -a "$BFDD" = "bfdd"; then
AC_MSG_ERROR(["you must use json-c library to use bfdd"])
fi
@@ -1580,7 +1580,7 @@ case "$host_os" in
no)
;;
yes)
- if test "${enable_clippy_only}" != "yes"; then
+ if test "$enable_clippy_only" != "yes"; then
if test "$c_ares_found" != "true" ; then
AC_MSG_ERROR([nhrpd requires libcares. Please install c-ares and its -dev headers.])
fi
@@ -1595,34 +1595,34 @@ case "$host_os" in
esac
;;
*)
- if test "${enable_nhrpd}" = "yes"; then
+ if test "$enable_nhrpd" = "yes"; then
AC_MSG_ERROR([nhrpd requires kernel APIs that are only present on Linux.])
fi
;;
esac
-if test "${enable_watchfrr}" = "no";then
+if test "$enable_watchfrr" = "no";then
WATCHFRR=""
else
WATCHFRR="watchfrr"
fi
OSPFCLIENT=""
-if test "${enable_ospfapi}" != "no";then
+if test "$enable_ospfapi" != "no";then
AC_DEFINE([SUPPORT_OSPF_API], [1], [OSPFAPI])
- if test "${enable_ospfclient}" != "no";then
+ if test "$enable_ospfclient" != "no";then
OSPFCLIENT="ospfclient"
fi
fi
-if test "${enable_bgp_announce}" = "no";then
+if test "$enable_bgp_announce" = "no";then
AC_DEFINE([DISABLE_BGP_ANNOUNCE], [1], [Disable BGP installation to zebra])
else
AC_DEFINE([DISABLE_BGP_ANNOUNCE], [0], [Disable BGP installation to zebra])
fi
-if test "${enable_bgp_vnc}" != "no";then
+if test "$enable_bgp_vnc" != "no";then
AC_DEFINE([ENABLE_BGP_VNC], [1], [Enable BGP VNC support])
fi
@@ -1645,15 +1645,15 @@ esac
dnl ##########################################################################
dnl LARGE if block
-if test "${enable_clippy_only}" != "yes"; then
+if test "$enable_clippy_only" != "yes"; then
dnl ##########################################################################
dnl ------------------
dnl check Net-SNMP library
dnl ------------------
-if test "${enable_snmp}" != "" -a "${enable_snmp}" != "no"; then
+if test "$enable_snmp" != "" -a "$enable_snmp" != "no"; then
AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
- if test x"$NETSNMP_CONFIG" = x"no"; then
+ if test "$NETSNMP_CONFIG" = "no"; then
AC_MSG_ERROR([--enable-snmp given but unable to find net-snmp-config])
fi
SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`"
@@ -1726,7 +1726,7 @@ dnl confd
dnl ---------------
if test "$enable_confd" != "" -a "$enable_confd" != "no"; then
AC_CHECK_PROG([CONFD], [confd], [confd], [/bin/false], "${enable_confd}/bin")
- if test "x$CONFD" = "x/bin/false"; then
+ if test "$CONFD" = "/bin/false"; then
AC_MSG_ERROR([confd was not found on your system.])]
fi
CONFD_CFLAGS="-I${enable_confd}/include -L${enable_confd}/lib"
@@ -1769,12 +1769,12 @@ fi
dnl ------
dnl ZeroMQ
dnl ------
-if test "x$enable_zeromq" != "xno"; then
+if test "$enable_zeromq" != "no"; then
PKG_CHECK_MODULES([ZEROMQ], [libzmq >= 4.0.0], [
AC_DEFINE([HAVE_ZEROMQ], [1], [Enable ZeroMQ support])
ZEROMQ=true
], [
- if test "x$enable_zeromq" = "xyes"; then
+ if test "$enable_zeromq" = "yes"; then
AC_MSG_ERROR([configuration specifies --enable-zeromq but libzmq was not found])
fi
])
@@ -1783,7 +1783,7 @@ fi
dnl ------------------------------------
dnl Enable RPKI and add librtr to libs
dnl ------------------------------------
-if test "${enable_rpki}" = "yes"; then
+if test "$enable_rpki" = "yes"; then
PKG_CHECK_MODULES([RTRLIB], [rtrlib >= 0.5.0],
[RPKI=true],
[RPKI=false
@@ -1827,7 +1827,7 @@ AC_CACHE_CHECK([for dlinfo(RTLD_DI_ORIGIN)], [frr_cv_rtld_di_origin], [
frr_cv_rtld_di_origin=no
])
])
-if test "$frr_cv_rtld_di_origin" = yes; then
+if test "$frr_cv_rtld_di_origin" = "yes"; then
AC_DEFINE([HAVE_DLINFO_ORIGIN], [1], [Have dlinfo RTLD_DI_ORIGIN])
fi
@@ -1847,12 +1847,12 @@ AC_CACHE_CHECK([for dlinfo(RTLD_DI_LINKMAP)], [frr_cv_rtld_di_linkmap], [
frr_cv_rtld_di_linkmap=no
])
])
-if test "$frr_cv_rtld_di_linkmap" = yes; then
+if test "$frr_cv_rtld_di_linkmap" = "yes"; then
AC_DEFINE([HAVE_DLINFO_LINKMAP], [1], [Have dlinfo RTLD_DI_LINKMAP])
fi
dnl ##########################################################################
-dnl test "${enable_clippy_only}" != "yes"
+dnl test "$enable_clippy_only" != "yes"
fi
dnl END OF LARGE if block
dnl ##########################################################################
@@ -2052,7 +2052,7 @@ fi
dnl -------------------
dnl capabilities checks
dnl -------------------
-if test "${enable_capabilities}" != "no"; then
+if test "$enable_capabilities" != "no"; then
AC_MSG_CHECKING([whether prctl PR_SET_KEEPCAPS is available])
AC_TRY_COMPILE([#include <sys/prctl.h>], [prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);],
[AC_MSG_RESULT([yes])
@@ -2060,11 +2060,11 @@ if test "${enable_capabilities}" != "no"; then
frr_ac_keepcaps="yes"],
AC_MSG_RESULT([no])
)
- if test x"${frr_ac_keepcaps}" = x"yes"; then
+ if test "$frr_ac_keepcaps" = "yes"; then
AC_CHECK_HEADERS([sys/capability.h])
fi
- if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then
- AC_CHECK_LIB([cap], [cap_init],
+ if test "$ac_cv_header_sys_capability_h" = "yes"; then
+ AC_CHECK_LIB([cap], [cap_init],
[AC_DEFINE([HAVE_LCAPS], [1], [Capabilities])
LIBCAP="-lcap"
frr_ac_lcaps="yes"]
@@ -2081,14 +2081,14 @@ if test "${enable_capabilities}" != "no"; then
]
)
fi
- if test x"${frr_ac_scaps}" = x"yes" \
- -o x"${frr_ac_lcaps}" = x"yes"; then
+ if test "$frr_ac_scaps" = "yes" \
+ -o "$frr_ac_lcaps" = "yes"; then
AC_DEFINE([HAVE_CAPABILITIES], [1], [capabilities])
fi
case "$host_os" in
linux*)
- if test "${enable_clippy_only}" != "yes"; then
+ if test "$enable_clippy_only" != "yes"; then
if test "$frr_ac_lcaps" != "yes"; then
AC_MSG_ERROR([libcap and/or its headers were not found. Running FRR without libcap support built in causes a huge performance penalty.])
fi
@@ -2106,8 +2106,8 @@ AC_SUBST([LIBCAP])
dnl ---------------------------
dnl check for glibc 'backtrace'
-dnl ---------------------------
-if test x"${enable_backtrace}" != x"no" ; then
+dnl ---------------------------
+if test "$enable_backtrace" != "no" ; then
backtrace_ok=no
PKG_CHECK_MODULES([UNWIND], [libunwind], [
AC_DEFINE([HAVE_LIBUNWIND], [1], [libunwind])
@@ -2134,7 +2134,7 @@ if test x"${enable_backtrace}" != x"no" ; then
])
;;
esac
- if test "$backtrace_ok" = no; then
+ if test "$backtrace_ok" = "no"; then
AC_CHECK_HEADER([execinfo.h], [
AC_SEARCH_LIBS([backtrace], [execinfo], [
AC_DEFINE([HAVE_GLIBC_BACKTRACE], [1], [Glibc backtrace])
@@ -2144,7 +2144,7 @@ if test x"${enable_backtrace}" != x"no" ; then
fi
fi
- if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then
+ if test "$enable_backtrace" = "yes" -a "$backtrace_ok" = "no"; then
dnl user explicitly requested backtrace but we failed to find support
AC_MSG_FAILURE([failed to find backtrace or libunwind support])
fi
@@ -2178,7 +2178,7 @@ struct mallinfo ac_x; ac_x = mallinfo ();
frr_cv_mallinfo=no
])
])
-if test "$frr_cv_mallinfo" = yes; then
+if test "$frr_cv_mallinfo" = "yes"; then
AC_DEFINE([HAVE_MALLINFO], [1], [mallinfo])
fi
@@ -2221,7 +2221,7 @@ dnl configure date
dnl ----------
dev_version=`echo $VERSION | grep dev`
#don't expire deprecated code in non 'dev' branch
-if test "${dev_version}" = ""; then
+if test "$dev_version" = ""; then
CONFDATE=0
else
CONFDATE=`date '+%Y%m%d'`
@@ -2232,12 +2232,12 @@ dnl ------------------------------
dnl set paths for state directory
dnl ------------------------------
AC_MSG_CHECKING([directory to use for state file])
-if test "${prefix}" = "NONE"; then
+if test "$prefix" = "NONE"; then
frr_statedir_prefix="";
else
frr_statedir_prefix=${prefix}
fi
-if test "${localstatedir}" = '${prefix}/var'; then
+if test "$localstatedir" = '${prefix}/var'; then
for FRR_STATE_DIR in ${frr_statedir_prefix}/var/run dnl
${frr_statedir_prefix}/var/adm dnl
${frr_statedir_prefix}/etc dnl
@@ -2252,7 +2252,7 @@ if test "${localstatedir}" = '${prefix}/var'; then
else
frr_statedir=${localstatedir}
fi
-if test $frr_statedir = "/dev/null"; then
+if test "$frr_statedir" = "/dev/null"; then
AC_MSG_ERROR([STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!])
fi
AC_MSG_RESULT([${frr_statedir}])
@@ -2265,8 +2265,8 @@ AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$frr_statedir%s%s"], [daemon vty director
AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$frr_statedir"], [daemon database directory])
dnl autoconf does this, but it does it too late...
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+test "$prefix" = "NONE" && prefix=$ac_default_prefix
+test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
dnl get the full path, recursing through variables...
vtysh_bin="$bindir/vtysh"
@@ -2298,44 +2298,44 @@ AC_DEFINE_UNQUOTED([YANG_MODELS_PATH], ["$CFG_YANGMODELS"], [path to YANG data m
AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh])
dnl various features
-AM_CONDITIONAL([SUPPORT_REALMS], [test "${enable_realms}" = "yes"])
-AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno])
+AM_CONDITIONAL([SUPPORT_REALMS], [test "$enable_realms" = "yes"])
+AM_CONDITIONAL([ENABLE_BGP_VNC], [test "$enable_bgp_vnc" != "no"])
AM_CONDITIONAL([BGP_BMP], [$bgpd_bmp])
dnl northbound
AM_CONDITIONAL([SQLITE3], [$SQLITE3])
-AM_CONDITIONAL([CONFD], [test "x$enable_confd" != "x"])
-AM_CONDITIONAL([SYSREPO], [test "x$enable_sysrepo" = "xyes"])
-AM_CONDITIONAL([GRPC], [test "x$enable_grpc" = "xyes"])
-AM_CONDITIONAL([ZEROMQ], [test "x$ZEROMQ" = "xtrue"])
+AM_CONDITIONAL([CONFD], [test "$enable_confd" != ""])
+AM_CONDITIONAL([SYSREPO], [test "$enable_sysrepo" = "yes"])
+AM_CONDITIONAL([GRPC], [test "$enable_grpc" = "yes"])
+AM_CONDITIONAL([ZEROMQ], [test "$ZEROMQ" = "true"])
dnl plugins
-AM_CONDITIONAL([RPKI], [test "x$RPKI" = "xtrue"])
-AM_CONDITIONAL([SNMP], [test "x$SNMP_METHOD" = "xagentx"])
+AM_CONDITIONAL([RPKI], [test "$RPKI" = "true"])
+AM_CONDITIONAL([SNMP], [test "$SNMP_METHOD" = "agentx"])
AM_CONDITIONAL([IRDP], [$IRDP])
-AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"])
-AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$enable_protobuf" = "xyes"])
+AM_CONDITIONAL([FPM], [test "$enable_fpm" = "yes"])
+AM_CONDITIONAL([HAVE_PROTOBUF], [test "$enable_protobuf" = "yes"])
AM_CONDITIONAL([HAVE_PROTOBUF3], [$PROTO3])
dnl daemons
-AM_CONDITIONAL([VTYSH], [test "x$VTYSH" = "xvtysh"])
-AM_CONDITIONAL([ZEBRA], [test "${enable_zebra}" != "no"])
-AM_CONDITIONAL([BGPD], [test "x${enable_bgpd}" != "no"])
-AM_CONDITIONAL([RIPD], [test "${enable_ripd}" != "no"])
-AM_CONDITIONAL([OSPFD], [test "${enable_ospfd}" != "no"])
-AM_CONDITIONAL([LDPD], [test "${enable_ldpd}" != "no"])
-AM_CONDITIONAL([BFDD], [test "x$BFDD" = "xbfdd"])
-AM_CONDITIONAL([NHRPD], [test "x$NHRPD" = "xnhrpd"])
-AM_CONDITIONAL([EIGRPD], [test "${enable_eigrpd}" != "no"])
-AM_CONDITIONAL([WATCHFRR], [test "x$WATCHFRR" = "xwatchfrr"])
-AM_CONDITIONAL([OSPFCLIENT], [test "x$OSPFCLIENT" = "xospfclient"])
-AM_CONDITIONAL([RIPNGD], [test "${enable_ripngd}" != "no"])
-AM_CONDITIONAL([BABELD], [test "${enable_babeld}" != "no"])
-AM_CONDITIONAL([OSPF6D], [test "${enable_ospf6d}" != "no"])
-AM_CONDITIONAL([ISISD], [test "${enable_isisd}" != "no"])
-AM_CONDITIONAL([PIMD], [test "${enable_pimd}" != "no"])
-AM_CONDITIONAL([PBRD], [test "${enable_pbrd}" != "no"])
-AM_CONDITIONAL([SHARPD], [test "${enable_sharpd}" = "yes"])
-AM_CONDITIONAL([STATICD], [test "${enable_staticd}" != "no"])
-AM_CONDITIONAL([FABRICD], [test "${enable_fabricd}" != "no"])
-AM_CONDITIONAL([VRRPD], [test "${enable_vrrpd}" != "no"])
+AM_CONDITIONAL([VTYSH], [test "$VTYSH" = "vtysh"])
+AM_CONDITIONAL([ZEBRA], [test "$enable_zebra" != "no"])
+AM_CONDITIONAL([BGPD], [test "$enable_bgpd" != "no"])
+AM_CONDITIONAL([RIPD], [test "$enable_ripd" != "no"])
+AM_CONDITIONAL([OSPFD], [test "$enable_ospfd" != "no"])
+AM_CONDITIONAL([LDPD], [test "$enable_ldpd" != "no"])
+AM_CONDITIONAL([BFDD], [test "$BFDD" = "bfdd"])
+AM_CONDITIONAL([NHRPD], [test "$NHRPD" = "nhrpd"])
+AM_CONDITIONAL([EIGRPD], [test "$enable_eigrpd" != "no"])
+AM_CONDITIONAL([WATCHFRR], [test "$WATCHFRR" = "watchfrr"])
+AM_CONDITIONAL([OSPFCLIENT], [test "$OSPFCLIENT" = "ospfclient"])
+AM_CONDITIONAL([RIPNGD], [test "$enable_ripngd" != "no"])
+AM_CONDITIONAL([BABELD], [test "$enable_babeld" != "no"])
+AM_CONDITIONAL([OSPF6D], [test "$enable_ospf6d" != "no"])
+AM_CONDITIONAL([ISISD], [test "$enable_isisd" != "no"])
+AM_CONDITIONAL([PIMD], [test "$enable_pimd" != "no"])
+AM_CONDITIONAL([PBRD], [test "$enable_pbrd" != "no"])
+AM_CONDITIONAL([SHARPD], [test "$enable_sharpd" = "yes"])
+AM_CONDITIONAL([STATICD], [test "$enable_staticd" != "no"])
+AM_CONDITIONAL([FABRICD], [test "$enable_fabricd" != "no"])
+AM_CONDITIONAL([VRRPD], [test "$enable_vrrpd" != "no"])
AC_CONFIG_FILES([Makefile],[sed -e 's/^#AUTODERP# //' -i Makefile])
@@ -2363,7 +2363,7 @@ AC_CONFIG_COMMANDS([lib/route_types.h], [
${PERL} "${ac_abs_top_srcdir}/lib/route_types.pl" \
< "${ac_abs_top_srcdir}/lib/route_types.txt" \
> "${dst}.tmp"
- test -f "${dst}" \
+ test -f "$dst" \
&& diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \
&& rm "${dst}.tmp" \
|| mv "${dst}.tmp" "${dst}"
@@ -2371,13 +2371,13 @@ AC_CONFIG_COMMANDS([lib/route_types.h], [
PERL="$PERL"
])
-AS_IF([test "x$with_pkg_git_version" = "xyes"], [
+AS_IF([test "$with_pkg_git_version" = "yes"], [
AC_CONFIG_COMMANDS([lib/gitversion.h], [
dst="${ac_abs_top_builddir}/lib/gitversion.h"
${PERL} "${ac_abs_top_srcdir}/lib/gitversion.pl" \
"${ac_abs_top_srcdir}" \
> "${dst}.tmp"
- test -f "${dst}" \
+ test -f "$dst" \
&& diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \
&& rm "${dst}.tmp" \
|| mv "${dst}.tmp" "${dst}"
@@ -2414,9 +2414,9 @@ zebra protobuf enabled : ${enable_protobuf:-no}
The above user and group must have read/write access to the state file
directory and to the config files in the config file directory."
-if test "${enable_doc}" != "no" -a "$frr_py_mod_sphinx" = false; then
+if test "$enable_doc" != "no" -a "$frr_py_mod_sphinx" = "false"; then
AC_MSG_WARN([sphinx is missing but required to build documentation])
fi
-if test "$frr_py_mod_pytest" = false; then
+if test "$frr_py_mod_pytest" = "false"; then
AC_MSG_WARN([pytest is missing, unit tests cannot be performed])
fi
diff --git a/doc/developer/cli.rst b/doc/developer/cli.rst
index 12fcb7a325..edabe61d92 100644
--- a/doc/developer/cli.rst
+++ b/doc/developer/cli.rst
@@ -101,7 +101,7 @@ Definition Grammar
FRR uses its own grammar for defining CLI commands. The grammar draws from
syntax commonly seen in \*nix manpages and should be fairly intuitive. The
parser is implemented in Bison and the lexer in Flex. These may be found in
-``lib/command_lex.l`` and ``lib/command_parse.y``, respectively.
+``lib/command_parse.y`` and ``lib/command_lex.l``, respectively.
**ProTip**: if you define a new command and find that the parser is
throwing syntax or other errors, the parser is the last place you want
diff --git a/doc/manpages/conf.py b/doc/manpages/conf.py
index 9121d38fe0..8b9bb021a3 100644
--- a/doc/manpages/conf.py
+++ b/doc/manpages/conf.py
@@ -192,7 +192,7 @@ html_theme = 'default'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = []
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index de690adb34..85ccc277a8 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -2412,6 +2412,12 @@ Debugging
Show all enabled debugs.
+.. index:: show bgp listeners
+.. clicmd:: show bgp listeners
+
+ Display Listen sockets and the vrf that created them. Useful for debugging of when
+ listen is not working and this is considered a developer debug statement.
+
.. index:: [no] debug bgp neighbor-events
.. clicmd:: [no] debug bgp neighbor-events
diff --git a/doc/user/overview.rst b/doc/user/overview.rst
index b72ceb8d38..e31799c1ef 100644
--- a/doc/user/overview.rst
+++ b/doc/user/overview.rst
@@ -300,10 +300,14 @@ BGP
:t:`The Generalized TTL Security Mechanism (GTSM). V. Gill, J. Heasley, D. Meyer, P. Savola, C. Pingnataro. October 2007.`
- :rfc:`5575`
:t:`Dissemination of Flow Specification Rules. P. Marques, N. Sheth, R. Raszuk, B. Greene, J. Mauch, D. McPherson. August 2009`
+- :rfc:`6608`
+ :t:`Subcodes for BGP Finite State Machine Error. J. Dong, M. Chen, Huawei Technologies, A. Suryanarayana, Cisco Systems. May 2012.`
- :rfc:`6810`
:t:`The Resource Public Key Infrastructure (RPKI) to Router Protocol. R. Bush, R. Austein. January 2013.`
- :rfc:`6811`
:t:`BGP Prefix Origin Validation. P. Mohapatra, J. Scudder, D. Ward, R. Bush, R. Austein. January 2013.`
+- :rfc:`7607`
+ :t:`Codification of AS 0 Processing. W. Kumari, R. Bush, H. Schiller, K. Patel. August 2015.`
- :rfc:`7611`
:t:`BGP ACCEPT_OWN Community Attribute. J. Uttaro, P. Mohapatra, D. Smith, R. Raszuk, J. Scudder. August 2015.`
- :rfc:`7999`
diff --git a/doc/user/pim.rst b/doc/user/pim.rst
index 9876216736..f480c6bdc4 100644
--- a/doc/user/pim.rst
+++ b/doc/user/pim.rst
@@ -66,6 +66,14 @@ Certain signals have special meanings to *pimd*.
prefix of group ranges covered. This command is vrf aware, to configure for
a vrf, enter the vrf submode.
+.. index:: ip pim register-accept-list PLIST
+.. clicmd:: ip pim register-accept-list PLIST
+
+ When pim receives a register packet the source of the packet will be compared
+ to the prefix-list specified, PLIST, and if a permit is received normal
+ processing continues. If a deny is returned for the source address of the
+ register packet a register stop message is sent to the source.
+
.. index:: ip pim spt-switchover infinity-and-beyond
.. clicmd:: ip pim spt-switchover infinity-and-beyond
@@ -174,6 +182,13 @@ PIM interface commands allow you to configure an interface as either a Receiver
or a interface that you would like to form pim neighbors on. If the interface
is in a vrf, enter the interface command with the vrf keyword at the end.
+.. index:: ip pim active-active
+.. clicmd:: ip pim active-active
+
+ Turn on pim active-active configuration for a Vxlan interface. This
+ command will not do anything if you do not have the underlying ability
+ of a mlag implementation.
+
.. index:: ip pim bfd
.. clicmd:: ip pim bfd
@@ -392,6 +407,11 @@ cause great confusion.
Display information about interfaces PIM is using.
+.. index:: show ip pim mlag [vrf NAME] interface [detail|WORD] [json]
+.. clicmd:: show ip pim mlag [vrf NAME|all] interface [detail|WORD] [json]
+
+ Display mlag interface information.
+
.. index:: show ip pim [vrf NAME] join [A.B.C.D [A.B.C.D]] [json]
.. clicmd:: show ip pim join
@@ -404,6 +424,11 @@ cause great confusion.
Display information about PIM interface local-membership.
+.. index:: show ip pim mlag summary [json]
+.. clicmd:: show ip pim mlag summary [json]
+
+ Display mlag information state that PIM is keeping track of.
+
.. index:: show ip pim neighbor
.. clicmd:: show ip pim neighbor
diff --git a/doc/user/sharp.rst b/doc/user/sharp.rst
index 111e9dc9e8..199685cdfb 100644
--- a/doc/user/sharp.rst
+++ b/doc/user/sharp.rst
@@ -86,3 +86,20 @@ keyword. At present, no sharp commands will be preserved in the config.
Allow end user to dump associated data with the nexthop tracking that
may have been turned on.
+
+.. index:: sharp lsp
+.. clicmd:: sharp lsp (0-100000) nexthop-group NAME [prefix A.B.C.D/M TYPE [instance (0-255)]]
+
+ Install an LSP using the specified in-label, with nexthops as
+ listed in nexthop-group ``NAME``. The LSP is installed as type
+ ZEBRA_LSP_SHARP. If ``prefix`` is specified, an existing route with
+ type ``TYPE`` (and optional ``instance`` id) will be updated to use
+ the LSP.
+
+.. index:: sharp remove lsp
+.. clicmd:: sharp remove lsp (0-100000) nexthop-group NAME [prefix A.B.C.D/M TYPE [instance (0-255)]]
+
+ Remove a SHARPD LSP that uses the specified in-label, where the
+ nexthops are specified in nexthop-group ``NAME``. If ``prefix`` is
+ specified, remove label bindings from the route of type ``TYPE``
+ also.
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index 48e9a18e5a..6090a1ef13 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -749,7 +749,7 @@ static struct stream *eigrp_recv_packet(struct eigrp *eigrp,
ip_len = iph->ip_len;
-#if !defined(GNU_LINUX) && (OpenBSD < 200311) && (__FreeBSD_version < 1000000)
+#if defined(__FreeBSD__) && (__FreeBSD_version < 1000000)
/*
* Kernel network code touches incoming IP header parameters,
* before protocol specific processing.
diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c
index 99cc34d3d0..e15f777954 100644
--- a/eigrpd/eigrp_routemap.c
+++ b/eigrpd/eigrp_routemap.c
@@ -295,7 +295,7 @@ static void *route_match_metric_compile(const char *arg)
{
// uint32_t *metric;
//
- // metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (uint32_t));
+ // metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
// *metric = atoi (arg);
//
// if(*metric > 0)
@@ -574,7 +574,7 @@ static void *route_match_tag_compile(const char *arg)
{
// unsigned short *tag;
//
- // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short));
+ // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
// *tag = atoi (arg);
//
// return tag;
@@ -667,7 +667,7 @@ static void *route_set_metric_compile(const char *arg)
// return NULL;*/
//
// mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
- // sizeof (struct rip_metric_modifier));
+ // sizeof(struct rip_metric_modifier));
// mod->type = type;
// mod->metric = metric;
@@ -718,7 +718,7 @@ static void *route_set_ip_nexthop_compile(const char *arg)
// int ret;
// struct in_addr *address;
//
- // address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct
+ // address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(struct
// in_addr));
//
// ret = inet_aton (arg, address);
@@ -775,7 +775,7 @@ static void *route_set_tag_compile(const char *arg)
{
// unsigned short *tag;
//
- // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short));
+ // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
// *tag = atoi (arg);
//
// return tag;
diff --git a/fpm/fpm.h b/fpm/fpm.h
index f73ab7c66f..0da8a5a8be 100644
--- a/fpm/fpm.h
+++ b/fpm/fpm.h
@@ -175,7 +175,7 @@ static inline size_t fpm_msg_align(size_t len)
* The (rounded up) size of the FPM message header. This ensures that
* the message payload always starts at an aligned address.
*/
-#define FPM_MSG_HDR_LEN (sizeof (fpm_msg_hdr_t))
+#define FPM_MSG_HDR_LEN (sizeof(fpm_msg_hdr_t))
#ifndef COMPILE_ASSERT
#define COMPILE_ASSERT(x) extern int __dummy[2 * !!(x) - 1]
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 5fa33f5500..96b76da92d 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -562,20 +562,12 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
void vty_out_timestr(struct vty *vty, time_t uptime)
{
- struct tm tm;
time_t difftime = time(NULL);
+ char buf[MONOTIME_STRLEN];
+
difftime -= uptime;
- gmtime_r(&difftime, &tm);
-
- if (difftime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (difftime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
- vty_out(vty, " ago");
+ frrtime_to_interval(difftime, buf, sizeof(buf));
+
+ vty_out(vty, "%s ago", buf);
}
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index cc22aa5ffd..9153512623 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1652,7 +1652,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
if (length != expected_length) {
flog_err(EC_ISIS_PACKET,
- "Exepected fixed header length = %" PRIu8
+ "Expected fixed header length = %" PRIu8
" but got %" PRIu8,
expected_length, length);
return ISIS_ERROR;
diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c
index df6280e5c3..5b0b709206 100644
--- a/isisd/isis_tlvs.c
+++ b/isisd/isis_tlvs.c
@@ -2266,7 +2266,7 @@ static int unpack_tlv_spine_leaf(enum isis_tlv_context context,
sbuf_push(log, indent, "Unpacking Spine Leaf Extension TLV...\n");
if (tlv_len < 2) {
- sbuf_push(log, indent, "WARNING: Unexepected TLV size\n");
+ sbuf_push(log, indent, "WARNING: Unexpected TLV size\n");
stream_forward_getp(s, tlv_len);
return 0;
}
@@ -2382,7 +2382,7 @@ static int unpack_tlv_threeway_adj(enum isis_tlv_context context,
sbuf_push(log, indent, "Unpacking P2P Three-Way Adjacency TLV...\n");
if (tlv_len != 5 && tlv_len != 15) {
- sbuf_push(log, indent, "WARNING: Unexepected TLV size\n");
+ sbuf_push(log, indent, "WARNING: Unexpected TLV size\n");
stream_forward_getp(s, tlv_len);
return 0;
}
diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c
index 88f7337a91..09b8d28258 100644
--- a/isisd/isis_vty_fabricd.c
+++ b/isisd/isis_vty_fabricd.c
@@ -115,6 +115,7 @@ DEFUN (no_triggered_csnp,
static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
{
char lspid[255];
+ char buf[MONOTIME_STRLEN];
lspid_print(lsp->hdr.lsp_id, lspid, true, true);
vty_out(vty, "Flooding information for %s\n", lspid);
@@ -129,21 +130,10 @@ static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)
lsp->flooding_interface : "(null)");
time_t uptime = time(NULL) - lsp->flooding_time;
- struct tm tm;
- gmtime_r(&uptime, &tm);
+ frrtime_to_interval(uptime, buf, sizeof(buf));
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7),
- tm.tm_hour);
- vty_out(vty, " ago)\n");
+ vty_out(vty, "%s ago)\n", buf);
if (lsp->flooding_circuit_scoped) {
vty_out(vty, " Received as circuit-scoped LSP, so not "
diff --git a/ldpd/hello.c b/ldpd/hello.c
index d17e80008e..a8d6e58cda 100644
--- a/ldpd/hello.c
+++ b/ldpd/hello.c
@@ -169,7 +169,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
int tlvs_rcvd;
int ds_tlv;
union ldpd_addr trans_addr;
- uint32_t scope_id = 0;
+ ifindex_t scope_id = 0;
uint32_t conf_seqnum;
uint16_t trans_pref;
int r;
diff --git a/ldpd/interface.c b/ldpd/interface.c
index 8b45703d22..c7d6dea518 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -109,7 +109,7 @@ ldpe_if_exit(struct iface *iface)
}
struct iface *
-if_lookup(struct ldpd_conf *xconf, unsigned short ifindex)
+if_lookup(struct ldpd_conf *xconf, ifindex_t ifindex)
{
struct iface *iface;
diff --git a/ldpd/lde.c b/ldpd/lde.c
index 006d27f6ab..5f94031320 100644
--- a/ldpd/lde.c
+++ b/ldpd/lde.c
@@ -71,9 +71,6 @@ struct nbr_tree lde_nbrs = RB_INITIALIZER(&lde_nbrs);
static struct imsgev *iev_ldpe;
static struct imsgev *iev_main, *iev_main_sync;
-/* Master of threads. */
-struct thread_master *master;
-
/* lde privileges */
static zebra_capabilities_t _caps_p [] =
{
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 7ab8d56f24..78b1c3e544 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -86,6 +86,8 @@ static struct imsgev *iev_lde, *iev_lde_sync;
static pid_t ldpe_pid;
static pid_t lde_pid;
+enum ldpd_process ldpd_process;
+
#define LDP_DEFAULT_CONFIG "ldpd.conf"
#define LDP_VTY_PORT 2612
diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h
index bd7562e5ad..006780f032 100644
--- a/ldpd/ldpd.h
+++ b/ldpd/ldpd.h
@@ -306,7 +306,7 @@ struct iface_af {
struct iface {
RB_ENTRY(iface) entry;
char name[IF_NAMESIZE];
- unsigned int ifindex;
+ ifindex_t ifindex;
struct if_addr_head addr_list;
struct in6_addr linklocal;
enum iface_type type;
@@ -391,7 +391,7 @@ struct l2vpn_if {
RB_ENTRY(l2vpn_if) entry;
struct l2vpn *l2vpn;
char ifname[IF_NAMESIZE];
- unsigned int ifindex;
+ ifindex_t ifindex;
int operative;
uint8_t mac[ETH_ALEN];
QOBJ_FIELDS
@@ -408,7 +408,7 @@ struct l2vpn_pw {
union ldpd_addr addr;
uint32_t pwid;
char ifname[IF_NAMESIZE];
- unsigned int ifindex;
+ ifindex_t ifindex;
bool enabled;
uint32_t remote_group;
uint16_t remote_mtu;
@@ -433,7 +433,7 @@ struct l2vpn {
int pw_type;
int mtu;
char br_ifname[IF_NAMESIZE];
- unsigned int br_ifindex;
+ ifindex_t br_ifindex;
struct l2vpn_if_head if_tree;
struct l2vpn_pw_head pw_tree;
struct l2vpn_pw_head pw_inactive_tree;
@@ -446,7 +446,7 @@ DECLARE_QOBJ_TYPE(l2vpn)
#define L2VPN_TYPE_VPLS 2
/* ldp_conf */
-enum ldpd_process {
+extern enum ldpd_process {
PROC_MAIN,
PROC_LDP_ENGINE,
PROC_LDE_ENGINE
@@ -542,7 +542,7 @@ struct kroute {
union ldpd_addr nexthop;
uint32_t local_label;
uint32_t remote_label;
- unsigned short ifindex;
+ ifindex_t ifindex;
uint8_t route_type;
uint8_t route_instance;
uint16_t flags;
@@ -550,7 +550,7 @@ struct kroute {
struct kaddr {
char ifname[IF_NAMESIZE];
- unsigned short ifindex;
+ ifindex_t ifindex;
int af;
union ldpd_addr addr;
uint8_t prefixlen;
@@ -559,7 +559,7 @@ struct kaddr {
struct kif {
char ifname[IF_NAMESIZE];
- unsigned short ifindex;
+ ifindex_t ifindex;
int flags;
int operative;
uint8_t mac[ETH_ALEN];
@@ -577,7 +577,7 @@ struct acl_check {
struct ctl_iface {
int af;
char name[IF_NAMESIZE];
- unsigned int ifindex;
+ ifindex_t ifindex;
int state;
enum iface_type type;
uint16_t hello_holdtime;
@@ -760,7 +760,7 @@ int sock_set_bindany(int, int);
int sock_set_md5sig(int, int, union ldpd_addr *, const char *);
int sock_set_ipv4_tos(int, int);
int sock_set_ipv4_pktinfo(int, int);
-int sock_set_ipv4_recvdstaddr(int, int);
+int sock_set_ipv4_recvdstaddr(int fd, ifindex_t ifindex);
int sock_set_ipv4_recvif(int, int);
int sock_set_ipv4_minttl(int, int);
int sock_set_ipv4_ucast_ttl(int fd, int);
@@ -783,7 +783,8 @@ struct fec;
const char *log_sockaddr(void *);
const char *log_in6addr(const struct in6_addr *);
-const char *log_in6addr_scope(const struct in6_addr *, unsigned int);
+const char *log_in6addr_scope(const struct in6_addr *addr,
+ ifindex_t ifidx);
const char *log_addr(int, const union ldpd_addr *);
char *log_label(uint32_t);
const char *log_time(time_t);
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index c16d92f28b..b34a1ecdd7 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -41,7 +41,7 @@ static int ldpe_dispatch_pfkey(struct thread *);
#endif
static void ldpe_setup_sockets(int, int, int, int);
static void ldpe_close_sockets(int);
-static void ldpe_iface_af_ctl(struct ctl_conn *, int, unsigned int);
+static void ldpe_iface_af_ctl(struct ctl_conn *c, int af, ifindex_t ifidx);
struct ldpd_conf *leconf;
#ifdef __OpenBSD__
@@ -54,9 +54,6 @@ static struct imsgev *iev_lde;
static struct thread *pfkey_ev;
#endif
-/* Master of threads. */
-struct thread_master *master;
-
/* ldpe privileges */
static zebra_capabilities_t _caps_p [] =
{
@@ -97,6 +94,8 @@ static struct quagga_signal_t ldpe_signals[] =
},
};
+char *pkt_ptr; /* packet buffer */
+
/* label distribution protocol engine */
void
ldpe(void)
@@ -828,7 +827,7 @@ ldpe_stop_init_backoff(int af)
}
static void
-ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx)
+ldpe_iface_af_ctl(struct ctl_conn *c, int af, ifindex_t idx)
{
struct iface *iface;
struct iface_af *ia;
@@ -848,7 +847,7 @@ ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx)
}
void
-ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx)
+ldpe_iface_ctl(struct ctl_conn *c, ifindex_t idx)
{
ldpe_iface_af_ctl(c, AF_INET, idx);
ldpe_iface_af_ctl(c, AF_INET6, idx);
diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h
index ccff1e803d..11650069b7 100644
--- a/ldpd/ldpe.h
+++ b/ldpd/ldpe.h
@@ -92,7 +92,7 @@ struct nbr {
struct in_addr id; /* lsr id */
union ldpd_addr laddr; /* local address */
union ldpd_addr raddr; /* remote address */
- uint32_t raddr_scope; /* remote address scope (v6) */
+ ifindex_t raddr_scope; /* remote address scope (v6) */
time_t uptime;
int fd;
int state;
@@ -208,7 +208,7 @@ void ldpe_reset_ds_nbrs(void);
void ldpe_remove_dynamic_tnbrs(int);
void ldpe_stop_init_backoff(int);
struct ctl_conn;
-void ldpe_iface_ctl(struct ctl_conn *, unsigned int);
+void ldpe_iface_ctl(struct ctl_conn *c, ifindex_t ifidx);
void ldpe_adj_ctl(struct ctl_conn *);
void ldpe_adj_detail_ctl(struct ctl_conn *);
void ldpe_nbr_ctl(struct ctl_conn *);
@@ -219,7 +219,7 @@ void mapping_list_clr(struct mapping_head *);
struct iface *if_new(const char *);
void ldpe_if_init(struct iface *);
void ldpe_if_exit(struct iface *);
-struct iface *if_lookup(struct ldpd_conf *, unsigned short);
+struct iface *if_lookup(struct ldpd_conf *c, ifindex_t ifidx);
struct iface *if_lookup_name(struct ldpd_conf *, const char *);
void if_update_info(struct iface *, struct kif *);
struct iface_af *iface_af_get(struct iface *, int);
@@ -291,7 +291,7 @@ struct tcp_conn *tcp_new(int, struct nbr *);
void pending_conn_del(struct pending_conn *);
struct pending_conn *pending_conn_find(int, union ldpd_addr *);
-char *pkt_ptr; /* packet buffer */
+extern char *pkt_ptr; /* packet buffer */
/* pfkey.c */
#ifdef __OpenBSD__
diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c
index a9b066a3da..2c9fbf0dae 100644
--- a/ldpd/logmsg.c
+++ b/ldpd/logmsg.c
@@ -59,7 +59,7 @@ log_in6addr(const struct in6_addr *addr)
}
const char *
-log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex)
+log_in6addr_scope(const struct in6_addr *addr, ifindex_t ifindex)
{
struct sockaddr_in6 sa_in6;
diff --git a/ldpd/socket.c b/ldpd/socket.c
index 997434620a..4909ea7ad8 100644
--- a/ldpd/socket.c
+++ b/ldpd/socket.c
@@ -329,7 +329,7 @@ sock_set_ipv4_tos(int fd, int tos)
}
int
-sock_set_ipv4_recvif(int fd, int enable)
+sock_set_ipv4_recvif(int fd, ifindex_t enable)
{
return (setsockopt_ifindex(AF_INET, fd, enable));
}
diff --git a/lib/agentx.c b/lib/agentx.c
index b479b5ea4c..d1b801fe8c 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -264,7 +264,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,
uint8_t sptrap)
{
oid objid_snmptrap[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
- size_t objid_snmptrap_len = sizeof objid_snmptrap / sizeof(oid);
+ size_t objid_snmptrap_len = sizeof(objid_snmptrap) / sizeof(oid);
oid notification_oid[MAX_OID_LEN];
size_t notification_oid_len;
unsigned int i;
diff --git a/lib/buffer.c b/lib/buffer.c
index 766b9791a5..ff49bc83df 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -288,7 +288,7 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,
/* Previously print out is performed. */
if (erase_flag) {
iov[iov_index].iov_base = erase;
- iov[iov_index].iov_len = sizeof erase;
+ iov[iov_index].iov_len = sizeof(erase);
iov_index++;
}
@@ -341,7 +341,7 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,
/* In case of `more' display need. */
if (b->tail && (b->tail->sp < b->tail->cp) && !no_more_flag) {
iov[iov_index].iov_base = more;
- iov[iov_index].iov_len = sizeof more;
+ iov[iov_index].iov_len = sizeof(more);
iov_index++;
}
diff --git a/lib/getopt.h b/lib/getopt.h
index 138870d199..63e12e947e 100644
--- a/lib/getopt.h
+++ b/lib/getopt.h
@@ -111,7 +111,7 @@ struct option {
#if defined(__STDC__) && __STDC__
-#if REALLY_NEED_PLAIN_GETOPT
+#ifdef REALLY_NEED_PLAIN_GETOPT
/*
* getopt is defined in POSIX.2. Assume that if the system defines
diff --git a/lib/if.c b/lib/if.c
index 5edb58a2de..dabf66799d 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -887,11 +887,8 @@ void connected_free(struct connected **connected)
{
struct connected *ptr = *connected;
- if (ptr->address)
- prefix_free(&ptr->address);
-
- if (ptr->destination)
- prefix_free(&ptr->destination);
+ prefix_free(&ptr->address);
+ prefix_free(&ptr->destination);
XFREE(MTYPE_CONNECTED_LABEL, ptr->label);
diff --git a/lib/md5.c b/lib/md5.c
index 5a3e7c8d1b..9c003a3af6 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -412,8 +412,8 @@ void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
*/
/* start out by storing key in pads */
- bzero(k_ipad, sizeof k_ipad);
- bzero(k_opad, sizeof k_opad);
+ bzero(k_ipad, sizeof(k_ipad));
+ bzero(k_opad, sizeof(k_opad));
bcopy(key, k_ipad, key_len);
bcopy(key, k_opad, key_len);
diff --git a/lib/mlag.c b/lib/mlag.c
index 1daf290725..733dd41ea8 100644
--- a/lib/mlag.c
+++ b/lib/mlag.c
@@ -81,22 +81,33 @@ char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf, size_t size)
}
-int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg)
+int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+#define LIB_MLAG_HDR_LENGTH 8
+ *length = stream_get_endp(s);
+
+ if (s == NULL || msg == NULL || *length < LIB_MLAG_HDR_LENGTH)
return -1;
+ *length -= LIB_MLAG_HDR_LENGTH;
+
STREAM_GETL(s, msg->msg_type);
STREAM_GETW(s, msg->data_len);
STREAM_GETW(s, msg->msg_cnt);
+
return 0;
stream_failure:
return -1;
}
-int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg)
+#define MLAG_MROUTE_ADD_LENGTH \
+ (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
+
+int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+ if (s == NULL || msg == NULL || *length < MLAG_MROUTE_ADD_LENGTH)
return -1;
STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
@@ -108,14 +119,18 @@ int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg)
STREAM_GETC(s, msg->am_i_dual_active);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
+
return 0;
stream_failure:
return -1;
}
-int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg)
+#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
+
+int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
+ size_t *length)
{
- if (s == NULL || msg == NULL)
+ if (s == NULL || msg == NULL || *length < MLAG_MROUTE_DEL_LENGTH)
return -1;
STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ);
@@ -124,6 +139,7 @@ int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg)
STREAM_GETL(s, msg->owner_id);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
+
return 0;
stream_failure:
return -1;
diff --git a/lib/mlag.h b/lib/mlag.h
index c531fb5b68..37bb3aa6db 100644
--- a/lib/mlag.h
+++ b/lib/mlag.h
@@ -125,11 +125,14 @@ struct mlag_msg {
extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size);
extern char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf,
size_t size);
-extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg);
+extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
+ size_t *length);
extern int mlag_lib_decode_mroute_add(struct stream *s,
- struct mlag_mroute_add *msg);
+ struct mlag_mroute_add *msg,
+ size_t *length);
extern int mlag_lib_decode_mroute_del(struct stream *s,
- struct mlag_mroute_del *msg);
+ struct mlag_mroute_del *msg,
+ size_t *length);
extern int mlag_lib_decode_mlag_status(struct stream *s,
struct mlag_status *msg);
extern int mlag_lib_decode_vxlan_update(struct stream *s,
diff --git a/lib/monotime.h b/lib/monotime.h
index e246f177de..dda763784f 100644
--- a/lib/monotime.h
+++ b/lib/monotime.h
@@ -112,6 +112,26 @@ static inline char *time_to_string(time_t ts, char *buf)
return ctime_r(&tbuf, buf);
}
+/* Convert interval to human-friendly string, used in cli output e.g. */
+static inline const char *frrtime_to_interval(time_t t, char *buf,
+ size_t buflen)
+{
+ struct tm tm;
+
+ gmtime_r(&t, &tm);
+
+ if (t < ONE_DAY_SECOND)
+ snprintf(buf, buflen, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
+ tm.tm_sec);
+ else if (t < ONE_WEEK_SECOND)
+ snprintf(buf, buflen, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
+ tm.tm_min);
+ else
+ snprintf(buf, buflen, "%02dw%dd%02dh", tm.tm_yday / 7,
+ tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
+ return buf;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/prefix.c b/lib/prefix.c
index 2b7727fd0a..80fe0f54a9 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1082,7 +1082,7 @@ struct prefix *prefix_new(void)
{
struct prefix *p;
- p = XCALLOC(MTYPE_PREFIX, sizeof *p);
+ p = XCALLOC(MTYPE_PREFIX, sizeof(*p));
return p;
}
diff --git a/lib/printf/printf-pos.c b/lib/printf/printf-pos.c
index 20a58eacdc..cc03f7ef9a 100644
--- a/lib/printf/printf-pos.c
+++ b/lib/printf/printf-pos.c
@@ -686,7 +686,7 @@ build_arg_table(struct typetable *types, va_list ap, union arg **argtable)
if (types->tablemax >= STATIC_ARG_TBL_SIZE) {
*argtable = (union arg *)
- malloc (sizeof (union arg) * (types->tablemax + 1));
+ malloc (sizeof(union arg) * (types->tablemax + 1));
if (*argtable == NULL)
return;
}
diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c
index 2d04a3d65c..69cebbd2a1 100644
--- a/lib/routemap_northbound.c
+++ b/lib/routemap_northbound.c
@@ -221,8 +221,7 @@ static int lib_route_map_entry_description_modify(enum nb_event event,
break;
case NB_EV_APPLY:
rmi = nb_running_get_entry(dnode, NULL, true);
- if (rmi->description != NULL)
- XFREE(MTYPE_TMP, rmi->description);
+ XFREE(MTYPE_TMP, rmi->description);
rmi->description = resource->ptr;
break;
}
diff --git a/lib/seqlock.c b/lib/seqlock.c
index 588a1175bc..77673146ea 100644
--- a/lib/seqlock.c
+++ b/lib/seqlock.c
@@ -165,7 +165,7 @@ bool seqlock_timedwait(struct seqlock *sqlo, seqlock_val_t val,
/*
* ABS_REALTIME - used on NetBSD, Solaris and OSX
*/
-#if TIME_ABS_REALTIME
+#ifdef TIME_ABS_REALTIME
#define time_arg1 &abs_rt
#define time_arg2 NULL
#define time_prep
@@ -187,7 +187,7 @@ bool seqlock_timedwait(struct seqlock *sqlo, seqlock_val_t val,
/*
* RELATIVE - used on OpenBSD (might get a patch to get absolute monotime)
*/
-#elif TIME_RELATIVE
+#elif defined(TIME_RELATIVE)
struct timespec reltime;
#define time_arg1 abs_monotime_limit
diff --git a/lib/skiplist.c b/lib/skiplist.c
index 67cc1ab378..d955c6eb9e 100644
--- a/lib/skiplist.c
+++ b/lib/skiplist.c
@@ -211,12 +211,12 @@ int skiplist_insert(register struct skiplist *l, register void *key,
q = newNodeOfLevel(k);
q->key = key;
q->value = value;
-#if SKIPLIST_0TIMER_DEBUG
+#ifdef SKIPLIST_0TIMER_DEBUG
q->flags = SKIPLIST_NODE_FLAG_INSERTED; /* debug */
#endif
++(l->stats->forward[k]);
-#if SKIPLIST_DEBUG
+#ifdef SKIPLIST_DEBUG
zlog_debug("%s: incremented stats @%p:%d, now %ld", __func__, l, k,
l->stats->forward[k] - (struct skiplistnode *)NULL);
#endif
@@ -281,7 +281,7 @@ int skiplist_delete(register struct skiplist *l, register void *key,
/*
* found node to delete
*/
-#if SKIPLIST_0TIMER_DEBUG
+#ifdef SKIPLIST_0TIMER_DEBUG
q->flags &= ~SKIPLIST_NODE_FLAG_INSERTED;
#endif
/*
@@ -300,7 +300,7 @@ int skiplist_delete(register struct skiplist *l, register void *key,
p->forward[k] = q->forward[k];
}
--(l->stats->forward[k - 1]);
-#if SKIPLIST_DEBUG
+#ifdef SKIPLIST_DEBUG
zlog_debug("%s: decremented stats @%p:%d, now %ld",
__func__, l, k - 1,
l->stats->forward[k - 1]
@@ -549,7 +549,7 @@ int skiplist_delete_first(register struct skiplist *l)
}
}
-#if SKIPLIST_0TIMER_DEBUG
+#ifdef SKIPLIST_0TIMER_DEBUG
q->flags &= ~SKIPLIST_NODE_FLAG_INSERTED;
#endif
/*
@@ -561,7 +561,7 @@ int skiplist_delete_first(register struct skiplist *l)
}
--(l->stats->forward[nodelevel]);
-#if SKIPLIST_DEBUG
+#ifdef SKIPLIST_DEBUG
zlog_debug("%s: decremented stats @%p:%d, now %ld", __func__, l,
nodelevel,
l->stats->forward[nodelevel] - (struct skiplistnode *)NULL);
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 52b1f0356e..45d9008796 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -683,7 +683,7 @@ int sockopt_tcp_signature_ext(int sock, union sockunion *su, uint16_t prefixlen,
#endif /* GNU_LINUX */
if ((ret = setsockopt(sock, IPPROTO_TCP, optname, &md5sig,
- sizeof md5sig))
+ sizeof(md5sig)))
< 0) {
/* ENOENT is harmless. It is returned when we clear a password
for which
diff --git a/lib/sockopt.h b/lib/sockopt.h
index 59d8a65964..4081e6a45b 100644
--- a/lib/sockopt.h
+++ b/lib/sockopt.h
@@ -39,7 +39,7 @@ extern int setsockopt_ipv6_hoplimit(int, int);
extern int setsockopt_ipv6_multicast_loop(int, int);
extern int setsockopt_ipv6_tclass(int, int);
-#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo));
+#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof(struct in6_pktinfo));
/*
* Size defines for control messages used to get ifindex. We define
@@ -49,7 +49,7 @@ extern int setsockopt_ipv6_tclass(int, int);
*/
#if defined(IP_PKTINFO)
/* Linux in_pktinfo. */
-#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (CMSG_SPACE(sizeof (struct in_pktinfo)))
+#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (CMSG_SPACE(sizeof(struct in_pktinfo)))
/* XXX This should perhaps be defined even if IP_PKTINFO is not. */
#define SOPT_SIZE_CMSG_PKTINFO(af) \
((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \
@@ -60,9 +60,9 @@ extern int setsockopt_ipv6_tclass(int, int);
/* BSD/Solaris */
#if defined(SUNOS_5)
-#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof (uint_t))
+#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof(uint_t))
#else
-#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof (struct sockaddr_dl))
+#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof(struct sockaddr_dl))
#endif /* SUNOS_5 */
#endif /* IP_RECVIF */
@@ -72,7 +72,7 @@ extern int setsockopt_ipv6_tclass(int, int);
#elif defined(SOPT_SIZE_CMSG_RECVIF_IPV4)
#define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_RECVIF_IPV4()
#else /* Nothing available */
-#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof (char *))
+#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof(char *))
#endif /* SOPT_SIZE_CMSG_IFINDEX_IPV4 */
#define SOPT_SIZE_CMSG_IFINDEX(af) \
diff --git a/lib/sockunion.c b/lib/sockunion.c
index e9c418fdf2..63d8a8c69b 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -214,7 +214,7 @@ enum connect_result sockunion_connect(int fd, const union sockunion *peersu,
if (errno != EINPROGRESS) {
char str[SU_ADDRSTRLEN];
zlog_info("can't connect to %s fd %d : %s",
- sockunion_log(&su, str, sizeof str), fd,
+ sockunion_log(&su, str, sizeof(str)), fd,
safe_strerror(errno));
return connect_error;
}
@@ -518,8 +518,8 @@ union sockunion *sockunion_getsockname(int fd)
} name;
union sockunion *su;
- memset(&name, 0, sizeof name);
- len = sizeof name;
+ memset(&name, 0, sizeof(name));
+ len = sizeof(name);
ret = getsockname(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
@@ -556,8 +556,8 @@ union sockunion *sockunion_getpeername(int fd)
} name;
union sockunion *su;
- memset(&name, 0, sizeof name);
- len = sizeof name;
+ memset(&name, 0, sizeof(name));
+ len = sizeof(name);
ret = getpeername(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
flog_err(EC_LIB_SOCKET, "Can't get remote address and port: %s",
diff --git a/lib/stream.h b/lib/stream.h
index c0d25e0579..36c65afa3c 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -110,7 +110,7 @@ struct stream {
size_t getp; /* next get position */
size_t endp; /* last valid data position */
size_t size; /* size of data segment */
- unsigned char data[0]; /* data pointer */
+ unsigned char data[]; /* data pointer */
};
/* First in first out queue structure. */
diff --git a/lib/systemd.c b/lib/systemd.c
index 81b0400ab9..c5cc3aa447 100644
--- a/lib/systemd.c
+++ b/lib/systemd.c
@@ -114,8 +114,10 @@ void systemd_send_started(struct thread_master *m, int the_process)
systemd_master = m;
systemd_send_information("READY=1");
- if (wsecs != 0)
+ if (wsecs != 0) {
+ systemd_send_information("WATCHDOG=1");
thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL);
+ }
}
void systemd_send_status(const char *status)
diff --git a/lib/thread.c b/lib/thread.c
index 651d26dfb2..2217a60f0a 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -171,7 +171,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
struct thread_master *m;
struct listnode *ln;
- memset(&tmp, 0, sizeof tmp);
+ memset(&tmp, 0, sizeof(tmp));
tmp.funcname = "TOTAL";
tmp.types = filter;
diff --git a/lib/wheel.c b/lib/wheel.c
index 214e5e8167..f5e5cc52c3 100644
--- a/lib/wheel.c
+++ b/lib/wheel.c
@@ -47,8 +47,8 @@ static int wheel_timer_thread_helper(struct thread *t)
curr_slot = wheel->curr_slot % wheel->slots;
if (debug_timer_wheel)
- zlog_debug("%s: Wheel Slot: %lld(%lld) count: %d",
- __PRETTY_FUNCTION__, wheel->curr_slot, curr_slot,
+ zlog_debug("%s: Wheel Slot: %lld(%lld) count: %d", __func__,
+ wheel->curr_slot, curr_slot,
listcount(wheel->wheel_slot_lists[curr_slot]));
for (ALL_LIST_ELEMENTS(wheel->wheel_slot_lists[curr_slot], node,
diff --git a/lib/zclient.c b/lib/zclient.c
index ec193035f5..eac6c7081d 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1976,7 +1976,7 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
"warning: interface %s address %s with peer flag set, but no peer address!",
ifp->name,
prefix2str(ifc->address, buf,
- sizeof buf));
+ sizeof(buf)));
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
}
}
diff --git a/m4/ax_python.m4 b/m4/ax_python.m4
index 69809184ee..d293da5257 100644
--- a/m4/ax_python.m4
+++ b/m4/ax_python.m4
@@ -3,7 +3,7 @@ dnl 2019 David Lamparter for NetDEF, Inc.
dnl SPDX-License-Identifier: GPL-2.0-or-later
dnl the _ at the beginning will be cut off (to support the empty version string)
-m4_define_default([_FRR_PY_VERS], [_3 _ _2 _3.7 _3.6 _3.5 _3.4 _3.3 _3.2 _2.7])
+m4_define_default([_FRR_PY_VERS], [_3 _ _2 _3.8 _3.7 _3.6 _3.5 _3.4 _3.3 _3.2 _2.7])
dnl check basic interpreter properties (py2/py3)
dnl doubles as simple check whether the interpreter actually works
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c
index 6666c6e96b..cf338a0876 100644
--- a/nhrpd/netlink_arp.c
+++ b/nhrpd/netlink_arp.c
@@ -65,11 +65,12 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)
struct nhrp_cache *c;
struct interface *ifp;
struct zbuf payload;
- union sockunion addr;
+ union sockunion addr, lladdr;
size_t len;
- char buf[SU_ADDRSTRLEN];
+ char buf[4][SU_ADDRSTRLEN];
int state;
+ memset(&lladdr, 0, sizeof(lladdr));
ndm = znl_pull(zb, sizeof(*ndm));
if (!ndm)
return;
@@ -82,6 +83,10 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)
sockunion_set(&addr, ndm->ndm_family,
zbuf_pulln(&payload, len), len);
break;
+ case NDA_LLADDR:
+ sockunion_set(&lladdr, ndm->ndm_family,
+ zbuf_pulln(&payload, len), len);
+ break;
}
}
@@ -93,20 +98,34 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)
if (!c)
return;
- if (msg->nlmsg_type == RTM_GETNEIGH) {
- debugf(NHRP_DEBUG_KERNEL, "Netlink: who-has %s dev %s",
- sockunion2str(&addr, buf, sizeof buf), ifp->name);
+ debugf(NHRP_DEBUG_KERNEL,
+ "Netlink: %s %s dev %s lladdr %s nud 0x%x cache used %u type %u",
+ (msg->nlmsg_type == RTM_GETNEIGH)
+ ? "who-has"
+ : (msg->nlmsg_type == RTM_NEWNEIGH) ? "new-neigh"
+ : "del-neigh",
+ sockunion2str(&addr, buf[0], sizeof(buf[0])), ifp->name,
+ sockunion2str(&lladdr, buf[1], sizeof(buf[1])), ndm->ndm_state,
+ c->used, c->cur.type);
+ if (msg->nlmsg_type == RTM_GETNEIGH) {
if (c->cur.type >= NHRP_CACHE_CACHED) {
nhrp_cache_set_used(c, 1);
- netlink_update_binding(ifp, &addr,
- &c->cur.peer->vc->remote.nbma);
+ debugf(NHRP_DEBUG_KERNEL,
+ "Netlink: update binding for %s dev %s from c %s peer.vc.nbma %s to lladdr %s",
+ sockunion2str(&addr, buf[0], sizeof(buf[0])),
+ ifp->name,
+ sockunion2str(&c->cur.remote_nbma_natoa, buf[1],
+ sizeof(buf[1])),
+ sockunion2str(&c->cur.peer->vc->remote.nbma,
+ buf[2], sizeof(buf[2])),
+ sockunion2str(&lladdr, buf[3], sizeof(buf[3])));
+ /* In case of shortcuts, nbma is given by lladdr, not
+ * vc->remote.nbma.
+ */
+ netlink_update_binding(ifp, &addr, &lladdr);
}
} else {
- debugf(NHRP_DEBUG_KERNEL, "Netlink: update %s dev %s nud %x",
- sockunion2str(&addr, buf, sizeof buf), ifp->name,
- ndm->ndm_state);
-
state = (msg->nlmsg_type == RTM_NEWNEIGH) ? ndm->ndm_state
: NUD_FAILED;
nhrp_cache_set_used(c, state == NUD_REACHABLE);
diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c
index cc18b36f6a..42f6a88f95 100644
--- a/nhrpd/nhrp_cache.c
+++ b/nhrpd/nhrp_cache.c
@@ -119,12 +119,43 @@ static void nhrp_cache_update_route(struct nhrp_cache *c)
{
struct prefix pfx;
struct nhrp_peer *p = c->cur.peer;
+ char buf[3][SU_ADDRSTRLEN];
+ struct nhrp_interface *nifp;
sockunion2hostprefix(&c->remote_addr, &pfx);
if (p && nhrp_peer_check(p, 1)) {
- netlink_update_binding(p->ifp, &c->remote_addr,
- &p->vc->remote.nbma);
+ if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) {
+ /* remote_nbma_natoa is already set. Therefore, binding
+ * should be updated to this value and not vc's remote
+ * nbma.
+ */
+ debugf(NHRP_DEBUG_COMMON,
+ "cache (remote_nbma_natoa set): Update binding for %s dev %s from (deleted) peer.vc.nbma %s to %s",
+ sockunion2str(&c->remote_addr, buf[0],
+ sizeof(buf[0])),
+ p->ifp->name,
+ sockunion2str(&p->vc->remote.nbma, buf[1],
+ sizeof(buf[1])),
+ sockunion2str(&c->cur.remote_nbma_natoa, buf[2],
+ sizeof(buf[2])));
+
+ netlink_update_binding(p->ifp, &c->remote_addr,
+ &c->cur.remote_nbma_natoa);
+ } else {
+ /* update binding to peer->vc->remote->nbma */
+ debugf(NHRP_DEBUG_COMMON,
+ "cache (remote_nbma_natoa unspec): Update binding for %s dev %s from (deleted) to peer.vc.nbma %s",
+ sockunion2str(&c->remote_addr, buf[0],
+ sizeof(buf[0])),
+ p->ifp->name,
+ sockunion2str(&p->vc->remote.nbma, buf[1],
+ sizeof(buf[1])));
+
+ netlink_update_binding(p->ifp, &c->remote_addr,
+ &p->vc->remote.nbma);
+ }
+
nhrp_route_announce(1, c->cur.type, &pfx, c->ifp, NULL,
c->cur.mtu);
if (c->cur.type >= NHRP_CACHE_DYNAMIC) {
@@ -139,6 +170,17 @@ static void nhrp_cache_update_route(struct nhrp_cache *c)
c->route_installed = 1;
}
} else {
+ /* debug the reason for peer check fail */
+ if (p) {
+ nifp = p->ifp->info;
+ debugf(NHRP_DEBUG_COMMON,
+ "cache (peer check failed: online?%d requested?%d ipsec?%d)",
+ p->online, p->requested,
+ nifp->ipsec_profile ? 1 : 0);
+ } else
+ debugf(NHRP_DEBUG_COMMON,
+ "cache (peer check failed: no p)");
+
if (c->nhrp_route_installed) {
nhrp_route_update_nhrp(&pfx, NULL);
c->nhrp_route_installed = 0;
@@ -207,10 +249,10 @@ static void nhrp_cache_update_timers(struct nhrp_cache *c)
static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg)
{
struct nhrp_cache *c = container_of(r, struct nhrp_cache, eventid);
- char buf[SU_ADDRSTRLEN];
+ char buf[3][SU_ADDRSTRLEN];
debugf(NHRP_DEBUG_COMMON, "cache: %s %s: %s", c->ifp->name,
- sockunion2str(&c->remote_addr, buf, sizeof buf),
+ sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),
(const char *)arg);
nhrp_reqid_free(&nhrp_event_reqid, r);
@@ -230,6 +272,26 @@ static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg)
if (c->cur.peer)
nhrp_peer_notify_add(c->cur.peer, &c->peer_notifier,
nhrp_cache_peer_notifier);
+
+ if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) {
+ debugf(NHRP_DEBUG_COMMON,
+ "cache: update binding for %s dev %s from (deleted) peer.vc.nbma %s to %s",
+ sockunion2str(&c->remote_addr, buf[0],
+ sizeof(buf[0])),
+ c->ifp->name,
+ (c->cur.peer ? sockunion2str(
+ &c->cur.peer->vc->remote.nbma, buf[1],
+ sizeof(buf[1]))
+ : "(no peer)"),
+ sockunion2str(&c->cur.remote_nbma_natoa, buf[2],
+ sizeof(buf[2])));
+
+ if (c->cur.peer)
+ netlink_update_binding(
+ c->cur.peer->ifp, &c->remote_addr,
+ &c->cur.remote_nbma_natoa);
+ }
+
nhrp_cache_update_route(c);
notifier_call(&c->notifier_list, NOTIFY_CACHE_BINDING_CHANGE);
} else {
@@ -273,6 +335,8 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type,
int holding_time, struct nhrp_peer *p,
uint32_t mtu, union sockunion *nbma_oa)
{
+ char buf[2][SU_ADDRSTRLEN];
+
if (c->cur.type > type || c->new.type > type) {
nhrp_peer_unref(p);
return 0;
@@ -293,17 +357,31 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type,
break;
}
+ sockunion2str(&c->cur.remote_nbma_natoa, buf[0], sizeof(buf[0]));
+ if (nbma_oa)
+ sockunion2str(nbma_oa, buf[1], sizeof(buf[1]));
+
nhrp_cache_reset_new(c);
if (c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu) {
+ debugf(NHRP_DEBUG_COMMON,
+ "cache: same type %u, updating expiry and changing nbma addr from %s to %s",
+ type, buf[0], nbma_oa ? buf[1] : "(NULL)");
if (holding_time > 0)
c->cur.expires = monotime(NULL) + holding_time;
+
if (nbma_oa)
c->cur.remote_nbma_natoa = *nbma_oa;
else
memset(&c->cur.remote_nbma_natoa, 0,
- sizeof c->cur.remote_nbma_natoa);
+ sizeof(c->cur.remote_nbma_natoa));
+
nhrp_peer_unref(p);
} else {
+ debugf(NHRP_DEBUG_COMMON,
+ "cache: new type %u/%u, or peer %s, or mtu %u/%u, nbma %s --> %s (map %d)",
+ c->cur.type, type, (c->cur.peer == p) ? "same" : "diff",
+ c->cur.mtu, mtu, buf[0], nbma_oa ? buf[1] : "(NULL)",
+ c->map);
c->new.type = type;
c->new.peer = p;
c->new.mtu = mtu;
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 7cf8dfbde4..1e576fc5ac 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -112,7 +112,7 @@ static void nhrp_interface_interface_notifier(struct notifier_block *n,
NOTIFY_INTERFACE_NBMA_CHANGED);
debugf(NHRP_DEBUG_IF, "%s: NBMA change: address %s",
nifp->ifp->name,
- sockunion2str(&nifp->nbma, buf, sizeof buf));
+ sockunion2str(&nifp->nbma, buf, sizeof(buf)));
break;
}
}
@@ -221,7 +221,7 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi,
if (best && if_ad->configured
&& best->address->prefixlen != 8 * prefix_blen(best->address)) {
zlog_notice("%s: %s is not a host prefix", ifp->name,
- prefix2str(best->address, buf, sizeof buf));
+ prefix2str(best->address, buf, sizeof(buf)));
best = NULL;
}
@@ -243,7 +243,7 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi,
debugf(NHRP_DEBUG_KERNEL, "%s: IPv%d address changed to %s", ifp->name,
afi == AFI_IP ? 4 : 6,
- best ? prefix2str(best->address, buf, sizeof buf) : "(none)");
+ best ? prefix2str(best->address, buf, sizeof(buf)) : "(none)");
if_ad->addr = addr;
if (if_ad->configured && sockunion_family(&if_ad->addr) != AF_UNSPEC) {
@@ -342,7 +342,7 @@ int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS)
return 0;
debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %s", ifc->ifp->name,
- prefix2str(ifc->address, buf, sizeof buf));
+ prefix2str(ifc->address, buf, sizeof(buf)));
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
@@ -360,7 +360,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
return 0;
debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %s", ifc->ifp->name,
- prefix2str(ifc->address, buf, sizeof buf));
+ prefix2str(ifc->address, buf, sizeof(buf)));
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c
index bec6c014a0..8509cedcee 100644
--- a/nhrpd/nhrp_nhs.c
+++ b/nhrpd/nhrp_nhs.c
@@ -136,7 +136,7 @@ static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd)
case NOTIFY_PEER_MTU_CHANGED:
debugf(NHRP_DEBUG_COMMON, "NHS: Flush timer for %s",
sockunion2str(&r->peer->vc->remote.nbma, buf,
- sizeof buf));
+ sizeof(buf)));
THREAD_TIMER_OFF(r->t_register);
thread_add_timer_msec(master, nhrp_reg_send_req, r, 10,
&r->t_register);
@@ -162,7 +162,7 @@ static int nhrp_reg_send_req(struct thread *t)
if (!nhrp_peer_check(r->peer, 2)) {
debugf(NHRP_DEBUG_COMMON, "NHS: Waiting link for %s",
sockunion2str(&r->peer->vc->remote.nbma, buf1,
- sizeof buf1));
+ sizeof(buf1)));
thread_add_timer(master, nhrp_reg_send_req, r, 120,
&r->t_register);
return 0;
diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c
index 2d6c263582..2dc019ce65 100644
--- a/nhrpd/nhrp_peer.c
+++ b/nhrpd/nhrp_peer.c
@@ -305,8 +305,8 @@ void nhrp_peer_send(struct nhrp_peer *p, struct zbuf *zb)
return;
debugf(NHRP_DEBUG_KERNEL, "PACKET: Send %s -> %s",
- sockunion2str(&p->vc->local.nbma, buf[0], sizeof buf[0]),
- sockunion2str(&p->vc->remote.nbma, buf[1], sizeof buf[1]));
+ sockunion2str(&p->vc->local.nbma, buf[0], sizeof(buf[0])),
+ sockunion2str(&p->vc->remote.nbma, buf[1], sizeof(buf[1])));
os_sendmsg(zb->head, zbuf_used(zb), p->ifp->ifindex,
sockunion_get_addr(&p->vc->remote.nbma),
@@ -314,23 +314,29 @@ void nhrp_peer_send(struct nhrp_peer *p, struct zbuf *zb)
zbuf_reset(zb);
}
-static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)
+static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp)
{
+ struct interface *ifp = pp->ifp;
struct zbuf *zb, payload;
struct nhrp_packet_header *hdr;
struct nhrp_cie_header *cie;
struct nhrp_extension_header *ext;
- struct nhrp_interface *nifp;
+ struct nhrp_cache *c;
+ union sockunion cie_nbma, cie_proto, *proto_addr, *nbma_addr;
+ int holdtime, prefix_len, hostprefix_len;
+ struct nhrp_interface *nifp = ifp->info;
struct nhrp_peer *peer;
+ size_t paylen;
+ char buf[SU_ADDRSTRLEN];
- if (!(p->if_ad->flags & NHRP_IFF_SHORTCUT)) {
+ if (!(pp->if_ad->flags & NHRP_IFF_SHORTCUT)) {
debugf(NHRP_DEBUG_COMMON, "Shortcuts disabled");
/* FIXME: Send error indication? */
return;
}
- if (p->if_ad->network_id && p->route_type == NHRP_ROUTE_OFF_NBMA
- && p->route_prefix.prefixlen < 8) {
+ if (pp->if_ad->network_id && pp->route_type == NHRP_ROUTE_OFF_NBMA
+ && pp->route_prefix.prefixlen < 8) {
debugf(NHRP_DEBUG_COMMON,
"Shortcut to more generic than /8 dropped");
return;
@@ -338,45 +344,101 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)
debugf(NHRP_DEBUG_COMMON, "Parsing and replying to Resolution Req");
- if (nhrp_route_address(p->ifp, &p->src_proto, NULL, &peer)
+ if (nhrp_route_address(ifp, &pp->src_proto, NULL, &peer)
!= NHRP_ROUTE_NBMA_NEXTHOP)
return;
-#if 0
- /* FIXME: Update requestors binding if CIE specifies holding time */
- nhrp_cache_update_binding(
- NHRP_CACHE_CACHED, &p->src_proto,
- nhrp_peer_get(p->ifp, &p->src_nbma),
- htons(cie->holding_time));
-#endif
+ /* Copy payload CIE */
+ hostprefix_len = 8 * sockunion_get_addrlen(&pp->if_ad->addr);
+ paylen = zbuf_used(&pp->payload);
+ debugf(NHRP_DEBUG_COMMON, "shortcut res_rep: paylen %zu", paylen);
+
+ while ((cie = nhrp_cie_pull(&pp->payload, pp->hdr, &cie_nbma,
+ &cie_proto))
+ != NULL) {
+ prefix_len = cie->prefix_length;
+ debugf(NHRP_DEBUG_COMMON,
+ "shortcut res_rep: parsing CIE with prefixlen=%u",
+ prefix_len);
+ if (prefix_len == 0 || prefix_len >= hostprefix_len)
+ prefix_len = hostprefix_len;
+
+ if (prefix_len != hostprefix_len
+ && !(pp->hdr->flags
+ & htons(NHRP_FLAG_REGISTRATION_UNIQUE))) {
+ cie->code = NHRP_CODE_BINDING_NON_UNIQUE;
+ continue;
+ }
+
+ /* We currently support only unique prefix registrations */
+ if (prefix_len != hostprefix_len) {
+ cie->code = NHRP_CODE_ADMINISTRATIVELY_PROHIBITED;
+ continue;
+ }
+
+ proto_addr = (sockunion_family(&cie_proto) == AF_UNSPEC)
+ ? &pp->src_proto
+ : &cie_proto;
+ nbma_addr = (sockunion_family(&cie_nbma) == AF_UNSPEC)
+ ? &pp->src_nbma
+ : &cie_nbma;
+
+ holdtime = htons(cie->holding_time);
+ debugf(NHRP_DEBUG_COMMON,
+ "shortcut res_rep: holdtime is %u (if 0, using %u)",
+ holdtime, pp->if_ad->holdtime);
+ if (!holdtime)
+ holdtime = pp->if_ad->holdtime;
+
+ c = nhrp_cache_get(ifp, proto_addr, 1);
+ if (!c) {
+ debugf(NHRP_DEBUG_COMMON,
+ "shortcut res_rep: no cache found");
+ cie->code = NHRP_CODE_INSUFFICIENT_RESOURCES;
+ continue;
+ }
+ if (nbma_addr)
+ sockunion2str(nbma_addr, buf, sizeof(buf));
+
+ debugf(NHRP_DEBUG_COMMON,
+ "shortcut res_rep: updating binding for nmba addr %s",
+ nbma_addr ? buf : "(NULL)");
+ if (!nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC, holdtime,
+ nhrp_peer_ref(pp->peer),
+ htons(cie->mtu), nbma_addr)) {
+ cie->code = NHRP_CODE_ADMINISTRATIVELY_PROHIBITED;
+ continue;
+ }
- nifp = peer->ifp->info;
+ cie->code = NHRP_CODE_SUCCESS;
+ }
/* Create reply */
zb = zbuf_alloc(1500);
- hdr = nhrp_packet_push(zb, NHRP_PACKET_RESOLUTION_REPLY, &p->src_nbma,
- &p->src_proto, &p->dst_proto);
+ hdr = nhrp_packet_push(zb, NHRP_PACKET_RESOLUTION_REPLY, &pp->src_nbma,
+ &pp->src_proto, &pp->dst_proto);
/* Copied information from request */
- hdr->flags =
- p->hdr->flags & htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER
- | NHRP_FLAG_RESOLUTION_SOURCE_STABLE);
+ hdr->flags = pp->hdr->flags
+ & htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER
+ | NHRP_FLAG_RESOLUTION_SOURCE_STABLE);
hdr->flags |= htons(NHRP_FLAG_RESOLUTION_DESTINATION_STABLE
| NHRP_FLAG_RESOLUTION_AUTHORATIVE);
- hdr->u.request_id = p->hdr->u.request_id;
+ hdr->u.request_id = pp->hdr->u.request_id;
- /* CIE payload */
+ /* CIE payload for the reply packet */
cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma,
- &p->if_ad->addr);
- cie->holding_time = htons(p->if_ad->holdtime);
- cie->mtu = htons(p->if_ad->mtu);
- if (p->if_ad->network_id && p->route_type == NHRP_ROUTE_OFF_NBMA)
- cie->prefix_length = p->route_prefix.prefixlen;
+ &pp->if_ad->addr);
+ cie->holding_time = htons(pp->if_ad->holdtime);
+ cie->mtu = htons(pp->if_ad->mtu);
+ if (pp->if_ad->network_id && pp->route_type == NHRP_ROUTE_OFF_NBMA)
+ cie->prefix_length = pp->route_prefix.prefixlen;
else
- cie->prefix_length = 8 * sockunion_get_addrlen(&p->if_ad->addr);
+ cie->prefix_length =
+ 8 * sockunion_get_addrlen(&pp->if_ad->addr);
/* Handle extensions */
- while ((ext = nhrp_ext_pull(&p->extensions, &payload)) != NULL) {
+ while ((ext = nhrp_ext_pull(&pp->extensions, &payload)) != NULL) {
switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {
case NHRP_EXTENSION_NAT_ADDRESS:
if (sockunion_family(&nifp->nat_nbma) == AF_UNSPEC)
@@ -386,13 +448,13 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)
if (!ext)
goto err;
cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS,
- &nifp->nat_nbma, &p->if_ad->addr);
+ &nifp->nat_nbma, &pp->if_ad->addr);
if (!cie)
goto err;
nhrp_ext_complete(zb, ext);
break;
default:
- if (nhrp_ext_reply(zb, hdr, p->ifp, ext, &payload) < 0)
+ if (nhrp_ext_reply(zb, hdr, ifp, ext, &payload) < 0)
goto err;
break;
}
@@ -584,15 +646,15 @@ void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type,
debugf(NHRP_DEBUG_COMMON,
"Send Traffic Indication to %s about packet to %s ignored",
sockunion2str(&p->vc->remote.nbma, buf[0],
- sizeof buf[0]),
- sockunion2str(&dst, buf[1], sizeof buf[1]));
+ sizeof(buf[0])),
+ sockunion2str(&dst, buf[1], sizeof(buf[1])));
return;
}
debugf(NHRP_DEBUG_COMMON,
"Send Traffic Indication to %s (online=%d) about packet to %s",
- sockunion2str(&p->vc->remote.nbma, buf[0], sizeof buf[0]),
- p->online, sockunion2str(&dst, buf[1], sizeof buf[1]));
+ sockunion2str(&p->vc->remote.nbma, buf[0], sizeof(buf[0])),
+ p->online, sockunion2str(&dst, buf[1], sizeof(buf[1])));
/* Create reply */
zb = zbuf_alloc(1500);
@@ -622,8 +684,8 @@ static void nhrp_handle_error_ind(struct nhrp_packet_parser *pp)
debugf(NHRP_DEBUG_COMMON,
"Error Indication from %s about packet to %s ignored",
- sockunion2str(&pp->src_proto, buf[0], sizeof buf[0]),
- sockunion2str(&dst_proto, buf[1], sizeof buf[1]));
+ sockunion2str(&pp->src_proto, buf[0], sizeof(buf[0])),
+ sockunion2str(&dst_proto, buf[1], sizeof(buf[1])));
reqid = nhrp_reqid_lookup(&nhrp_packet_reqid, htonl(hdr->u.request_id));
if (reqid)
@@ -641,8 +703,8 @@ static void nhrp_handle_traffic_ind(struct nhrp_packet_parser *p)
debugf(NHRP_DEBUG_COMMON,
"Traffic Indication from %s about packet to %s: %s",
- sockunion2str(&p->src_proto, buf[0], sizeof buf[0]),
- sockunion2str(&dst, buf[1], sizeof buf[1]),
+ sockunion2str(&p->src_proto, buf[0], sizeof(buf[0])),
+ sockunion2str(&dst, buf[1], sizeof(buf[1])),
(p->if_ad->flags & NHRP_IFF_SHORTCUT) ? "trying shortcut"
: "ignored");
@@ -657,7 +719,7 @@ enum packet_type_t {
PACKET_INDICATION,
};
-static const struct {
+static struct {
enum packet_type_t type;
const char *name;
void (*handler)(struct nhrp_packet_parser *);
@@ -809,8 +871,8 @@ static void nhrp_packet_debug(struct zbuf *zb, const char *dir)
zbuf_init(&zhdr, zb->buf, zb->tail - zb->buf, zb->tail - zb->buf);
hdr = nhrp_packet_pull(&zhdr, &src_nbma, &src_proto, &dst_proto);
- sockunion2str(&src_proto, buf[0], sizeof buf[0]);
- sockunion2str(&dst_proto, buf[1], sizeof buf[1]);
+ sockunion2str(&src_proto, buf[0], sizeof(buf[0]));
+ sockunion2str(&dst_proto, buf[1], sizeof(buf[1]));
reply = packet_types[hdr->type].type == PACKET_REPLY;
debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", dir,
@@ -852,8 +914,8 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)
afi_t nbma_afi, proto_afi;
debugf(NHRP_DEBUG_KERNEL, "PACKET: Recv %s -> %s",
- sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]),
- sockunion2str(&vc->local.nbma, buf[1], sizeof buf[1]));
+ sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])),
+ sockunion2str(&vc->local.nbma, buf[1], sizeof(buf[1])));
if (!p->online) {
info = "peer not online";
@@ -885,7 +947,7 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)
|| htons(hdr->packet_size) > realsize) {
zlog_info(
"From %s: error: packet type %d, version %d, AFI %d, proto %x, size %d (real size %d)",
- sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]),
+ sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])),
(int)hdr->type, (int)hdr->version, (int)nbma_afi,
(int)htons(hdr->protocol_type),
(int)htons(hdr->packet_size), (int)realsize);
@@ -897,11 +959,15 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)
if (extoff) {
assert(zb->head > zb->buf);
uint32_t header_offset = zb->head - zb->buf;
- if ((extoff >= realsize) || (extoff < (header_offset))) {
- info = "extoff larger than packet, or smaller than header";
+ if (extoff >= realsize) {
+ info = "extoff larger than packet";
+ goto drop;
+ }
+ if (extoff < header_offset) {
+ info = "extoff smaller than header offset";
goto drop;
}
- paylen = extoff - (zb->head - zb->buf);
+ paylen = extoff - header_offset;
} else {
paylen = zbuf_used(zb);
}
@@ -962,7 +1028,7 @@ drop:
if (info) {
zlog_info(
"From %s: error: %s",
- sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]),
+ sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])),
info);
}
if (peer)
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index ddb69a1aca..f242c2e367 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -199,10 +199,6 @@ int nhrp_route_read(ZAPI_CALLBACK_ARGS)
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
return 0;
- /* ignore our routes */
- if (api.type == ZEBRA_ROUTE_NHRP)
- return 0;
-
sockunion_family(&nexthop_addr) = AF_UNSPEC;
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
api_nh = &api.nexthops[0];
@@ -224,8 +220,8 @@ int nhrp_route_read(ZAPI_CALLBACK_ARGS)
added = (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD);
debugf(NHRP_DEBUG_ROUTE, "if-route-%s: %s via %s dev %s",
added ? "add" : "del",
- prefix2str(&api.prefix, buf[0], sizeof buf[0]),
- sockunion2str(&nexthop_addr, buf[1], sizeof buf[1]),
+ prefix2str(&api.prefix, buf[0], sizeof(buf[0])),
+ sockunion2str(&nexthop_addr, buf[1], sizeof(buf[1])),
ifp ? ifp->name : "(none)");
nhrp_route_update_zebra(&api.prefix, &nexthop_addr, ifp);
@@ -252,7 +248,7 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,
ri = rn->info;
if (ri->nhrp_ifp) {
debugf(NHRP_DEBUG_ROUTE, "lookup %s: nhrp_if=%s",
- prefix2str(&lookup, buf, sizeof buf),
+ prefix2str(&lookup, buf, sizeof(buf)),
ri->nhrp_ifp->name);
if (via)
@@ -261,7 +257,7 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,
*ifp = ri->nhrp_ifp;
} else {
debugf(NHRP_DEBUG_ROUTE, "lookup %s: zebra route dev %s",
- prefix2str(&lookup, buf, sizeof buf),
+ prefix2str(&lookup, buf, sizeof(buf)),
ri->ifp ? ri->ifp->name : "(none)");
if (via)
diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c
index b3fdecf0ec..1c2b2b28f2 100644
--- a/nhrpd/nhrp_shortcut.c
+++ b/nhrpd/nhrp_shortcut.c
@@ -32,7 +32,7 @@ static void nhrp_shortcut_check_use(struct nhrp_shortcut *s)
if (s->expiring && s->cache && s->cache->used) {
debugf(NHRP_DEBUG_ROUTE, "Shortcut %s used and expiring",
- prefix2str(s->p, buf, sizeof buf));
+ prefix2str(s->p, buf, sizeof(buf)));
nhrp_shortcut_send_resolution_req(s);
}
}
@@ -53,14 +53,21 @@ static int nhrp_shortcut_do_expire(struct thread *t)
static void nhrp_shortcut_cache_notify(struct notifier_block *n,
unsigned long cmd)
{
+ char buf[PREFIX_STRLEN];
+
struct nhrp_shortcut *s =
container_of(n, struct nhrp_shortcut, cache_notifier);
switch (cmd) {
case NOTIFY_CACHE_UP:
if (!s->route_installed) {
- nhrp_route_announce(1, s->type, s->p, NULL,
- &s->cache->remote_addr, 0);
+ debugf(NHRP_DEBUG_ROUTE,
+ "Shortcut: route install %s nh (unspec) dev %s",
+ prefix2str(s->p, buf, sizeof(buf)),
+ s->cache->ifp->name);
+
+ nhrp_route_announce(1, s->type, s->p, s->cache->ifp,
+ NULL, 0);
s->route_installed = 1;
}
break;
@@ -84,6 +91,8 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s,
enum nhrp_cache_type type,
struct nhrp_cache *c, int holding_time)
{
+ char buf[2][PREFIX_STRLEN];
+
s->type = type;
if (c != s->cache) {
if (s->cache) {
@@ -98,13 +107,29 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s,
/* Force renewal of Zebra announce on prefix
* change */
s->route_installed = 0;
+ debugf(NHRP_DEBUG_ROUTE,
+ "Shortcut: forcing renewal of zebra announce on prefix change peer %s ht %u cur nbma %s dev %s",
+ sockunion2str(&s->cache->remote_addr,
+ buf[0], sizeof(buf[0])),
+ holding_time,
+ sockunion2str(
+ &s->cache->cur.remote_nbma_natoa,
+ buf[1], sizeof(buf[1])),
+ s->cache->ifp->name);
nhrp_shortcut_cache_notify(&s->cache_notifier,
NOTIFY_CACHE_UP);
}
}
- if (!s->cache || !s->cache->route_installed)
+ if (!s->cache || !s->cache->route_installed) {
+ debugf(NHRP_DEBUG_ROUTE,
+ "Shortcut: notify cache down because cache?%s or ri?%s",
+ s->cache ? "yes" : "no",
+ s->cache ? (s->cache->route_installed ? "yes"
+ : "no")
+ : "n/a");
nhrp_shortcut_cache_notify(&s->cache_notifier,
NOTIFY_CACHE_DOWN);
+ }
}
if (s->type == NHRP_CACHE_NEGATIVE && !s->route_installed) {
nhrp_route_announce(1, s->type, s->p, NULL, NULL, 0);
@@ -133,7 +158,7 @@ static void nhrp_shortcut_delete(struct nhrp_shortcut *s)
nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);
debugf(NHRP_DEBUG_ROUTE, "Shortcut %s purged",
- prefix2str(s->p, buf, sizeof buf));
+ prefix2str(s->p, buf, sizeof(buf)));
nhrp_shortcut_update_binding(s, NHRP_CACHE_INVALID, NULL, 0);
@@ -141,6 +166,7 @@ static void nhrp_shortcut_delete(struct nhrp_shortcut *s)
rn = route_node_lookup(shortcut_rib[afi], s->p);
if (rn) {
XFREE(MTYPE_NHRP_SHORTCUT, rn->info);
+ rn->info = NULL;
route_unlock_node(rn);
route_unlock_node(rn);
}
@@ -172,7 +198,7 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)
s->p = &rn->p;
debugf(NHRP_DEBUG_ROUTE, "Shortcut %s created",
- prefix2str(s->p, buf, sizeof buf));
+ prefix2str(s->p, buf, sizeof(buf)));
} else {
s = rn->info;
route_unlock_node(rn);
@@ -190,11 +216,10 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
struct nhrp_extension_header *ext;
struct nhrp_cie_header *cie;
struct nhrp_cache *c = NULL;
- union sockunion *proto, cie_proto, *nbma, *nbma_natoa, cie_nbma,
- nat_nbma;
+ union sockunion *proto, cie_proto, *nbma, cie_nbma, nat_nbma;
struct prefix prefix, route_prefix;
struct zbuf extpl;
- char bufp[PREFIX_STRLEN], buf[3][SU_ADDRSTRLEN];
+ char bufp[PREFIX_STRLEN], buf[4][SU_ADDRSTRLEN];
int holding_time = pp->if_ad->holdtime;
nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);
@@ -217,7 +242,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
}
/* Parse extensions */
- memset(&nat_nbma, 0, sizeof nat_nbma);
+ memset(&nat_nbma, 0, sizeof(nat_nbma));
while ((ext = nhrp_ext_pull(&pp->extensions, &extpl)) != NULL) {
switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {
case NHRP_EXTENSION_NAT_ADDRESS:
@@ -231,8 +256,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
if (!sockunion_same(&cie_proto, &pp->dst_proto)) {
debugf(NHRP_DEBUG_COMMON,
"Shortcut: Warning dst_proto altered from %s to %s",
- sockunion2str(&cie_proto, buf[0], sizeof buf[0]),
- sockunion2str(&pp->dst_proto, buf[1], sizeof buf[1]));
+ sockunion2str(&cie_proto, buf[0], sizeof(buf[0])),
+ sockunion2str(&pp->dst_proto, buf[1], sizeof(buf[1])));
}
/* One or more CIEs should be given as reply, we support only one */
@@ -262,39 +287,55 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
}
debugf(NHRP_DEBUG_COMMON,
- "Shortcut: %s is at proto %s cie-nbma %s nat-nbma %s cie-holdtime %d",
- prefix2str(&prefix, bufp, sizeof bufp),
- sockunion2str(proto, buf[0], sizeof buf[0]),
- sockunion2str(&cie_nbma, buf[1], sizeof buf[1]),
- sockunion2str(&nat_nbma, buf[2], sizeof buf[2]),
+ "Shortcut: %s is at proto %s dst_proto %s cie-nbma %s nat-nbma %s cie-holdtime %d",
+ prefix2str(&prefix, bufp, sizeof(bufp)),
+ sockunion2str(proto, buf[0], sizeof(buf[0])),
+ sockunion2str(&pp->dst_proto, buf[1], sizeof(buf[1])),
+ sockunion2str(&cie_nbma, buf[2], sizeof(buf[2])),
+ sockunion2str(&nat_nbma, buf[3], sizeof(buf[3])),
htons(cie->holding_time));
/* Update cache entry for the protocol to nbma binding */
- if (sockunion_family(&nat_nbma) != AF_UNSPEC) {
+ if (sockunion_family(&nat_nbma) != AF_UNSPEC)
nbma = &nat_nbma;
- nbma_natoa = &cie_nbma;
- } else {
+ else
nbma = &cie_nbma;
- nbma_natoa = NULL;
- }
+
if (sockunion_family(nbma)) {
c = nhrp_cache_get(pp->ifp, proto, 1);
if (c) {
- nhrp_cache_update_binding(c, NHRP_CACHE_CACHED,
+ debugf(NHRP_DEBUG_COMMON,
+ "Shortcut: cache found, update binding");
+ nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC,
holding_time,
nhrp_peer_get(pp->ifp, nbma),
- htons(cie->mtu), nbma_natoa);
+ htons(cie->mtu), nbma);
+ } else {
+ debugf(NHRP_DEBUG_COMMON,
+ "Shortcut: no cache for nbma %s", buf[2]);
}
}
/* Update shortcut entry for subnet to protocol gw binding */
- if (c && !sockunion_same(proto, &pp->dst_proto)) {
+ if (c) {
ps = nhrp_shortcut_get(&prefix);
if (ps) {
ps->addr = s->addr;
- nhrp_shortcut_update_binding(ps, NHRP_CACHE_CACHED, c,
+ debugf(NHRP_DEBUG_COMMON,
+ "Shortcut: calling update_binding");
+ nhrp_shortcut_update_binding(ps, NHRP_CACHE_DYNAMIC, c,
holding_time);
+ } else {
+ debugf(NHRP_DEBUG_COMMON,
+ "Shortcut: proto diff but no ps");
}
+ } else {
+ debugf(NHRP_DEBUG_COMMON,
+ "NO Shortcut because c NULL?%s or same proto?%s",
+ c ? "no" : "yes",
+ proto && pp && sockunion_same(proto, &pp->dst_proto)
+ ? "yes"
+ : "no");
}
debugf(NHRP_DEBUG_COMMON, "Shortcut: Resolution reply handled");
@@ -306,7 +347,9 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s)
struct nhrp_packet_header *hdr;
struct interface *ifp;
struct nhrp_interface *nifp;
+ struct nhrp_afi_data *if_ad;
struct nhrp_peer *peer;
+ struct nhrp_cie_header *cie;
if (nhrp_route_address(NULL, &s->addr, NULL, &peer)
!= NHRP_ROUTE_NBMA_NEXTHOP)
@@ -336,7 +379,15 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s)
* - MTU: MTU of the source station
* - Holding Time: Max time to cache the source information
* */
- /* FIXME: Send holding time, and MTU */
+ /* FIXME: push CIE for each local protocol address */
+ cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, NULL, NULL);
+ cie->prefix_length = 0xff;
+ if_ad = &nifp->afi[family2afi(sockunion_family(&s->addr))];
+ cie->holding_time = htons(if_ad->holdtime);
+ cie->mtu = htons(if_ad->mtu);
+ debugf(NHRP_DEBUG_COMMON,
+ "Shortcut res_req: set cie ht to %u and mtu to %u. shortcut ht is %u",
+ ntohs(cie->holding_time), ntohs(cie->mtu), s->holding_time);
nhrp_ext_request(zb, hdr, ifp);
diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c
index 605aa34ff9..6567b231a9 100644
--- a/nhrpd/nhrp_vc.c
+++ b/nhrpd/nhrp_vc.c
@@ -142,8 +142,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
sa->vc->abort_migration = 0;
debugf(NHRP_DEBUG_COMMON, "IPsec NBMA change of %s to %s",
sockunion2str(&sa->vc->remote.nbma, buf[0],
- sizeof buf[0]),
- sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]));
+ sizeof(buf[0])),
+ sockunion2str(&vc->remote.nbma, buf[1], sizeof(buf[1])));
nhrp_vc_update(sa->vc, NOTIFY_VC_IPSEC_UPDATE_NBMA);
abort_migration = sa->vc->abort_migration;
}
diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index 8438f3cb4a..f6d18fb77f 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -613,9 +613,9 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)
vty_out(ctx->vty, "%-8s %-8s %-24s %-24s %c%c%c %s\n", c->ifp->name,
nhrp_cache_type_str[c->cur.type],
- sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]),
+ sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),
c->cur.peer ? sockunion2str(&c->cur.peer->vc->remote.nbma,
- buf[1], sizeof buf[1])
+ buf[1], sizeof(buf[1]))
: "-",
c->used ? 'U' : ' ', c->t_timeout ? 'T' : ' ',
c->t_auth ? 'A' : ' ',
@@ -637,10 +637,10 @@ static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg,
vty_out(vty, "%-8s %-24s %-16s %-16s\n", n->ifp->name, n->nbma_fqdn,
(reg && reg->peer) ? sockunion2str(&reg->peer->vc->remote.nbma,
- buf[0], sizeof buf[0])
+ buf[0], sizeof(buf[0]))
: "-",
sockunion2str(reg ? &reg->proto_addr : &n->proto_addr, buf[1],
- sizeof buf[1]));
+ sizeof(buf[1])));
}
static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
@@ -658,8 +658,8 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
c = s->cache;
vty_out(ctx->vty, "%-8s %-24s %-24s %s\n", nhrp_cache_type_str[s->type],
- prefix2str(s->p, buf1, sizeof buf1),
- c ? sockunion2str(&c->remote_addr, buf2, sizeof buf2) : "",
+ prefix2str(s->p, buf1, sizeof(buf1)),
+ c ? sockunion2str(&c->remote_addr, buf2, sizeof(buf2)) : "",
(c && c->cur.peer) ? c->cur.peer->vc->remote.id : "");
}
@@ -678,19 +678,19 @@ static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx)
nhrp_cache_type_str[c->cur.type],
(c->cur.peer && c->cur.peer->online) ? " up" : "",
c->used ? " used" : "",
- sockunion2str(&c->remote_addr, buf, sizeof buf),
+ sockunion2str(&c->remote_addr, buf, sizeof(buf)),
8 * family2addrsize(sockunion_family(&c->remote_addr)));
if (c->cur.peer) {
vty_out(ctx->vty, "NBMA-Address: %s\n",
sockunion2str(&c->cur.peer->vc->remote.nbma, buf,
- sizeof buf));
+ sizeof(buf)));
}
if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) {
vty_out(ctx->vty, "NBMA-NAT-OA-Address: %s\n",
sockunion2str(&c->cur.remote_nbma_natoa, buf,
- sizeof buf));
+ sizeof(buf)));
}
vty_out(ctx->vty, "\n\n");
@@ -741,8 +741,8 @@ static void show_dmvpn_entry(struct nhrp_vc *vc, void *ctx)
char buf[2][SU_ADDRSTRLEN];
vty_out(vty, "%-24s %-24s %c %-4d %-24s\n",
- sockunion2str(&vc->local.nbma, buf[0], sizeof buf[0]),
- sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]),
+ sockunion2str(&vc->local.nbma, buf[0], sizeof(buf[0])),
+ sockunion2str(&vc->remote.nbma, buf[1], sizeof(buf[1])),
notifier_active(&vc->notifier_list) ? 'n' : ' ', vc->ipsec,
vc->remote.id);
}
@@ -824,11 +824,11 @@ static void interface_config_write_nhrp_map(struct nhrp_cache *c, void *data)
return;
vty_out(vty, " %s nhrp map %s %s\n", ctx->aficmd,
- sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]),
+ sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),
c->cur.type == NHRP_CACHE_LOCAL
? "local"
: sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1],
- sizeof buf[1]));
+ sizeof(buf[1])));
}
static int interface_config_write(struct vty *vty)
@@ -904,7 +904,7 @@ static int interface_config_write(struct vty *vty)
? "dynamic"
: sockunion2str(
&nhs->proto_addr, buf,
- sizeof buf),
+ sizeof(buf)),
nhs->nbma_fqdn);
}
}
diff --git a/nhrpd/vici.c b/nhrpd/vici.c
index 4f12d796a5..2dc05a4aa7 100644
--- a/nhrpd/vici.c
+++ b/nhrpd/vici.c
@@ -303,7 +303,7 @@ static void vici_recv_sa(struct vici_conn *vici, struct zbuf *msg, int event)
if (ctx.kill_ikesa && ctx.ike_uniqueid) {
debugf(NHRP_DEBUG_COMMON, "VICI: Deleting IKE_SA %u",
ctx.ike_uniqueid);
- snprintf(buf, sizeof buf, "%u", ctx.ike_uniqueid);
+ snprintf(buf, sizeof(buf), "%u", ctx.ike_uniqueid);
vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike-id",
strlen(buf), buf, VICI_END);
}
@@ -527,8 +527,8 @@ void vici_request_vc(const char *profile, union sockunion *src,
struct vici_conn *vici = &vici_connection;
char buf[2][SU_ADDRSTRLEN];
- sockunion2str(src, buf[0], sizeof buf[0]);
- sockunion2str(dst, buf[1], sizeof buf[1]);
+ sockunion2str(src, buf[0], sizeof(buf[0]));
+ sockunion2str(dst, buf[1], sizeof(buf[1]));
vici_submit_request(vici, "initiate", VICI_KEY_VALUE, "child",
strlen(profile), profile, VICI_KEY_VALUE, "timeout",
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index b0d501dab4..ead186b6fc 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -763,11 +763,13 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route,
}
if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX))
- zlog_debug("%s: paths %u nh %u", __PRETTY_FUNCTION__,
- old_route->paths ?
- listcount(old_route->paths) : 0,
- old_route->nh_list ?
- listcount(old_route->nh_list) : 0);
+ zlog_debug("%s: paths %u nh %u", __func__,
+ old_route->paths
+ ? listcount(old_route->paths)
+ : 0,
+ old_route->nh_list
+ ? listcount(old_route->nh_list)
+ : 0);
if (table->hook_add)
(*table->hook_add)(old_route);
@@ -823,9 +825,10 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
prefix2str(&old->prefix, buf,
sizeof(buf));
zlog_debug("%s: old %s updated nh %u",
- __PRETTY_FUNCTION__, buf,
- old->nh_list ?
- listcount(old->nh_list) : 0);
+ __func__, buf,
+ old->nh_list ? listcount(
+ old->nh_list)
+ : 0);
}
if (table->hook_add)
@@ -879,8 +882,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_PREFIX)) {
if (IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) {
is_debug++;
- zlog_debug("%s: Examin %s in area %s",
- __PRETTY_FUNCTION__, lsa->name, oa->name);
+ zlog_debug("%s: Examin %s in area %s", __func__,
+ lsa->name, oa->name);
}
prefix_lsa =
@@ -899,8 +902,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
} else if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_ROUTER)) {
if (IS_OSPF6_DEBUG_EXAMIN(INTER_ROUTER)) {
is_debug++;
- zlog_debug("%s: Examin %s in area %s",
- __PRETTY_FUNCTION__, lsa->name, oa->name);
+ zlog_debug("%s: Examin %s in area %s", __func__,
+ lsa->name, oa->name);
}
router_lsa =
@@ -947,9 +950,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
old = route;
if (is_debug)
- zlog_debug("%s: old entry found in paths, adv_router %s",
- __PRETTY_FUNCTION__,
- adv_router);
+ zlog_debug(
+ "%s: old entry found in paths, adv_router %s",
+ __func__,
+ adv_router);
break;
}
@@ -974,8 +978,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
}
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
if (is_debug)
- zlog_debug("%s: LSA %s is MaxAge, ignore",
- __PRETTY_FUNCTION__, lsa->name);
+ zlog_debug("%s: LSA %s is MaxAge, ignore", __func__,
+ lsa->name);
if (old)
ospf6_abr_old_route_remove(lsa, old, table);
return;
@@ -1054,21 +1058,21 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
|| CHECK_FLAG(abr_entry->flag, OSPF6_ROUTE_REMOVE)
|| !CHECK_FLAG(abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B)) {
if (is_debug)
- zlog_debug("%s: ABR router entry does not exist, ignore",
- __PRETTY_FUNCTION__);
+ zlog_debug(
+ "%s: ABR router entry does not exist, ignore",
+ __func__);
if (old) {
if (old->type == OSPF6_DEST_TYPE_ROUTER &&
oa->intra_brouter_calc) {
if (is_debug)
zlog_debug(
- "%s: intra_brouter_calc is on, skip brouter remove: %s (%p)",
- __PRETTY_FUNCTION__, buf,
- (void *)old);
+ "%s: intra_brouter_calc is on, skip brouter remove: %s (%p)",
+ __func__, buf, (void *)old);
} else {
if (is_debug)
- zlog_debug("%s: remove old entry: %s %p ",
- __PRETTY_FUNCTION__, buf,
- (void *)old);
+ zlog_debug(
+ "%s: remove old entry: %s %p ",
+ __func__, buf, (void *)old);
ospf6_route_remove(old, table);
}
}
@@ -1143,11 +1147,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if ((ospf6_route_cmp(route, old_route) != 0)) {
if (is_debug) {
prefix2str(&prefix, buf, sizeof(buf));
- zlog_debug("%s: old %p %s cost %u new route cost %u are not same",
- __PRETTY_FUNCTION__,
- (void *)old_route, buf,
- old_route->path.cost,
- route->path.cost);
+ zlog_debug(
+ "%s: old %p %s cost %u new route cost %u are not same",
+ __func__, (void *)old_route, buf,
+ old_route->path.cost, route->path.cost);
}
/* Check new route's adv. router is same in one of
@@ -1186,14 +1189,15 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
inet_ntop(AF_INET,
&ecmp_path->origin.adv_router,
adv_router, sizeof(adv_router));
- zlog_debug("%s: route %s cost %u another path %s added with nh %u, effective paths %u nh %u",
- __PRETTY_FUNCTION__, buf,
- old_route->path.cost,
- adv_router,
- listcount(ecmp_path->nh_list),
- old_route->paths ?
- listcount(old_route->paths) : 0,
- listcount(old_route->nh_list));
+ zlog_debug(
+ "%s: route %s cost %u another path %s added with nh %u, effective paths %u nh %u",
+ __func__, buf, old_route->path.cost,
+ adv_router,
+ listcount(ecmp_path->nh_list),
+ old_route->paths
+ ? listcount(old_route->paths)
+ : 0,
+ listcount(old_route->nh_list));
}
} else {
/* adv. router exists in the list, update the nhs */
@@ -1202,10 +1206,11 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
}
if (is_debug)
- zlog_debug("%s: Update route: %s %p old cost %u new cost %u nh %u",
- __PRETTY_FUNCTION__, buf, (void *)old_route,
- old_route->path.cost, route->path.cost,
- listcount(route->nh_list));
+ zlog_debug(
+ "%s: Update route: %s %p old cost %u new cost %u nh %u",
+ __func__, buf, (void *)old_route,
+ old_route->path.cost, route->path.cost,
+ listcount(route->nh_list));
/* For Inter-Prefix route: Update RIB/FIB,
* For Inter-Router trigger summary update
@@ -1222,9 +1227,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (is_debug) {
inet_ntop(AF_INET, &route->path.origin.adv_router,
adv_router, sizeof(adv_router));
- zlog_debug("%s: Install route: %s cost %u nh %u adv_router %s ",
- __PRETTY_FUNCTION__, buf, route->path.cost,
- listcount(route->nh_list), adv_router);
+ zlog_debug(
+ "%s: Install route: %s cost %u nh %u adv_router %s ",
+ __func__, buf, route->path.cost,
+ listcount(route->nh_list), adv_router);
}
path = ospf6_path_dup(&route->path);
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 486e4d8d2a..805e411c7b 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -166,7 +166,7 @@ int ospf6_orig_as_external_lsa(struct thread *thread)
if (IS_OSPF6_DEBUG_ASBR)
zlog_debug(
"%s: Send update of AS-External LSA %s seq 0x%x",
- __PRETTY_FUNCTION__, lsa->name,
+ __func__, lsa->name,
ntohl(lsa->header->seqnum));
ospf6_flood_interface(NULL, lsa, oi);
@@ -245,7 +245,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
sizeof(buf));
zlog_debug(
"%s: route %s cost old %u new %u is not same, replace route",
- __PRETTY_FUNCTION__, buf, o_path->cost,
+ __func__, buf, o_path->cost,
route->path.cost);
}
@@ -309,7 +309,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
sizeof(buf));
zlog_debug(
"%s: route %s old cost %u new cost %u, delete old entry.",
- __PRETTY_FUNCTION__, buf,
+ __func__, buf,
old_route->path.cost,
route->path.cost);
}
@@ -340,8 +340,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
sizeof(buf));
zlog_debug(
"%s: old route %s path cost %u e2 %u",
- __PRETTY_FUNCTION__, buf,
- old_route->path.cost,
+ __func__, buf, old_route->path.cost,
old_route->path.u.cost_e2);
}
route_found = true;
@@ -378,13 +377,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
sizeof(buf));
zlog_debug(
"%s: route %s another path added with nh %u, effective paths %u nh %u",
- __PRETTY_FUNCTION__, buf,
+ __func__, buf,
listcount(ecmp_path->nh_list),
- old_route->paths
- ? listcount(
- old_route
- ->paths)
- : 0,
+ old_route->paths ? listcount(
+ old_route->paths)
+ : 0,
listcount(old_route->nh_list));
}
} else {
@@ -410,9 +407,9 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
AS_EXTERNAL)) {
prefix2str(&old_route->prefix,
buf, sizeof(buf));
- zlog_debug("%s: ls_prfix %s asbr_entry not found.",
- __PRETTY_FUNCTION__,
- buf);
+ zlog_debug(
+ "%s: ls_prfix %s asbr_entry not found.",
+ __func__, buf);
}
continue;
}
@@ -422,12 +419,15 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("%s: route %s with effective paths %u nh %u",
- __PRETTY_FUNCTION__, buf,
- old_route->paths ?
- listcount(old_route->paths) : 0,
- old_route->nh_list ?
- listcount(old_route->nh_list) : 0);
+ zlog_debug(
+ "%s: route %s with effective paths %u nh %u",
+ __func__, buf,
+ old_route->paths
+ ? listcount(old_route->paths)
+ : 0,
+ old_route->nh_list
+ ? listcount(old_route->nh_list)
+ : 0);
}
/* Update RIB/FIB */
@@ -621,9 +621,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
prefix2str(&prefix, buf, sizeof(buf));
zlog_debug(
"%s: Current route %s cost %u e2 %u, route to del cost %u e2 %u",
- __PRETTY_FUNCTION__, buf, route->path.cost,
- route->path.u.cost_e2, route_to_del->path.cost,
- route_to_del->path.u.cost_e2);
+ __func__, buf, route->path.cost, route->path.u.cost_e2,
+ route_to_del->path.cost, route_to_del->path.u.cost_e2);
}
for (ospf6_route_lock(route);
@@ -670,8 +669,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
sizeof(buf));
zlog_debug(
"%s: route %s to delete is not same, cost %u del cost %u. skip",
- __PRETTY_FUNCTION__,
- buf, route->path.cost,
+ __func__, buf,
+ route->path.cost,
route_to_del->path
.cost);
}
@@ -682,8 +681,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
prefix2str(&prefix, buf, sizeof(buf));
zlog_debug(
"%s: route %s path found with cost %u nh %u to remove.",
- __PRETTY_FUNCTION__, buf,
- route->path.cost,
+ __func__, buf, route->path.cost,
listcount(o_path->nh_list));
}
@@ -726,14 +724,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
sizeof(buf));
zlog_debug(
"%s: AS-External %u route %s update paths %u nh %u",
- __PRETTY_FUNCTION__,
+ __func__,
(route->path.type
== OSPF6_PATH_TYPE_EXTERNAL1)
? 1
: 2,
buf, listcount(route->paths),
- route->nh_list ?
- listcount(route->nh_list) : 0);
+ route->nh_list ? listcount(
+ route->nh_list)
+ : 0);
}
if (listcount(route->paths)) {
@@ -785,8 +784,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
prefix2str(&prefix, buf, sizeof(buf));
zlog_debug(
"%s: route %s to delete is not same, cost %u del cost %u. skip",
- __PRETTY_FUNCTION__, buf,
- route->path.cost,
+ __func__, buf, route->path.cost,
route_to_del->path.cost);
}
continue;
@@ -802,7 +800,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
prefix2str(&route->prefix, buf, sizeof(buf));
zlog_debug(
"%s: AS-External %u route remove %s cost %u(%u) nh %u",
- __PRETTY_FUNCTION__,
+ __func__,
route->path.type == OSPF6_PATH_TYPE_EXTERNAL1
? 1
: 2,
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index 891421b7e8..85d02c186b 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -373,7 +373,7 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa,
if (is_debug)
zlog_debug(
"%s: Send LSA %s (age %d) update now",
- __PRETTY_FUNCTION__, lsa->name,
+ __func__, lsa->name,
ntohs(lsa->header->age));
ospf6_lsupdate_send_neighbor_now(on, lsa);
continue;
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 192e6356b1..9c239b75ff 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -1022,8 +1022,9 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
*/
if (oa->intra_prefix_originate) {
if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
- zlog_debug("%s: Re-originate intra prefix LSA, Current full nbrs %u",
- __PRETTY_FUNCTION__, oa->full_nbrs);
+ zlog_debug(
+ "%s: Re-originate intra prefix LSA, Current full nbrs %u",
+ __func__, oa->full_nbrs);
if (old)
ospf6_lsa_purge_multi_ls_id(oa, old);
oa->intra_prefix_originate = 0;
@@ -1401,9 +1402,10 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {
prefix2str(&old_route->prefix, buf,
sizeof(buf));
- zlog_debug("%s: route %s cost old %u new %u is not same, replace route",
- __PRETTY_FUNCTION__, buf,
- o_path->cost, route->path.cost);
+ zlog_debug(
+ "%s: route %s cost old %u new %u is not same, replace route",
+ __func__, buf, o_path->cost,
+ route->path.cost);
}
/* Remove selected current path's nh from
@@ -1458,10 +1460,11 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {
prefix2str(&old_route->prefix, buf,
sizeof(buf));
- zlog_debug("%s: route %s old cost %u new cost %u, delete old entry.",
- __PRETTY_FUNCTION__, buf,
- old_route->path.cost,
- route->path.cost);
+ zlog_debug(
+ "%s: route %s old cost %u new cost %u, delete old entry.",
+ __func__, buf,
+ old_route->path.cost,
+ route->path.cost);
}
if (oa->route_table->hook_remove)
ospf6_route_remove(old_route,
@@ -1516,13 +1519,13 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
sizeof(buf));
zlog_debug(
"%s: route %s %p another path added with nh %u, effective paths %u nh %u",
- __PRETTY_FUNCTION__, buf,
+ __func__, buf,
(void *)old_route,
listcount(ecmp_path->nh_list),
- old_route->paths ?
- listcount(old_route->paths) : 0,
+ old_route->paths ? listcount(
+ old_route->paths)
+ : 0,
listcount(old_route->nh_list));
-
}
} else {
list_delete_all_node(o_path->nh_list);
@@ -1540,9 +1543,9 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
oa->spf_table);
if (ls_entry == NULL) {
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX))
- zlog_debug("%s: ls_prfix %s ls_entry not found.",
- __PRETTY_FUNCTION__,
- buf);
+ zlog_debug(
+ "%s: ls_prfix %s ls_entry not found.",
+ __func__, buf);
continue;
}
lsa = ospf6_lsdb_lookup(o_path->origin.type,
@@ -1559,9 +1562,9 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
o_path->origin.id, &adv_prefix);
prefix2str(&adv_prefix, buf,
sizeof(buf));
- zlog_debug("%s: adv_router %s lsa not found",
- __PRETTY_FUNCTION__,
- buf);
+ zlog_debug(
+ "%s: adv_router %s lsa not found",
+ __func__, buf);
}
continue;
}
@@ -1587,12 +1590,13 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {
prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("%s: route %s %p with final effective paths %u nh%u",
- __PRETTY_FUNCTION__, buf,
- (void *)old_route,
- old_route->paths ?
- listcount(old_route->paths) : 0,
- listcount(old_route->nh_list));
+ zlog_debug(
+ "%s: route %s %p with final effective paths %u nh%u",
+ __func__, buf, (void *)old_route,
+ old_route->paths
+ ? listcount(old_route->paths)
+ : 0,
+ listcount(old_route->nh_list));
}
/* used in intra_route_calculation() to add to
@@ -1784,7 +1788,7 @@ static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa,
prefix2str(&route->prefix, buf, sizeof(buf));
zlog_debug(
"%s: route %s path found with cost %u nh %u to remove.",
- __PRETTY_FUNCTION__, buf, o_path->cost,
+ __func__, buf, o_path->cost,
listcount(o_path->nh_list));
}
@@ -1820,11 +1824,10 @@ static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa,
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {
prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("%s: route %s update paths %u nh %u",
- __PRETTY_FUNCTION__, buf,
- route->paths ? listcount(route->paths) : 0,
- route->nh_list ? listcount(route->nh_list)
- : 0);
+ zlog_debug(
+ "%s: route %s update paths %u nh %u", __func__,
+ buf, route->paths ? listcount(route->paths) : 0,
+ route->nh_list ? listcount(route->nh_list) : 0);
}
/* Update Global Route table and
diff --git a/ospf6d/ospf6_proto.h b/ospf6d/ospf6_proto.h
index c9e7b549db..3876a98c50 100644
--- a/ospf6d/ospf6_proto.h
+++ b/ospf6d/ospf6_proto.h
@@ -71,7 +71,7 @@ struct ospf6_prefix {
#define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */
/* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */
-#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix))
+#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof(struct ospf6_prefix))
/* size_t OSPF6_PREFIX_SPACE (int prefixlength); */
#define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4)
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index 27f5ef8edd..9a1141f631 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -1356,7 +1356,7 @@ static int ospf6TrapNbrStateChange(struct ospf6_neighbor *on, int next_state,
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
- sizeof ospfv3_oid / sizeof(oid), index, 3, ospf6NbrTrapList,
+ sizeof(ospfv3_oid) / sizeof(oid), index, 3, ospf6NbrTrapList,
array_size(ospf6NbrTrapList), NBRSTATECHANGE);
return 0;
}
@@ -1378,7 +1378,7 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state,
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
- sizeof ospfv3_oid / sizeof(oid), index, 2, ospf6IfTrapList,
+ sizeof(ospfv3_oid) / sizeof(oid), index, 2, ospf6IfTrapList,
array_size(ospf6IfTrapList), IFSTATECHANGE);
return 0;
}
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index 524017a31e..b0fe890d33 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -1089,7 +1089,7 @@ void ospf6_remove_temp_router_lsa(struct ospf6_area *area)
if (IS_OSPF6_DEBUG_SPF(PROCESS))
zlog_debug(
"%s Remove LSA %s lsa->lock %u lsdb count %u",
- __PRETTY_FUNCTION__, lsa->name, lsa->lock,
+ __func__, lsa->name, lsa->lock,
area->temp_router_lsa_lsdb->count);
ospf6_lsdb_remove(lsa, area->temp_router_lsa_lsdb);
}
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 1717f1e650..f8df37094f 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -256,7 +256,7 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
&& ospf6_route_is_same(request, request->next)) {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
zlog_debug(
- " Best-path removal resulted Sencondary addition");
+ " Best-path removal resulted Secondary addition");
type = ADD;
request = request->next;
}
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index a16fb81ce3..a712ecde95 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -386,7 +386,7 @@ static void ospf_packet_db_desc_dump(struct stream *s, uint16_t length)
zlog_debug(" Options %d (%s)", dd->options,
ospf_options_dump(dd->options));
zlog_debug(" Flags %d (%s)", dd->flags,
- ospf_dd_flags_dump(dd->flags, dd_flags, sizeof dd_flags));
+ ospf_dd_flags_dump(dd->flags, dd_flags, sizeof(dd_flags)));
zlog_debug(" Sequence Number 0x%08lx",
(unsigned long)ntohl(dd->dd_seqnum));
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 52db1de2d9..55ec638522 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -434,7 +434,7 @@ static char link_info_set(struct stream **s, struct in_addr id,
/* we futz the size here for simplicity, really we need
* to account
* for just:
- * IP Header - (sizeof (struct ip))
+ * IP Header - (sizeof(struct ip))
* OSPF Header - OSPF_HEADER_SIZE
* LSA Header - OSPF_LSA_HEADER_SIZE
* MD5 auth data, if MD5 is configured -
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 58f087ca4f..9cd83c245c 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -731,7 +731,7 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state)
OSPF_DD_FLAG_I | OSPF_DD_FLAG_M | OSPF_DD_FLAG_MS;
if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
zlog_info(
- "%s: Intializing [DD]: %s with seqnum:%x , flags:%x",
+ "%s: Initializing [DD]: %s with seqnum:%x , flags:%x",
(oi->ospf->name) ? oi->ospf->name
: VRF_DEFAULT_NAME,
inet_ntoa(nbr->router_id), nbr->dd_seqnum,
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index de8c371f17..d87f02627b 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -725,7 +725,7 @@ static int ospf_write(struct thread *thread)
* but.. */
if (sizeof(struct ip)
> (unsigned int)(iph.ip_hl << OSPF_WRITE_IPHL_SHIFT))
- iph.ip_hl++; /* we presume sizeof struct ip cant
+ iph.ip_hl++; /* we presume sizeof(struct ip) cant
overflow ip_hl.. */
iph.ip_v = IPVERSION;
@@ -3250,7 +3250,7 @@ static int ospf_make_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
switch (ospf_auth_type(oi)) {
case OSPF_AUTH_NULL:
- /* memset (ospfh->u.auth_data, 0, sizeof (ospfh->u.auth_data));
+ /* memset (ospfh->u.auth_data, 0, sizeof(ospfh->u.auth_data));
*/
break;
case OSPF_AUTH_SIMPLE:
@@ -3273,7 +3273,7 @@ static int ospf_make_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
/* note: the seq is done in ospf_make_md5_digest() */
break;
default:
- /* memset (ospfh->u.auth_data, 0, sizeof (ospfh->u.auth_data));
+ /* memset (ospfh->u.auth_data, 0, sizeof(ospfh->u.auth_data));
*/
break;
}
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 5c9fbdb902..550e5ee9ee 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -2463,7 +2463,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
array_size(ospf_trap_oid), ospf_oid,
- sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
+ sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
ospfNbrTrapList, array_size(ospfNbrTrapList), NBRSTATECHANGE);
}
@@ -2478,7 +2478,7 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
array_size(ospf_trap_oid), ospf_oid,
- sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
+ sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
ospfVirtNbrTrapList, array_size(ospfVirtNbrTrapList),
VIRTNBRSTATECHANGE);
}
@@ -2517,7 +2517,7 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
array_size(ospf_trap_oid), ospf_oid,
- sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
+ sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
ospfIfTrapList, array_size(ospfIfTrapList), IFSTATECHANGE);
}
@@ -2532,7 +2532,7 @@ static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
array_size(ospf_trap_oid), ospf_oid,
- sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
+ sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,
ospfVirtIfTrapList, array_size(ospfVirtIfTrapList),
VIRTIFSTATECHANGE);
}
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 620691a98d..8b605b3bac 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -1345,7 +1345,7 @@ static int ospf_spf_calculate_timer(struct thread *thread)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s: ospf install new route, vrf %s id %u new_table count %lu",
- __PRETTY_FUNCTION__, ospf_vrf_id_to_name(ospf->vrf_id),
+ __func__, ospf_vrf_id_to_name(ospf->vrf_id),
ospf->vrf_id, new_table->count);
/* Update routing table. */
monotime(&start_time);
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index fb4082e509..75f556e39f 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -93,7 +93,7 @@ static int str2metric(const char *str, int *metric)
return 0;
*metric = strtol(str, NULL, 10);
- if (*metric < 0 && *metric > 16777214) {
+ if (*metric < 0 || *metric > 16777214) {
/* vty_out (vty, "OSPF metric value is invalid\n"); */
return 0;
}
@@ -619,8 +619,7 @@ DEFUN (ospf_network_area,
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s ospf vrf %s num of %u ip osp area x config",
- __PRETTY_FUNCTION__,
- ospf->name ? ospf->name : "NIL",
+ __func__, ospf->name ? ospf->name : "NIL",
ospf->if_ospf_cli_count);
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 1cea79d641..385a7ece7b 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -957,8 +957,8 @@ static int ospf_distribute_list_update_timer(struct thread *thread)
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug(
"%s: ospf distribute-list update arg_type %d vrf %s id %d",
- __PRETTY_FUNCTION__, arg_type,
- ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id);
+ __func__, arg_type, ospf_vrf_id_to_name(ospf->vrf_id),
+ ospf->vrf_id);
}
/* foreach all external info. */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 2a0f8cdc0c..f3fe9e17b2 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -2060,8 +2060,8 @@ static int ospf_vrf_enable(struct vrf *vrf)
int ret = 0;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("%s: VRF %s id %u enabled", __PRETTY_FUNCTION__,
- vrf->name, vrf->vrf_id);
+ zlog_debug("%s: VRF %s id %u enabled", __func__, vrf->name,
+ vrf->vrf_id);
ospf = ospf_lookup_by_name(vrf->name);
if (ospf) {
@@ -2075,8 +2075,7 @@ static int ospf_vrf_enable(struct vrf *vrf)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"%s: ospf linked to vrf %s vrf_id %u (old id %u)",
- __PRETTY_FUNCTION__, vrf->name, ospf->vrf_id,
- old_vrf_id);
+ __func__, vrf->name, ospf->vrf_id, old_vrf_id);
if (old_vrf_id != ospf->vrf_id) {
frr_with_privs(&ospfd_privs) {
diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c
index 9f4a75fa49..e45e629649 100644
--- a/pbrd/pbr_map.c
+++ b/pbrd/pbr_map.c
@@ -327,8 +327,7 @@ void pbr_map_vrf_update(const struct pbr_vrf *pbr_vrf)
enabled ? "enabled" : "disabled");
RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) {
- DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __PRETTY_FUNCTION__,
- pbrm->name);
+ DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __func__, pbrm->name);
for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms))
pbrms_vrf_update(pbrms, pbr_vrf);
}
@@ -417,8 +416,7 @@ struct pbr_map_sequence *pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex,
for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, snode,
pbrms)) {
DEBUGD(&pbr_dbg_map, "%s: Comparing %u to %u",
- __PRETTY_FUNCTION__, pbrms->unique,
- unique);
+ __func__, pbrms->unique, unique);
if (pbrms->unique == unique)
return pbrms;
}
@@ -611,8 +609,7 @@ void pbr_map_schedule_policy_from_nhg(const char *nh_group)
struct listnode *node;
RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) {
- DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __PRETTY_FUNCTION__,
- pbrm->name);
+ DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __func__, pbrm->name);
for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms)) {
DEBUGD(&pbr_dbg_map, "\tNH Grp name: %s",
pbrms->nhgrp_name ?
@@ -643,16 +640,15 @@ void pbr_map_policy_install(const char *name)
struct listnode *node, *inode;
struct pbr_map_interface *pmi;
- DEBUGD(&pbr_dbg_map, "%s: for %s", __PRETTY_FUNCTION__, name);
+ DEBUGD(&pbr_dbg_map, "%s: for %s", __func__, name);
pbrm = pbrm_find(name);
if (!pbrm)
return;
for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms)) {
DEBUGD(&pbr_dbg_map,
- "%s: Looking at what to install %s(%u) %d %d",
- __PRETTY_FUNCTION__, name, pbrms->seqno, pbrm->valid,
- pbrms->nhs_installed);
+ "%s: Looking at what to install %s(%u) %d %d", __func__,
+ name, pbrms->seqno, pbrm->valid, pbrms->nhs_installed);
if (pbrm->valid && pbrms->nhs_installed
&& pbrm->incoming->count) {
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index c0c417a743..ecd375333c 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -431,13 +431,13 @@ static afi_t pbr_nht_which_afi(struct nexthop_group nhg,
if (!bh && v6 && v4)
DEBUGD(&pbr_dbg_nht,
- "%s: Saw both V6 and V4 nexthops...using %s",
- __PRETTY_FUNCTION__, afi2str(install_afi));
+ "%s: Saw both V6 and V4 nexthops...using %s", __func__,
+ afi2str(install_afi));
if (bh && (v6 || v4))
DEBUGD(&pbr_dbg_nht,
"%s: Saw blackhole nexthop(s) with %s%s%s nexthop(s), using AFI_MAX.",
- __PRETTY_FUNCTION__, v4 ? "v4" : "",
- (v4 && v6) ? " and " : "", v6 ? "v6" : "");
+ __func__, v4 ? "v4" : "", (v4 && v6) ? " and " : "",
+ v6 ? "v6" : "");
return install_afi;
}
@@ -485,7 +485,7 @@ void pbr_nht_change_group(const char *name)
if (!pnhgc) {
DEBUGD(&pbr_dbg_nht,
"%s: Could not find nexthop-group cache w/ name '%s'",
- __PRETTY_FUNCTION__, name);
+ __func__, name);
return;
}
@@ -579,7 +579,7 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *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__, name);
+ __func__, name);
return NULL;
}
@@ -587,14 +587,13 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name)
if (!nhgc) {
DEBUGD(&pbr_dbg_nht, "%s: Could not find nhgc with name: %s\n",
- __PRETTY_FUNCTION__, name);
+ __func__, name);
return NULL;
}
snprintf(lookup.name, sizeof(lookup.name), "%s", name);
pnhgc = hash_get(pbr_nhg_hash, &lookup, pbr_nhgc_alloc);
- DEBUGD(&pbr_dbg_nht, "%s: Retrieved NHGC @ %p", __PRETTY_FUNCTION__,
- pnhgc);
+ DEBUGD(&pbr_dbg_nht, "%s: Retrieved NHGC @ %p", __func__, pnhgc);
for (ALL_NEXTHOPS(nhgc->nhg, nhop)) {
struct pbr_nexthop_cache lookupc;
diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c
index f5fc1eebf6..84f6733eaf 100644
--- a/pimd/pim_bfd.c
+++ b/pimd/pim_bfd.c
@@ -240,16 +240,15 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
if (!pim_ifp->bfd_info) {
if (PIM_DEBUG_PIM_TRACE)
zlog_debug("%s: pim interface %s BFD is disabled ",
- __PRETTY_FUNCTION__, ifp->name);
+ __func__, ifp->name);
return 0;
}
if (PIM_DEBUG_PIM_TRACE) {
char buf[PREFIX2STR_BUFFER];
prefix2str(&p, buf, sizeof(buf));
- zlog_debug("%s: interface %s bfd destination %s %s",
- __PRETTY_FUNCTION__, ifp->name, buf,
- bfd_get_status_str(status));
+ zlog_debug("%s: interface %s bfd destination %s %s", __func__,
+ ifp->name, buf, bfd_get_status_str(status));
}
for (ALL_LIST_ELEMENTS(pim_ifp->pim_neighbor_list, neigh_node,
@@ -265,7 +264,7 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
pim_inet4_dump("<nht_nbr?>", neigh->source_addr,
str, sizeof(str));
zlog_debug("%s: bfd status is same for nbr %s",
- __PRETTY_FUNCTION__, str);
+ __func__, str);
}
continue;
}
@@ -275,8 +274,7 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)
bfd_info->last_update = tv.tv_sec;
if (PIM_DEBUG_PIM_TRACE) {
- zlog_debug("%s: status %s old_status %s",
- __PRETTY_FUNCTION__,
+ zlog_debug("%s: status %s old_status %s", __func__,
bfd_get_status_str(status),
bfd_get_status_str(old_status));
}
@@ -328,8 +326,7 @@ static int pim_bfd_nbr_replay(ZAPI_CALLBACK_ARGS)
sizeof(str));
zlog_debug(
"%s: Replaying Pim Neigh %s to BFD vrf_id %u",
- __PRETTY_FUNCTION__, str,
- vrf->vrf_id);
+ __func__, str, vrf->vrf_id);
}
pim_bfd_reg_dereg_nbr(neigh,
ZEBRA_BFD_DEST_UPDATE);
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 91fbddf939..bcf11aedbd 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -335,7 +335,7 @@ static int pim_on_g2rp_timer(struct thread *t)
rn = route_node_lookup(pim->rp_table, &bsgrp_node->group);
if (!rn) {
- zlog_warn("%s: Route node doesn't exist", __PRETTY_FUNCTION__);
+ zlog_warn("%s: Route node doesn't exist", __func__);
return 0;
}
@@ -910,8 +910,8 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)
if (PIM_DEBUG_BSM) {
pim_inet4_dump("<src?>", neigh->source_addr, neigh_src_str,
sizeof(neigh_src_str));
- zlog_debug("%s: New neighbor %s seen on %s",
- __PRETTY_FUNCTION__, neigh_src_str, ifp->name);
+ zlog_debug("%s: New neighbor %s seen on %s", __func__,
+ neigh_src_str, ifp->name);
}
pim_ifp = ifp->info;
@@ -921,13 +921,13 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)
if (PIM_DEBUG_BSM)
zlog_debug(
"%s: It is not DR, so don't forward BSM packet",
- __PRETTY_FUNCTION__);
+ __func__);
}
if (!pim_ifp->bsm_enable) {
if (PIM_DEBUG_BSM)
- zlog_debug("%s: BSM proc not enabled on %s",
- __PRETTY_FUNCTION__, ifp->name);
+ zlog_debug("%s: BSM proc not enabled on %s", __func__,
+ ifp->name);
return ret;
}
@@ -936,20 +936,20 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)
if (!scope->bsm_list->count) {
if (PIM_DEBUG_BSM)
zlog_debug("%s: BSM list for the scope is empty",
- __PRETTY_FUNCTION__);
+ __func__);
return ret;
}
if (!pim_ifp->ucast_bsm_accept) {
dst_addr = qpim_all_pim_routers_addr;
if (PIM_DEBUG_BSM)
- zlog_debug("%s: Sending BSM mcast to %s",
- __PRETTY_FUNCTION__, neigh_src_str);
+ zlog_debug("%s: Sending BSM mcast to %s", __func__,
+ neigh_src_str);
} else {
dst_addr = neigh->source_addr;
if (PIM_DEBUG_BSM)
- zlog_debug("%s: Sending BSM ucast to %s",
- __PRETTY_FUNCTION__, neigh_src_str);
+ zlog_debug("%s: Sending BSM ucast to %s", __func__,
+ neigh_src_str);
}
pim_mtu = ifp->mtu - MAX_IP_HDR_LEN;
pim_hello_require(ifp);
@@ -962,7 +962,7 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)
if (PIM_DEBUG_BSM)
zlog_debug(
"%s: pim_bsm_frag_send failed",
- __PRETTY_FUNCTION__);
+ __func__);
}
} else {
/* Pim header needs to be constructed */
@@ -974,7 +974,7 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)
if (PIM_DEBUG_BSM)
zlog_debug(
"%s: pim_bsm_frag_send failed",
- __PRETTY_FUNCTION__);
+ __func__);
}
}
}
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 85ce41ef35..af25d930d1 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -909,7 +909,7 @@ static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty)
static void pim_show_interfaces_single(struct pim_instance *pim,
struct vty *vty, const char *ifname,
- bool uj)
+ bool mlag, bool uj)
{
struct in_addr ifaddr;
struct interface *ifp;
@@ -952,6 +952,9 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
if (!pim_ifp)
continue;
+ if (mlag == true && pim_ifp->activeactive == false)
+ continue;
+
if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
continue;
@@ -1380,7 +1383,7 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty,
}
static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
- bool uj)
+ bool mlag, bool uj)
{
struct interface *ifp;
struct pim_interface *pim_ifp;
@@ -1400,6 +1403,9 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
if (!pim_ifp)
continue;
+ if (mlag == true && pim_ifp->activeactive == false)
+ continue;
+
pim_nbrs = pim_ifp->pim_neighbor_list->count;
pim_ifchannels = pim_if_ifchannel_count(pim_ifp);
fhr = 0;
@@ -1700,7 +1706,10 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags));
if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags))
json_object_int_add(json_row, "SGRpt", 1);
-
+ if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags))
+ json_object_int_add(json_row, "protocolPim", 1);
+ if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
+ json_object_int_add(json_row, "protocolIgmp", 1);
json_object_object_get_ex(json_iface, ch_grp_str, &json_grp);
if (!json_grp) {
json_grp = json_object_new_object();
@@ -3726,8 +3735,6 @@ static void pim_show_bsr(struct pim_instance *pim,
char bsr_str[PREFIX_STRLEN];
json_object *json = NULL;
- vty_out(vty, "PIMv2 Bootstrap information\n");
-
if (pim->global_scope.current_bsr.s_addr == INADDR_ANY) {
strlcpy(bsr_str, "0.0.0.0", sizeof(bsr_str));
pim_time_uptime(uptime, sizeof(uptime),
@@ -3773,6 +3780,7 @@ static void pim_show_bsr(struct pim_instance *pim,
}
else {
+ vty_out(vty, "PIMv2 Bootstrap information\n");
vty_out(vty, "Current preferred BSR address: %s\n", bsr_str);
vty_out(vty,
"Priority Fragment-Tag State UpTime\n");
@@ -3927,7 +3935,7 @@ static void clear_mroute(struct pim_instance *pim)
/* clean up all upstreams*/
while ((up = rb_pim_upstream_first(&pim->upstream_head))) {
- pim_upstream_del(pim, up, __PRETTY_FUNCTION__);
+ pim_upstream_del(pim, up, __func__);
}
}
@@ -4295,6 +4303,113 @@ DEFUN (show_ip_igmp_statistics,
return CMD_SUCCESS;
}
+DEFUN (show_ip_pim_mlag_summary,
+ show_ip_pim_mlag_summary_cmd,
+ "show ip pim mlag summary [json]",
+ SHOW_STR
+ IP_STR
+ PIM_STR
+ "MLAG\n"
+ "status and stats\n"
+ JSON_STR)
+{
+ bool uj = use_json(argc, argv);
+ char role_buf[MLAG_ROLE_STRSIZE];
+ char addr_buf[INET_ADDRSTRLEN];
+
+ if (uj) {
+ json_object *json = NULL;
+ json_object *json_stat = NULL;
+
+ json = json_object_new_object();
+ if (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
+ json_object_boolean_true_add(json, "mlagConnUp");
+ if (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
+ json_object_boolean_true_add(json, "mlagPeerConnUp");
+ if (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
+ json_object_boolean_true_add(json, "mlagPeerZebraUp");
+ json_object_string_add(json, "mlagRole",
+ mlag_role2str(router->mlag_role,
+ role_buf, sizeof(role_buf)));
+ inet_ntop(AF_INET, &router->local_vtep_ip,
+ addr_buf, INET_ADDRSTRLEN);
+ json_object_string_add(json, "localVtepIp", addr_buf);
+ inet_ntop(AF_INET, &router->anycast_vtep_ip,
+ addr_buf, INET_ADDRSTRLEN);
+ json_object_string_add(json, "anycastVtepIp", addr_buf);
+ json_object_string_add(json, "peerlinkRif",
+ router->peerlink_rif);
+
+ json_stat = json_object_new_object();
+ json_object_int_add(json_stat, "mlagConnFlaps",
+ router->mlag_stats.mlagd_session_downs);
+ json_object_int_add(json_stat, "mlagPeerConnFlaps",
+ router->mlag_stats.peer_session_downs);
+ json_object_int_add(json_stat, "mlagPeerZebraFlaps",
+ router->mlag_stats.peer_zebra_downs);
+ json_object_int_add(json_stat, "mrouteAddRx",
+ router->mlag_stats.msg.mroute_add_rx);
+ json_object_int_add(json_stat, "mrouteAddTx",
+ router->mlag_stats.msg.mroute_add_tx);
+ json_object_int_add(json_stat, "mrouteDelRx",
+ router->mlag_stats.msg.mroute_del_rx);
+ json_object_int_add(json_stat, "mrouteDelTx",
+ router->mlag_stats.msg.mroute_del_tx);
+ json_object_int_add(json_stat, "mlagStatusUpdates",
+ router->mlag_stats.msg.mlag_status_updates);
+ json_object_int_add(json_stat, "peerZebraStatusUpdates",
+ router->mlag_stats.msg.peer_zebra_status_updates);
+ json_object_int_add(json_stat, "pimStatusUpdates",
+ router->mlag_stats.msg.pim_status_updates);
+ json_object_int_add(json_stat, "vxlanUpdates",
+ router->mlag_stats.msg.vxlan_updates);
+ json_object_object_add(json, "connStats", json_stat);
+
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
+ json_object_free(json);
+ return CMD_SUCCESS;
+ }
+
+ vty_out(vty, "MLAG daemon connection: %s\n",
+ (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
+ ? "up" : "down");
+ vty_out(vty, "MLAG peer state: %s\n",
+ (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
+ ? "up" : "down");
+ vty_out(vty, "Zebra peer state: %s\n",
+ (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
+ ? "up" : "down");
+ vty_out(vty, "MLAG role: %s\n",
+ mlag_role2str(router->mlag_role, role_buf, sizeof(role_buf)));
+ inet_ntop(AF_INET, &router->local_vtep_ip,
+ addr_buf, INET_ADDRSTRLEN);
+ vty_out(vty, "Local VTEP IP: %s\n", addr_buf);
+ inet_ntop(AF_INET, &router->anycast_vtep_ip,
+ addr_buf, INET_ADDRSTRLEN);
+ vty_out(vty, "Anycast VTEP IP: %s\n", addr_buf);
+ vty_out(vty, "Peerlink: %s\n", router->peerlink_rif);
+ vty_out(vty, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n",
+ router->mlag_stats.mlagd_session_downs,
+ router->mlag_stats.peer_session_downs,
+ router->mlag_stats.peer_zebra_downs);
+ vty_out(vty, "Message Statistics:\n");
+ vty_out(vty, " mroute adds: rx: %d, tx: %d\n",
+ router->mlag_stats.msg.mroute_add_rx,
+ router->mlag_stats.msg.mroute_add_tx);
+ vty_out(vty, " mroute dels: rx: %d, tx: %d\n",
+ router->mlag_stats.msg.mroute_del_rx,
+ router->mlag_stats.msg.mroute_del_tx);
+ vty_out(vty, " peer zebra status updates: %d\n",
+ router->mlag_stats.msg.peer_zebra_status_updates);
+ vty_out(vty, " PIM status updates: %d\n",
+ router->mlag_stats.msg.pim_status_updates);
+ vty_out(vty, " VxLAN updates: %d\n",
+ router->mlag_stats.msg.vxlan_updates);
+
+ return CMD_SUCCESS;
+}
+
DEFUN (show_ip_pim_assert,
show_ip_pim_assert_cmd,
"show ip pim [vrf NAME] assert",
@@ -4377,10 +4492,11 @@ DEFUN (show_ip_pim_assert_winner_metric,
DEFUN (show_ip_pim_interface,
show_ip_pim_interface_cmd,
- "show ip pim [vrf NAME] interface [detail|WORD] [json]",
+ "show ip pim [mlag] [vrf NAME] interface [detail|WORD] [json]",
SHOW_STR
IP_STR
PIM_STR
+ "MLAG\n"
VRF_CMD_HELP_STR
"PIM interface information\n"
"Detailed output\n"
@@ -4390,36 +4506,47 @@ DEFUN (show_ip_pim_interface,
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
bool uj = use_json(argc, argv);
+ bool mlag = false;
if (!vrf)
return CMD_WARNING;
+ if (argv_find(argv, argc, "mlag", &idx))
+ mlag = true;
+
if (argv_find(argv, argc, "WORD", &idx)
|| argv_find(argv, argc, "detail", &idx))
- pim_show_interfaces_single(vrf->info, vty, argv[idx]->arg, uj);
+ pim_show_interfaces_single(vrf->info, vty, argv[idx]->arg, mlag,
+ uj);
else
- pim_show_interfaces(vrf->info, vty, uj);
+ pim_show_interfaces(vrf->info, vty, mlag, uj);
return CMD_SUCCESS;
}
DEFUN (show_ip_pim_interface_vrf_all,
show_ip_pim_interface_vrf_all_cmd,
- "show ip pim vrf all interface [detail|WORD] [json]",
+ "show ip pim [mlag] vrf all interface [detail|WORD] [json]",
SHOW_STR
IP_STR
PIM_STR
+ "MLAG\n"
VRF_CMD_HELP_STR
"PIM interface information\n"
"Detailed output\n"
"interface name\n"
JSON_STR)
{
- int idx = 6;
+ int idx = 2;
bool uj = use_json(argc, argv);
struct vrf *vrf;
bool first = true;
+ bool mlag = false;
+ if (argv_find(argv, argc, "mlag", &idx))
+ mlag = true;
+
+ idx = 6;
if (uj)
vty_out(vty, "{ ");
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
@@ -4433,9 +4560,9 @@ DEFUN (show_ip_pim_interface_vrf_all,
if (argv_find(argv, argc, "WORD", &idx)
|| argv_find(argv, argc, "detail", &idx))
pim_show_interfaces_single(vrf->info, vty,
- argv[idx]->arg, uj);
+ argv[idx]->arg, mlag, uj);
else
- pim_show_interfaces(vrf->info, vty, uj);
+ pim_show_interfaces(vrf->info, vty, mlag, uj);
}
if (uj)
vty_out(vty, "}\n");
@@ -4625,113 +4752,6 @@ DEFUN (show_ip_pim_local_membership,
return CMD_SUCCESS;
}
-DEFUN (show_ip_pim_mlag_summary,
- show_ip_pim_mlag_summary_cmd,
- "show ip pim mlag summary [json]",
- SHOW_STR
- IP_STR
- PIM_STR
- "MLAG\n"
- "status and stats\n"
- JSON_STR)
-{
- bool uj = use_json(argc, argv);
- char role_buf[MLAG_ROLE_STRSIZE];
- char addr_buf[INET_ADDRSTRLEN];
-
- if (uj) {
- json_object *json = NULL;
- json_object *json_stat = NULL;
-
- json = json_object_new_object();
- if (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
- json_object_boolean_true_add(json, "mlagConnUp");
- if (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
- json_object_boolean_true_add(json, "mlagPeerConnUp");
- if (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
- json_object_boolean_true_add(json, "mlagPeerZebraUp");
- json_object_string_add(json, "mlagRole",
- mlag_role2str(router->mlag_role,
- role_buf, sizeof(role_buf)));
- inet_ntop(AF_INET, &router->local_vtep_ip,
- addr_buf, INET_ADDRSTRLEN);
- json_object_string_add(json, "localVtepIp", addr_buf);
- inet_ntop(AF_INET, &router->anycast_vtep_ip,
- addr_buf, INET_ADDRSTRLEN);
- json_object_string_add(json, "anycastVtepIp", addr_buf);
- json_object_string_add(json, "peerlinkRif",
- router->peerlink_rif);
-
- json_stat = json_object_new_object();
- json_object_int_add(json_stat, "mlagConnFlaps",
- router->mlag_stats.mlagd_session_downs);
- json_object_int_add(json_stat, "mlagPeerConnFlaps",
- router->mlag_stats.peer_session_downs);
- json_object_int_add(json_stat, "mlagPeerZebraFlaps",
- router->mlag_stats.peer_zebra_downs);
- json_object_int_add(json_stat, "mrouteAddRx",
- router->mlag_stats.msg.mroute_add_rx);
- json_object_int_add(json_stat, "mrouteAddTx",
- router->mlag_stats.msg.mroute_add_tx);
- json_object_int_add(json_stat, "mrouteDelRx",
- router->mlag_stats.msg.mroute_del_rx);
- json_object_int_add(json_stat, "mrouteDelTx",
- router->mlag_stats.msg.mroute_del_tx);
- json_object_int_add(json_stat, "mlagStatusUpdates",
- router->mlag_stats.msg.mlag_status_updates);
- json_object_int_add(json_stat, "peerZebraStatusUpdates",
- router->mlag_stats.msg.peer_zebra_status_updates);
- json_object_int_add(json_stat, "pimStatusUpdates",
- router->mlag_stats.msg.pim_status_updates);
- json_object_int_add(json_stat, "vxlanUpdates",
- router->mlag_stats.msg.vxlan_updates);
- json_object_object_add(json, "connStats", json_stat);
-
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- return CMD_SUCCESS;
- }
-
- vty_out(vty, "MLAG daemon connection: %s\n",
- (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP)
- ? "up" : "down");
- vty_out(vty, "MLAG peer state: %s\n",
- (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP)
- ? "up" : "down");
- vty_out(vty, "Zebra peer state: %s\n",
- (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP)
- ? "up" : "down");
- vty_out(vty, "MLAG role: %s\n",
- mlag_role2str(router->mlag_role, role_buf, sizeof(role_buf)));
- inet_ntop(AF_INET, &router->local_vtep_ip,
- addr_buf, INET_ADDRSTRLEN);
- vty_out(vty, "Local VTEP IP: %s\n", addr_buf);
- inet_ntop(AF_INET, &router->anycast_vtep_ip,
- addr_buf, INET_ADDRSTRLEN);
- vty_out(vty, "Anycast VTEP IP: %s\n", addr_buf);
- vty_out(vty, "Peerlink: %s\n", router->peerlink_rif);
- vty_out(vty, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n",
- router->mlag_stats.mlagd_session_downs,
- router->mlag_stats.peer_session_downs,
- router->mlag_stats.peer_zebra_downs);
- vty_out(vty, "Message Statistics:\n");
- vty_out(vty, " mroute adds: rx: %d, tx: %d\n",
- router->mlag_stats.msg.mroute_add_rx,
- router->mlag_stats.msg.mroute_add_tx);
- vty_out(vty, " mroute dels: rx: %d, tx: %d\n",
- router->mlag_stats.msg.mroute_del_rx,
- router->mlag_stats.msg.mroute_del_tx);
- vty_out(vty, " peer zebra status updates: %d\n",
- router->mlag_stats.msg.peer_zebra_status_updates);
- vty_out(vty, " PIM status updates: %d\n",
- router->mlag_stats.msg.pim_status_updates);
- vty_out(vty, " VxLAN updates: %d\n",
- router->mlag_stats.msg.vxlan_updates);
-
- return CMD_SUCCESS;
-}
-
static void pim_show_mlag_up_entry_detail(struct vrf *vrf,
struct vty *vty, struct pim_upstream *up,
char *src_str, char *grp_str, json_object *json)
@@ -5772,12 +5792,18 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
int oif_vif_index;
struct interface *ifp_in;
char proto[100];
+ char state_str[PIM_REG_STATE_STR_LEN];
+ char mroute_uptime[10];
if (uj) {
json = json_object_new_object();
} else {
+ vty_out(vty, "IP Multicast Routing Table\n");
+ vty_out(vty, "Flags: S- Sparse, C - Connected, P - Pruned\n");
vty_out(vty,
- "Source Group Proto Input Output TTL Uptime\n");
+ " R - RP-bit set, F - Register flag, T - SPT-bit set\n");
+ vty_out(vty,
+ "\nSource Group Flags Proto Input Output TTL Uptime\n");
}
now = pim_time_monotonic_sec();
@@ -5800,6 +5826,23 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
sizeof(grp_str));
pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, src_str,
sizeof(src_str));
+
+ strlcpy(state_str, "S", sizeof(state_str));
+ /* When a non DR receives a igmp join, it creates a (*,G)
+ * channel_oil without any upstream creation */
+ if (c_oil->up) {
+ if (PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(c_oil->up->flags))
+ strlcat(state_str, "C", sizeof(state_str));
+ if (pim_upstream_is_sg_rpt(c_oil->up))
+ strlcat(state_str, "R", sizeof(state_str));
+ if (PIM_UPSTREAM_FLAG_TEST_FHR(c_oil->up->flags))
+ strlcat(state_str, "F", sizeof(state_str));
+ if (c_oil->up->sptbit == PIM_UPSTREAM_SPTBIT_TRUE)
+ strlcat(state_str, "T", sizeof(state_str));
+ }
+ if (pim_channel_oil_empty(c_oil))
+ strlcat(state_str, "P", sizeof(state_str));
+
ifp_in = pim_if_find_by_vif_index(pim, c_oil->oil.mfcc_parent);
if (ifp_in)
@@ -5807,6 +5850,10 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
else
strlcpy(in_ifname, "<iif?>", sizeof(in_ifname));
+
+ pim_time_uptime(mroute_uptime, sizeof(mroute_uptime),
+ now - c_oil->mroute_creation);
+
if (uj) {
/* Find the group, create it if it doesn't exist */
@@ -5819,7 +5866,8 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
}
/* Find the source nested under the group, create it if
- * it doesn't exist */
+ * it doesn't exist
+ */
json_object_object_get_ex(json_group, src_str,
&json_source);
@@ -5840,13 +5888,14 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
json_object_int_add(json_source, "OilInheritedRescan",
c_oil->oil_inherited_rescan);
json_object_string_add(json_source, "iif", in_ifname);
+ json_object_string_add(json_source, "upTime",
+ mroute_uptime);
json_oil = NULL;
}
for (oif_vif_index = 0; oif_vif_index < MAXVIFS;
++oif_vif_index) {
struct interface *ifp_out;
- char mroute_uptime[10];
int ttl;
ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
@@ -5864,9 +5913,6 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
continue;
ifp_out = pim_if_find_by_vif_index(pim, oif_vif_index);
- pim_time_uptime(
- mroute_uptime, sizeof(mroute_uptime),
- now - c_oil->mroute_creation);
found_oif = 1;
if (ifp_out)
@@ -5944,23 +5990,27 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
}
vty_out(vty,
- "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
- src_str, grp_str, proto, in_ifname,
- out_ifname, ttl, mroute_uptime);
+ "%-15s %-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
+ src_str, grp_str, state_str, proto,
+ in_ifname, out_ifname, ttl,
+ mroute_uptime);
if (first) {
src_str[0] = '\0';
grp_str[0] = '\0';
in_ifname[0] = '\0';
+ state_str[0] = '\0';
+ mroute_uptime[0] = '\0';
first = 0;
}
}
}
if (!uj && !found_oif) {
- vty_out(vty, "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
- src_str, grp_str, "none", in_ifname, "none", 0,
- "--:--:--");
+ vty_out(vty,
+ "%-15s %-15s %-15s %-6s %-16s %-16s %-3d %8s\n",
+ src_str, grp_str, state_str, "none", in_ifname,
+ "none", 0, "--:--:--");
}
}
@@ -6578,18 +6628,18 @@ static int pim_cmd_spt_switchover(struct pim_instance *pim,
switch (pim->spt.switchover) {
case PIM_SPT_IMMEDIATE:
- XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->spt.plist);
pim_upstream_add_lhr_star_pimreg(pim);
break;
case PIM_SPT_INFINITY:
pim_upstream_remove_lhr_star_pimreg(pim, plist);
- XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->spt.plist);
if (plist)
pim->spt.plist =
- XSTRDUP(MTYPE_PIM_SPT_PLIST_NAME, plist);
+ XSTRDUP(MTYPE_PIM_PLIST_NAME, plist);
break;
}
@@ -6650,6 +6700,26 @@ DEFUN (no_ip_pim_spt_switchover_infinity_plist,
return pim_cmd_spt_switchover(pim, PIM_SPT_IMMEDIATE, NULL);
}
+DEFPY (pim_register_accept_list,
+ pim_register_accept_list_cmd,
+ "[no] ip pim register-accept-list WORD$word",
+ NO_STR
+ IP_STR
+ PIM_STR
+ "Only accept registers from a specific source prefix list\n"
+ "Prefix-List name\n")
+{
+ PIM_DECLVAR_CONTEXT(vrf, pim);
+
+ if (no)
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
+ else {
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
+ pim->register_plist = XSTRDUP(MTYPE_PIM_PLIST_NAME, word);
+ }
+ return CMD_SUCCESS;
+}
+
DEFUN (ip_pim_joinprune_time,
ip_pim_joinprune_time_cmd,
"ip pim join-prune-interval (60-600)",
@@ -8035,13 +8105,13 @@ DEFPY_HIDDEN (pim_test_sg_keepalive,
return CMD_SUCCESS;
}
-DEFPY_HIDDEN (interface_ip_pim_activeactive,
- interface_ip_pim_activeactive_cmd,
- "[no$no] ip pim active-active",
- NO_STR
- IP_STR
- PIM_STR
- "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n")
+DEFPY (interface_ip_pim_activeactive,
+ interface_ip_pim_activeactive_cmd,
+ "[no$no] ip pim active-active",
+ NO_STR
+ IP_STR
+ PIM_STR
+ "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
@@ -8051,6 +8121,11 @@ DEFPY_HIDDEN (interface_ip_pim_activeactive,
return CMD_WARNING_CONFIG_FAILED;
}
+
+ if (PIM_DEBUG_MLAG)
+ zlog_debug("%sConfiguring PIM active-active on Interface: %s",
+ no ? "Un-":" ", ifp->name);
+
pim_ifp = ifp->info;
if (no)
pim_if_unconfigure_mlag_dualactive(pim_ifp);
@@ -10743,6 +10818,8 @@ void pim_cmd_init(void)
install_element(CONFIG_NODE,
&no_ip_pim_spt_switchover_infinity_plist_cmd);
install_element(VRF_NODE, &no_ip_pim_spt_switchover_infinity_plist_cmd);
+ install_element(CONFIG_NODE, &pim_register_accept_list_cmd);
+ install_element(VRF_NODE, &pim_register_accept_list_cmd);
install_element(CONFIG_NODE, &ip_pim_joinprune_time_cmd);
install_element(VRF_NODE, &ip_pim_joinprune_time_cmd);
install_element(CONFIG_NODE, &no_ip_pim_joinprune_time_cmd);
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 16eea1d6df..cb31878e01 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -514,7 +514,7 @@ void pim_if_addr_add(struct connected *ifc)
char buf[BUFSIZ];
prefix2str(ifc->address, buf, BUFSIZ);
zlog_debug("%s: %s ifindex=%d connected IP address %s %s",
- __PRETTY_FUNCTION__, ifp->name, ifp->ifindex, buf,
+ __func__, ifp->name, ifp->ifindex, buf,
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
@@ -522,7 +522,7 @@ void pim_if_addr_add(struct connected *ifc)
ifaddr = ifc->address->u.prefix4;
- detect_address_change(ifp, 0, __PRETTY_FUNCTION__);
+ detect_address_change(ifp, 0, __func__);
// if (ifc->address->family != AF_INET)
// return;
@@ -570,8 +570,8 @@ void pim_if_addr_add(struct connected *ifc)
source_str, sizeof(source_str));
zlog_warn(
"%s: igmp_join_sock() failure for IGMP group %s source %s on interface %s",
- __PRETTY_FUNCTION__, group_str,
- source_str, ifp->name);
+ __func__, group_str, source_str,
+ ifp->name);
/* warning only */
} else
ij->sock_fd = join_fd;
@@ -876,7 +876,7 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)
if (PIM_INADDR_IS_ANY(p->u.prefix4)) {
zlog_warn(
"%s: null IPv4 address connected to interface %s",
- __PRETTY_FUNCTION__, ifp->name);
+ __func__, ifp->name);
continue;
}
@@ -1128,8 +1128,8 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
pim_ifp = ifp->info;
if (!pim_ifp) {
- zlog_warn("%s: multicast not enabled on interface %s",
- __PRETTY_FUNCTION__, ifp->name);
+ zlog_warn("%s: multicast not enabled on interface %s", __func__,
+ ifp->name);
return 0;
}
@@ -1154,7 +1154,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
zlog_debug(
"%s: neighbor not found for address %s on interface %s",
- __PRETTY_FUNCTION__, addr_str, ifp->name);
+ __func__, addr_str, ifp->name);
}
return NULL;
@@ -1379,8 +1379,8 @@ static void pim_if_igmp_join_del_all(struct interface *ifp)
pim_ifp = ifp->info;
if (!pim_ifp) {
- zlog_warn("%s: multicast not enabled on interface %s",
- __PRETTY_FUNCTION__, ifp->name);
+ zlog_warn("%s: multicast not enabled on interface %s", __func__,
+ ifp->name);
return;
}
diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h
index 1b76b52305..570bf5eac3 100644
--- a/pimd/pim_iface.h
+++ b/pimd/pim_iface.h
@@ -55,6 +55,7 @@
#define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
#define PIM_I_am_DR(pim_ifp) (pim_ifp)->pim_dr_addr.s_addr == (pim_ifp)->primary_address.s_addr
+#define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true
struct pim_iface_upstream_switch {
struct in_addr address;
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index f3975a3879..70e06ccc4e 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -43,6 +43,7 @@
#include "pim_upstream.h"
#include "pim_ssm.h"
#include "pim_rp.h"
+#include "pim_mlag.h"
RB_GENERATE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb, pim_ifchannel_compare);
@@ -127,9 +128,29 @@ static void pim_ifchannel_find_new_children(struct pim_ifchannel *ch)
void pim_ifchannel_delete(struct pim_ifchannel *ch)
{
struct pim_interface *pim_ifp;
+ struct pim_upstream *up;
pim_ifp = ch->interface->info;
+ if (PIM_DEBUG_PIM_TRACE)
+ zlog_debug("%s: ifchannel entry %s(%s) del start", __func__,
+ ch->sg_str, ch->interface->name);
+
+ if (PIM_I_am_DualActive(pim_ifp)) {
+ if (PIM_DEBUG_MLAG)
+ zlog_debug(
+ "%s: if-chnanel-%s is deleted from a Dual "
+ "active Interface",
+ __func__, ch->sg_str);
+ /* Post Delete only if it is the last Dual-active Interface */
+ if (ch->upstream->dualactive_ifchannel_count == 1) {
+ pim_mlag_up_local_del(pim_ifp->pim, ch->upstream);
+ PIM_UPSTREAM_FLAG_UNSET_MLAG_INTERFACE(
+ ch->upstream->flags);
+ }
+ ch->upstream->dualactive_ifchannel_count--;
+ }
+
if (ch->upstream->channel_oil) {
uint32_t mask = PIM_OIF_FLAG_PROTO_PIM;
if (ch->upstream->flags & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
@@ -181,22 +202,22 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch)
listnode_delete(ch->upstream->ifchannels, ch);
- pim_upstream_update_join_desired(pim_ifp->pim, ch->upstream);
+ up = ch->upstream;
/* upstream is common across ifchannels, check if upstream's
ifchannel list is empty before deleting upstream_del
ref count will take care of it.
*/
if (ch->upstream->ref_count > 0)
- pim_upstream_del(pim_ifp->pim, ch->upstream,
- __PRETTY_FUNCTION__);
+ up = pim_upstream_del(pim_ifp->pim, ch->upstream, __func__);
else {
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: Avoiding deletion of upstream with ref_count %d "
- "from ifchannel(%s): %s", __PRETTY_FUNCTION__,
- ch->upstream->ref_count, ch->interface->name,
- ch->sg_str);
+ zlog_debug(
+ "%s: Avoiding deletion of upstream with ref_count %d "
+ "from ifchannel(%s): %s",
+ __func__, ch->upstream->ref_count,
+ ch->interface->name, ch->sg_str);
}
ch->upstream = NULL;
@@ -213,10 +234,13 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch)
RB_REMOVE(pim_ifchannel_rb, &pim_ifp->ifchannel_rb, ch);
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: ifchannel entry %s is deleted ",
- __PRETTY_FUNCTION__, ch->sg_str);
+ zlog_debug("%s: ifchannel entry %s(%s) is deleted ", __func__,
+ ch->sg_str, ch->interface->name);
XFREE(MTYPE_PIM_IFCHANNEL, ch);
+
+ if (up)
+ pim_upstream_update_join_desired(pim_ifp->pim, up);
}
void pim_ifchannel_delete_all(struct interface *ifp)
@@ -263,7 +287,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
if (PIM_DEBUG_PIM_EVENTS) {
zlog_debug(
"%s calledby %s: non-transition on state %d (%s)",
- __PRETTY_FUNCTION__, caller, new_state,
+ __func__, caller, new_state,
pim_ifchannel_ifjoin_name(new_state, 0));
}
return;
@@ -286,8 +310,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"%s %s: Prune(S,G)=%s from %s",
- __FILE__,
- __PRETTY_FUNCTION__,
+ __FILE__, __func__,
child->sg_str,
up->sg_str);
if (!c_oil)
@@ -313,8 +336,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"%s %s: Join(S,G)=%s from %s",
- __FILE__,
- __PRETTY_FUNCTION__,
+ __FILE__, __func__,
child->sg_str,
up->sg_str);
@@ -588,9 +610,33 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
else
PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(ch->flags);
+ /*
+ * advertise MLAG Data to MLAG peer
+ */
+ if (PIM_I_am_DualActive(pim_ifp)) {
+ up->dualactive_ifchannel_count++;
+ /* Sync once for upstream */
+ if (up->dualactive_ifchannel_count == 1) {
+ PIM_UPSTREAM_FLAG_SET_MLAG_INTERFACE(up->flags);
+ pim_mlag_up_local_add(pim_ifp->pim, up);
+ }
+ if (PIM_DEBUG_MLAG)
+ zlog_debug(
+ "%s: New Dual active if-chnanel is added to upstream:%s "
+ "count:%d, flags:0x%x",
+ __func__, up->sg_str,
+ up->dualactive_ifchannel_count, up->flags);
+ }
+
+ if (up_flags == PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
+ PIM_IF_FLAG_SET_PROTO_PIM(ch->flags);
+
+ if (up_flags == PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
+ PIM_IF_FLAG_SET_PROTO_IGMP(ch->flags);
+
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: ifchannel %s is created ", __func__,
- ch->sg_str);
+ zlog_debug("%s: ifchannel %s(%s) is created ", __func__,
+ ch->sg_str, ch->interface->name);
return ch;
}
@@ -1050,16 +1096,15 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,
if (!pim_ifp) {
if (PIM_DEBUG_EVENTS)
zlog_debug("%s:%s Expected pim interface setup for %s",
- __PRETTY_FUNCTION__,
- pim_str_sg_dump(sg), ifp->name);
+ __func__, pim_str_sg_dump(sg), ifp->name);
return 0;
}
if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
if (PIM_DEBUG_EVENTS)
- zlog_debug("%s:%s PIM is not configured on this interface %s",
- __PRETTY_FUNCTION__,
- pim_str_sg_dump(sg), ifp->name);
+ zlog_debug(
+ "%s:%s PIM is not configured on this interface %s",
+ __func__, pim_str_sg_dump(sg), ifp->name);
return 0;
}
@@ -1071,12 +1116,14 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,
if (PIM_DEBUG_PIM_EVENTS)
zlog_debug(
"%s: local membership (S,G)=%s ignored as group is SSM",
- __PRETTY_FUNCTION__,
- pim_str_sg_dump(sg));
+ __func__, pim_str_sg_dump(sg));
return 1;
}
}
+ /* vxlan term mroutes use ipmr-lo as local member to
+ * pull down multicast vxlan tunnel traffic
+ */
up_flags = is_vxlan ? PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM :
PIM_UPSTREAM_FLAG_MASK_SRC_IGMP;
ch = pim_ifchannel_add(ifp, sg, 0, up_flags);
@@ -1093,9 +1140,8 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,
for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {
if (PIM_DEBUG_EVENTS)
zlog_debug("%s %s: IGMP (S,G)=%s(%s) from %s",
- __FILE__, __PRETTY_FUNCTION__,
- child->sg_str, ifp->name,
- up->sg_str);
+ __FILE__, __func__, child->sg_str,
+ ifp->name, up->sg_str);
ch = pim_ifchannel_find(ifp, &child->sg);
if (pim_upstream_evaluate_join_desired_interface(
@@ -1167,9 +1213,8 @@ void pim_ifchannel_local_membership_del(struct interface *ifp,
if (PIM_DEBUG_EVENTS)
zlog_debug("%s %s: Prune(S,G)=%s(%s) from %s",
- __FILE__, __PRETTY_FUNCTION__,
- up->sg_str, ifp->name,
- child->sg_str);
+ __FILE__, __func__, up->sg_str,
+ ifp->name, child->sg_str);
ch = pim_ifchannel_find(ifp, &child->sg);
/*
@@ -1361,7 +1406,7 @@ void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
- "%s: %s %s eom: %d join %u", __PRETTY_FUNCTION__,
+ "%s: %s %s eom: %d join %u", __func__,
pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags),
ch->sg_str, eom, join);
if (!ch->sources)
diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h
index 3d5cbd8ecf..425622b79e 100644
--- a/pimd/pim_ifchannel.h
+++ b/pimd/pim_ifchannel.h
@@ -69,7 +69,7 @@ struct pim_assert_metric {
#define PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(flags) ((flags) &= ~PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
/*
- * Flat to tell us if the ifchannel is (S,G,rpt)
+ * Flag to tell us if the ifchannel is (S,G,rpt)
*/
#define PIM_IF_FLAG_MASK_S_G_RPT (1 << 2)
#define PIM_IF_FLAG_TEST_S_G_RPT(flags) ((flags) & PIM_IF_FLAG_MASK_S_G_RPT)
@@ -77,6 +77,23 @@ struct pim_assert_metric {
#define PIM_IF_FLAG_UNSET_S_G_RPT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_S_G_RPT)
/*
+ * Flag to tell us if the ifchannel is proto PIM
+ */
+#define PIM_IF_FLAG_MASK_PROTO_PIM (1 << 3)
+#define PIM_IF_FLAG_TEST_PROTO_PIM(flags) ((flags)&PIM_IF_FLAG_MASK_PROTO_PIM)
+#define PIM_IF_FLAG_SET_PROTO_PIM(flags) ((flags) |= PIM_IF_FLAG_MASK_PROTO_PIM)
+#define PIM_IF_FLAG_UNSET_PROTO_PIM(flags) \
+ ((flags) &= ~PIM_IF_FLAG_MASK_PROTO_PIM)
+/*
+ * Flag to tell us if the ifchannel is proto IGMP
+ */
+#define PIM_IF_FLAG_MASK_PROTO_IGMP (1 << 4)
+#define PIM_IF_FLAG_TEST_PROTO_IGMP(flags) ((flags)&PIM_IF_FLAG_MASK_PROTO_IGMP)
+#define PIM_IF_FLAG_SET_PROTO_IGMP(flags) \
+ ((flags) |= PIM_IF_FLAG_MASK_PROTO_IGMP)
+#define PIM_IF_FLAG_UNSET_PROTO_IGMP(flags) \
+ ((flags) &= ~PIM_IF_FLAG_MASK_PROTO_IGMP)
+/*
Per-interface (S,G) state
*/
struct pim_ifchannel {
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index d63269da9f..ffd872ce03 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -1133,7 +1133,7 @@ static int group_retransmit_sources(struct igmp_group *group,
group_str, sizeof(group_str));
zlog_warn(
"%s: group %s on %s: s_flag=1 unable to fit %d sources into buf_size=%zu (max_sources=%d)",
- __PRETTY_FUNCTION__, group_str,
+ __func__, group_str,
igmp->interface->name,
num_sources_tosend1, sizeof(query_buf1),
query_buf1_max_sources);
@@ -1177,9 +1177,9 @@ static int group_retransmit_sources(struct igmp_group *group,
sizeof(group_str));
zlog_warn(
"%s: group %s on %s: s_flag=0 unable to fit %d sources into buf_size=%zu (max_sources=%d)",
- __PRETTY_FUNCTION__, group_str,
- igmp->interface->name, num_sources_tosend2,
- sizeof(query_buf2), query_buf2_max_sources);
+ __func__, group_str, igmp->interface->name,
+ num_sources_tosend2, sizeof(query_buf2),
+ query_buf2_max_sources);
} else {
/*
RFC3376: 4.1.12. IP Destination Addresses for Queries
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index 347b0fc284..2cda628a90 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -69,6 +69,8 @@ static void pim_instance_terminate(struct pim_instance *pim)
pim_msdp_exit(pim);
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->spt.plist);
+ XFREE(MTYPE_PIM_PLIST_NAME, pim->register_plist);
XFREE(MTYPE_PIM_PIM_INSTANCE, pim);
}
diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h
index 7b1fd2e172..48dc2d9530 100644
--- a/pimd/pim_instance.h
+++ b/pimd/pim_instance.h
@@ -135,6 +135,9 @@ struct pim_instance {
char *plist;
} spt;
+ /* The name of the register-accept prefix-list */
+ char *register_plist;
+
struct hash *rpf_hash;
void *ssm_info; /* per-vrf SSM configuration */
diff --git a/pimd/pim_join.c b/pimd/pim_join.c
index f2cd04e453..62bd2360c3 100644
--- a/pimd/pim_join.c
+++ b/pimd/pim_join.c
@@ -445,17 +445,15 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
if (rpf->source_nexthop.interface)
pim_ifp = rpf->source_nexthop.interface->info;
else {
- zlog_warn("%s: RPF interface is not present",
- __PRETTY_FUNCTION__);
+ zlog_warn("%s: RPF interface is not present", __func__);
return -1;
}
- on_trace(__PRETTY_FUNCTION__, rpf->source_nexthop.interface,
- rpf->rpf_addr.u.prefix4);
+ on_trace(__func__, rpf->source_nexthop.interface,
+ rpf->rpf_addr.u.prefix4);
if (!pim_ifp) {
- zlog_warn("%s: multicast not enabled on interface %s",
- __PRETTY_FUNCTION__,
+ zlog_warn("%s: multicast not enabled on interface %s", __func__,
rpf->source_nexthop.interface->name);
return -1;
}
@@ -466,7 +464,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
pim_inet4_dump("<dst?>", rpf->rpf_addr.u.prefix4,
dst_str, sizeof(dst_str));
zlog_debug("%s: upstream=%s is myself on interface %s",
- __PRETTY_FUNCTION__, dst_str,
+ __func__, dst_str,
rpf->source_nexthop.interface->name);
}
return 0;
@@ -515,7 +513,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
sizeof(grp_str));
zlog_debug(
"%s: sending (G)=%s to upstream=%s on interface %s",
- __PRETTY_FUNCTION__, grp_str, dst_str,
+ __func__, grp_str, dst_str,
rpf->source_nexthop.interface->name);
}
@@ -530,7 +528,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
rpf->source_nexthop.interface->name)) {
zlog_warn(
"%s: could not send PIM message on interface %s",
- __PRETTY_FUNCTION__,
+ __func__,
rpf->source_nexthop.interface->name);
}
@@ -571,8 +569,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"%s: interface %s num_joins %u num_prunes %u",
- __PRETTY_FUNCTION__,
- rpf->source_nexthop.interface->name,
+ __func__, rpf->source_nexthop.interface->name,
ntohs(grp->joins), ntohs(grp->prunes));
grp = (struct pim_jp_groups *)curr_ptr;
@@ -587,7 +584,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
rpf->source_nexthop.interface->name)) {
zlog_warn(
"%s: could not send PIM message on interface %s",
- __PRETTY_FUNCTION__,
+ __func__,
rpf->source_nexthop.interface->name);
}
@@ -606,8 +603,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
rpf->source_nexthop.interface->name)) {
zlog_warn(
"%s: could not send PIM message on interface %s",
- __PRETTY_FUNCTION__,
- rpf->source_nexthop.interface->name);
+ __func__, rpf->source_nexthop.interface->name);
}
}
return 0;
diff --git a/pimd/pim_jp_agg.c b/pimd/pim_jp_agg.c
index 2662c9eae6..5279a00855 100644
--- a/pimd/pim_jp_agg.c
+++ b/pimd/pim_jp_agg.c
@@ -239,8 +239,8 @@ void pim_jp_agg_upstream_verification(struct pim_upstream *up, bool ignore)
if (!up->rpf.source_nexthop.interface) {
if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: up %s RPF is not present",
- __PRETTY_FUNCTION__, up->sg_str);
+ zlog_debug("%s: up %s RPF is not present", __func__,
+ up->sg_str);
return;
}
diff --git a/pimd/pim_macro.c b/pimd/pim_macro.c
index ea3e1a244f..c6961d30c2 100644
--- a/pimd/pim_macro.c
+++ b/pimd/pim_macro.c
@@ -157,6 +157,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch)
int pim_macro_chisin_pim_include(const struct pim_ifchannel *ch)
{
struct pim_interface *pim_ifp = ch->interface->info;
+ bool mlag_active = false;
if (!pim_ifp) {
zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s",
@@ -172,9 +173,21 @@ int pim_macro_chisin_pim_include(const struct pim_ifchannel *ch)
if (ch->ifassert_winner.s_addr == pim_ifp->primary_address.s_addr)
return 1; /* true */
+ /*
+ * When we have a activeactive interface we need to signal
+ * that this interface is interesting to the upstream
+ * decision to JOIN *if* we are syncing over the interface
+ */
+ if (pim_ifp->activeactive) {
+ struct pim_upstream *up = ch->upstream;
+
+ if (PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags))
+ mlag_active = true;
+ }
+
return (
/* I_am_DR( I ) ? */
- PIM_I_am_DR(pim_ifp) &&
+ (PIM_I_am_DR(pim_ifp) || mlag_active) &&
/* lost_assert(S,G,I) == false ? */
(!pim_macro_ch_lost_assert(ch)));
}
diff --git a/pimd/pim_memory.c b/pimd/pim_memory.c
index 2bbab67e45..6bc8062c4b 100644
--- a/pimd/pim_memory.c
+++ b/pimd/pim_memory.c
@@ -51,5 +51,5 @@ DEFINE_MTYPE(PIMD, PIM_JP_AGG_SOURCE, "PIM JP AGG Source")
DEFINE_MTYPE(PIMD, PIM_PIM_INSTANCE, "PIM global state")
DEFINE_MTYPE(PIMD, PIM_NEXTHOP_CACHE, "PIM nexthop cache state")
DEFINE_MTYPE(PIMD, PIM_SSM_INFO, "PIM SSM configuration")
-DEFINE_MTYPE(PIMD, PIM_SPT_PLIST_NAME, "PIM SPT Prefix List Name")
+DEFINE_MTYPE(PIMD, PIM_PLIST_NAME, "PIM Prefix List Names")
DEFINE_MTYPE(PIMD, PIM_VXLAN_SG, "PIM VxLAN mroute cache")
diff --git a/pimd/pim_memory.h b/pimd/pim_memory.h
index e5ca57a15d..6beeb60075 100644
--- a/pimd/pim_memory.h
+++ b/pimd/pim_memory.h
@@ -50,7 +50,7 @@ DECLARE_MTYPE(PIM_JP_AGG_SOURCE)
DECLARE_MTYPE(PIM_PIM_INSTANCE)
DECLARE_MTYPE(PIM_NEXTHOP_CACHE)
DECLARE_MTYPE(PIM_SSM_INFO)
-DECLARE_MTYPE(PIM_SPT_PLIST_NAME);
+DECLARE_MTYPE(PIM_PLIST_NAME);
DECLARE_MTYPE(PIM_VXLAN_SG)
#endif /* _QUAGGA_PIM_MEMORY_H */
diff --git a/pimd/pim_mlag.c b/pimd/pim_mlag.c
index cbde45abb8..304e6ac6bc 100644
--- a/pimd/pim_mlag.c
+++ b/pimd/pim_mlag.c
@@ -32,6 +32,76 @@ extern struct zclient *zclient;
#define PIM_MLAG_METADATA_LEN 4
+/*********************ACtual Data processing *****************************/
+/* TBD: There can be duplicate updates to FIB***/
+#define PIM_MLAG_ADD_OIF_TO_OIL(ch, ch_oil) \
+ do { \
+ if (PIM_DEBUG_MLAG) \
+ zlog_debug( \
+ "%s: add Dual-active Interface to %s " \
+ "to oil:%s", \
+ __func__, ch->interface->name, ch->sg_str); \
+ pim_channel_add_oif(ch_oil, ch->interface, \
+ PIM_OIF_FLAG_PROTO_IGMP, __func__); \
+ } while (0)
+
+#define PIM_MLAG_DEL_OIF_TO_OIL(ch, ch_oil) \
+ do { \
+ if (PIM_DEBUG_MLAG) \
+ zlog_debug( \
+ "%s: del Dual-active Interface to %s " \
+ "to oil:%s", \
+ __func__, ch->interface->name, ch->sg_str); \
+ pim_channel_del_oif(ch_oil, ch->interface, \
+ PIM_OIF_FLAG_PROTO_IGMP, __func__); \
+ } while (0)
+
+
+static void pim_mlag_calculate_df_for_ifchannels(struct pim_upstream *up,
+ bool is_df)
+{
+ struct listnode *chnode;
+ struct listnode *chnextnode;
+ struct pim_ifchannel *ch;
+ struct pim_interface *pim_ifp = NULL;
+ struct channel_oil *ch_oil = NULL;
+
+ ch_oil = (up) ? up->channel_oil : NULL;
+
+ if (!ch_oil)
+ return;
+
+ if (PIM_DEBUG_MLAG)
+ zlog_debug("%s: Calculating DF for Dual active if-channel%s",
+ __func__, up->sg_str);
+
+ for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) {
+ pim_ifp = (ch->interface) ? ch->interface->info : NULL;
+ if (!pim_ifp || !PIM_I_am_DualActive(pim_ifp))
+ continue;
+
+ if (is_df)
+ PIM_MLAG_ADD_OIF_TO_OIL(ch, ch_oil);
+ else
+ PIM_MLAG_DEL_OIF_TO_OIL(ch, ch_oil);
+ }
+}
+
+static void pim_mlag_inherit_mlag_flags(struct pim_upstream *up, bool is_df)
+{
+ struct listnode *listnode;
+ struct pim_upstream *child;
+
+ for (ALL_LIST_ELEMENTS_RO(up->sources, listnode, child)) {
+ PIM_UPSTREAM_FLAG_SET_MLAG_PEER(child->flags);
+ if (is_df)
+ PIM_UPSTREAM_FLAG_UNSET_MLAG_NON_DF(child->flags);
+ else
+ PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(child->flags);
+ pim_mlag_calculate_df_for_ifchannels(child, is_df);
+ }
+}
+
/******************************* pim upstream sync **************************/
/* Update DF role for the upstream entry and return true on role change */
bool pim_mlag_up_df_role_update(struct pim_instance *pim,
@@ -59,6 +129,15 @@ bool pim_mlag_up_df_role_update(struct pim_instance *pim,
PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(up->flags);
+ /*
+ * This Upstream entry synced to peer Because of Dual-active
+ * Interface configuration
+ */
+ if (PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) {
+ pim_mlag_calculate_df_for_ifchannels(up, is_df);
+ pim_mlag_inherit_mlag_flags(up, is_df);
+ }
+
/* If the DF role has changed check if ipmr-lo needs to be
* muted/un-muted. Active-Active devices and vxlan termination
* devices (ipmr-lo) are suppressed on the non-DF.
@@ -91,7 +170,8 @@ static bool pim_mlag_up_df_role_elect(struct pim_instance *pim,
uint32_t local_cost;
bool rv;
- if (!pim_up_mlag_is_local(up))
+ if (!pim_up_mlag_is_local(up)
+ && !PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags))
return false;
/* We are yet to rx a status update from the local MLAG daemon so
@@ -210,17 +290,20 @@ static void pim_mlag_up_peer_add(struct mlag_mroute_add *msg)
* - if a local entry continues to exisy and has a MLAG OIF DF election
* is re-run (at the end of which the local entry will be the DF).
*/
-static void pim_mlag_up_peer_deref(struct pim_instance *pim,
- struct pim_upstream *up)
+static struct pim_upstream *pim_mlag_up_peer_deref(struct pim_instance *pim,
+ struct pim_upstream *up)
{
if (!PIM_UPSTREAM_FLAG_TEST_MLAG_PEER(up->flags))
- return;
+ return up;
PIM_UPSTREAM_FLAG_UNSET_MLAG_PEER(up->flags);
up = pim_upstream_del(pim, up, __func__);
if (up)
pim_mlag_up_df_role_elect(pim, up);
+
+ return up;
}
+
static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)
{
struct pim_upstream *up;
@@ -256,7 +339,7 @@ static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)
return;
}
- pim_mlag_up_peer_deref(pim, up);
+ (void)pim_mlag_up_peer_deref(pim, up);
}
/* When we lose connection to the local MLAG daemon we can drop all peer
@@ -300,26 +383,19 @@ static void pim_mlag_up_peer_del_all(void)
up = listnode_head(temp);
listnode_delete(temp, up);
- pim_mlag_up_peer_deref(pim, up);
+ up = pim_mlag_up_peer_deref(pim, up);
/*
* This is the deletion of the reference added
* above
*/
- pim_upstream_del(pim, up, __func__);
+ if (up)
+ pim_upstream_del(pim, up, __func__);
}
}
list_delete(&temp);
}
-static int pim_mlag_signal_zpthread(void)
-{
- /* XXX - This is a temporary stub; the MLAG thread code is planned for
- * a separate commit
- */
- return (0);
-}
-
/* Send upstream entry to the local MLAG daemon (which will subsequently
* send it to the peer MLAG switch).
*/
@@ -425,7 +501,8 @@ static void pim_mlag_up_local_replay(void)
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
pim = vrf->info;
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
- if (pim_up_mlag_is_local(up))
+ if (pim_up_mlag_is_local(up)
+ || PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags))
pim_mlag_up_local_add_send(pim, up);
}
}
@@ -446,7 +523,9 @@ static void pim_mlag_up_local_reeval(bool mlagd_send, const char *reason_code)
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
pim = vrf->info;
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
- if (!pim_up_mlag_is_local(up))
+ if (!pim_up_mlag_is_local(up)
+ && !PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(
+ up->flags))
continue;
/* if role changes re-send to peer */
if (pim_mlag_up_df_role_elect(pim, up) &&
@@ -690,8 +769,9 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len)
struct mlag_msg mlag_msg;
char buf[ZLOG_FILTER_LENGTH_MAX];
int rc = 0;
+ size_t length;
- rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg);
+ rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg, &length);
if (rc)
return (rc);
@@ -730,7 +810,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len)
case MLAG_MROUTE_ADD: {
struct mlag_mroute_add msg;
- rc = mlag_lib_decode_mroute_add(s, &msg);
+ rc = mlag_lib_decode_mroute_add(s, &msg, &length);
if (rc)
return (rc);
pim_mlag_process_mroute_add(msg);
@@ -738,7 +818,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len)
case MLAG_MROUTE_DEL: {
struct mlag_mroute_del msg;
- rc = mlag_lib_decode_mroute_del(s, &msg);
+ rc = mlag_lib_decode_mroute_del(s, &msg, &length);
if (rc)
return (rc);
pim_mlag_process_mroute_del(msg);
@@ -748,8 +828,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len)
int i;
for (i = 0; i < mlag_msg.msg_cnt; i++) {
-
- rc = mlag_lib_decode_mroute_add(s, &msg);
+ rc = mlag_lib_decode_mroute_add(s, &msg, &length);
if (rc)
return (rc);
pim_mlag_process_mroute_add(msg);
@@ -760,8 +839,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len)
int i;
for (i = 0; i < mlag_msg.msg_cnt; i++) {
-
- rc = mlag_lib_decode_mroute_del(s, &msg);
+ rc = mlag_lib_decode_mroute_del(s, &msg, &length);
if (rc)
return (rc);
pim_mlag_process_mroute_del(msg);
@@ -780,6 +858,12 @@ int pim_zebra_mlag_process_up(void)
if (PIM_DEBUG_MLAG)
zlog_debug("%s: Received Process-Up from Mlag", __func__);
+ /*
+ * Incase of local MLAG restart, PIM needs to replay all the data
+ * since MLAG is empty.
+ */
+ router->connected_to_mlag = true;
+ router->mlag_flags |= PIM_MLAGF_LOCAL_CONN_UP;
return 0;
}
@@ -872,7 +956,7 @@ static int pim_mlag_deregister_handler(struct thread *thread)
void pim_mlag_deregister(void)
{
/* if somebody still interested in the MLAG channel skip de-reg */
- if (router->pim_mlag_intf_cnt)
+ if (router->pim_mlag_intf_cnt || pim_vxlan_do_mlag_reg())
return;
/* not registered; nothing do */
@@ -890,10 +974,6 @@ void pim_if_configure_mlag_dualactive(struct pim_interface *pim_ifp)
if (!pim_ifp || !pim_ifp->pim || pim_ifp->activeactive == true)
return;
- if (PIM_DEBUG_MLAG)
- zlog_debug("%s: Configuring active-active on Interface: %s",
- __func__, "NULL");
-
pim_ifp->activeactive = true;
if (pim_ifp->pim)
pim_ifp->pim->inst_mlag_intf_cnt++;
@@ -919,10 +999,6 @@ void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp)
if (!pim_ifp || !pim_ifp->pim || pim_ifp->activeactive == false)
return;
- if (PIM_DEBUG_MLAG)
- zlog_debug("%s: UnConfiguring active-active on Interface: %s",
- __func__, "NULL");
-
pim_ifp->activeactive = false;
pim_ifp->pim->inst_mlag_intf_cnt--;
@@ -939,6 +1015,7 @@ void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp)
* De-register to Zebra
*/
pim_mlag_deregister();
+ pim_mlag_param_reset();
}
}
diff --git a/pimd/pim_mlag.h b/pimd/pim_mlag.h
index dab29cc9a2..eb316695f7 100644
--- a/pimd/pim_mlag.h
+++ b/pimd/pim_mlag.h
@@ -32,15 +32,22 @@ extern void pim_instance_mlag_init(struct pim_instance *pim);
extern void pim_instance_mlag_terminate(struct pim_instance *pim);
extern void pim_if_configure_mlag_dualactive(struct pim_interface *pim_ifp);
extern void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp);
-extern void pim_mlag_register(void);
-extern void pim_mlag_deregister(void);
extern int pim_zebra_mlag_process_up(void);
extern int pim_zebra_mlag_process_down(void);
extern int pim_zebra_mlag_handle_msg(struct stream *msg, int len);
+
+/* pm_zpthread.c */
+extern int pim_mlag_signal_zpthread(void);
+extern void pim_zpthread_init(void);
+extern void pim_zpthread_terminate(void);
+
+extern void pim_mlag_register(void);
+extern void pim_mlag_deregister(void);
extern void pim_mlag_up_local_add(struct pim_instance *pim,
- struct pim_upstream *upstream);
+ struct pim_upstream *upstream);
extern void pim_mlag_up_local_del(struct pim_instance *pim,
- struct pim_upstream *upstream);
+ struct pim_upstream *upstream);
extern bool pim_mlag_up_df_role_update(struct pim_instance *pim,
- struct pim_upstream *up, bool is_df, const char *reason);
+ struct pim_upstream *up, bool is_df,
+ const char *reason);
#endif
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 36b066735c..5ce7863611 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -65,10 +65,9 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
&data, data_len);
if (err) {
zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
- __FILE__, __PRETTY_FUNCTION__,
- pim->mroute_socket, data, errno,
- safe_strerror(errno));
+ "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ data, errno, safe_strerror(errno));
return -1;
}
@@ -86,11 +85,10 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
opt, &data, data_len);
if (err) {
zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
- __FILE__, __PRETTY_FUNCTION__,
- pim->mroute_socket,
- enable ? "MRT_INIT" : "MRT_DONE", data, errno,
- safe_strerror(errno));
+ "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ enable ? "MRT_INIT" : "MRT_DONE", data, errno,
+ safe_strerror(errno));
return -1;
}
}
@@ -445,6 +443,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
{
const struct ip *ip_hdr = (const struct ip *)buf;
struct pim_interface *pim_ifp;
+ struct pim_instance *pim;
struct pim_ifchannel *ch;
struct pim_upstream *up;
struct prefix_sg star_g;
@@ -467,16 +466,18 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
star_g = sg;
star_g.src.s_addr = INADDR_ANY;
-#if 0
- ch = pim_ifchannel_find(ifp, &star_g);
- if (ch)
- {
- if (PIM_DEBUG_MROUTE)
- zlog_debug ("WRVIFWHOLE (*,G)=%s found ifchannel on interface %s",
- pim_str_sg_dump (&star_g), ifp->name);
- return -1;
- }
-#endif
+
+ pim = pim_ifp->pim;
+ /*
+ * If the incoming interface is the pimreg, then
+ * we know the callback is associated with a pim register
+ * packet and there is nothing to do here as that
+ * normal pim processing will see the packet and allow
+ * us to do the right thing.
+ */
+ if (ifp == pim->regiface) {
+ return 0;
+ }
up = pim_upstream_find(pim_ifp->pim, &sg);
if (up) {
@@ -504,8 +505,17 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
* the pimreg period, so I believe we can ignore this packet
*/
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
- // No if channel, but upstream we are at the RP.
- if (pim_nexthop_lookup(pim_ifp->pim, &source,
+ /*
+ * No if channel, but upstream we are at the RP.
+ *
+ * This could be a anycast RP too and we may
+ * not have received a register packet from
+ * the source here at all. So gracefully
+ * bow out of doing a nexthop lookup and
+ * setting the SPTBIT to true
+ */
+ if (up->upstream_register.s_addr != INADDR_ANY &&
+ pim_nexthop_lookup(pim_ifp->pim, &source,
up->upstream_register, 0)) {
pim_register_stop_send(source.interface, &sg,
pim_ifp->primary_address,
@@ -1007,8 +1017,10 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
}
- c_oil->installed = 1;
- c_oil->mroute_creation = pim_time_monotonic_sec();
+ if (!c_oil->installed) {
+ c_oil->installed = 1;
+ c_oil->mroute_creation = pim_time_monotonic_sec();
+ }
return 0;
}
diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c
index 50489ca88c..7620cd5792 100644
--- a/pimd/pim_msdp_socket.c
+++ b/pimd/pim_msdp_socket.c
@@ -162,14 +162,14 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
if (!ifp) {
flog_err(EC_LIB_INTERFACE,
"%s: Unable to lookup vrf interface: %s",
- __PRETTY_FUNCTION__, pim->vrf->name);
+ __func__, pim->vrf->name);
close(sock);
return -1;
}
if (pim_socket_bind(sock, ifp)) {
flog_err_sys(EC_LIB_SOCKET,
"%s: Unable to bind to socket: %s",
- __PRETTY_FUNCTION__, safe_strerror(errno));
+ __func__, safe_strerror(errno));
close(sock);
return -1;
}
diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c
index fba76d84dd..65b6405c81 100644
--- a/pimd/pim_msg.c
+++ b/pimd/pim_msg.c
@@ -123,7 +123,7 @@ size_t pim_msg_get_jp_group_size(struct list *sources)
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
"%s: Considering (%s) children for (S,G,rpt) prune",
- __PRETTY_FUNCTION__, up->sg_str);
+ __func__, up->sg_str);
for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {
if (!PIM_UPSTREAM_FLAG_TEST_USE_RPT(child->flags)) {
@@ -144,13 +144,12 @@ size_t pim_msg_get_jp_group_size(struct list *sources)
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
"%s: SPT Bit and RPF'(%s) != RPF'(S,G): Add Prune (%s,rpt) to compound message",
- __PRETTY_FUNCTION__,
- up->sg_str,
+ __func__, up->sg_str,
child->sg_str);
} else if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
"%s: SPT Bit and RPF'(%s) == RPF'(S,G): Not adding Prune for (%s,rpt)",
- __PRETTY_FUNCTION__, up->sg_str,
+ __func__, up->sg_str,
child->sg_str);
} else if (pim_upstream_empty_inherited_olist(child)) {
/* S is supposed to be forwarded along the RPT
@@ -163,14 +162,12 @@ size_t pim_msg_get_jp_group_size(struct list *sources)
child->flags);
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
- "%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message",
- __PRETTY_FUNCTION__,
- child->sg_str);
+ "%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message",
+ __func__, child->sg_str);
} else if (PIM_DEBUG_PIM_PACKETS)
zlog_debug(
- "%s: Do not add Prune %s to compound message %s",
- __PRETTY_FUNCTION__, child->sg_str,
- up->sg_str);
+ "%s: Do not add Prune %s to compound message %s",
+ __func__, child->sg_str, up->sg_str);
}
}
return size;
diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c
index ec40beec7f..ca7ca11402 100644
--- a/pimd/pim_neighbor.c
+++ b/pimd/pim_neighbor.c
@@ -53,8 +53,7 @@ static void dr_election_by_addr(struct interface *ifp)
pim_ifp->pim_dr_addr = pim_ifp->primary_address;
if (PIM_DEBUG_PIM_TRACE) {
- zlog_debug("%s: on interface %s", __PRETTY_FUNCTION__,
- ifp->name);
+ zlog_debug("%s: on interface %s", __func__, ifp->name);
}
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh)) {
@@ -79,14 +78,14 @@ static void dr_election_by_pri(struct interface *ifp)
dr_pri = pim_ifp->pim_dr_priority;
if (PIM_DEBUG_PIM_TRACE) {
- zlog_debug("%s: dr pri %u on interface %s", __PRETTY_FUNCTION__,
- dr_pri, ifp->name);
+ zlog_debug("%s: dr pri %u on interface %s", __func__, dr_pri,
+ ifp->name);
}
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh)) {
if (PIM_DEBUG_PIM_TRACE) {
zlog_info("%s: neigh pri %u addr %x if dr addr %x",
- __PRETTY_FUNCTION__, neigh->dr_priority,
+ __func__, neigh->dr_priority,
ntohl(neigh->source_addr.s_addr),
ntohl(pim_ifp->pim_dr_addr.s_addr));
}
@@ -389,7 +388,7 @@ static void delete_prefix_list(struct pim_neighbor *neigh)
sizeof(addr_str));
zlog_debug(
"%s: DUMP_PREFIX_LIST neigh=%x prefix_list=%x prefix=%x addr=%s [%d/%d]",
- __PRETTY_FUNCTION__, (unsigned)neigh,
+ __func__, (unsigned)neigh,
(unsigned)neigh->prefix_list, (unsigned)p,
addr_str, i, list_size);
++i;
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index 289f2a2eda..60b7c73d43 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -217,7 +217,7 @@ void pim_delete_tracked_nexthop(struct pim_instance *pim, struct prefix *addr,
if (PIM_DEBUG_PIM_NHT) {
char buf[PREFIX_STRLEN];
- prefix2str(addr, buf, sizeof buf);
+ prefix2str(addr, buf, sizeof(buf));
zlog_debug(
"%s: NHT %s(%s) rp_list count:%d upstream count:%ld",
__func__, buf, pim->vrf->name,
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index 0618308ba8..21febcc969 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -33,9 +33,6 @@
#include "pim_time.h"
#include "pim_vxlan.h"
-// struct list *pim_channel_oil_list = NULL;
-// struct hash *pim_channel_oil_hash = NULL;
-
static void pim_channel_update_mute(struct channel_oil *c_oil);
char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
@@ -174,7 +171,7 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
}
struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
- const char *name)
+ const char *name)
{
if (PIM_DEBUG_MROUTE) {
struct prefix_sg sg = {.src = c_oil->oil.mfcc_mcastgrp,
@@ -496,6 +493,23 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
}
}
+ if (PIM_DEBUG_MROUTE) {
+ char group_str[INET_ADDRSTRLEN];
+ char source_str[INET_ADDRSTRLEN];
+ pim_inet4_dump("<group?>",
+ channel_oil->oil.mfcc_mcastgrp,
+ group_str, sizeof(group_str));
+ pim_inet4_dump("<source?>",
+ channel_oil->oil.mfcc_origin, source_str,
+ sizeof(source_str));
+ zlog_debug(
+ "%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d added to 0x%x",
+ __func__, caller, source_str, group_str,
+ proto_mask, oif->name,
+ pim_ifp->mroute_vif_index,
+ channel_oil
+ ->oif_flags[pim_ifp->mroute_vif_index]);
+ }
return 0;
}
diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h
index 788ddaa16c..8a808afa73 100644
--- a/pimd/pim_oil.h
+++ b/pimd/pim_oil.h
@@ -130,7 +130,7 @@ void pim_channel_oil_change_iif(struct pim_instance *pim,
struct channel_oil *c_oil, int input_vif_index,
const char *name);
struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
- const char *name);
+ const char *name);
int pim_channel_add_oif(struct channel_oil *c_oil, struct interface *oif,
uint32_t proto_mask, const char *caller);
@@ -146,6 +146,6 @@ void pim_channel_update_oif_mute(struct channel_oil *c_oil,
void pim_channel_oil_upstream_deref(struct channel_oil *c_oil);
void pim_channel_del_inherited_oif(struct channel_oil *c_oil,
- struct interface *oif, const char *caller);
+ struct interface *oif, const char *caller);
#endif /* PIM_OIL_H */
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index 19baecb9c2..7b0af89993 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -324,14 +324,13 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
struct prefix_sg sg;
uint32_t *bits;
int i_am_rp = 0;
- struct pim_interface *pim_ifp = NULL;
-
- pim_ifp = ifp->info;
+ struct pim_interface *pim_ifp = ifp->info;
+ struct pim_instance *pim = pim_ifp->pim;
#define PIM_MSG_REGISTER_BIT_RESERVED_LEN 4
ip_hdr = (struct ip *)(tlv_buf + PIM_MSG_REGISTER_BIT_RESERVED_LEN);
- if (!pim_rp_check_is_my_ip_address(pim_ifp->pim, dest_addr)) {
+ if (!pim_rp_check_is_my_ip_address(pim, dest_addr)) {
if (PIM_DEBUG_PIM_REG) {
char dest[INET_ADDRSTRLEN];
@@ -375,7 +374,7 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
sg.src = ip_hdr->ip_src;
sg.grp = ip_hdr->ip_dst;
- i_am_rp = I_am_RP(pim_ifp->pim, sg.grp);
+ i_am_rp = I_am_RP(pim, sg.grp);
if (PIM_DEBUG_PIM_REG) {
char src_str[INET_ADDRSTRLEN];
@@ -387,9 +386,36 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
if (i_am_rp
&& (dest_addr.s_addr
- == ((RP(pim_ifp->pim, sg.grp))->rpf_addr.u.prefix4.s_addr))) {
+ == ((RP(pim, sg.grp))->rpf_addr.u.prefix4.s_addr))) {
sentRegisterStop = 0;
+ if (pim->register_plist) {
+ struct prefix_list *plist;
+ struct prefix src;
+
+ plist = prefix_list_lookup(AFI_IP, pim->register_plist);
+
+ src.family = AF_INET;
+ src.prefixlen = IPV4_MAX_PREFIXLEN;
+ src.u.prefix4 = sg.src;
+
+ if (prefix_list_apply(plist, &src) == PREFIX_DENY) {
+ pim_register_stop_send(ifp, &sg, dest_addr,
+ src_addr);
+ if (PIM_DEBUG_PIM_PACKETS) {
+ char src_str[INET_ADDRSTRLEN];
+
+ pim_inet4_dump("<src?>", src_addr,
+ src_str,
+ sizeof(src_str));
+ zlog_debug("%s: Sending register-stop to %s for %pSG4 due to prefix-list denial, dropping packet",
+ __func__, src_str, &sg);
+ }
+
+ return 0;
+ }
+ }
+
if (*bits & PIM_REGISTER_BORDER_BIT) {
struct in_addr pimbr = pim_br_get_pmbr(&sg);
if (PIM_DEBUG_PIM_PACKETS)
@@ -411,14 +437,13 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
}
}
- struct pim_upstream *upstream =
- pim_upstream_find(pim_ifp->pim, &sg);
+ struct pim_upstream *upstream = pim_upstream_find(pim, &sg);
/*
* If we don't have a place to send ignore the packet
*/
if (!upstream) {
upstream = pim_upstream_add(
- pim_ifp->pim, &sg, ifp,
+ pim, &sg, ifp,
PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, __func__,
NULL);
if (!upstream) {
@@ -452,9 +477,8 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
}
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE)
- || ((SwitchToSptDesiredOnRp(pim_ifp->pim, &sg))
- && pim_upstream_inherited_olist(pim_ifp->pim, upstream)
- == 0)) {
+ || ((SwitchToSptDesiredOnRp(pim, &sg))
+ && pim_upstream_inherited_olist(pim, upstream) == 0)) {
pim_register_stop_send(ifp, &sg, dest_addr, src_addr);
sentRegisterStop = 1;
} else {
@@ -463,15 +487,13 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
upstream->sptbit);
}
if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE)
- || (SwitchToSptDesiredOnRp(pim_ifp->pim, &sg))) {
+ || (SwitchToSptDesiredOnRp(pim, &sg))) {
if (sentRegisterStop) {
pim_upstream_keep_alive_timer_start(
- upstream,
- pim_ifp->pim->rp_keep_alive_time);
+ upstream, pim->rp_keep_alive_time);
} else {
pim_upstream_keep_alive_timer_start(
- upstream,
- pim_ifp->pim->keep_alive_time);
+ upstream, pim->keep_alive_time);
}
}
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 55b7db6a5c..355aa07048 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -240,7 +240,7 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
flog_err(
EC_LIB_DEVELOPMENT,
"%s: BUG We should have found default group information\n",
- __PRETTY_FUNCTION__);
+ __func__);
return best;
}
@@ -248,13 +248,14 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
if (PIM_DEBUG_PIM_TRACE) {
char buf[PREFIX_STRLEN];
- route_unlock_node(rn);
zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", rn,
rp_info,
prefix2str(&rp_info->group, buf, sizeof(buf)),
rn->lock);
}
+ route_unlock_node(rn);
+
if (!best)
return rp_info;
@@ -550,7 +551,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
prefix2str(&rp_all->group, buf1, sizeof(buf1));
zlog_debug(
"%s: NHT Register rp_all addr %s grp %s ",
- __PRETTY_FUNCTION__, buf, buf1);
+ __func__, buf, buf1);
}
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
@@ -676,7 +677,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
prefix2str(&nht_p, buf, sizeof(buf));
prefix2str(&rp_info->group, buf1, sizeof(buf1));
zlog_debug("%s: NHT Register RP addr %s grp %s with Zebra ",
- __PRETTY_FUNCTION__, buf, buf1);
+ __func__, buf, buf1);
}
pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false, NULL);
if (!pim_ecmp_nexthop_lookup(pim, &rp_info->rp.source_nexthop, &nht_p,
@@ -1394,8 +1395,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
sizeof(str));
zlog_debug(
"%s: addr %s new nexthop addr %s interface %s",
- __PRETTY_FUNCTION__, str, str1,
- ifp1->name);
+ __func__, str, str1, ifp1->name);
}
}
}
diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c
index 177dab05ca..ae5781f0cc 100644
--- a/pimd/pim_sock.c
+++ b/pimd/pim_sock.c
@@ -69,8 +69,7 @@ void pim_socket_ip_hdr(int fd)
if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)))
zlog_err("%s: Could not turn on IP_HDRINCL option: %s",
- __PRETTY_FUNCTION__, safe_strerror(errno));
-
+ __func__, safe_strerror(errno));
}
}
diff --git a/pimd/pim_static.c b/pimd/pim_static.c
index 7b121c9136..91c9b5b933 100644
--- a/pimd/pim_static.c
+++ b/pimd/pim_static.c
@@ -79,7 +79,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
if (!iif_index || !oif_index || iif_index == -1 || oif_index == -1) {
zlog_warn(
"%s %s: Unable to add static route: Invalid interface index(iif=%d,oif=%d)",
- __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index);
+ __FILE__, __func__, iif_index, oif_index);
return -2;
}
@@ -88,7 +88,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
/* looped MFC entry */
zlog_warn(
"%s %s: Unable to add static route: Looped MFC entry(iif=%d,oif=%d)",
- __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index);
+ __FILE__, __func__, iif_index, oif_index);
return -4;
}
#endif
@@ -109,9 +109,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_warn(
"%s %s: Unable to add static route: Route already exists (iif=%d,oif=%d,group=%s,source=%s)",
- __FILE__, __PRETTY_FUNCTION__,
- iif_index, oif_index, gifaddr_str,
- sifaddr_str);
+ __FILE__, __func__, iif_index,
+ oif_index, gifaddr_str, sifaddr_str);
return -3;
}
@@ -138,9 +137,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
} else {
/* input interface changed */
s_route->iif = iif_index;
- pim_static_mroute_iif_update(&s_route->c_oil,
- iif_index,
- __PRETTY_FUNCTION__);
+ pim_static_mroute_iif_update(
+ &s_route->c_oil, iif_index, __func__);
#ifdef PIM_ENFORCE_LOOPFREE_MFC
/* check to make sure the new input was not an
@@ -179,7 +177,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
s_route->c_oil.pim = pim;
- if (pim_static_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__)) {
+ if (pim_static_mroute_add(&s_route->c_oil, __func__)) {
char gifaddr_str[INET_ADDRSTRLEN];
char sifaddr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<ifaddr?>", group, gifaddr_str,
@@ -188,8 +186,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_warn(
"%s %s: Unable to add static route(iif=%d,oif=%d,group=%s,source=%s)",
- __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index,
- gifaddr_str, sifaddr_str);
+ __FILE__, __func__, iif_index, oif_index, gifaddr_str,
+ sifaddr_str);
/* Need to put s_route back to the way it was */
if (original_s_route) {
@@ -223,7 +221,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_debug(
"%s: Static route added(iif=%d,oif=%d,group=%s,source=%s)",
- __PRETTY_FUNCTION__, iif_index, oif_index, gifaddr_str,
+ __func__, iif_index, oif_index, gifaddr_str,
sifaddr_str);
}
@@ -245,7 +243,7 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,
if (!iif_index || !oif_index) {
zlog_warn(
"%s %s: Unable to remove static route: Invalid interface index(iif=%d,oif=%d)",
- __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index);
+ __FILE__, __func__, iif_index, oif_index);
return -2;
}
@@ -262,10 +260,9 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,
* route, otherwise set the route with the new outputs
*/
if (s_route->c_oil.oil_ref_count <= 0
- ? pim_mroute_del(&s_route->c_oil,
- __PRETTY_FUNCTION__)
+ ? pim_mroute_del(&s_route->c_oil, __func__)
: pim_static_mroute_add(&s_route->c_oil,
- __PRETTY_FUNCTION__)) {
+ __func__)) {
char gifaddr_str[INET_ADDRSTRLEN];
char sifaddr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<ifaddr?>", group, gifaddr_str,
@@ -274,9 +271,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_warn(
"%s %s: Unable to remove static route(iif=%d,oif=%d,group=%s,source=%s)",
- __FILE__, __PRETTY_FUNCTION__,
- iif_index, oif_index, gifaddr_str,
- sifaddr_str);
+ __FILE__, __func__, iif_index,
+ oif_index, gifaddr_str, sifaddr_str);
s_route->oif_ttls[oif_index] = 1;
s_route->c_oil.oil.mfcc_ttls[oif_index] = 1;
@@ -301,8 +297,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_debug(
"%s: Static route removed(iif=%d,oif=%d,group=%s,source=%s)",
- __PRETTY_FUNCTION__, iif_index,
- oif_index, gifaddr_str, sifaddr_str);
+ __func__, iif_index, oif_index,
+ gifaddr_str, sifaddr_str);
}
break;
@@ -318,8 +314,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,
sizeof(sifaddr_str));
zlog_warn(
"%s %s: Unable to remove static route: Route does not exist(iif=%d,oif=%d,group=%s,source=%s)",
- __FILE__, __PRETTY_FUNCTION__, iif_index, oif_index,
- gifaddr_str, sifaddr_str);
+ __FILE__, __func__, iif_index, oif_index, gifaddr_str,
+ sifaddr_str);
return -3;
}
diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c
index 7b27211edc..5a751ac929 100644
--- a/pimd/pim_tlv.c
+++ b/pimd/pim_tlv.c
@@ -143,7 +143,7 @@ int pim_encode_addr_ucast(uint8_t *buf, struct prefix *p)
}
}
-#define group_ipv4_encoding_len (4 + sizeof (struct in_addr))
+#define group_ipv4_encoding_len (4 + sizeof(struct in_addr))
/*
* Encoded-Group addresses take the following format:
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index ef65f097ad..07f8315a19 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -57,6 +57,7 @@
static void join_timer_stop(struct pim_upstream *up);
static void
pim_upstream_update_assert_tracking_desired(struct pim_upstream *up);
+static bool pim_upstream_sg_running_proc(struct pim_upstream *up);
/*
* A (*,G) or a (*,*) is going away
@@ -141,6 +142,18 @@ static struct pim_upstream *pim_upstream_find_parent(struct pim_instance *pim,
if (up)
listnode_add(up->sources, child);
+ /*
+ * In case parent is MLAG entry copy the data to child
+ */
+ if (up && PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) {
+ PIM_UPSTREAM_FLAG_SET_MLAG_INTERFACE(child->flags);
+ if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags))
+ PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(child->flags);
+ else
+ PIM_UPSTREAM_FLAG_UNSET_MLAG_NON_DF(
+ child->flags);
+ }
+
return up;
}
@@ -178,7 +191,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"%s(%s): Delete %s[%s] ref count: %d , flags: %d c_oil ref count %d (Pre decrement)",
- __PRETTY_FUNCTION__, name, up->sg_str, pim->vrf->name,
+ __func__, name, up->sg_str, pim->vrf->name,
up->ref_count, up->flags,
up->channel_oil->oil_ref_count);
@@ -221,7 +234,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
notify_msdp = true;
}
- pim_mroute_del(up->channel_oil, __PRETTY_FUNCTION__);
+ pim_mroute_del(up->channel_oil, __func__);
upstream_channel_oil_detach(up);
for (ALL_LIST_ELEMENTS(up->ifchannels, node, nnode, ch))
@@ -256,8 +269,9 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
if (PIM_DEBUG_PIM_TRACE) {
char buf[PREFIX2STR_BUFFER];
prefix2str(&nht_p, buf, sizeof(buf));
- zlog_debug("%s: Deregister upstream %s addr %s with Zebra NHT",
- __PRETTY_FUNCTION__, up->sg_str, buf);
+ zlog_debug(
+ "%s: Deregister upstream %s addr %s with Zebra NHT",
+ __func__, up->sg_str, buf);
}
pim_delete_tracked_nexthop(pim, &nht_p, up, NULL, false);
}
@@ -852,9 +866,23 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,
up->ifchannels = list_new();
up->ifchannels->cmp = (int (*)(void *, void *))pim_ifchannel_compare;
- if (up->sg.src.s_addr != INADDR_ANY)
+ if (up->sg.src.s_addr != INADDR_ANY) {
wheel_add_item(pim->upstream_sg_wheel, up);
+ /* Inherit the DF role from the parent (*, G) entry for
+ * VxLAN BUM groups
+ */
+ if (up->parent
+ && PIM_UPSTREAM_FLAG_TEST_MLAG_VXLAN(up->parent->flags)
+ && PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->parent->flags)) {
+ PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(up->flags);
+ if (PIM_DEBUG_VXLAN)
+ zlog_debug(
+ "upstream %s inherited mlag non-df flag from parent",
+ up->sg_str);
+ }
+ }
+
if (PIM_UPSTREAM_FLAG_TEST_STATIC_IIF(up->flags)
|| PIM_UPSTREAM_FLAG_TEST_SRC_NOCACHE(up->flags)) {
pim_upstream_fill_static_iif(up, incoming);
@@ -884,24 +912,12 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,
}
}
- /* If (S, G) inherit the MLAG_VXLAN from the parent
- * (*, G) entry.
- */
- if ((up->sg.src.s_addr != INADDR_ANY) &&
- up->parent &&
- PIM_UPSTREAM_FLAG_TEST_MLAG_VXLAN(up->parent->flags) &&
- !PIM_UPSTREAM_FLAG_TEST_SRC_VXLAN_ORIG(up->flags)) {
- PIM_UPSTREAM_FLAG_SET_MLAG_VXLAN(up->flags);
- if (PIM_DEBUG_VXLAN)
- zlog_debug("upstream %s inherited mlag vxlan flag from parent",
- up->sg_str);
- }
-
/* send the entry to the MLAG peer */
/* XXX - duplicate send is possible here if pim_rpf_update
* successfully resolved the nexthop
*/
- if (pim_up_mlag_is_local(up))
+ if (pim_up_mlag_is_local(up)
+ || PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags))
pim_mlag_up_local_add(pim, up);
if (PIM_DEBUG_PIM_TRACE) {
@@ -916,7 +932,8 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,
uint32_t pim_up_mlag_local_cost(struct pim_upstream *up)
{
- if (!(pim_up_mlag_is_local(up)))
+ if (!(pim_up_mlag_is_local(up))
+ && !(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE))
return router->infinite_assert_metric.route_metric;
if ((up->rpf.source_nexthop.interface ==
@@ -1437,6 +1454,11 @@ static int pim_upstream_keep_alive_timer(struct thread *t)
up = THREAD_ARG(t);
+ /* pull the stats and re-check */
+ if (pim_upstream_sg_running_proc(up))
+ /* kat was restarted because of new activity */
+ return 0;
+
pim_upstream_keep_alive_timer_proc(up);
return 0;
}
@@ -1750,6 +1772,7 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
up->sg_str);
FOR_ALL_INTERFACES (pim->vrf, ifp) {
+ struct pim_interface *pim_ifp;
if (!ifp->info)
continue;
@@ -1763,12 +1786,24 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim,
if (!ch && !starch)
continue;
+ pim_ifp = ifp->info;
+ if (PIM_I_am_DualActive(pim_ifp)
+ && PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)
+ && (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags)
+ || !PIM_UPSTREAM_FLAG_TEST_MLAG_PEER(up->flags)))
+ continue;
if (pim_upstream_evaluate_join_desired_interface(up, ch,
starch)) {
- int flag = PIM_OIF_FLAG_PROTO_PIM;
+ int flag = 0;
if (!ch)
flag = PIM_OIF_FLAG_PROTO_STAR;
+ else {
+ if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
+ flag = PIM_OIF_FLAG_PROTO_IGMP;
+ if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags))
+ flag |= PIM_OIF_FLAG_PROTO_PIM;
+ }
pim_channel_add_oif(up->channel_oil, ifp, flag,
__func__);
@@ -1942,39 +1977,14 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up)
return false;
}
-/*
- * Code to check and see if we've received packets on a S,G mroute
- * and if so to set the SPT bit appropriately
- */
-static void pim_upstream_sg_running(void *arg)
+static bool pim_upstream_sg_running_proc(struct pim_upstream *up)
{
- struct pim_upstream *up = (struct pim_upstream *)arg;
- struct pim_instance *pim = up->channel_oil->pim;
+ bool rv = false;
+ struct pim_instance *pim = up->pim;
- // No packet can have arrived here if this is the case
- if (!up->channel_oil->installed) {
- if (PIM_DEBUG_PIM_TRACE)
- zlog_debug("%s: %s%s is not installed in mroute",
- __func__, up->sg_str, pim->vrf->name);
- return;
- }
+ if (!up->channel_oil->installed)
+ return rv;
- /*
- * This is a bit of a hack
- * We've noted that we should rescan but
- * we've missed the window for doing so in
- * pim_zebra.c for some reason. I am
- * only doing this at this point in time
- * to get us up and working for the moment
- */
- if (up->channel_oil->oil_inherited_rescan) {
- if (PIM_DEBUG_PIM_TRACE)
- zlog_debug(
- "%s: Handling unscanned inherited_olist for %s[%s]",
- __func__, up->sg_str, pim->vrf->name);
- pim_upstream_inherited_olist_decide(pim, up);
- up->channel_oil->oil_inherited_rescan = 0;
- }
pim_mroute_update_counters(up->channel_oil);
// Have we seen packets?
@@ -1988,7 +1998,7 @@ static void pim_upstream_sg_running(void *arg)
up->channel_oil->cc.pktcnt,
up->channel_oil->cc.lastused / 100);
}
- return;
+ return rv;
}
if (pim_upstream_kat_start_ok(up)) {
@@ -2006,14 +2016,55 @@ static void pim_upstream_sg_running(void *arg)
pim_upstream_fhr_kat_start(up);
}
pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time);
- } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags))
+ rv = true;
+ } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) {
pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time);
+ rv = true;
+ }
if ((up->sptbit != PIM_UPSTREAM_SPTBIT_TRUE) &&
(up->rpf.source_nexthop.interface)) {
pim_upstream_set_sptbit(up, up->rpf.source_nexthop.interface);
}
- return;
+
+ return rv;
+}
+
+/*
+ * Code to check and see if we've received packets on a S,G mroute
+ * and if so to set the SPT bit appropriately
+ */
+static void pim_upstream_sg_running(void *arg)
+{
+ struct pim_upstream *up = (struct pim_upstream *)arg;
+ struct pim_instance *pim = up->channel_oil->pim;
+
+ // No packet can have arrived here if this is the case
+ if (!up->channel_oil->installed) {
+ if (PIM_DEBUG_TRACE)
+ zlog_debug("%s: %s%s is not installed in mroute",
+ __func__, up->sg_str, pim->vrf->name);
+ return;
+ }
+
+ /*
+ * This is a bit of a hack
+ * We've noted that we should rescan but
+ * we've missed the window for doing so in
+ * pim_zebra.c for some reason. I am
+ * only doing this at this point in time
+ * to get us up and working for the moment
+ */
+ if (up->channel_oil->oil_inherited_rescan) {
+ if (PIM_DEBUG_TRACE)
+ zlog_debug(
+ "%s: Handling unscanned inherited_olist for %s[%s]",
+ __func__, up->sg_str, pim->vrf->name);
+ pim_upstream_inherited_olist_decide(pim, up);
+ up->channel_oil->oil_inherited_rescan = 0;
+ }
+
+ pim_upstream_sg_running_proc(up);
}
void pim_upstream_add_lhr_star_pimreg(struct pim_instance *pim)
diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h
index 4d693b8b64..ca693ee73f 100644
--- a/pimd/pim_upstream.h
+++ b/pimd/pim_upstream.h
@@ -237,6 +237,8 @@ struct pim_upstream {
struct channel_oil *channel_oil;
struct list *sources;
struct list *ifchannels;
+ /* Counter for Dual active ifchannels*/
+ uint32_t dualactive_ifchannel_count;
enum pim_upstream_state join_state;
enum pim_reg_state reg_state;
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index b5a5089ae7..72540903be 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -117,6 +117,11 @@ int pim_debug_config_write(struct vty *vty)
++writes;
}
+ if (PIM_DEBUG_MLAG) {
+ vty_out(vty, "debug pim mlag\n");
+ ++writes;
+ }
+
if (PIM_DEBUG_BSM) {
vty_out(vty, "debug pim bsm\n");
++writes;
@@ -211,6 +216,11 @@ int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
ssm->plist_name);
++writes;
}
+ if (pim->register_plist) {
+ vty_out(vty, "%sip pim register-accept-list %s\n", spaces,
+ pim->register_plist);
+ ++writes;
+ }
if (pim->spt.switchover == PIM_SPT_INFINITY) {
if (pim->spt.plist)
vty_out(vty,
diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c
index 93e2f00f90..569b04d278 100644
--- a/pimd/pim_vxlan.c
+++ b/pimd/pim_vxlan.c
@@ -85,8 +85,16 @@ static void pim_vxlan_do_reg_work(void)
if (PIM_DEBUG_VXLAN)
zlog_debug("vxlan SG %s periodic NULL register",
vxlan_sg->sg_str);
- pim_null_register_send(vxlan_sg->up);
- ++work_cnt;
+
+ /*
+ * If we are on the work queue *and* the rpf
+ * has been lost on the vxlan_sg->up let's
+ * make sure that we don't send it.
+ */
+ if (vxlan_sg->up->rpf.source_nexthop.interface) {
+ pim_null_register_send(vxlan_sg->up);
+ ++work_cnt;
+ }
}
if (work_cnt > vxlan_info.max_work_cnt) {
@@ -217,6 +225,7 @@ static void pim_vxlan_orig_mr_up_del(struct pim_vxlan_sg *vxlan_sg)
vxlan_sg->sg_str);
vxlan_sg->up = NULL;
+
if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG) {
/* clear out all the vxlan properties */
up->flags &= ~(PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG |
@@ -284,6 +293,7 @@ static void pim_vxlan_orig_mr_up_iif_update(struct pim_vxlan_sg *vxlan_sg)
static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg)
{
struct pim_upstream *up;
+ struct pim_interface *term_ifp;
int flags = 0;
struct prefix nht_p;
struct pim_instance *pim = vxlan_sg->pim;
@@ -345,6 +355,11 @@ static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg)
pim_upstream_update_use_rpt(up, false /*update_mroute*/);
pim_upstream_ref(up, flags, __func__);
vxlan_sg->up = up;
+ term_ifp = pim_vxlan_get_term_ifp(pim);
+ /* mute termination device on origination mroutes */
+ if (term_ifp)
+ pim_channel_update_oif_mute(up->channel_oil,
+ term_ifp);
pim_vxlan_orig_mr_up_iif_update(vxlan_sg);
/* mute pimreg on origination mroutes */
if (pim->regiface)
@@ -748,14 +763,8 @@ struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim,
return vxlan_sg;
}
-void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg)
+static void pim_vxlan_sg_del_item(struct pim_vxlan_sg *vxlan_sg)
{
- struct pim_vxlan_sg *vxlan_sg;
-
- vxlan_sg = pim_vxlan_sg_find(pim, sg);
- if (!vxlan_sg)
- return;
-
vxlan_sg->flags |= PIM_VXLAN_SGF_DEL_IN_PROG;
pim_vxlan_del_work(vxlan_sg);
@@ -765,14 +774,24 @@ void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg)
else
pim_vxlan_term_mr_del(vxlan_sg);
- hash_release(vxlan_sg->pim->vxlan.sg_hash, vxlan_sg);
-
if (PIM_DEBUG_VXLAN)
zlog_debug("vxlan SG %s free", vxlan_sg->sg_str);
XFREE(MTYPE_PIM_VXLAN_SG, vxlan_sg);
}
+void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg)
+{
+ struct pim_vxlan_sg *vxlan_sg;
+
+ vxlan_sg = pim_vxlan_sg_find(pim, sg);
+ if (!vxlan_sg)
+ return;
+
+ pim_vxlan_sg_del_item(vxlan_sg);
+ hash_release(pim->vxlan.sg_hash, vxlan_sg);
+}
+
/******************************* MLAG handling *******************************/
bool pim_vxlan_do_mlag_reg(void)
{
@@ -1147,8 +1166,14 @@ void pim_vxlan_init(struct pim_instance *pim)
void pim_vxlan_exit(struct pim_instance *pim)
{
if (pim->vxlan.sg_hash) {
- hash_clean(pim->vxlan.sg_hash, NULL);
+ hash_clean(pim->vxlan.sg_hash,
+ (void (*)(void *))pim_vxlan_sg_del_item);
hash_free(pim->vxlan.sg_hash);
pim->vxlan.sg_hash = NULL;
}
}
+
+void pim_vxlan_terminate(void)
+{
+ pim_vxlan_work_timer_setup(false);
+}
diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h
index 198d1c3281..18f1b74175 100644
--- a/pimd/pim_vxlan.h
+++ b/pimd/pim_vxlan.h
@@ -148,4 +148,6 @@ extern bool pim_vxlan_do_mlag_reg(void);
extern void pim_vxlan_inherit_mlag_flags(struct pim_instance *pim,
struct pim_upstream *up, bool inherit);
+/* Shutdown of PIM stop the thread */
+extern void pim_vxlan_terminate(void);
#endif /* PIM_VXLAN_H */
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index 13d6a2eea8..8355c2099d 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -89,8 +89,8 @@ static void dump_if_address(struct interface *ifp)
struct connected *ifc;
struct listnode *node;
- zlog_debug("%s %s: interface %s addresses:", __FILE__,
- __PRETTY_FUNCTION__, ifp->name);
+ zlog_debug("%s %s: interface %s addresses:", __FILE__, __func__,
+ ifp->name);
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
struct prefix *p = ifc->address;
@@ -99,8 +99,7 @@ static void dump_if_address(struct interface *ifp)
continue;
zlog_debug("%s %s: interface %s address %s %s", __FILE__,
- __PRETTY_FUNCTION__, ifp->name,
- inet_ntoa(p->u.prefix4),
+ __func__, ifp->name, inet_ntoa(p->u.prefix4),
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
? "secondary"
: "primary");
@@ -836,7 +835,7 @@ void igmp_source_forward_stop(struct igmp_source *source)
void pim_forward_start(struct pim_ifchannel *ch)
{
struct pim_upstream *up = ch->upstream;
- uint32_t mask = PIM_OIF_FLAG_PROTO_PIM;
+ uint32_t mask = 0;
if (PIM_DEBUG_PIM_TRACE) {
char source_str[INET_ADDRSTRLEN];
@@ -854,9 +853,12 @@ void pim_forward_start(struct pim_ifchannel *ch)
inet_ntoa(up->upstream_addr));
}
- if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
+ if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
mask = PIM_OIF_FLAG_PROTO_IGMP;
+ if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags))
+ mask |= PIM_OIF_FLAG_PROTO_PIM;
+
pim_channel_add_oif(up->channel_oil, ch->interface,
mask, __func__);
}
diff --git a/pimd/pim_zpthread.c b/pimd/pim_zpthread.c
new file mode 100644
index 0000000000..518b024749
--- /dev/null
+++ b/pimd/pim_zpthread.c
@@ -0,0 +1,225 @@
+/*
+ * PIM for Quagga
+ * Copyright (C) 2008 Everton da Silva Marques
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <zebra.h>
+#include <lib/log.h>
+#include <lib/lib_errors.h>
+
+#include "pimd.h"
+#include "pim_mlag.h"
+#include "pim_zebra.h"
+
+extern struct zclient *zclient;
+
+#define PIM_MLAG_POST_LIMIT 100
+
+int32_t mlag_bulk_cnt;
+
+static void pim_mlag_zebra_fill_header(enum mlag_msg_type msg_type)
+{
+ uint32_t fill_msg_type = msg_type;
+ uint16_t data_len;
+ uint16_t msg_cnt = 1;
+
+ if (msg_type == MLAG_MSG_NONE)
+ return;
+
+ switch (msg_type) {
+ case MLAG_REGISTER:
+ case MLAG_DEREGISTER:
+ data_len = sizeof(struct mlag_msg);
+ break;
+ case MLAG_MROUTE_ADD:
+ data_len = sizeof(struct mlag_mroute_add);
+ fill_msg_type = MLAG_MROUTE_ADD_BULK;
+ break;
+ case MLAG_MROUTE_DEL:
+ data_len = sizeof(struct mlag_mroute_del);
+ fill_msg_type = MLAG_MROUTE_DEL_BULK;
+ break;
+ default:
+ data_len = 0;
+ break;
+ }
+
+ stream_reset(router->mlag_stream);
+ /* ADD Hedaer */
+ stream_putl(router->mlag_stream, fill_msg_type);
+ /*
+ * In case of Bulk actual size & msg_cnt will be updated
+ * just before writing onto zebra
+ */
+ stream_putw(router->mlag_stream, data_len);
+ stream_putw(router->mlag_stream, msg_cnt);
+
+ if (PIM_DEBUG_MLAG)
+ zlog_debug(":%s: msg_type: %d/%d len %d",
+ __func__, msg_type, fill_msg_type, data_len);
+}
+
+static void pim_mlag_zebra_flush_buffer(void)
+{
+ uint32_t msg_type;
+
+ /* Stream had bulk messages update the Hedaer */
+ if (mlag_bulk_cnt > 1) {
+ /*
+ * No need to reset the pointer, below api reads from data[0]
+ */
+ STREAM_GETL(router->mlag_stream, msg_type);
+ if (msg_type == MLAG_MROUTE_ADD_BULK) {
+ stream_putw_at(
+ router->mlag_stream, 4,
+ (mlag_bulk_cnt * sizeof(struct mlag_mroute_add)));
+ stream_putw_at(router->mlag_stream, 6, mlag_bulk_cnt);
+ } else if (msg_type == MLAG_MROUTE_DEL_BULK) {
+ stream_putw_at(
+ router->mlag_stream, 4,
+ (mlag_bulk_cnt * sizeof(struct mlag_mroute_del)));
+ stream_putw_at(router->mlag_stream, 6, mlag_bulk_cnt);
+ } else {
+ flog_err(EC_LIB_ZAPI_ENCODE,
+ "unknown bulk message type %d bulk_count %d",
+ msg_type, mlag_bulk_cnt);
+ stream_reset(router->mlag_stream);
+ mlag_bulk_cnt = 0;
+ return;
+ }
+ }
+
+ zclient_send_mlag_data(zclient, router->mlag_stream);
+stream_failure:
+ stream_reset(router->mlag_stream);
+ mlag_bulk_cnt = 0;
+}
+
+/*
+ * Only ROUTE add & Delete will be bulked.
+ * Buffer will be flushed, when
+ * 1) there were no messages in the queue
+ * 2) Curr_msg_type != prev_msg_type
+ */
+
+static void pim_mlag_zebra_check_for_buffer_flush(uint32_t curr_msg_type,
+ uint32_t prev_msg_type)
+{
+ /* First Message, keep bulking */
+ if (prev_msg_type == MLAG_MSG_NONE) {
+ mlag_bulk_cnt = 1;
+ return;
+ }
+
+ /*msg type is route add & delete, keep bulking */
+ if (curr_msg_type == prev_msg_type
+ && (curr_msg_type == MLAG_MROUTE_ADD
+ || curr_msg_type == MLAG_MROUTE_DEL)) {
+ mlag_bulk_cnt++;
+ return;
+ }
+
+ pim_mlag_zebra_flush_buffer();
+}
+
+/*
+ * Thsi thread reads the clients data from the Gloabl queue and encodes with
+ * protobuf and pass on to the MLAG socket.
+ */
+static int pim_mlag_zthread_handler(struct thread *event)
+{
+ struct stream *read_s;
+ uint32_t wr_count = 0;
+ uint32_t prev_msg_type = MLAG_MSG_NONE;
+ uint32_t curr_msg_type = MLAG_MSG_NONE;
+
+ router->zpthread_mlag_write = NULL;
+ wr_count = stream_fifo_count_safe(router->mlag_fifo);
+
+ if (PIM_DEBUG_MLAG)
+ zlog_debug(":%s: Processing MLAG write, %d messages in queue",
+ __func__, wr_count);
+
+ if (wr_count == 0)
+ return 0;
+
+ for (wr_count = 0; wr_count < PIM_MLAG_POST_LIMIT; wr_count++) {
+ /* FIFO is empty,wait for teh message to be add */
+ if (stream_fifo_count_safe(router->mlag_fifo) == 0)
+ break;
+
+ read_s = stream_fifo_pop_safe(router->mlag_fifo);
+ if (!read_s) {
+ zlog_debug(":%s: Got a NULL Messages, some thing wrong",
+ __func__);
+ break;
+ }
+ STREAM_GETL(read_s, curr_msg_type);
+ /*
+ * Check for Buffer Overflow,
+ * MLAG Can't process more than 'PIM_MLAG_BUF_LIMIT' bytes
+ */
+ if (router->mlag_stream->endp + read_s->endp + ZEBRA_HEADER_SIZE
+ > MLAG_BUF_LIMIT)
+ pim_mlag_zebra_flush_buffer();
+
+ pim_mlag_zebra_check_for_buffer_flush(curr_msg_type,
+ prev_msg_type);
+
+ /*
+ * First message to Buffer, fill the Header
+ */
+ if (router->mlag_stream->endp == 0)
+ pim_mlag_zebra_fill_header(curr_msg_type);
+
+ /*
+ * add the data now
+ */
+ stream_put(router->mlag_stream, read_s->data + read_s->getp,
+ read_s->endp - read_s->getp);
+
+ stream_free(read_s);
+ prev_msg_type = curr_msg_type;
+ }
+
+stream_failure:
+ /*
+ * we are here , because
+ * 1. Queue might be empty
+ * 2. we crossed the max Q Read limit
+ * In any acse flush the buffer towards zebra
+ */
+ pim_mlag_zebra_flush_buffer();
+
+ if (wr_count >= PIM_MLAG_POST_LIMIT)
+ pim_mlag_signal_zpthread();
+
+ return 0;
+}
+
+
+int pim_mlag_signal_zpthread(void)
+{
+ if (router->master) {
+ if (PIM_DEBUG_MLAG)
+ zlog_debug(":%s: Scheduling PIM MLAG write Thread",
+ __func__);
+ thread_add_event(router->master, pim_mlag_zthread_handler, NULL,
+ 0, &router->zpthread_mlag_write);
+ }
+ return (0);
+}
diff --git a/pimd/pimd.c b/pimd/pimd.c
index a2af66fdc7..5ccbac32f2 100644
--- a/pimd/pimd.c
+++ b/pimd/pimd.c
@@ -39,6 +39,7 @@
#include "pim_static.h"
#include "pim_rp.h"
#include "pim_ssm.h"
+#include "pim_vxlan.h"
#include "pim_zlookup.h"
#include "pim_zebra.h"
@@ -102,6 +103,8 @@ void pim_router_init(void)
router->packet_process = PIM_DEFAULT_PACKET_PROCESS;
router->register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
router->vrf_id = VRF_DEFAULT;
+ router->pim_mlag_intf_cnt = 0;
+ router->connected_to_mlag = false;
}
void pim_router_terminate(void)
@@ -133,6 +136,7 @@ void pim_terminate(void)
prefix_list_delete_hook(NULL);
prefix_list_reset();
+ pim_vxlan_terminate();
pim_vrf_terminate();
zclient = pim_zebra_zclient_get();
diff --git a/pimd/subdir.am b/pimd/subdir.am
index b5d135d032..0e30590079 100644
--- a/pimd/subdir.am
+++ b/pimd/subdir.am
@@ -34,6 +34,7 @@ pimd_libpim_a_SOURCES = \
pimd/pim_jp_agg.c \
pimd/pim_macro.c \
pimd/pim_memory.c \
+ pimd/pim_mlag.c \
pimd/pim_mroute.c \
pimd/pim_msdp.c \
pimd/pim_msdp_packet.c \
@@ -62,7 +63,7 @@ pimd_libpim_a_SOURCES = \
pimd/pim_zebra.c \
pimd/pim_zlookup.c \
pimd/pim_vxlan.c \
- pimd/pim_mlag.c \
+ pimd/pim_zpthread.c \
pimd/pimd.c \
# end
@@ -88,6 +89,7 @@ noinst_HEADERS += \
pimd/pim_jp_agg.h \
pimd/pim_macro.h \
pimd/pim_memory.h \
+ pimd/pim_mlag.h \
pimd/pim_mroute.h \
pimd/pim_msdp.h \
pimd/pim_msdp_packet.h \
@@ -115,7 +117,6 @@ noinst_HEADERS += \
pimd/pim_zebra.h \
pimd/pim_zlookup.h \
pimd/pim_vxlan.h \
- pimd/pim_mlag.h \
pimd/pim_vxlan_instance.h \
pimd/pimd.h \
pimd/mtracebis_netlink.h \
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 2ed8d5394d..c05d776eb1 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -216,7 +216,7 @@ rip_request_neighbor (struct in_addr addr)
{
struct sockaddr_in to;
- memset (&to, 0, sizeof (struct sockaddr_in));
+ memset (&to, 0, sizeof(struct sockaddr_in));
to.sin_port = htons (RIP_PORT_DEFAULT);
to.sin_addr = addr;
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 55dafd7c1f..77c73ab398 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -131,7 +131,6 @@ void rip_peer_bad_packet(struct rip *rip, struct sockaddr_in *from)
static char *rip_peer_uptime(struct rip_peer *peer, char *buf, size_t len)
{
time_t uptime;
- struct tm tm;
/* If there is no connection has been done before print `never'. */
if (peer->uptime == 0) {
@@ -142,17 +141,9 @@ static char *rip_peer_uptime(struct rip_peer *peer, char *buf, size_t len)
/* Get current time. */
uptime = time(NULL);
uptime -= peer->uptime;
- gmtime_r(&uptime, &tm);
-
- if (uptime < ONE_DAY_SECOND)
- snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
+
+ frrtime_to_interval(uptime, buf, len);
+
return buf;
}
diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c
index 39e07f3c2e..be222c7a5f 100644
--- a/ripd/rip_snmp.c
+++ b/ripd/rip_snmp.c
@@ -553,7 +553,7 @@ static uint8_t *rip2PeerTable(struct variable *v, oid name[], size_t *length,
* - don't support this variable, at all
* Currently, we do the latter...
*/
- *val_len = sizeof (time_t);
+ *val_len = sizeof(time_t);
uptime = peer->uptime; /* now - snmp_agent_startup - peer->uptime */
return (uint8_t *) &uptime;
#else
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 5009b788ff..f092da847d 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -104,7 +104,7 @@ static int sockopt_broadcast(int sock)
int on = 1;
ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&on,
- sizeof on);
+ sizeof(on));
if (ret < 0) {
zlog_warn("can't set sockopt SO_BROADCAST to socket %d", sock);
return -1;
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index c038bfccf0..e6ff58dd0c 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -141,7 +141,6 @@ void ripng_peer_bad_packet(struct ripng *ripng, struct sockaddr_in6 *from)
static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)
{
time_t uptime;
- struct tm tm;
/* If there is no connection has been done before print `never'. */
if (peer->uptime == 0) {
@@ -152,17 +151,9 @@ static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)
/* Get current time. */
uptime = time(NULL);
uptime -= peer->uptime;
- gmtime_r(&uptime, &tm);
-
- if (uptime < ONE_DAY_SECOND)
- snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
+
+ frrtime_to_interval(uptime, buf, len);
+
return buf;
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index b583df4deb..bb33abdb2c 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -271,7 +271,7 @@ static int ripng_recv_packet(int sock, uint8_t *buf, int bufsize,
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = (void *)adata;
- msg.msg_controllen = sizeof adata;
+ msg.msg_controllen = sizeof(adata);
iov.iov_base = buf;
iov.iov_len = bufsize;
@@ -1455,7 +1455,7 @@ static int ripng_update(struct thread *t)
if (ri->passive)
continue;
-#if RIPNG_ADVANCED
+#ifdef RIPNG_ADVANCED
if (ri->ri_send == RIPNG_SEND_OFF) {
if (IS_RIPNG_DEBUG_EVENT)
zlog_debug(
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index 486ccf6bfe..fd2e37e675 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -337,11 +337,129 @@ DEFUN_NOSH (show_debugging_sharpd,
DEBUG_STR
"Sharp Information\n")
{
- vty_out(vty, "Sharp debugging status\n");
+ vty_out(vty, "Sharp debugging status:\n");
return CMD_SUCCESS;
}
+DEFPY(sharp_lsp_prefix_v4, sharp_lsp_prefix_v4_cmd,
+ "sharp lsp (0-100000)$inlabel\
+ nexthop-group NHGNAME$nhgname\
+ [prefix A.B.C.D/M$pfx\
+ " FRR_IP_REDIST_STR_SHARPD "$type_str [instance (0-255)$instance]]",
+ "Sharp Routing Protocol\n"
+ "Add an LSP\n"
+ "The ingress label to use\n"
+ "Use nexthops from a nexthop-group\n"
+ "The nexthop-group name\n"
+ "Label a prefix\n"
+ "The v4 prefix to label\n"
+ FRR_IP_REDIST_HELP_STR_SHARPD
+ "Instance to use\n"
+ "Instance\n")
+{
+ struct nexthop_group_cmd *nhgc = NULL;
+ struct prefix p = {};
+ int type = 0;
+
+ /* We're offered a v4 prefix */
+ if (pfx->family > 0 && type_str) {
+ p.family = pfx->family;
+ p.prefixlen = pfx->prefixlen;
+ p.u.prefix4 = pfx->prefix;
+
+ type = proto_redistnum(AFI_IP, type_str);
+ if (type < 0) {
+ vty_out(vty, "%% Unknown route type '%s'\n", type_str);
+ return CMD_WARNING;
+ }
+ } else if (pfx->family > 0 || type_str) {
+ vty_out(vty, "%% Must supply both prefix and type\n");
+ return CMD_WARNING;
+ }
+
+ nhgc = nhgc_find(nhgname);
+ if (!nhgc) {
+ vty_out(vty, "%% Nexthop-group '%s' does not exist\n",
+ nhgname);
+ return CMD_WARNING;
+ }
+
+ if (nhgc->nhg.nexthop == NULL) {
+ vty_out(vty, "%% Nexthop-group '%s' is empty\n", nhgname);
+ return CMD_WARNING;
+ }
+
+ if (sharp_install_lsps_helper(true, pfx->family > 0 ? &p : NULL,
+ type, instance, inlabel,
+ &(nhgc->nhg)) == 0)
+ return CMD_SUCCESS;
+ else {
+ vty_out(vty, "%% LSP install failed!\n");
+ return CMD_WARNING;
+ }
+}
+
+DEFPY(sharp_remove_lsp_prefix_v4, sharp_remove_lsp_prefix_v4_cmd,
+ "sharp remove lsp \
+ (0-100000)$inlabel\
+ nexthop-group NHGNAME$nhgname\
+ [prefix A.B.C.D/M$pfx\
+ " FRR_IP_REDIST_STR_SHARPD "$type_str [instance (0-255)$instance]]",
+ "Sharp Routing Protocol\n"
+ "Remove data\n"
+ "Remove an LSP\n"
+ "The ingress label\n"
+ "Use nexthops from a nexthop-group\n"
+ "The nexthop-group name\n"
+ "Specify a v4 prefix\n"
+ "The v4 prefix to label\n"
+ FRR_IP_REDIST_HELP_STR_SHARPD
+ "Routing instance\n"
+ "Instance to use\n")
+{
+ struct nexthop_group_cmd *nhgc = NULL;
+ struct prefix p = {};
+ int type = 0;
+
+ /* We're offered a v4 prefix */
+ if (pfx->family > 0 && type_str) {
+ p.family = pfx->family;
+ p.prefixlen = pfx->prefixlen;
+ p.u.prefix4 = pfx->prefix;
+
+ type = proto_redistnum(AFI_IP, type_str);
+ if (type < 0) {
+ vty_out(vty, "%% Unknown route type '%s'\n", type_str);
+ return CMD_WARNING;
+ }
+ } else if (pfx->family > 0 || type_str) {
+ vty_out(vty, "%% Must supply both prefix and type\n");
+ return CMD_WARNING;
+ }
+
+ nhgc = nhgc_find(nhgname);
+ if (!nhgc) {
+ vty_out(vty, "%% Nexthop-group '%s' does not exist\n",
+ nhgname);
+ return CMD_WARNING;
+ }
+
+ if (nhgc->nhg.nexthop == NULL) {
+ vty_out(vty, "%% Nexthop-group '%s' is empty\n", nhgname);
+ return CMD_WARNING;
+ }
+
+ if (sharp_install_lsps_helper(false, pfx->family > 0 ? &p : NULL,
+ type, instance, inlabel,
+ &(nhgc->nhg)) == 0)
+ return CMD_SUCCESS;
+ else {
+ vty_out(vty, "%% LSP remove failed!\n");
+ return CMD_WARNING;
+ }
+}
+
void sharp_vty_init(void)
{
install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
@@ -351,6 +469,8 @@ void sharp_vty_init(void)
install_element(ENABLE_NODE, &sharp_nht_data_dump_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v6_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v4_cmd);
+ install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd);
+ install_element(ENABLE_NODE, &sharp_remove_lsp_prefix_v4_cmd);
install_element(VIEW_NODE, &show_debugging_sharpd_cmd);
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 5baa74fe96..882e73f873 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -87,6 +87,61 @@ static int sharp_ifp_down(struct interface *ifp)
return 0;
}
+int sharp_install_lsps_helper(bool install_p, const struct prefix *p,
+ uint8_t type, int instance, uint32_t in_label,
+ const struct nexthop_group *nhg)
+{
+ struct zapi_labels zl = {};
+ struct zapi_nexthop *znh;
+ const struct nexthop *nh;
+ int i, ret;
+
+ zl.type = ZEBRA_LSP_SHARP;
+ zl.local_label = in_label;
+
+ if (p) {
+ SET_FLAG(zl.message, ZAPI_LABELS_FTN);
+ prefix_copy(&zl.route.prefix, p);
+ zl.route.type = type;
+ zl.route.instance = instance;
+ }
+
+ i = 0;
+ for (ALL_NEXTHOPS_PTR(nhg, nh)) {
+ znh = &zl.nexthops[i];
+
+ /* Must have labels to be useful */
+ if (nh->nh_label == NULL || nh->nh_label->num_labels == 0)
+ continue;
+
+ if (nh->type == NEXTHOP_TYPE_IFINDEX ||
+ nh->type == NEXTHOP_TYPE_BLACKHOLE)
+ /* Hmm - can't really deal with these types */
+ continue;
+
+ ret = zapi_nexthop_from_nexthop(znh, nh);
+ if (ret < 0)
+ return -1;
+
+ i++;
+ }
+
+ /* Whoops - no nexthops isn't very useful */
+ if (i == 0)
+ return -1;
+
+ zl.nexthop_num = i;
+
+ if (install_p)
+ ret = zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_ADD,
+ &zl);
+ else
+ ret = zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE,
+ &zl);
+
+ return ret;
+}
+
void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint8_t instance, struct nexthop_group *nhg,
uint32_t routes)
@@ -241,43 +296,8 @@ void route_add(struct prefix *p, vrf_id_t vrf_id,
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
api_nh = &api.nexthops[i];
- api_nh->vrf_id = nh->vrf_id;
- api_nh->type = nh->type;
- api_nh->weight = nh->weight;
-
- switch (nh->type) {
- case NEXTHOP_TYPE_IPV4:
- api_nh->gate = nh->gate;
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- api_nh->gate = nh->gate;
- api_nh->ifindex = nh->ifindex;
- break;
- case NEXTHOP_TYPE_IFINDEX:
- api_nh->ifindex = nh->ifindex;
- break;
- case NEXTHOP_TYPE_IPV6:
- memcpy(&api_nh->gate.ipv6, &nh->gate.ipv6, 16);
- break;
- case NEXTHOP_TYPE_IPV6_IFINDEX:
- api_nh->ifindex = nh->ifindex;
- memcpy(&api_nh->gate.ipv6, &nh->gate.ipv6, 16);
- break;
- case NEXTHOP_TYPE_BLACKHOLE:
- api_nh->bh_type = nh->bh_type;
- break;
- }
-
- if (nh->nh_label && nh->nh_label->num_labels > 0) {
- int j;
-
- SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_LABEL);
-
- api_nh->label_num = nh->nh_label->num_labels;
- for (j = 0; j < nh->nh_label->num_labels; j++)
- api_nh->labels[j] = nh->nh_label->label[j];
- }
+ zapi_nexthop_from_nexthop(api_nh, nh);
i++;
}
api.nexthop_num = i;
diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h
index 57ffcc7690..c995d557af 100644
--- a/sharpd/sharp_zebra.h
+++ b/sharpd/sharp_zebra.h
@@ -37,4 +37,8 @@ extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint32_t routes);
extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint8_t instance, uint32_t routes);
+
+int sharp_install_lsps_helper(bool install_p, const struct prefix *p,
+ uint8_t type, int instance, uint32_t in_label,
+ const struct nexthop_group *nhg);
#endif
diff --git a/staticd/static_debug.h b/staticd/static_debug.h
index 6e58118ed0..8932e2d429 100644
--- a/staticd/static_debug.h
+++ b/staticd/static_debug.h
@@ -29,7 +29,7 @@
#include "lib/debug.h"
/* staticd debugging records */
-struct debug static_dbg_events;
+extern struct debug static_dbg_events;
/*
* Initialize staticd debugging.
diff --git a/staticd/static_main.c b/staticd/static_main.c
index 43cb7db51d..3aa8a8db3e 100644
--- a/staticd/static_main.c
+++ b/staticd/static_main.c
@@ -73,6 +73,8 @@ static void sigint(void)
{
zlog_notice("Terminating on signal");
+ static_vrf_terminate();
+
exit(0);
}
diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c
index abb64aad3f..6c065932a1 100644
--- a/staticd/static_vrf.c
+++ b/staticd/static_vrf.c
@@ -111,6 +111,7 @@ static int static_vrf_delete(struct vrf *vrf)
svrf->stable[afi][safi] = NULL;
}
}
+ XFREE(MTYPE_TMP, svrf);
return 0;
}
@@ -204,3 +205,8 @@ void static_vrf_init(void)
vrf_cmd_init(static_vrf_config_write, &static_privs);
}
+
+void static_vrf_terminate(void)
+{
+ vrf_terminate();
+}
diff --git a/staticd/static_vrf.h b/staticd/static_vrf.h
index 28fcdd0d36..6951e56712 100644
--- a/staticd/static_vrf.h
+++ b/staticd/static_vrf.h
@@ -35,4 +35,5 @@ void static_vrf_init(void);
struct route_table *static_vrf_static_table(afi_t afi, safi_t safi,
struct static_vrf *svrf);
+extern void static_vrf_terminate(void);
#endif
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index 3903a5a5c5..40bcf2b5d3 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -591,7 +591,7 @@ void static_config_install_delayed_routes(struct static_vrf *svrf)
if (installed != CMD_SUCCESS)
zlog_debug(
"%s: Attempt to install %s as a route and it was rejected",
- __PRETTY_FUNCTION__, shr->dest_str);
+ __func__, shr->dest_str);
listnode_delete(static_list, shr);
static_list_delete(shr);
}
diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c
index 9feec7156a..b94355e8b8 100644
--- a/tests/bgpd/test_aspath.c
+++ b/tests/bgpd/test_aspath.c
@@ -474,6 +474,20 @@ static struct test_segment {
14,
{NULL, NULL, 0, 0, 0, 0, 0, 0},
},
+ {
+ /* 28 */
+ "BGP_AS_ZERO",
+ "seq(8466,3,52737,0,4096)",
+ {0x2, 0x5,
+ 0x21, 0x12,
+ 0x00, 0x03,
+ 0xce, 0x01,
+ 0x00, 0x00,
+ 0x10, 0x00},
+ 12,
+ {"8466 3 52737 0 4096", "8466 3 52737 0 4096", 5, 0,
+ NOT_ALL_PRIVATE, 4096, 4, 8466},
+ },
{NULL, NULL, {0}, 0, {NULL, 0, 0}}};
#define COMMON_ATTRS \
@@ -678,6 +692,21 @@ static struct aspath_tests {
COMMON_ATTR_SIZE + 3,
&test_segments[0],
},
+ /* 13 */
+ {
+ "4b AS4_PATH: BGP_AS_ZERO",
+ &test_segments[28],
+ "8466 3 52737 0 4096",
+ AS4_DATA,
+ -1,
+ PEER_CAP_AS4_RCV | PEER_CAP_AS4_ADV,
+ {
+ COMMON_ATTRS,
+ BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
+ BGP_ATTR_AS4_PATH, 22,
+ },
+ COMMON_ATTR_SIZE + 3,
+ },
{NULL, NULL, NULL, 0, 0, 0, {0}, 0},
};
diff --git a/tests/bgpd/test_aspath.py b/tests/bgpd/test_aspath.py
index 15ae514c87..5fa1f11629 100644
--- a/tests/bgpd/test_aspath.py
+++ b/tests/bgpd/test_aspath.py
@@ -52,6 +52,7 @@ TestAspath.parsertest("redundantset2")
TestAspath.parsertest("zero-size overflow")
TestAspath.parsertest("zero-size overflow + valid segment")
TestAspath.parsertest("invalid segment type")
+TestAspath.parsertest("BGP_AS_ZERO")
for i in range(10):
TestAspath.okfail("prepend test %d" % i)
@@ -77,3 +78,4 @@ TestAspath.attrtest("4b AS_PATH: too long2")
TestAspath.attrtest("4b AS_PATH: bad flags")
TestAspath.attrtest("4b AS4_PATH w/o AS_PATH")
TestAspath.attrtest("4b AS4_PATH: confed")
+TestAspath.attrtest("4b AS4_PATH: BGP_AS_ZERO")
diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c
index 81dd4308ec..2258df9491 100644
--- a/tests/bgpd/test_mpath.c
+++ b/tests/bgpd/test_mpath.c
@@ -75,7 +75,7 @@ struct testcase_t__ {
/* need these to link in libbgp */
struct thread_master *master = NULL;
-struct zclient *zclient;
+extern struct zclient *zclient;
struct zebra_privs_t bgpd_privs = {
.user = NULL,
.group = NULL,
diff --git a/tests/isisd/test_fuzz_isis_tlv_tests.h.gz b/tests/isisd/test_fuzz_isis_tlv_tests.h.gz
index 46e45e5ee0..4f59d1d7c0 100644
--- a/tests/isisd/test_fuzz_isis_tlv_tests.h.gz
+++ b/tests/isisd/test_fuzz_isis_tlv_tests.h.gz
Binary files differ
diff --git a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
index e99111d90b..43639a81d1 100755
--- a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
+++ b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
@@ -79,6 +79,9 @@ try:
except IOError:
assert False, "Could not read file {}".format(jsonFile)
+#Global Variable
+KEEPALIVETIMER = 2
+HOLDDOWNTIMER = 6
class CreateTopo(Topo):
"""
@@ -292,8 +295,8 @@ def test_bgp_timers_functionality(request):
"r2": {
"dest_link":{
"r1": {
- "keepalivetimer": 60,
- "holddowntimer": 180,
+ "keepalivetimer": KEEPALIVETIMER,
+ "holddowntimer": HOLDDOWNTIMER
}
}
}
@@ -319,8 +322,6 @@ def test_bgp_timers_functionality(request):
write_test_footer(tc_name)
-
-
def test_static_routes(request):
""" Test to create and verify static routes. """
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py
index f3c17be684..997b72d691 100644
--- a/tests/topotests/lib/bgp.py
+++ b/tests/topotests/lib/bgp.py
@@ -382,8 +382,8 @@ def __create_bgp_neighbor(topo, input_dict, router, addr_type, add_neigh=True):
disable_connected = peer.setdefault("disable_connected_check",
False)
- keep_alive = peer.setdefault("keep_alive", 60)
- hold_down = peer.setdefault("hold_down", 180)
+ keep_alive = peer.setdefault("keepalivetimer", 60)
+ hold_down = peer.setdefault("holddowntimer", 180)
password = peer.setdefault("password", None)
max_hop_limit = peer.setdefault("ebgp_multihop", 1)
diff --git a/tests/topotests/pim-basic/r1/pimd.conf b/tests/topotests/pim-basic/r1/pimd.conf
index cec765699d..f64a46deb3 100644
--- a/tests/topotests/pim-basic/r1/pimd.conf
+++ b/tests/topotests/pim-basic/r1/pimd.conf
@@ -7,6 +7,10 @@ interface r1-eth0
interface r1-eth1
ip pim
!
+interface r1-eth2
+ ip igmp
+ ip pim
+!
interface lo
ip pim
!
diff --git a/tests/topotests/pim-basic/r1/zebra.conf b/tests/topotests/pim-basic/r1/zebra.conf
index b0a25f12aa..e43041758b 100644
--- a/tests/topotests/pim-basic/r1/zebra.conf
+++ b/tests/topotests/pim-basic/r1/zebra.conf
@@ -6,6 +6,9 @@ interface r1-eth0
interface r1-eth1
ip address 10.0.30.1/24
!
+interface r1-eth2
+ ip address 10.0.40.1/24
+!
interface lo
ip address 10.254.0.1/32
!
diff --git a/tests/topotests/pim-basic/r3/pimd.conf b/tests/topotests/pim-basic/r3/pimd.conf
new file mode 100644
index 0000000000..f94ee99930
--- /dev/null
+++ b/tests/topotests/pim-basic/r3/pimd.conf
@@ -0,0 +1 @@
+hostname r3
diff --git a/tests/topotests/pim-basic/r3/zebra.conf b/tests/topotests/pim-basic/r3/zebra.conf
new file mode 100644
index 0000000000..8e58e8c66a
--- /dev/null
+++ b/tests/topotests/pim-basic/r3/zebra.conf
@@ -0,0 +1,8 @@
+hostname r3
+!
+interface r3-eth0
+ ip address 10.0.40.4/24
+!
+interface lo
+ ip address 10.254.0.4/32
+!
diff --git a/tests/topotests/pim-basic/rp/pimd.conf b/tests/topotests/pim-basic/rp/pimd.conf
index 3f1b4d65c9..6e35c97971 100644
--- a/tests/topotests/pim-basic/rp/pimd.conf
+++ b/tests/topotests/pim-basic/rp/pimd.conf
@@ -7,3 +7,6 @@ interface lo
ip pim
!
ip pim rp 10.254.0.3
+ip pim register-accept-list ACCEPT
+
+ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32
diff --git a/tests/topotests/pim-basic/test_pim.py b/tests/topotests/pim-basic/test_pim.py
index 0e0569e234..9101d7e035 100644
--- a/tests/topotests/pim-basic/test_pim.py
+++ b/tests/topotests/pim-basic/test_pim.py
@@ -46,14 +46,18 @@ class PIMTopo(Topo):
"Build function"
tgen = get_topogen(self)
- for routern in range(1, 3):
+ for routern in range(1, 4):
tgen.add_router('r{}'.format(routern))
tgen.add_router('rp')
+ # rp ------ r1 -------- r2
+ # \
+ # --------- r3
# r1 -> .1
# r2 -> .2
# rp -> .3
+ # r3 -> .4
# loopback network is 10.254.0.X/32
#
# r1 <- sw1 -> r2
@@ -70,6 +74,10 @@ class PIMTopo(Topo):
sw.add_link(tgen.gears['r1'])
sw.add_link(tgen.gears['rp'])
+ # 10.0.40.0/24
+ sw = tgen.add_switch('sw3')
+ sw.add_link(tgen.gears['r1'])
+ sw.add_link(tgen.gears['r3'])
def setup_module(mod):
"Sets up the pytest environment"
@@ -130,12 +138,15 @@ def test_pim_send_mcast_stream():
pytest.skip(tgen.errors)
rp = tgen.gears['rp']
+ r3 = tgen.gears['r3']
r2 = tgen.gears['r2']
r1 = tgen.gears['r1']
# Let's establish a S,G stream from r2 -> r1
CWD = os.path.dirname(os.path.realpath(__file__))
r2.run("{}/mcast-tx.py --ttl 5 --count 5 --interval 10 229.1.1.1 r2-eth0 > /tmp/bar".format(CWD))
+ # And from r3 -> r1
+ r3.run("{}/mcast-tx.py --ttl 5 --count 5 --interval 10 229.1.1.1 r3-eth0 > /tmp/bar".format(CWD))
# Let's see that it shows up and we have established some basic state
out = r1.vtysh_cmd("show ip pim upstream json", isjson=True)
diff --git a/scripts/coccinelle/__func__.cocci b/tools/coccinelle/__func__.cocci
index fb68494d43..fb68494d43 100644
--- a/scripts/coccinelle/__func__.cocci
+++ b/tools/coccinelle/__func__.cocci
diff --git a/scripts/coccinelle/bool_assignment.cocci b/tools/coccinelle/bool_assignment.cocci
index e6146ea310..e6146ea310 100644
--- a/scripts/coccinelle/bool_assignment.cocci
+++ b/tools/coccinelle/bool_assignment.cocci
diff --git a/scripts/coccinelle/bool_expression.cocci b/tools/coccinelle/bool_expression.cocci
index c0c329cb59..c0c329cb59 100644
--- a/scripts/coccinelle/bool_expression.cocci
+++ b/tools/coccinelle/bool_expression.cocci
diff --git a/scripts/coccinelle/bool_function.cocci b/tools/coccinelle/bool_function.cocci
index 0328ecfbbe..0328ecfbbe 100644
--- a/scripts/coccinelle/bool_function.cocci
+++ b/tools/coccinelle/bool_function.cocci
diff --git a/scripts/coccinelle/bool_function_type.cocci b/tools/coccinelle/bool_function_type.cocci
index 71bf4f53b8..71bf4f53b8 100644
--- a/scripts/coccinelle/bool_function_type.cocci
+++ b/tools/coccinelle/bool_function_type.cocci
diff --git a/scripts/coccinelle/replace_bgp_flag_functions.cocci b/tools/coccinelle/replace_bgp_flag_functions.cocci
index 3064fc0267..3064fc0267 100644
--- a/scripts/coccinelle/replace_bgp_flag_functions.cocci
+++ b/tools/coccinelle/replace_bgp_flag_functions.cocci
diff --git a/scripts/coccinelle/return_without_parenthesis.cocci b/tools/coccinelle/return_without_parenthesis.cocci
index 7097e87ddc..7097e87ddc 100644
--- a/scripts/coccinelle/return_without_parenthesis.cocci
+++ b/tools/coccinelle/return_without_parenthesis.cocci
diff --git a/scripts/coccinelle/s_addr_0_to_INADDR_ANY.cocci b/tools/coccinelle/s_addr_0_to_INADDR_ANY.cocci
index bd7f4af4f2..bd7f4af4f2 100644
--- a/scripts/coccinelle/s_addr_0_to_INADDR_ANY.cocci
+++ b/tools/coccinelle/s_addr_0_to_INADDR_ANY.cocci
diff --git a/scripts/coccinelle/shorthand_operator.cocci b/tools/coccinelle/shorthand_operator.cocci
index f7019d4040..f7019d4040 100644
--- a/scripts/coccinelle/shorthand_operator.cocci
+++ b/tools/coccinelle/shorthand_operator.cocci
diff --git a/scripts/coccinelle/test_after_assert.cocci b/tools/coccinelle/test_after_assert.cocci
index 30596a89c2..30596a89c2 100644
--- a/scripts/coccinelle/test_after_assert.cocci
+++ b/tools/coccinelle/test_after_assert.cocci
diff --git a/scripts/coccinelle/void_no_return.cocci b/tools/coccinelle/void_no_return.cocci
index 7da9e73933..7da9e73933 100644
--- a/scripts/coccinelle/void_no_return.cocci
+++ b/tools/coccinelle/void_no_return.cocci
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index da6de341e1..3ef9fd90aa 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -185,6 +185,11 @@ static bool vrrp_ifp_has_vrrp_mac(struct interface *ifp)
* is used to look up any existing instances that match the interface. It does
* not matter whether the instance is already bound to the interface or not.
*
+ * Note that the interface linkages must be correct for this to work. In other
+ * words, the macvlan must have a valid VRRP MAC, and its link_ifindex must be
+ * be equal to the ifindex of another interface in the interface RB trees (its
+ * parent). If these conditions aren't satisfied we won't find the VR.
+ *
* mvl_ifp
* Interface pointer to use to lookup. Should be a macvlan device.
*
@@ -1646,7 +1651,7 @@ static int vrrp_shutdown(struct vrrp_router *r)
r->vr->vrid, family2str(r->family),
vrrp_event_names[VRRP_EVENT_SHUTDOWN],
vrrp_state_names[VRRP_STATE_INITIALIZE]);
- break;
+ return 0;
}
/* Cancel all timers */
@@ -2214,18 +2219,57 @@ void vrrp_if_del(struct interface *ifp)
{
struct listnode *ln;
struct vrrp_vrouter *vr;
- struct list *vrs = vrrp_lookup_by_if_any(ifp);
vrrp_if_down(ifp);
+ /*
+ * You think we'd be able use vrrp_lookup_by_if_any to find interfaces?
+ * Nah. FRR's interface management is insane. There are no ordering
+ * guarantees about what interfaces are deleted when. Maybe this is a
+ * macvlan and its parent was already deleted, in which case its
+ * ifindex is now IFINDEX_INTERNAL, so ifp->link_ifindex - while still
+ * valid - doesn't match any interface on the system, meaning we can't
+ * use any of the vrrp_lookup* functions since they rely on finding the
+ * base interface of what they're given by following link_ifindex.
+ *
+ * Since we need to actually NULL out pointers in this function to
+ * avoid a UAF - since the caller will (might) free ifp after we return
+ * - we need to look up based on pointers.
+ */
+ struct list *vrs = hash_to_list(vrrp_vrouters_hash);
+
for (ALL_LIST_ELEMENTS_RO(vrs, ln, vr)) {
- if ((vr->v4->mvl_ifp == ifp || vr->ifp == ifp)
- && vr->v4->fsm.state != VRRP_STATE_INITIALIZE) {
+ if (ifp == vr->ifp) {
+ vrrp_event(vr->v4, VRRP_EVENT_SHUTDOWN);
+ vrrp_event(vr->v6, VRRP_EVENT_SHUTDOWN);
+ /*
+ * Stands to reason if the base was deleted, so were
+ * (or will be) its children
+ */
+ vr->v4->mvl_ifp = NULL;
+ vr->v6->mvl_ifp = NULL;
+ /*
+ * We shouldn't need to lose the reference if it's the
+ * primary interface, because that was configured
+ * explicitly in our config, and thus will be kept as a
+ * stub; to avoid stupid bugs, double check that
+ */
+ assert(ifp->configured);
+ } else if (ifp == vr->v4->mvl_ifp) {
vrrp_event(vr->v4, VRRP_EVENT_SHUTDOWN);
+ /*
+ * If this is a macvlan, then it wasn't explicitly
+ * configured and will be deleted when we return from
+ * this function, so we need to lose the reference
+ */
vr->v4->mvl_ifp = NULL;
- } else if ((vr->v6->mvl_ifp == ifp || vr->ifp == ifp)
- && vr->v6->fsm.state != VRRP_STATE_INITIALIZE) {
+ } else if (ifp == vr->v6->mvl_ifp) {
vrrp_event(vr->v6, VRRP_EVENT_SHUTDOWN);
+ /*
+ * If this is a macvlan, then it wasn't explicitly
+ * configured and will be deleted when we return from
+ * this function, so we need to lose the reference
+ */
vr->v6->mvl_ifp = NULL;
}
}
diff --git a/vrrpd/vrrp_debug.h b/vrrpd/vrrp_debug.h
index 20f9930955..459d4d01aa 100644
--- a/vrrpd/vrrp_debug.h
+++ b/vrrpd/vrrp_debug.h
@@ -25,13 +25,13 @@
#include "lib/debug.h"
/* VRRP debugging records */
-struct debug vrrp_dbg_arp;
-struct debug vrrp_dbg_auto;
-struct debug vrrp_dbg_ndisc;
-struct debug vrrp_dbg_pkt;
-struct debug vrrp_dbg_proto;
-struct debug vrrp_dbg_sock;
-struct debug vrrp_dbg_zebra;
+extern struct debug vrrp_dbg_arp;
+extern struct debug vrrp_dbg_auto;
+extern struct debug vrrp_dbg_ndisc;
+extern struct debug vrrp_dbg_pkt;
+extern struct debug vrrp_dbg_proto;
+extern struct debug vrrp_dbg_sock;
+extern struct debug vrrp_dbg_zebra;
/*
* Initialize VRRP debugging.
diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
index b7ac0abe02..c4f293fd3b 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -43,7 +43,9 @@ sub scan_file {
open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -Ivtysh/@top_builddir@ -Ivtysh/@top_srcdir@ -Ivtysh/@top_srcdir@/lib -Ivtysh/@top_builddir@/lib -Ivtysh/@top_srcdir@/bgpd -Ivtysh/@top_srcdir@/bgpd/rfapi @LUA_INCLUDE@ @CPPFLAGS@ $cppadd $file |");
local $/; undef $/;
$line = <FH>;
- close (FH);
+ if (!close (FH)) {
+ printf "File: $file failed to compile, when extracting cli from it please inspect\n"
+ }
# ?: makes a group non-capturing
@defun = ($line =~ /((?:DEFUN|DEFUN_HIDDEN|ALIAS|ALIAS_HIDDEN)\s*\(.+?\));?\s?\s?\n/sg);
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 92d52ff650..310acdf37f 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3670,7 +3670,7 @@ char *vtysh_prompt(void)
{
static char buf[512];
- snprintf(buf, sizeof buf, cmd_prompt(vty->node), cmd_hostname_get());
+ snprintf(buf, sizeof(buf), cmd_prompt(vty->node), cmd_hostname_get());
return buf;
}
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index cc8c536c74..25d1bf7db0 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -237,7 +237,7 @@ static void log_it(const char *line)
if (!user)
user = "boot";
- strftime(tod, sizeof tod, "%Y%m%d-%H:%M.%S", &tmp);
+ strftime(tod, sizeof(tod), "%Y%m%d-%H:%M.%S", &tmp);
fprintf(logfile, "%s:%s %s\n", tod, user, line);
}
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 580efee40e..65a0add57e 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -286,7 +286,7 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
ifi = NLMSG_DATA(h);
- memset(linkinfo, 0, sizeof linkinfo);
+ memset(linkinfo, 0, sizeof(linkinfo));
parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);
if (!linkinfo[IFLA_INFO_DATA]) {
@@ -297,7 +297,7 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
return;
}
- memset(attr, 0, sizeof attr);
+ memset(attr, 0, sizeof(attr));
parse_rtattr_nested(attr, IFLA_VRF_MAX, linkinfo[IFLA_INFO_DATA]);
if (!attr[IFLA_VRF_TABLE]) {
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -433,7 +433,7 @@ static int netlink_extract_bridge_info(struct rtattr *link_data,
struct rtattr *attr[IFLA_BR_MAX + 1];
memset(bridge_info, 0, sizeof(*bridge_info));
- memset(attr, 0, sizeof attr);
+ memset(attr, 0, sizeof(attr));
parse_rtattr_nested(attr, IFLA_BR_MAX, link_data);
if (attr[IFLA_BR_VLAN_FILTERING])
bridge_info->vlan_aware =
@@ -448,7 +448,7 @@ static int netlink_extract_vlan_info(struct rtattr *link_data,
vlanid_t vid_in_msg;
memset(vlan_info, 0, sizeof(*vlan_info));
- memset(attr, 0, sizeof attr);
+ memset(attr, 0, sizeof(attr));
parse_rtattr_nested(attr, IFLA_VLAN_MAX, link_data);
if (!attr[IFLA_VLAN_ID]) {
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -469,7 +469,7 @@ static int netlink_extract_vxlan_info(struct rtattr *link_data,
struct in_addr vtep_ip_in_msg;
memset(vxl_info, 0, sizeof(*vxl_info));
- memset(attr, 0, sizeof attr);
+ memset(attr, 0, sizeof(attr));
parse_rtattr_nested(attr, IFLA_VXLAN_MAX, link_data);
if (!attr[IFLA_VXLAN_ID]) {
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -543,7 +543,7 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,
/* Fetch name and ifindex */
ifi = NLMSG_DATA(h);
- memset(tb, 0, sizeof tb);
+ memset(tb, 0, sizeof(tb));
netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
if (tb[IFLA_IFNAME] == NULL)
@@ -567,7 +567,7 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,
/* There is a 1-to-1 mapping of VLAN to VxLAN - hence
* only 1 access VLAN is accepted.
*/
- memset(aftb, 0, sizeof aftb);
+ memset(aftb, 0, sizeof(aftb));
parse_rtattr_nested(aftb, IFLA_BRIDGE_MAX, tb[IFLA_AF_SPEC]);
if (!aftb[IFLA_BRIDGE_VLAN_INFO])
return 0;
@@ -628,8 +628,8 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return netlink_bridge_interface(h, len, ns_id, startup);
/* Looking up interface name. */
- memset(tb, 0, sizeof tb);
- memset(linkinfo, 0, sizeof linkinfo);
+ memset(tb, 0, sizeof(tb));
+ memset(linkinfo, 0, sizeof(linkinfo));
netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
/* check for wireless messages to ignore */
@@ -858,7 +858,7 @@ int kernel_interface_set_master(struct interface *master,
char buf[NL_PKT_BUF_SIZE];
} req;
- memset(&req, 0, sizeof req);
+ memset(&req, 0, sizeof(req));
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
req.n.nlmsg_flags = NLM_F_REQUEST;
@@ -867,8 +867,8 @@ int kernel_interface_set_master(struct interface *master,
req.ifa.ifi_index = slave->ifindex;
- addattr_l(&req.n, sizeof req, IFLA_MASTER, &master->ifindex, 4);
- addattr_l(&req.n, sizeof req, IFLA_LINK, &slave->ifindex, 4);
+ addattr_l(&req.n, sizeof(req), IFLA_MASTER, &master->ifindex, 4);
+ addattr_l(&req.n, sizeof(req), IFLA_LINK, &slave->ifindex, 4);
return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
0);
@@ -982,7 +982,7 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return -1;
}
- memset(tb, 0, sizeof tb);
+ memset(tb, 0, sizeof(tb));
netlink_parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len);
ifp = if_lookup_by_index_per_ns(zns, ifa->ifa_index);
@@ -1188,8 +1188,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return netlink_bridge_interface(h, len, ns_id, startup);
/* Looking up interface name. */
- memset(tb, 0, sizeof tb);
- memset(linkinfo, 0, sizeof linkinfo);
+ memset(tb, 0, sizeof(tb));
+ memset(linkinfo, 0, sizeof(linkinfo));
netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
/* check for wireless messages to ignore */
diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c
index ac8f537075..48ab95d1ba 100644
--- a/zebra/ipforward_sysctl.c
+++ b/zebra/ipforward_sysctl.c
@@ -41,7 +41,7 @@ int ipforward(void)
size_t len;
int ipforwarding = 0;
- len = sizeof ipforwarding;
+ len = sizeof(ipforwarding);
if (sysctl(mib, MIB_SIZ, &ipforwarding, &len, 0, 0) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"Can't get ipforwarding value");
@@ -55,7 +55,7 @@ int ipforward_on(void)
size_t len;
int ipforwarding = 1;
- len = sizeof ipforwarding;
+ len = sizeof(ipforwarding);
frr_with_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
@@ -71,7 +71,7 @@ int ipforward_off(void)
size_t len;
int ipforwarding = 0;
- len = sizeof ipforwarding;
+ len = sizeof(ipforwarding);
frr_with_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
@@ -96,7 +96,7 @@ int ipforward_ipv6(void)
size_t len;
int ip6forwarding = 0;
- len = sizeof ip6forwarding;
+ len = sizeof(ip6forwarding);
frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
@@ -112,7 +112,7 @@ int ipforward_ipv6_on(void)
size_t len;
int ip6forwarding = 1;
- len = sizeof ip6forwarding;
+ len = sizeof(ip6forwarding);
frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
@@ -129,7 +129,7 @@ int ipforward_ipv6_off(void)
size_t len;
int ip6forwarding = 0;
- len = sizeof ip6forwarding;
+ len = sizeof(ip6forwarding);
frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 0de618625d..a1e6e8248e 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -190,7 +190,7 @@ static void irdp_send(struct interface *ifp, struct prefix *p, struct stream *s)
if (irdp->flags & IF_DEBUG_MESSAGES)
zlog_debug("IRDP: TX Advert on %s %s Holdtime=%d Preference=%d",
- ifp->name, prefix2str(p, buf, sizeof buf),
+ ifp->name, prefix2str(p, buf, sizeof(buf)),
irdp->flags & IF_SHUTDOWN ? 0 : irdp->Lifetime,
get_pref(irdp, p));
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 13dcab9294..502a2f277c 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -196,7 +196,7 @@ static int irdp_recvmsg(int sock, uint8_t *buf, int size, int *ifindex)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = (void *)adata;
- msg.msg_controllen = sizeof adata;
+ msg.msg_controllen = sizeof(adata);
iov.iov_base = buf;
iov.iov_len = size;
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 0d25798d39..97b0238362 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -231,12 +231,12 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
return -1;
}
- memset(&snl, 0, sizeof snl);
+ memset(&snl, 0, sizeof(snl));
snl.nl_family = AF_NETLINK;
snl.nl_groups = groups;
/* Bind the socket to the netlink structure for anything. */
- ret = bind(sock, (struct sockaddr *)&snl, sizeof snl);
+ ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl));
}
if (ret < 0) {
@@ -247,9 +247,9 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
}
/* multiple netlink sockets will have different nl_pid */
- namelen = sizeof snl;
+ namelen = sizeof(snl);
ret = getsockname(sock, (struct sockaddr *)&snl, (socklen_t *)&namelen);
- if (ret < 0 || namelen != sizeof snl) {
+ if (ret < 0 || namelen != sizeof(snl)) {
flog_err_sys(EC_LIB_SOCKET, "Can't get %s socket name: %s",
nl->name, safe_strerror(errno));
close(sock);
@@ -738,10 +738,10 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
while (1) {
char buf[NL_RCV_PKT_BUF_SIZE];
- struct iovec iov = {.iov_base = buf, .iov_len = sizeof buf};
+ struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};
struct sockaddr_nl snl;
struct msghdr msg = {.msg_name = (void *)&snl,
- .msg_namelen = sizeof snl,
+ .msg_namelen = sizeof(snl),
.msg_iov = &iov,
.msg_iovlen = 1};
struct nlmsghdr *h;
@@ -783,7 +783,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
return -1;
}
- if (msg.msg_namelen != sizeof snl) {
+ if (msg.msg_namelen != sizeof(snl)) {
flog_err(EC_ZEBRA_NETLINK_LENGTH_ERROR,
"%s sender address length error: length %d",
nl->name, msg.msg_namelen);
@@ -989,14 +989,14 @@ int netlink_talk_info(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
int save_errno = 0;
const struct nlsock *nl;
- memset(&snl, 0, sizeof snl);
- memset(&iov, 0, sizeof iov);
- memset(&msg, 0, sizeof msg);
+ memset(&snl, 0, sizeof(snl));
+ memset(&iov, 0, sizeof(iov));
+ memset(&msg, 0, sizeof(msg));
iov.iov_base = n;
iov.iov_len = n->nlmsg_len;
msg.msg_name = (void *)&snl;
- msg.msg_namelen = sizeof snl;
+ msg.msg_namelen = sizeof(snl);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
@@ -1077,13 +1077,13 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
n->nlmsg_pid = nl->snl.nl_pid;
n->nlmsg_seq = ++nl->seq;
- memset(&snl, 0, sizeof snl);
+ memset(&snl, 0, sizeof(snl));
snl.nl_family = AF_NETLINK;
/* Raise capabilities and send message, then lower capabilities. */
frr_with_privs(&zserv_privs) {
ret = sendto(nl->sock, (void *)n, n->nlmsg_len, 0,
- (struct sockaddr *)&snl, sizeof snl);
+ (struct sockaddr *)&snl, sizeof(snl));
}
if (ret < 0) {
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 7cdd6ef84e..5ab5210664 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -1371,7 +1371,7 @@ static int kernel_read(struct thread *thread)
/* Fetch routing socket. */
sock = THREAD_FD(thread);
- nbytes = read(sock, &buf, sizeof buf);
+ nbytes = read(sock, &buf, sizeof(buf));
if (nbytes <= 0) {
if (nbytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
diff --git a/zebra/main.c b/zebra/main.c
index 5951c7e280..dab1449194 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -53,6 +53,7 @@
#include "zebra/zebra_rnh.h"
#include "zebra/zebra_pbr.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_routemap.h"
#if defined(HANDLE_NETLINK_FUZZING)
#include "zebra/kernel_netlink.h"
@@ -179,7 +180,13 @@ static void sigint(void)
access_list_reset();
prefix_list_reset();
- route_map_finish();
+ /*
+ * zebra_routemap_finish will
+ * 1 set rmap upd timer to 0 so that rmap update wont be scheduled again
+ * 2 Put off the rmap update thread
+ * 3 route_map_finish
+ */
+ zebra_routemap_finish();
list_delete(&zrouter.client_list);
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 32051a62b7..d1148061b9 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -75,6 +75,10 @@ static void zebra_redistribute_default(struct zserv *client, vrf_id_t vrf_id)
struct route_entry *newre;
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
+
+ if (!vrf_bitmap_check(client->redist_default[afi], vrf_id))
+ continue;
+
/* Lookup table. */
table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
if (!table)
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index a417175da1..e40bf45f59 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -142,7 +142,7 @@ static uint16_t neigh_state_to_netlink(uint16_t dplane_state)
}
-static inline int is_selfroute(int proto)
+static inline bool is_selfroute(int proto)
{
if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF)
|| (proto == RTPROT_ZSTATIC) || (proto == RTPROT_ZEBRA)
@@ -151,10 +151,10 @@ static inline int is_selfroute(int proto)
|| (proto == RTPROT_LDP) || (proto == RTPROT_BABEL)
|| (proto == RTPROT_RIP) || (proto == RTPROT_SHARP)
|| (proto == RTPROT_PBR) || (proto == RTPROT_OPENFABRIC)) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
static inline int zebra2proto(int proto)
@@ -513,6 +513,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
struct prefix p;
struct prefix_ipv6 src_p = {};
vrf_id_t vrf_id;
+ bool selfroute;
char anyaddr[16] = {0};
@@ -564,7 +565,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
return -1;
}
- memset(tb, 0, sizeof tb);
+ memset(tb, 0, sizeof(tb));
netlink_parse_rtattr(tb, RTA_MAX, RTM_RTA(rtm), len);
if (rtm->rtm_flags & RTM_F_CLONED)
@@ -574,8 +575,9 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
if (rtm->rtm_protocol == RTPROT_KERNEL)
return 0;
- if (!startup && is_selfroute(rtm->rtm_protocol)
- && h->nlmsg_type == RTM_NEWROUTE) {
+ selfroute = is_selfroute(rtm->rtm_protocol);
+
+ if (!startup && selfroute && h->nlmsg_type == RTM_NEWROUTE) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("Route type: %d Received that we think we have originated, ignoring",
rtm->rtm_protocol);
@@ -602,7 +604,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
}
/* Route which inserted by Zebra. */
- if (is_selfroute(rtm->rtm_protocol)) {
+ if (selfroute) {
flags |= ZEBRA_FLAG_SELFROUTE;
proto = proto2zebra(rtm->rtm_protocol, rtm->rtm_family, false);
}
@@ -639,7 +641,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
if (tb[RTA_METRICS]) {
struct rtattr *mxrta[RTAX_MAX + 1];
- memset(mxrta, 0, sizeof mxrta);
+ memset(mxrta, 0, sizeof(mxrta));
netlink_parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(tb[RTA_METRICS]),
RTA_PAYLOAD(tb[RTA_METRICS]));
@@ -849,7 +851,7 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,
len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg));
- memset(tb, 0, sizeof tb);
+ memset(tb, 0, sizeof(tb));
netlink_parse_rtattr(tb, RTA_MAX, RTM_RTA(rtm), len);
if (tb[RTA_TABLE])
@@ -2588,7 +2590,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
struct interface *br_if;
struct ethaddr mac;
vlanid_t vid = 0;
- struct prefix vtep_ip;
+ struct in_addr vtep_ip;
int vid_present = 0, dst_present = 0;
char buf[ETHER_ADDR_STRLEN];
char vid_buf[20];
@@ -2601,66 +2603,25 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (!is_evpn_enabled())
return 0;
- /* The interface should exist. */
- ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id),
- ndm->ndm_ifindex);
- if (!ifp || !ifp->info) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("\t%s without associated interface: %u",
- __func__, ndm->ndm_ifindex);
- return 0;
- }
-
- /* The interface should be something we're interested in. */
- if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp)) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("\t%s Not interested in %s, not a slave",
- __func__, ifp->name);
- return 0;
- }
-
- /* Drop "permanent" entries. */
- if (ndm->ndm_state & NUD_PERMANENT) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("\t%s Entry is PERMANENT, dropping",
- __func__);
- return 0;
- }
-
- zif = (struct zebra_if *)ifp->info;
- if ((br_if = zif->brslave_info.br_if) == NULL) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug(
- "%s family %s IF %s(%u) brIF %u - no bridge master",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex,
- zif->brslave_info.bridge_ifindex);
- return 0;
- }
-
- /* Parse attributes and extract fields of interest. */
+ /* Parse attributes and extract fields of interest. Do basic
+ * validation of the fields.
+ */
memset(tb, 0, sizeof tb);
netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);
if (!tb[NDA_LLADDR]) {
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("%s family %s IF %s(%u) brIF %u - no LLADDR",
+ zlog_debug("%s AF_BRIDGE IF %u - no LLADDR",
nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex,
- zif->brslave_info.bridge_ifindex);
+ ndm->ndm_ifindex);
return 0;
}
if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %lu",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex,
- zif->brslave_info.bridge_ifindex,
+ "%s AF_BRIDGE IF %u - LLADDR is not MAC, len %lu",
+ nl_msg_type_to_str(h->nlmsg_type), ndm->ndm_ifindex,
(unsigned long)RTA_PAYLOAD(tb[NDA_LLADDR]));
return 0;
}
@@ -2676,24 +2637,42 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (tb[NDA_DST]) {
/* TODO: Only IPv4 supported now. */
dst_present = 1;
- vtep_ip.family = AF_INET;
- vtep_ip.prefixlen = IPV4_MAX_BITLEN;
- memcpy(&(vtep_ip.u.prefix4.s_addr), RTA_DATA(tb[NDA_DST]),
+ memcpy(&vtep_ip.s_addr, RTA_DATA(tb[NDA_DST]),
IPV4_MAX_BYTELEN);
- sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip.u.prefix4));
+ sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip));
}
- sticky = !!(ndm->ndm_state & NUD_NOARP);
-
if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("Rx %s family %s IF %s(%u)%s %sMAC %s%s",
+ zlog_debug("Rx %s AF_BRIDGE IF %u%s st 0x%x fl 0x%x MAC %s%s",
nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
ndm->ndm_ifindex, vid_present ? vid_buf : "",
- sticky ? "sticky " : "",
+ ndm->ndm_state, ndm->ndm_flags,
prefix_mac2str(&mac, buf, sizeof(buf)),
dst_present ? dst_buf : "");
+ /* The interface should exist. */
+ ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id),
+ ndm->ndm_ifindex);
+ if (!ifp || !ifp->info)
+ return 0;
+
+ /* The interface should be something we're interested in. */
+ if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp))
+ return 0;
+
+ zif = (struct zebra_if *)ifp->info;
+ if ((br_if = zif->brslave_info.br_if) == NULL) {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug(
+ "%s AF_BRIDGE IF %s(%u) brIF %u - no bridge master",
+ nl_msg_type_to_str(h->nlmsg_type), ifp->name,
+ ndm->ndm_ifindex,
+ zif->brslave_info.bridge_ifindex);
+ return 0;
+ }
+
+ sticky = !!(ndm->ndm_state & NUD_NOARP);
+
if (filter_vlan && vid != filter_vlan) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("\tFiltered due to filter vlan: %d",
@@ -2707,6 +2686,13 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
* so perform an implicit delete of any local entry (if it exists).
*/
if (h->nlmsg_type == RTM_NEWNEIGH) {
+ /* Drop "permanent" entries. */
+ if (ndm->ndm_state & NUD_PERMANENT) {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("\tDropping entry because of NUD_PERMANENT");
+ return 0;
+ }
+
if (IS_ZEBRA_IF_VXLAN(ifp))
return zebra_vxlan_check_del_local_mac(ifp, br_if, &mac,
vid);
@@ -2716,16 +2702,20 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
}
/* This is a delete notification.
+ * Ignore the notification with IP dest as it may just signify that the
+ * MAC has moved from remote to local. The exception is the special
+ * all-zeros MAC that represents the BUM flooding entry; we may have
+ * to readd it. Otherwise,
* 1. For a MAC over VxLan, check if it needs to be refreshed(readded)
* 2. For a MAC over "local" interface, delete the mac
* Note: We will get notifications from both bridge driver and VxLAN
* driver.
- * Ignore the notification from VxLan driver as it is also generated
- * when mac moves from remote to local.
*/
if (dst_present) {
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("\tNo Destination Present");
+ u_char zero_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
+
+ if (!memcmp(zero_mac, mac.octet, ETH_ALEN))
+ return zebra_vxlan_check_readd_vtep(ifp, vtep_ip);
return 0;
}
@@ -3050,7 +3040,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
zif = (struct zebra_if *)ifp->info;
/* Parse attributes and extract fields of interest. */
- memset(tb, 0, sizeof tb);
+ memset(tb, 0, sizeof(tb));
netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);
if (!tb[NDA_DST]) {
@@ -3285,6 +3275,15 @@ static int netlink_request_specific_neigh_in_vlan(struct zebra_ns *zns,
addattr_l(&req.n, sizeof(req), NDA_DST, &ip->ip.addr, ipa_len);
+ if (IS_ZEBRA_DEBUG_KERNEL) {
+ char buf[INET6_ADDRSTRLEN];
+
+ zlog_debug("%s: Tx %s family %s IF %u IP %s flags 0x%x",
+ __func__, nl_msg_type_to_str(type),
+ nl_family_to_str(req.ndm.ndm_family), ifindex,
+ ipaddr2str(ip, buf, sizeof(buf)), req.n.nlmsg_flags);
+ }
+
return netlink_request(&zns->netlink_cmd, &req.n);
}
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 829dcfcfd2..60ac471b5a 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -130,7 +130,7 @@ static int rtadv_recv_packet(struct zebra_vrf *zvrf, int sock, uint8_t *buf,
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = (void *)adata;
- msg.msg_controllen = sizeof adata;
+ msg.msg_controllen = sizeof(adata);
iov.iov_base = buf;
iov.iov_len = buflen;
@@ -1118,18 +1118,31 @@ void rtadv_stop_ra(struct interface *ifp)
}
/*
- * send router lifetime value of zero in RAs on all interfaces since we're
+ * Send router lifetime value of zero in RAs on all interfaces since we're
* ceasing to advertise globally and want to let all of our neighbors know
* RFC 4861 secion 6.2.5
+ *
+ * Delete all ipv6 global prefixes added to the router advertisement prefix
+ * lists prior to ceasing.
*/
void rtadv_stop_ra_all(void)
{
struct vrf *vrf;
struct interface *ifp;
+ struct listnode *node, *nnode;
+ struct zebra_if *zif;
+ struct rtadv_prefix *rprefix;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- FOR_ALL_INTERFACES (vrf, ifp)
+ FOR_ALL_INTERFACES (vrf, ifp) {
+ zif = ifp->info;
+
+ for (ALL_LIST_ELEMENTS(zif->rtadv.AdvPrefixList,
+ node, nnode, rprefix))
+ rtadv_prefix_reset(zif, rprefix);
+
rtadv_stop_ra(ifp);
+ }
}
void zebra_interface_radv_disable(ZAPI_HANDLER_ARGS)
@@ -2425,7 +2438,7 @@ static int if_join_all_router(int sock, struct interface *ifp)
mreq.ipv6mr_interface = ifp->ifindex;
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq,
- sizeof mreq);
+ sizeof(mreq));
if (ret < 0)
flog_err_sys(EC_LIB_SOCKET,
"%s(%u): Failed to join group, socket %u error %s",
@@ -2451,7 +2464,7 @@ static int if_leave_all_router(int sock, struct interface *ifp)
mreq.ipv6mr_interface = ifp->ifindex;
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *)&mreq,
- sizeof mreq);
+ sizeof(mreq));
if (ret < 0)
flog_err_sys(
EC_LIB_SOCKET,
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index 3ba5d6ee73..28529cc138 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -231,7 +231,7 @@ void route_read(struct zebra_ns *zns)
!= 0) {
zlog_debug(
"getmsg(data) returned "
- "msgdata.len = %d (%% sizeof (mib2_ipRouteEntry_t) != 0)",
+ "msgdata.len = %d (%% sizeof(mib2_ipRouteEntry_t) != 0)",
msgdata.len);
goto exit;
}
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 509c0e1019..f1c181438e 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -790,8 +790,7 @@ void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,
struct stream *s;
if (IS_ZEBRA_DEBUG_PACKET)
- zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
- rule->rule.unique);
+ zlog_debug("%s: Notifying %u", __func__, rule->rule.unique);
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
if (rule->sock == client->sock)
@@ -823,8 +822,7 @@ void zsend_ipset_notify_owner(struct zebra_pbr_ipset *ipset,
struct stream *s;
if (IS_ZEBRA_DEBUG_PACKET)
- zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
- ipset->unique);
+ zlog_debug("%s: Notifying %u", __func__, ipset->unique);
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
if (ipset->sock == client->sock)
@@ -853,8 +851,7 @@ void zsend_ipset_entry_notify_owner(struct zebra_pbr_ipset_entry *ipset,
struct stream *s;
if (IS_ZEBRA_DEBUG_PACKET)
- zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
- ipset->unique);
+ zlog_debug("%s: Notifying %u", __func__, ipset->unique);
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
if (ipset->sock == client->sock)
@@ -883,8 +880,7 @@ void zsend_iptable_notify_owner(struct zebra_pbr_iptable *iptable,
struct stream *s;
if (IS_ZEBRA_DEBUG_PACKET)
- zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__,
- iptable->unique);
+ zlog_debug("%s: Notifying %u", __func__, iptable->unique);
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
if (iptable->sock == client->sock)
@@ -2422,9 +2418,11 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
}
if (!(zpr.rule.filter.dst_ip.family == AF_INET
|| zpr.rule.filter.dst_ip.family == AF_INET6)) {
- zlog_warn("Unsupported PBR IP family: %s (%" PRIu8 ")",
- family2str(zpr.rule.filter.dst_ip.family),
- zpr.rule.filter.dst_ip.family);
+ zlog_warn(
+ "Unsupported PBR destination IP family: %s (%" PRIu8
+ ")",
+ family2str(zpr.rule.filter.dst_ip.family),
+ zpr.rule.filter.dst_ip.family);
return;
}
@@ -2514,6 +2512,23 @@ static inline void zread_ipset_entry(ZAPI_HANDLER_ARGS)
if (zpi.proto != 0)
zpi.filter_bm |= PBR_FILTER_PROTO;
+ if (!(zpi.dst.family == AF_INET
+ || zpi.dst.family == AF_INET6)) {
+ zlog_warn(
+ "Unsupported PBR destination IP family: %s (%" PRIu8
+ ")",
+ family2str(zpi.dst.family), zpi.dst.family);
+ goto stream_failure;
+ }
+ if (!(zpi.src.family == AF_INET
+ || zpi.src.family == AF_INET6)) {
+ zlog_warn(
+ "Unsupported PBR source IP family: %s (%" PRIu8
+ ")",
+ family2str(zpi.src.family), zpi.src.family);
+ goto stream_failure;
+ }
+
/* calculate backpointer */
zpi.backpointer =
zebra_pbr_lookup_ipset_pername(ipset.ipset_name);
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 5d0d0a48c3..459d2bc620 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -3331,7 +3331,7 @@ skip_one:
return 0;
}
-#if DPLANE_TEST_PROVIDER
+#ifdef DPLANE_TEST_PROVIDER
/*
* Test dataplane provider plugin
@@ -3415,7 +3415,7 @@ static void dplane_provider_init(void)
zlog_err("Unable to register kernel dplane provider: %d",
ret);
-#if DPLANE_TEST_PROVIDER
+#ifdef DPLANE_TEST_PROVIDER
/* Optional test provider ... */
ret = dplane_provider_register("Test",
DPLANE_PRIO_PRE_KERNEL,
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index d60da336fd..0d6428026a 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -300,8 +300,7 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,
return 1;
if (!re) {
- zfpm_debug("%s: Expected non-NULL re pointer",
- __PRETTY_FUNCTION__);
+ zfpm_debug("%s: Expected non-NULL re pointer", __func__);
return 0;
}
diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c
index bda1ad6b35..19a280c0ca 100644
--- a/zebra/zebra_gr.c
+++ b/zebra/zebra_gr.c
@@ -127,8 +127,7 @@ static void zebra_gr_client_info_delte(struct zserv *client,
THREAD_OFF(info->t_stale_removal);
- if (info->current_prefix)
- XFREE(MTYPE_TMP, info->current_prefix);
+ XFREE(MTYPE_TMP, info->current_prefix);
LOG_GR("%s: Instance info is being deleted for client %s", __func__,
zebra_route_string(client->proto));
diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c
index 5b721a8eac..8ba7998f50 100644
--- a/zebra/zebra_mlag.c
+++ b/zebra/zebra_mlag.c
@@ -322,7 +322,7 @@ static int zebra_mlag_post_data_from_main_thread(struct thread *thread)
STREAM_GETL(s, msg_type);
if (IS_ZEBRA_DEBUG_MLAG)
zlog_debug(
- "%s: Posting MLAG data for msg_type:0x%x to interested cleints",
+ "%s: Posting MLAG data for msg_type:0x%x to interested clients",
__func__, msg_type);
msg_len = s->endp - ZEBRA_MLAG_METADATA_LEN;
@@ -364,7 +364,7 @@ stream_failure:
/*
* Start the MLAG Thread, this will be used to write client data on to
- * MLAG Process and to read the data from MLAG and post to cleints.
+ * MLAG Process and to read the data from MLAG and post to clients.
* when all clients are un-registered, this Thread will be
* suspended.
*/
@@ -667,14 +667,17 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
int n_len = 0;
int rc = 0;
char buf[ZLOG_FILTER_LENGTH_MAX];
+ size_t length;
if (IS_ZEBRA_DEBUG_MLAG)
zlog_debug("%s: Entering..", __func__);
- rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg);
+ rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg, &length);
if (rc)
return rc;
+ memset(tmp_buf, 0, ZEBRA_MLAG_BUF_LIMIT);
+
if (IS_ZEBRA_DEBUG_MLAG)
zlog_debug("%s: Mlag ProtoBuf encoding of message:%s, len:%d",
__func__,
@@ -688,9 +691,10 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
ZebraMlagMrouteAdd pay_load = ZEBRA_MLAG_MROUTE_ADD__INIT;
uint32_t vrf_name_len = 0;
- rc = mlag_lib_decode_mroute_add(s, &msg);
+ rc = mlag_lib_decode_mroute_add(s, &msg, &length);
if (rc)
return rc;
+
vrf_name_len = strlen(msg.vrf_name) + 1;
pay_load.vrf_name = XMALLOC(MTYPE_MLAG_PBUF, vrf_name_len);
strlcpy(pay_load.vrf_name, msg.vrf_name, vrf_name_len);
@@ -720,7 +724,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
ZebraMlagMrouteDel pay_load = ZEBRA_MLAG_MROUTE_DEL__INIT;
uint32_t vrf_name_len = 0;
- rc = mlag_lib_decode_mroute_del(s, &msg);
+ rc = mlag_lib_decode_mroute_del(s, &msg, &length);
if (rc)
return rc;
vrf_name_len = strlen(msg.vrf_name) + 1;
@@ -749,18 +753,18 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
ZebraMlagMrouteAddBulk Bulk_msg =
ZEBRA_MLAG_MROUTE_ADD_BULK__INIT;
ZebraMlagMrouteAdd **pay_load = NULL;
- int i;
bool cleanup = false;
+ uint32_t i, actual;
Bulk_msg.n_mroute_add = mlag_msg.msg_cnt;
pay_load = XMALLOC(MTYPE_MLAG_PBUF, sizeof(ZebraMlagMrouteAdd *)
* mlag_msg.msg_cnt);
- for (i = 0; i < mlag_msg.msg_cnt; i++) {
+ for (i = 0, actual = 0; i < mlag_msg.msg_cnt; i++, actual++) {
uint32_t vrf_name_len = 0;
- rc = mlag_lib_decode_mroute_add(s, &msg);
+ rc = mlag_lib_decode_mroute_add(s, &msg, &length);
if (rc) {
cleanup = true;
break;
@@ -796,7 +800,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
tmp_buf);
}
- for (i = 0; i < mlag_msg.msg_cnt; i++) {
+ for (i = 0; i < actual; i++) {
+ /*
+ * The mlag_lib_decode_mroute_add can
+ * fail to properly decode and cause nothing
+ * to be allocated. Prevent a crash
+ */
+ if (!pay_load[i])
+ continue;
+
XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE
&& pay_load[i]->intf_name)
@@ -812,18 +824,18 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
ZebraMlagMrouteDelBulk Bulk_msg =
ZEBRA_MLAG_MROUTE_DEL_BULK__INIT;
ZebraMlagMrouteDel **pay_load = NULL;
- int i;
bool cleanup = false;
+ uint32_t i, actual;
Bulk_msg.n_mroute_del = mlag_msg.msg_cnt;
pay_load = XMALLOC(MTYPE_MLAG_PBUF, sizeof(ZebraMlagMrouteDel *)
* mlag_msg.msg_cnt);
- for (i = 0; i < mlag_msg.msg_cnt; i++) {
+ for (i = 0, actual = 0; i < mlag_msg.msg_cnt; i++, actual++) {
uint32_t vrf_name_len = 0;
- rc = mlag_lib_decode_mroute_del(s, &msg);
+ rc = mlag_lib_decode_mroute_del(s, &msg, &length);
if (rc) {
cleanup = true;
break;
@@ -858,7 +870,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
tmp_buf);
}
- for (i = 0; i < mlag_msg.msg_cnt; i++) {
+ for (i = 0; i < actual; i++) {
+ /*
+ * The mlag_lib_decode_mroute_add can
+ * fail to properly decode and cause nothing
+ * to be allocated. Prevent a crash
+ */
+ if (!pay_load[i])
+ continue;
+
XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE
&& pay_load[i]->intf_name)
@@ -915,6 +935,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
return len;
}
+static void zebra_fill_protobuf_msg(struct stream *s, char *name, int len)
+{
+ int str_len = strlen(name) + 1;
+
+ stream_put(s, name, str_len);
+ /* Fill the rest with Null Character for aligning */
+ stream_put(s, NULL, len - str_len);
+}
+
int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
uint32_t len)
{
@@ -966,7 +995,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
/* No Batching */
stream_putw(s, MLAG_MSG_NO_BATCH);
/* Actual Data */
- stream_put(s, msg->peerlink, INTERFACE_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->peerlink,
+ INTERFACE_NAMSIZ);
stream_putl(s, msg->my_role);
stream_putl(s, msg->peer_state);
zebra_mlag_status_update__free_unpacked(msg, NULL);
@@ -1003,7 +1033,7 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
/* No Batching */
stream_putw(s, MLAG_MSG_NO_BATCH);
/* Actual Data */
- stream_put(s, msg->vrf_name, VRF_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->vrf_name, VRF_NAMSIZ);
stream_putl(s, msg->source_ip);
stream_putl(s, msg->group_ip);
@@ -1013,7 +1043,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
stream_putc(s, msg->am_i_dual_active);
stream_putl(s, msg->vrf_id);
if (msg->owner_id == MLAG_OWNER_INTERFACE)
- stream_put(s, msg->intf_name, INTERFACE_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->intf_name,
+ INTERFACE_NAMSIZ);
else
stream_put(s, NULL, INTERFACE_NAMSIZ);
zebra_mlag_mroute_add__free_unpacked(msg, NULL);
@@ -1032,15 +1063,15 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
/* No Batching */
stream_putw(s, MLAG_MSG_NO_BATCH);
/* Actual Data */
- stream_put(s, msg->vrf_name, VRF_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->vrf_name, VRF_NAMSIZ);
stream_putl(s, msg->source_ip);
stream_putl(s, msg->group_ip);
- stream_putl(s, msg->group_ip);
stream_putl(s, msg->owner_id);
stream_putl(s, msg->vrf_id);
if (msg->owner_id == MLAG_OWNER_INTERFACE)
- stream_put(s, msg->intf_name, INTERFACE_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->intf_name,
+ INTERFACE_NAMSIZ);
else
stream_put(s, NULL, INTERFACE_NAMSIZ);
zebra_mlag_mroute_del__free_unpacked(msg, NULL);
@@ -1067,7 +1098,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
msg = Bulk_msg->mroute_add[i];
- stream_put(s, msg->vrf_name, VRF_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->vrf_name,
+ VRF_NAMSIZ);
stream_putl(s, msg->source_ip);
stream_putl(s, msg->group_ip);
stream_putl(s, msg->cost_to_rp);
@@ -1076,8 +1108,9 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
stream_putc(s, msg->am_i_dual_active);
stream_putl(s, msg->vrf_id);
if (msg->owner_id == MLAG_OWNER_INTERFACE)
- stream_put(s, msg->intf_name,
- INTERFACE_NAMSIZ);
+ zebra_fill_protobuf_msg(
+ s, msg->intf_name,
+ INTERFACE_NAMSIZ);
else
stream_put(s, NULL, INTERFACE_NAMSIZ);
}
@@ -1106,14 +1139,16 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data,
msg = Bulk_msg->mroute_del[i];
- stream_put(s, msg->vrf_name, VRF_NAMSIZ);
+ zebra_fill_protobuf_msg(s, msg->vrf_name,
+ VRF_NAMSIZ);
stream_putl(s, msg->source_ip);
stream_putl(s, msg->group_ip);
stream_putl(s, msg->owner_id);
stream_putl(s, msg->vrf_id);
if (msg->owner_id == MLAG_OWNER_INTERFACE)
- stream_put(s, msg->intf_name,
- INTERFACE_NAMSIZ);
+ zebra_fill_protobuf_msg(
+ s, msg->intf_name,
+ INTERFACE_NAMSIZ);
else
stream_put(s, NULL, INTERFACE_NAMSIZ);
}
diff --git a/zebra/zebra_mlag.h b/zebra/zebra_mlag.h
index c35fa15561..d44a400666 100644
--- a/zebra/zebra_mlag.h
+++ b/zebra/zebra_mlag.h
@@ -46,6 +46,7 @@ extern uint32_t mlag_rd_buf_offset;
static inline void zebra_mlag_reset_read_buffer(void)
{
+ memset(mlag_wr_buffer, 0, ZEBRA_MLAG_BUF_LIMIT);
mlag_rd_buf_offset = 0;
}
diff --git a/zebra/zebra_mlag_private.c b/zebra/zebra_mlag_private.c
index 3024407ada..0f0285ed31 100644
--- a/zebra/zebra_mlag_private.c
+++ b/zebra/zebra_mlag_private.c
@@ -78,6 +78,8 @@ static int zebra_mlag_read(struct thread *thread)
uint32_t h_msglen;
uint32_t tot_len, curr_len = mlag_rd_buf_offset;
+ zrouter.mlag_info.t_read = NULL;
+
/*
* Received message in sock_stream looks like below
* | len-1 (4 Bytes) | payload-1 (len-1) |
@@ -157,8 +159,6 @@ static int zebra_mlag_read(struct thread *thread)
static int zebra_mlag_connect(struct thread *thread)
{
struct sockaddr_un svr = {0};
- struct ucred ucred;
- socklen_t len = 0;
/* Reset the Timer-running flag */
zrouter.mlag_info.timer_running = false;
@@ -182,11 +182,8 @@ static int zebra_mlag_connect(struct thread *thread)
&zrouter.mlag_info.t_read);
return 0;
}
- len = sizeof(struct ucred);
- ucred.pid = getpid();
set_nonblocking(mlag_socket);
- setsockopt(mlag_socket, SOL_SOCKET, SO_PEERCRED, &ucred, len);
if (IS_ZEBRA_DEBUG_MLAG)
zlog_debug("%s: Connection with MLAG is established ",
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 097dd7f024..f0d43756b5 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -687,9 +687,9 @@ static struct nh_grp *nhg_ctx_get_grp(struct nhg_ctx *ctx)
return ctx->u.grp;
}
-static struct nhg_ctx *nhg_ctx_new()
+static struct nhg_ctx *nhg_ctx_new(void)
{
- struct nhg_ctx *new = NULL;
+ struct nhg_ctx *new;
new = XCALLOC(MTYPE_NHG_CTX, sizeof(struct nhg_ctx));
@@ -1193,12 +1193,6 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
assert(nhg->nexthop);
vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nhg->nexthop->vrf_id;
- if (!(nhg && nhg->nexthop)) {
- flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
- "No nexthop passed to %s", __func__);
- return NULL;
- }
-
zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, 0);
return nhe;
@@ -1418,7 +1412,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Onlink and interface: %u[%u] does not exist",
- __PRETTY_FUNCTION__, nexthop->ifindex,
+ __func__, nexthop->ifindex,
nexthop->vrf_id);
return 0;
}
@@ -1429,14 +1423,14 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Onlink and interface %s is not operative",
- __PRETTY_FUNCTION__, ifp->name);
+ __func__, ifp->name);
return 0;
}
if (!if_is_operative(ifp)) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Interface %s is not unnumbered",
- __PRETTY_FUNCTION__, ifp->name);
+ __func__, ifp->name);
return 0;
}
}
@@ -1448,7 +1442,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t:%s: Attempting to install a max prefixlength route through itself",
- __PRETTY_FUNCTION__);
+ __func__);
return 0;
}
@@ -1475,8 +1469,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
zvrf = zebra_vrf_lookup_by_id(nexthop->vrf_id);
if (!table || !zvrf) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- zlog_debug("\t%s: Table not found",
- __PRETTY_FUNCTION__);
+ zlog_debug("\t%s: Table not found", __func__);
return 0;
}
@@ -1495,7 +1488,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Matched against ourself and prefix length is not max bit length",
- __PRETTY_FUNCTION__);
+ __func__);
return 0;
}
@@ -1508,7 +1501,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t:%s: Resolved against default route",
- __PRETTY_FUNCTION__);
+ __func__);
return 0;
}
@@ -1560,7 +1553,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (!resolved && IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("\t%s: Recursion failed to find",
- __PRETTY_FUNCTION__);
+ __func__);
return resolved;
} else if (re->type == ZEBRA_ROUTE_STATIC) {
resolved = 0;
@@ -1582,14 +1575,13 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (!resolved && IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Static route unable to resolve",
- __PRETTY_FUNCTION__);
+ __func__);
return resolved;
} else {
if (IS_ZEBRA_DEBUG_RIB_DETAILED) {
zlog_debug(
"\t%s: Route Type %s has not turned on recursion",
- __PRETTY_FUNCTION__,
- zebra_route_string(re->type));
+ __func__, zebra_route_string(re->type));
if (re->type == ZEBRA_ROUTE_BGP
&& !CHECK_FLAG(re->flags, ZEBRA_FLAG_IBGP))
zlog_debug(
@@ -1599,8 +1591,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
}
}
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- zlog_debug("\t%s: Nexthop did not lookup in table",
- __PRETTY_FUNCTION__);
+ zlog_debug("\t%s: Nexthop did not lookup in table", __func__);
return 0;
}
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index a11f428b57..6728567e6e 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -710,7 +710,7 @@ void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)
XFREE(MTYPE_TMP, lookup);
} else
zlog_debug("%s: IPTable being deleted we know nothing about",
- __PRETTY_FUNCTION__);
+ __func__);
}
/*
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 35a4db3064..6cfc68eb74 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -643,8 +643,8 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,
char buf[PREFIX_STRLEN];
char buf1[PREFIX_STRLEN];
- zlog_debug("%s: %u:%s Possible Match to %s",
- __PRETTY_FUNCTION__, rnh->vrf_id,
+ zlog_debug("%s: %u:%s Possible Match to %s", __func__,
+ rnh->vrf_id,
prefix2str(&rnh->node->p, buf, sizeof(buf)),
srcdest_rnode2str(rn, buf1, sizeof(buf)));
}
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 2963d83828..500c2c84a1 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1793,6 +1793,15 @@ static void zebra_route_map_set_delay_timer(uint32_t value)
}
}
+void zebra_routemap_finish(void)
+{
+ /* Set zebra_rmap_update_timer to 0 so that it wont schedule again */
+ zebra_rmap_update_timer = 0;
+ /* Thread off if any scheduled already */
+ THREAD_TIMER_OFF(zebra_t_rmap_update);
+ route_map_finish();
+}
+
void zebra_route_map_write_delay_timer(struct vty *vty)
{
if (vty && (zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER))
diff --git a/zebra/zebra_routemap.h b/zebra/zebra_routemap.h
index 6a630e1ac0..56e805ea03 100644
--- a/zebra/zebra_routemap.h
+++ b/zebra/zebra_routemap.h
@@ -56,4 +56,5 @@ zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p,
}
#endif
+extern void zebra_routemap_finish(void);
#endif
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index bf6c63cb63..ccc6e9e46b 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -241,25 +241,13 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
vty_out(vty, "\n");
time_t uptime;
- struct tm tm;
uptime = monotime(NULL);
uptime -= re->uptime;
- gmtime_r(&uptime, &tm);
- vty_out(vty, " Last update ");
+ frrtime_to_interval(uptime, buf, sizeof(buf));
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7),
- tm.tm_hour);
- vty_out(vty, " ago\n");
+ vty_out(vty, " Last update %s ago\n", buf);
if (show_ng)
vty_out(vty, " Nexthop Group ID: %u\n", re->nhe_id);
@@ -286,7 +274,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out(vty, " %s",
inet_ntop(AF_INET6, &nexthop->gate.ipv6,
- buf, sizeof buf));
+ buf, sizeof(buf)));
if (nexthop->ifindex)
vty_out(vty, ", via %s",
ifindex2ifname(
@@ -348,7 +336,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
if (nexthop->src.ipv4.s_addr) {
if (inet_ntop(AF_INET,
&nexthop->src.ipv4,
- addrstr, sizeof addrstr))
+ addrstr, sizeof(addrstr)))
vty_out(vty, ", src %s",
addrstr);
}
@@ -359,7 +347,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
&in6addr_any)) {
if (inet_ntop(AF_INET6,
&nexthop->src.ipv6,
- addrstr, sizeof addrstr))
+ addrstr, sizeof(addrstr)))
vty_out(vty, ", src %s",
addrstr);
}
@@ -378,7 +366,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
mpls_label2str(
nexthop->nh_label->num_labels,
nexthop->nh_label->label, buf,
- sizeof buf, 1));
+ sizeof(buf), 1));
}
if (nexthop->weight)
@@ -402,14 +390,15 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object *json_route = NULL;
json_object *json_labels = NULL;
time_t uptime;
- struct tm tm;
struct vrf *vrf = NULL;
rib_dest_t *dest = rib_dest_from_rnode(rn);
struct nexthop_group *nhg;
+ char up_str[MONOTIME_STRLEN];
uptime = monotime(NULL);
uptime -= re->uptime;
- gmtime_r(&uptime, &tm);
+
+ frrtime_to_interval(uptime, up_str, sizeof(up_str));
/* If showing fib information, use the fib view of the
* nexthops.
@@ -424,7 +413,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_nexthops = json_object_new_array();
json_object_string_add(json_route, "prefix",
- srcdest_rnode2str(rn, buf, sizeof buf));
+ srcdest_rnode2str(rn, buf, sizeof(buf)));
json_object_string_add(json_route, "protocol",
zebra_route_string(re->type));
@@ -474,18 +463,8 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_int_add(json_route, "internalNextHopActiveNum",
nexthop_group_active_nexthop_num(
&(re->nhe->nhg)));
- if (uptime < ONE_DAY_SECOND)
- sprintf(buf, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- sprintf(buf, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- sprintf(buf, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7),
- tm.tm_hour);
- json_object_string_add(json_route, "uptime", buf);
+ json_object_string_add(json_route, "uptime", up_str);
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
json_nexthop = json_object_new_object();
@@ -526,7 +505,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
json_object_string_add(
json_nexthop, "ip",
inet_ntop(AF_INET6, &nexthop->gate.ipv6,
- buf, sizeof buf));
+ buf, sizeof(buf)));
json_object_string_add(json_nexthop, "afi",
"ipv6");
@@ -606,7 +585,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (nexthop->src.ipv4.s_addr) {
if (inet_ntop(AF_INET,
&nexthop->src.ipv4, buf,
- sizeof buf))
+ sizeof(buf)))
json_object_string_add(
json_nexthop, "source",
buf);
@@ -618,7 +597,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
&in6addr_any)) {
if (inet_ntop(AF_INET6,
&nexthop->src.ipv6, buf,
- sizeof buf))
+ sizeof(buf)))
json_object_string_add(
json_nexthop, "source",
buf);
@@ -667,7 +646,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
? '>'
: ' ',
re_status_output_char(re, nexthop),
- srcdest_rnode2str(rn, buf, sizeof buf));
+ srcdest_rnode2str(rn, buf, sizeof(buf)));
/* Distance and metric display. */
if (((re->type == ZEBRA_ROUTE_CONNECT) &&
@@ -694,7 +673,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out(vty, " via %s",
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf,
- sizeof buf));
+ sizeof(buf)));
if (nexthop->ifindex)
vty_out(vty, ", %s",
ifindex2ifname(nexthop->ifindex,
@@ -750,7 +729,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
case NEXTHOP_TYPE_IPV4_IFINDEX:
if (nexthop->src.ipv4.s_addr) {
if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf,
- sizeof buf))
+ sizeof(buf)))
vty_out(vty, ", src %s", buf);
}
break;
@@ -758,7 +737,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
case NEXTHOP_TYPE_IPV6_IFINDEX:
if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) {
if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf,
- sizeof buf))
+ sizeof(buf)))
vty_out(vty, ", src %s", buf);
}
break;
@@ -771,20 +750,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
vty_out(vty, ", label %s",
mpls_label2str(nexthop->nh_label->num_labels,
nexthop->nh_label->label, buf,
- sizeof buf, 1));
+ sizeof(buf), 1));
}
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, ", %02d:%02d:%02d", tm.tm_hour,
- tm.tm_min, tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, ", %dd%02dh%02dm", tm.tm_yday,
- tm.tm_hour, tm.tm_min);
- else
- vty_out(vty, ", %02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7),
- tm.tm_hour);
- vty_out(vty, "\n");
+ vty_out(vty, ", %s\n", up_str);
}
}
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index caff99dbe2..61865e5baf 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -443,12 +443,11 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE)) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "%s: duplicate addr MAC %s flags 0x%x skip update to client, learn count %u recover time %u",
- __PRETTY_FUNCTION__,
- prefix_mac2str(&mac->macaddr, buf,
- sizeof(buf)),
- mac->flags, mac->dad_count,
- zvrf->dad_freeze_time);
+ "%s: duplicate addr MAC %s flags 0x%x skip update to client, learn count %u recover time %u",
+ __func__,
+ prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
+ mac->flags, mac->dad_count,
+ zvrf->dad_freeze_time);
/* For duplicate MAC do not update
* client but update neigh due to
@@ -479,11 +478,10 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
if (reset_params) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "%s: duplicate addr MAC %s flags 0x%x detection time passed, reset learn count %u"
- , __PRETTY_FUNCTION__,
- prefix_mac2str(&mac->macaddr, buf,
- sizeof(buf)),
- mac->flags, mac->dad_count);
+ "%s: duplicate addr MAC %s flags 0x%x detection time passed, reset learn count %u",
+ __func__,
+ prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
+ mac->flags, mac->dad_count);
mac->dad_count = 0;
/* Start dup. addr detection (DAD) start time,
@@ -547,8 +545,8 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,
if (zvrf->dad_freeze && zvrf->dad_freeze_time) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "%s: duplicate addr MAC %s flags 0x%x auto recovery time %u start"
- , __PRETTY_FUNCTION__,
+ "%s: duplicate addr MAC %s flags 0x%x auto recovery time %u start",
+ __func__,
prefix_mac2str(&mac->macaddr, buf,
sizeof(buf)),
mac->flags, zvrf->dad_freeze_time);
@@ -7790,6 +7788,52 @@ stream_failure:
}
/*
+ * Handle remote vtep delete by kernel; re-add the vtep if we have it
+ */
+int zebra_vxlan_check_readd_vtep(struct interface *ifp,
+ struct in_addr vtep_ip)
+{
+ struct zebra_if *zif;
+ struct zebra_vrf *zvrf = NULL;
+ struct zebra_l2info_vxlan *vxl;
+ vni_t vni;
+ zebra_vni_t *zvni = NULL;
+ zebra_vtep_t *zvtep = NULL;
+
+ zif = ifp->info;
+ assert(zif);
+ vxl = &zif->l2info.vxl;
+ vni = vxl->vni;
+
+ /* If EVPN is not enabled, nothing to do. */
+ if (!is_evpn_enabled())
+ return 0;
+
+ /* Locate VRF corresponding to interface. */
+ zvrf = vrf_info_lookup(ifp->vrf_id);
+ if (!zvrf)
+ return -1;
+
+ /* Locate hash entry; it is expected to exist. */
+ zvni = zvni_lookup(vni);
+ if (!zvni)
+ return 0;
+
+ /* If the remote vtep entry doesn't exists nothing to do */
+ zvtep = zvni_vtep_find(zvni, &vtep_ip);
+ if (!zvtep)
+ return 0;
+
+ if (IS_ZEBRA_DEBUG_VXLAN)
+ zlog_debug(
+ "Del MAC for remote VTEP %s intf %s(%u) VNI %u - readd",
+ inet_ntoa(vtep_ip), ifp->name, ifp->ifindex, vni);
+
+ zvni_vtep_install(zvni, zvtep);
+ return 0;
+}
+
+/*
* Handle notification of MAC add/update over VxLAN. If the kernel is notifying
* us, this must involve a multihoming scenario. Treat this as implicit delete
* of any prior local MAC.
@@ -9787,12 +9831,11 @@ static int zebra_vxlan_dad_mac_auto_recovery_exp(struct thread *t)
return 0;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("%s: duplicate addr mac %s flags 0x%x learn count %u host count %u auto recovery expired",
- __PRETTY_FUNCTION__,
- prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
- mac->flags,
- mac->dad_count,
- listcount(mac->neigh_list));
+ zlog_debug(
+ "%s: duplicate addr mac %s flags 0x%x learn count %u host count %u auto recovery expired",
+ __func__,
+ prefix_mac2str(&mac->macaddr, buf, sizeof(buf)),
+ mac->flags, mac->dad_count, listcount(mac->neigh_list));
/* Remove all IPs as duplicate associcated with this MAC */
for (ALL_LIST_ELEMENTS_RO(mac->neigh_list, node, nbr)) {
diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h
index b551ba8dff..6ca93f6cb6 100644
--- a/zebra/zebra_vxlan.h
+++ b/zebra/zebra_vxlan.h
@@ -183,6 +183,8 @@ extern int zebra_vxlan_check_readd_remote_mac(struct interface *ifp,
extern int zebra_vxlan_check_del_local_mac(struct interface *ifp,
struct interface *br_if,
struct ethaddr *mac, vlanid_t vid);
+extern int zebra_vxlan_check_readd_vtep(struct interface *ifp,
+ struct in_addr vtep_ip);
extern int zebra_vxlan_if_up(struct interface *ifp);
extern int zebra_vxlan_if_down(struct interface *ifp);
extern int zebra_vxlan_if_add(struct interface *ifp);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 40aa9010c5..7f806d82c3 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -858,7 +858,6 @@ void zserv_event(struct zserv *client, enum zserv_event event)
#define ZEBRA_TIME_BUF 32
static char *zserv_time_buf(time_t *time1, char *buf, int buflen)
{
- struct tm tm;
time_t now;
assert(buf != NULL);
@@ -872,17 +871,9 @@ static char *zserv_time_buf(time_t *time1, char *buf, int buflen)
now = monotime(NULL);
now -= *time1;
- gmtime_r(&now, &tm);
-
- if (now < ONE_DAY_SECOND)
- snprintf(buf, buflen, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (now < ONE_WEEK_SECOND)
- snprintf(buf, buflen, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- snprintf(buf, buflen, "%02dw%dd%02dh", tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);
+
+ frrtime_to_interval(now, buf, buflen);
+
return buf;
}
@@ -1001,8 +992,6 @@ static void zebra_show_stale_client_detail(struct vty *vty,
struct zserv *client)
{
char buf[PREFIX2STR_BUFFER];
- struct tm tm;
- struct timeval tv;
time_t uptime;
struct client_gr_info *info = NULL;
struct zserv *s = NULL;
@@ -1028,26 +1017,13 @@ static void zebra_show_stale_client_detail(struct vty *vty,
if (ZEBRA_CLIENT_GR_ENABLED(info->capabilities)) {
if (info->stale_client_ptr) {
s = (struct zserv *)(info->stale_client_ptr);
- uptime = monotime(&tv);
+ uptime = monotime(NULL);
uptime -= s->restart_time;
- gmtime_r(&uptime, &tm);
-
- vty_out(vty, "Last restart time : ");
- if (uptime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d",
- tm.tm_hour, tm.tm_min,
- tm.tm_sec);
- else if (uptime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm",
- tm.tm_yday, tm.tm_hour,
- tm.tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh",
- tm.tm_yday / 7,
- tm.tm_yday - ((tm.tm_yday / 7)
- * 7),
- tm.tm_hour);
- vty_out(vty, " ago\n");
+
+ frrtime_to_interval(uptime, buf, sizeof(buf));
+
+ vty_out(vty, "Last restart time : %s ago\n",
+ buf);
vty_out(vty, "Stalepath removal time: %d sec\n",
info->stale_removal_time);