Merge pull request #1158 from opensourcerouting/ldpd-label-allocation

ldpd label allocation
This commit is contained in:
Donald Sharp 2017-09-13 12:24:14 -04:00 committed by GitHub
commit 8ce42777bc
5 changed files with 28 additions and 6 deletions

View File

@ -1609,7 +1609,6 @@ static void
zclient_sync_init(u_short instance)
{
/* Initialize special zclient for synchronous message exchanges. */
log_debug("Initializing synchronous zclient for label manager");
zclient_sync = zclient_new(master);
zclient_sync->sock = -1;
zclient_sync->redist_default = ZEBRA_ROUTE_LDP;
@ -1640,7 +1639,7 @@ lde_get_label_chunk(void)
int ret;
uint32_t start, end;
log_debug("Getting label chunk");
debug_labels("getting label chunk (size %u)", CHUNK_SIZE);
ret = lm_get_label_chunk(zclient_sync, 0, CHUNK_SIZE, &start, &end);
if (ret < 0) {
log_warnx("Error getting label chunk!");
@ -1670,7 +1669,7 @@ on_get_label_chunk_response(uint32_t start, uint32_t end)
{
struct label_chunk *new_label_chunk;
log_debug("Label Chunk assign: %u - %u", start, end);
debug_labels("label chunk assign: %u - %u", start, end);
new_label_chunk = calloc(1, sizeof(struct label_chunk));
if (!new_label_chunk) {
@ -1693,7 +1692,8 @@ static uint32_t
lde_get_next_label(void)
{
struct label_chunk *label_chunk;
uint32_t i, pos, size;
uint32_t i, size;
uint64_t pos;
uint32_t label = NO_LABEL;
while (current_label_chunk) {

View File

@ -66,6 +66,11 @@ ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
DEBUG_OFF(event, EVENT);
else
DEBUG_ON(event, EVENT);
} else if (strcmp(type_str, "labels") == 0) {
if (negate)
DEBUG_OFF(labels, LABELS);
else
DEBUG_ON(labels, LABELS);
} else if (strcmp(type_str, "messages") == 0) {
if (dir_str == NULL)
return (CMD_WARNING_CONFIG_FAILED);
@ -115,6 +120,8 @@ ldp_vty_show_debugging(struct vty *vty)
vty_out (vty, " LDP errors debugging is on\n");
if (LDP_DEBUG(event, EVENT))
vty_out (vty, " LDP events debugging is on\n");
if (LDP_DEBUG(labels, LABELS))
vty_out (vty, " LDP labels debugging is on\n");
if (LDP_DEBUG(msg, MSG_RECV_ALL))
vty_out (vty,
" LDP detailed messages debugging is on (inbound)\n");
@ -157,6 +164,11 @@ ldp_debug_config_write(struct vty *vty)
write = 1;
}
if (CONF_LDP_DEBUG(labels, LABELS)) {
vty_out (vty, "debug mpls ldp labels\n");
write = 1;
}
if (CONF_LDP_DEBUG(msg, MSG_RECV_ALL)) {
vty_out (vty, "debug mpls ldp messages recv all\n");
write = 1;

View File

@ -31,6 +31,9 @@ struct ldp_debug {
int event;
#define LDP_DEBUG_EVENT 0x01
int labels;
#define LDP_DEBUG_LABELS 0x01
int msg;
#define LDP_DEBUG_MSG_RECV 0x01
#define LDP_DEBUG_MSG_RECV_ALL 0x02
@ -90,6 +93,12 @@ do { \
log_debug("event: " emsg, __VA_ARGS__); \
} while (0)
#define debug_labels(emsg, ...) \
do { \
if (LDP_DEBUG(labels, LABELS)) \
log_debug("labels: " emsg, __VA_ARGS__); \
} while (0)
#define debug_msg_recv(emsg, ...) \
do { \
if (LDP_DEBUG(msg, MSG_RECV)) \

View File

@ -538,13 +538,14 @@ DEFPY (ldp_debug_mpls_ldp_discovery_hello,
DEFPY (ldp_debug_mpls_ldp_type,
ldp_debug_mpls_ldp_type_cmd,
"[no] debug mpls ldp <errors|event|zebra>$type",
"[no] debug mpls ldp <errors|event|labels|zebra>$type",
NO_STR
"Debugging functions\n"
"MPLS information\n"
"Label Distribution Protocol\n"
"Errors\n"
"LDP event information\n"
"LDP label allocation information\n"
"LDP zebra information\n")
{
return (ldp_vty_debug(vty, no, type, NULL, NULL));

View File

@ -370,9 +370,9 @@ main(int argc, char *argv[])
if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf))
fatal("could not establish imsg links");
main_imsg_compose_both(IMSG_INIT, &init, sizeof(init));
main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
sizeof(ldp_debug));
main_imsg_compose_both(IMSG_INIT, &init, sizeof(init));
main_imsg_send_config(ldpd_conf);
if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)