bgpd, zebra: Use next hop tracking for connected routes too
Allow next hop tracking to work with connected routes
And cleanup obsolete code in bgp_scan and bgp_import.
Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Edits: Paul Jakma <paul.jakma@hpe.com> Rebase re-ordering conflicts with
NHT route-map, potential errors.
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 4f1838a..d84a865 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -42,6 +42,7 @@
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_dump.h"
#include "bgpd/bgp_open.h"
+#include "bgpd/bgp_nht.h"
#ifdef HAVE_SNMP
#include "bgpd/bgp_snmp.h"
#endif /* HAVE_SNMP */
@@ -675,6 +676,7 @@
bgp_start (struct peer *peer)
{
int status;
+ int connected = 0;
if (BGP_PEER_START_SUPPRESSED (peer))
{
@@ -713,6 +715,12 @@
return 0;
}
+ /* Register to be notified on peer up */
+ if ((peer->ttl == 1) || (peer->gtsm_hops == 1))
+ connected = 1;
+
+ bgp_find_or_add_nexthop(family2afi(peer->su.sa.sa_family), NULL, peer,
+ connected);
status = bgp_connect (peer);
switch (status)
@@ -939,6 +947,45 @@
return 0;
}
+void
+bgp_fsm_nht_update(struct peer *peer, int valid)
+{
+ int ret = 0;
+
+ if (!peer)
+ return;
+
+ switch (peer->status)
+ {
+ case Idle:
+ if (valid)
+ BGP_EVENT_ADD(peer, BGP_Start);
+ break;
+ case Connect:
+ ret = bgp_connect_check(peer, 0);
+ if (!ret && valid)
+ {
+ BGP_TIMER_OFF(peer->t_connect);
+ BGP_EVENT_ADD(peer, ConnectRetry_timer_expired);
+ }
+ break;
+ case Active:
+ if (valid)
+ {
+ BGP_TIMER_OFF(peer->t_connect);
+ BGP_EVENT_ADD(peer, ConnectRetry_timer_expired);
+ }
+ case OpenSent:
+ case OpenConfirm:
+ case Established:
+ case Clearing:
+ case Deleted:
+ default:
+ break;
+ }
+}
+
+
/* Finite State Machine structure */
static const struct {
int (*func) (struct peer *);