read/write and timer thread. */
void bgp_fsm_change_status(struct peer *peer, int status)
{
+ struct bgp *bgp;
+ uint32_t peer_count;
bgp_dump_state(peer, peer->status, status);
+ bgp = peer->bgp;
+ peer_count = bgp->established_peers;
+
+ if (status == Established)
+ bgp->established_peers++;
+ else if ((peer->status == Established) && (status != Established))
+ bgp->established_peers--;
+
+ if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS))
+ zlog_debug("%s : vrf %u, established_peers %u", __func__,
+ bgp->vrf_id, bgp->established_peers);
+ /* Set to router ID to the value provided by RIB if there are no peers
+ * in the established state and peer count did not change
+ */
+ if ((peer_count != bgp->established_peers) &&
+ (bgp->established_peers == 0))
+ bgp_router_id_zebra_bump(bgp->vrf_id, NULL);
+
/* Transition into Clearing or Deleted must /always/ clear all routes..
* (and must do so before actually changing into Deleted..
*/
{
struct listnode *node, *nnode;
struct bgp *bgp;
+ struct in_addr *addr = NULL;
+
+ if (router_id != NULL)
+ addr = (struct in_addr *)&(router_id->u.prefix4);
if (vrf_id == VRF_DEFAULT) {
/* Router-id change for default VRF has to also update all
if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
continue;
- bgp->router_id_zebra = router_id->u.prefix4;
- if (!bgp->router_id_static.s_addr)
- bgp_router_id_set(bgp, &router_id->u.prefix4);
+ if (addr)
+ bgp->router_id_zebra = *addr;
+ else
+ addr = &bgp->router_id_zebra;
+
+ if (!bgp->router_id_static.s_addr) {
+ /* Router ID is updated if there are no active
+ * peer sessions
+ */
+ if (bgp->established_peers == 0) {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("RID change : vrf %u, RTR ID %s",
+ bgp->vrf_id, inet_ntoa(*addr));
+ bgp_router_id_set(bgp, addr);
+ }
+ }
}
} else {
bgp = bgp_lookup_by_vrf_id(vrf_id);
if (bgp) {
- bgp->router_id_zebra = router_id->u.prefix4;
+ if (addr)
+ bgp->router_id_zebra = *addr;
+ else
+ addr = &bgp->router_id_zebra;
+
+ if (!bgp->router_id_static.s_addr) {
+ /* Router ID is updated if there are no active
+ * peer sessions
+ */
+ if (bgp->established_peers == 0) {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("RID change : vrf %u, RTR ID %s",
+ bgp->vrf_id, inet_ntoa(*addr));
+ bgp_router_id_set(bgp, addr);
+ }
+ }
- if (!bgp->router_id_static.s_addr)
- bgp_router_id_set(bgp, &router_id->u.prefix4);
}
}
}
/* local esi hash table */
struct hash *esihash;
+ /* Count of peers in established state */
+ uint32_t established_peers;
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(bgp)
struct thread *t_process_packet;
/* Thread flags. */
- _Atomic uint16_t thread_flags;
+ _Atomic uint32_t thread_flags;
#define PEER_THREAD_WRITES_ON (1 << 0)
#define PEER_THREAD_READS_ON (1 << 1)
#define PEER_THREAD_KEEPALIVES_ON (1 << 2)
/* For benefit of rfapi */
extern struct peer *peer_new(struct bgp *bgp);
-
#endif /* _QUAGGA_BGPD_H */
while (!skiplist_next(f->neighbors, NULL, (void **)&n, &cursor)) {
n->present = true;
- struct isis_lsp *lsp = lsp_for_vertex(f->spftree, n->vertex);
- if (!lsp || !lsp->tlvs || !lsp->tlvs->spine_leaf)
- continue;
-
- if (!lsp->tlvs->spine_leaf->has_tier
- || lsp->tlvs->spine_leaf->tier != 0)
+ struct isis_lsp *node_lsp = lsp_for_vertex(f->spftree,
+ n->vertex);
+ if (!node_lsp
+ || !node_lsp->tlvs
+ || !node_lsp->tlvs->spine_leaf
+ || !node_lsp->tlvs->spine_leaf->has_tier
+ || node_lsp->tlvs->spine_leaf->tier != 0) {
continue;
+ }
if (isis->debugs & DEBUG_FABRICD_FLOODING) {
zlog_debug("Moving %s to DNR because it's T0",
- rawlspid_print(lsp->hdr.lsp_id));
+ rawlspid_print(node_lsp->hdr.lsp_id));
}
move_to_dnr(lsp, n);
if (seqno > lsp->hdr.seqno
|| (seqno == lsp->hdr.seqno
&& ((lsp->hdr.rem_lifetime != 0 && rem_lifetime == 0)
- || lsp->hdr.checksum != checksum))) {
+ || (lsp->hdr.checksum != checksum
+ && lsp->hdr.rem_lifetime)))) {
if (isis->debugs & DEBUG_SNP_PACKETS) {
zlog_debug(
"ISIS-Snp (%s): Compare LSP %s seq 0x%08" PRIx32
* is
* "greater" than that held by S, ... */
- if (hdr.seqno > lsp->hdr.seqno) {
+ if (comp == LSP_NEWER) {
/* 7.3.16.1 */
lsp_inc_seqno(lsp, hdr.seqno);
- if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ if (isis->debugs & DEBUG_UPDATE_PACKETS) {
zlog_debug(
"ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08" PRIx32,
circuit->area->area_tag,
rawlspid_print(hdr.lsp_id),
lsp->hdr.seqno);
+ }
+ lsp_flood(lsp, NULL);
+ } else if (comp == LSP_EQUAL) {
+ isis_tx_queue_del(circuit->tx_queue, lsp);
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_SET_FLAG(lsp->SSNflags, circuit);
+ } else {
+ isis_tx_queue_add(circuit->tx_queue, lsp,
+ TX_LSP_NORMAL);
+ ISIS_CLEAR_FLAG(lsp->SSNflags, circuit);
}
- /* If the received LSP is older or equal,
- * resend the LSP which will act as ACK */
- lsp_flood(lsp, NULL);
} else {
/* 7.3.15.1 e) - This lsp originated on another system */
_Atomic unsigned long total, max;
} real;
struct time_stats cpu;
- _Atomic uint8_t types;
+ _Atomic uint32_t types;
const char *funcname;
};
ERROR("NONSTANDARD_INTEGRAL_TYPES",
"Please, no nonstandard integer types in new code.\n" . $herecurr)
}
+
+# check for usage of non-32 bit atomics
+ if ($line =~ /_Atomic [u]?int(?!32)[0-9]+_t/) {
+ WARN("NON_32BIT_ATOMIC",
+ "Please, only use 32 bit atomics.\n" . $herecurr);
+ }
+
}
# If we have no input at all, then there is nothing to report on
dplane_provider_fini_fp dp_fini;
- _Atomic uint64_t dp_in_counter;
- _Atomic uint64_t dp_error_counter;
+ _Atomic uint32_t dp_in_counter;
+ _Atomic uint32_t dp_error_counter;
/* Embedded list linkage */
TAILQ_ENTRY(zebra_dplane_provider) dp_q_providers;
/* Limit number of pending, unprocessed updates */
_Atomic uint32_t dg_max_queued_updates;
- _Atomic uint64_t dg_routes_in;
+ _Atomic uint32_t dg_routes_in;
_Atomic uint32_t dg_routes_queued;
_Atomic uint32_t dg_routes_queued_max;
- _Atomic uint64_t dg_route_errors;
+ _Atomic uint32_t dg_route_errors;
/* Event-delivery context 'master' for the dplane */
struct thread_master *dg_master;
char cbuf[ZEBRA_TIME_BUF], rbuf[ZEBRA_TIME_BUF];
char wbuf[ZEBRA_TIME_BUF], nhbuf[ZEBRA_TIME_BUF], mbuf[ZEBRA_TIME_BUF];
time_t connect_time, last_read_time, last_write_time;
- uint16_t last_read_cmd, last_write_cmd;
+ uint32_t last_read_cmd, last_write_cmd;
vty_out(vty, "Client: %s", zebra_route_string(client->proto));
if (client->instance)
/* monotime of last message sent */
_Atomic uint32_t last_write_time;
/* command code of last message read */
- _Atomic uint16_t last_read_cmd;
+ _Atomic uint32_t last_read_cmd;
/* command code of last message written */
- _Atomic uint16_t last_write_cmd;
+ _Atomic uint32_t last_write_cmd;
};
#define ZAPI_HANDLER_ARGS \