]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #3368 from pacovn/static_analysis__ISO_C_empty_initializer
authorRenato Westphal <renato@openbsd.org>
Wed, 21 Nov 2018 16:14:45 +0000 (14:14 -0200)
committerGitHub <noreply@github.com>
Wed, 21 Nov 2018 16:14:45 +0000 (14:14 -0200)
isisd lib ospfd pbrd python: fix empty init

bgpd/bgp_fsm.c
bgpd/bgpd.c
bgpd/bgpd.h
isisd/fabricd.c
isisd/isis_lsp.c
isisd/isis_pdu.c
lib/thread.h
tools/checkpatch.pl
zebra/zebra_dplane.c
zebra/zserv.c
zebra/zserv.h

index 1f0cfd6e257e92ce815f9bf14ceccce8430fdfa6..b70c8bbd631cb88b2cf55b12838185ade095d858 100644 (file)
@@ -935,9 +935,29 @@ static void bgp_update_delay_process_status_change(struct peer *peer)
    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..
         */
index a078c4f58743b8c7065f241556709a109941cc7e..48a3b1bb0902a9bfe27cd62bb3ffaf1e3d416cde 100644 (file)
@@ -274,6 +274,10 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
 {
        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
@@ -282,17 +286,43 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)
                        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);
                }
        }
 }
index 70193104b41b30dc85aaa273d1a1ac2acf1e17a1..725fe1ac9bca9f14b4f0b22afa386ee90023023b 100644 (file)
@@ -542,6 +542,9 @@ struct bgp {
        /* local esi hash table */
        struct hash *esihash;
 
+       /* Count of peers in established state */
+       uint32_t established_peers;
+
        QOBJ_FIELDS
 };
 DECLARE_QOBJ_TYPE(bgp)
@@ -1004,7 +1007,7 @@ struct peer {
        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)
@@ -1886,5 +1889,4 @@ extern void bgp_update_redist_vrf_bitmaps(struct bgp *, vrf_id_t);
 
 /* For benefit of rfapi */
 extern struct peer *peer_new(struct bgp *bgp);
-
 #endif /* _QUAGGA_BGPD_H */
index 76c8087f2d8331b14bfffee89a2552cd88adadaa..2b3116b1ff19fd107d4f69c31b7cf1db1903f7a4 100644 (file)
@@ -585,17 +585,19 @@ void fabricd_lsp_flood(struct isis_lsp *lsp)
        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);
index 38239d5919ccc9fec89aaa1981d810da63e994a9..9a57d0d0ac2f522cba654e01bb40e9ac10873257 100644 (file)
@@ -253,7 +253,8 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
        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
index f0aa52463d46370f14d267dd6e05d15a8595fcbe..7df152f1fabdb366a7e0d60b81523a54d4b0a66f 100644 (file)
@@ -1011,19 +1011,26 @@ dontcheckadj:
                 * 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 */
 
index 70090cf7841447b4146cc0747aca95d9dba09ba6..4de9a65562ab13895c760325d06e278e52bc7421 100644 (file)
@@ -125,7 +125,7 @@ struct cpu_thread_history {
                _Atomic unsigned long total, max;
        } real;
        struct time_stats cpu;
-       _Atomic uint8_t types;
+       _Atomic uint32_t types;
        const char *funcname;
 };
 
index 22354c1e882b72478a5e31ce6db1dac89fa22794..547a4b21370e4ca01157eb49855545b1045d5b4f 100755 (executable)
@@ -6367,6 +6367,13 @@ sub process {
                        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
index 61eba92c98f59b235e0e1f7ddc9918d91425712f..3e61418b6486638c834c21869147b49b39a24dab 100644 (file)
@@ -135,8 +135,8 @@ struct zebra_dplane_provider {
 
        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;
@@ -171,10 +171,10 @@ static struct zebra_dplane_globals {
        /* 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;
index 3c3bf4077b745bb8a41f2f51a61406625fd7ca9f..b40e9e2af51fff8688d09ba9a7fd3bd2e5d68f0a 100644 (file)
@@ -875,7 +875,7 @@ static void zebra_show_client_detail(struct vty *vty, struct zserv *client)
        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)
index f21ea17fe884d1fe3d63b5afd4f54b489d7bc611..f7967f54f00b18e6afa5da7b5e4db12950ad21bd 100644 (file)
@@ -157,9 +157,9 @@ struct zserv {
        /* 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                                                      \