Skip to content

Commit

Permalink
bgpd: bgp_sync_label_manager failure case
Browse files Browse the repository at this point in the history
There are several problems with the bgp_sync_label_manager
function:

a) It is possible that a request in the lp->requests
fifo will be unable to be filled at this point in time
and the lf will be leaked and not ever fullfilled.

b) The bgp_sync_label_manager runs one time a second
irrelevant if there is work to do or not.

To fix (a) just add the request back to the requests
fifo and set the timer to pop in the future.

To fix (b) just every time something is put into
the request pool start a timer to run in 1 second
and do not restart it if all the work is done.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Jan 7, 2024
1 parent 4e249eb commit 02049ff
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bgpd/bgp_labelpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ static void lptest_init(void);
static void lptest_finish(void);
#endif

static void bgp_sync_label_manager(struct event *e);

/*
* Remember where pool data are kept
*/
Expand Down Expand Up @@ -455,6 +457,9 @@ void bgp_lp_get(
if ((lp->next_chunksize << 1) <= LP_CHUNK_SIZE_MAX)
lp->next_chunksize <<= 1;
}

event_add_timer(bm->master, bgp_sync_label_manager, NULL, 1,
&bm->t_bgp_sync_label_manager);
}

void bgp_lp_release(
Expand Down Expand Up @@ -557,6 +562,10 @@ static void bgp_sync_label_manager(struct event *e)
zlog_debug("%s: out of labels, await more",
__func__);
}

lp_fifo_add_tail(&lp->requests, lf);
event_add_timer(bm->master, bgp_sync_label_manager,
NULL, 1, &bm->t_bgp_sync_label_manager);
break;
}

Expand All @@ -582,9 +591,6 @@ static void bgp_sync_label_manager(struct event *e)
finishedrequest:
XFREE(MTYPE_BGP_LABEL_FIFO, lf);
}

event_add_timer(bm->master, bgp_sync_label_manager, NULL, 1,
&bm->t_bgp_sync_label_manager);
}

void bgp_lp_event_chunk(uint32_t first, uint32_t last)
Expand Down

0 comments on commit 02049ff

Please sign in to comment.