diff options
Diffstat (limited to 'ldpd/adjacency.c')
| -rw-r--r-- | ldpd/adjacency.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 2e7b43296a..8659202ee4 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -41,6 +41,16 @@ RB_GENERATE(tnbr_head, tnbr, entry, tnbr_compare) static __inline int adj_compare(struct adj *a, struct adj *b) { + if (adj_get_af(a) < adj_get_af(b)) + return (-1); + if (adj_get_af(a) > adj_get_af(b)) + return (1); + + if (ntohl(a->lsr_id.s_addr) < ntohl(b->lsr_id.s_addr)) + return (-1); + if (ntohl(a->lsr_id.s_addr) > ntohl(b->lsr_id.s_addr)) + return (1); + if (a->source.type < b->source.type) return (-1); if (a->source.type > b->source.type) @@ -54,21 +64,13 @@ adj_compare(struct adj *a, struct adj *b) if (strcmp(a->source.link.ia->iface->name, b->source.link.ia->iface->name) > 0) return (1); - if (a->source.link.ia->af < b->source.link.ia->af) - return (-1); - if (a->source.link.ia->af > b->source.link.ia->af) - return (1); return (ldp_addrcmp(a->source.link.ia->af, &a->source.link.src_addr, &b->source.link.src_addr)); case HELLO_TARGETED: - if (a->source.target->af < b->source.target->af) - return (-1); - if (a->source.target->af > b->source.target->af) - return (1); return (ldp_addrcmp(a->source.target->af, &a->source.target->addr, &b->source.target->addr)); default: - fatalx("adj_get_af: unknown hello type"); + fatalx("adj_compare: unknown hello type"); } return (0); @@ -150,9 +152,10 @@ adj_del(struct adj *adj, uint32_t notif_status) } struct adj * -adj_find(struct hello_source *source) +adj_find(struct in_addr lsr_id, struct hello_source *source) { struct adj adj; + adj.lsr_id = lsr_id; adj.source = *source; return (RB_FIND(global_adj_head, &global.adj_tree, &adj)); } @@ -372,13 +375,17 @@ adj_to_ctl(struct adj *adj) case HELLO_LINK: memcpy(actl.ifname, adj->source.link.ia->iface->name, sizeof(actl.ifname)); + actl.src_addr = adj->source.link.src_addr; break; case HELLO_TARGETED: actl.src_addr = adj->source.target->addr; break; } actl.holdtime = adj->holdtime; + actl.holdtime_remaining = + thread_timer_remain_second(adj->inactivity_timer); actl.trans_addr = adj->trans_addr; + actl.ds_tlv = adj->ds_tlv; return (&actl); } |
