]> git.proxmox.com Git - mirror_frr.git/commitdiff
bfdd: simplify code flow
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 13 Apr 2020 17:23:03 +0000 (14:23 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 14 Apr 2020 12:35:08 +0000 (09:35 -0300)
Don't attempt to handle out-of-memory situations: XMALLOC/XCALLOC will
`assert` if there is no memory left.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
bfdd/bfd.c
bfdd/bfdd_nb_config.c
bfdd/control.c
bfdd/ptm_adapter.c

index 80bfae632f08bca9c488966170e42847c8b61162..0d2c61ac7dafbe8988ea32d7803a5b0b755f99bd 100644 (file)
@@ -526,8 +526,7 @@ int bfd_session_update_label(struct bfd_session *bs, const char *nlabel)
                        return -1;
                }
 
-               if (pl_new(nlabel, bs) == NULL)
-                       return -1;
+               pl_new(nlabel, bs);
 
                return 0;
        }
@@ -685,10 +684,6 @@ struct bfd_session *ptm_bfd_sess_new(struct bfd_peer_cfg *bpc)
 
        /* Get BFD session storage with its defaults. */
        bfd = bfd_session_new();
-       if (bfd == NULL) {
-               zlog_err("session-new: allocation failed");
-               return NULL;
-       }
 
        /*
         * Store interface/VRF name in case we need to delay session
index c1123c4c330ebd38a50c17d6b141b4576fe77138..7b95bd23c6721201f763c4fe155d454ae459ab6a 100644 (file)
@@ -107,8 +107,6 @@ static int bfd_session_create(enum nb_event event, const struct lyd_node *dnode,
                }
 
                bs = bfd_session_new();
-               if (bs == NULL)
-                       return NB_ERR_RESOURCE;
 
                /* Fill the session key. */
                bfd_session_get_key(mhop, dnode, &bs->key);
index 4adc54a64a25011ab49358b59bd4b4320a19e427..3b954c64f823b0b35c9316e47891702384cc36a9 100644 (file)
@@ -168,8 +168,7 @@ int control_accept(struct thread *t)
                return 0;
        }
 
-       if (control_new(csock) == NULL)
-               close(csock);
+       control_new(csock);
 
        bglobal.bg_csockev = NULL;
        thread_add_read(master, control_accept, NULL, sd, &bglobal.bg_csockev);
@@ -334,8 +333,6 @@ static int control_queue_enqueue(struct bfd_control_socket *bcs,
        struct bfd_control_buffer *bcb;
 
        bcq = control_queue_new(bcs);
-       if (bcq == NULL)
-               return -1;
 
        bcb = &bcq->bcq_bcb;
        bcb->bcb_left = sizeof(struct bfd_control_msg) + ntohl(bcm->bcm_length);
@@ -656,8 +653,7 @@ static int notify_add_cb(struct bfd_peer_cfg *bpc, void *arg)
        if (bs == NULL)
                return -1;
 
-       if (control_notifypeer_new(bcs, bs) == NULL)
-               return -1;
+       control_notifypeer_new(bcs, bs);
 
        /* Notify peer status. */
        _control_notify(bcs, bs);
index 0f1c4d06c0683d172359b5bb034d9944f086ca9e..d3fb26c348cdaf98167b0376d54fbb58d365e1b3 100644 (file)
@@ -315,10 +315,6 @@ static int _ptm_msg_read(struct stream *msg, int command, vrf_id_t vrf_id,
        STREAM_GETL(msg, pid);
 
        *pc = pc_new(pid);
-       if (*pc == NULL) {
-               zlog_debug("ptm-read: failed to allocate memory");
-               return -1;
-       }
 
        /* Register/update peer information. */
        _ptm_msg_read_address(msg, &bpc->bpc_peer);
@@ -404,7 +400,6 @@ stream_failure:
 static void bfdd_dest_register(struct stream *msg, vrf_id_t vrf_id)
 {
        struct ptm_client *pc;
-       struct ptm_client_notification *pcn;
        struct bfd_session *bs;
        struct bfd_peer_cfg bpc;
 
@@ -432,11 +427,7 @@ static void bfdd_dest_register(struct stream *msg, vrf_id_t vrf_id)
        }
 
        /* Create client peer notification register. */
-       pcn = pcn_new(pc, bs);
-       if (pcn == NULL) {
-               zlog_err("ptm-add-dest: failed to registrate notifications");
-               return;
-       }
+       pcn_new(pc, bs);
 
        ptm_bfd_notify(bs, bs->ses_state);
 }
@@ -481,17 +472,12 @@ static void bfdd_dest_deregister(struct stream *msg, vrf_id_t vrf_id)
  */
 static void bfdd_client_register(struct stream *msg)
 {
-       struct ptm_client *pc;
        uint32_t pid;
 
        /* Find or allocate process context data. */
        STREAM_GETL(msg, pid);
 
-       pc = pc_new(pid);
-       if (pc == NULL) {
-               zlog_err("ptm-add-client: failed to register client: %u", pid);
-               return;
-       }
+       pc_new(pid);
 
        return;