mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 16:20:08 +00:00
ldpd: change the sorting algorithm of adjacencies
Now the "show mpls ldp discovery" command will display all LDP adjancencies sorted by address family, neighbor ID and then type (link or targeted). Example: vtysh# show mpls ldp discovery AF ID Type Source Holdtime ipv4 3.3.3.3 Link rt2-eth1 15 ipv4 3.3.3.3 Link rt2-eth2 15 ipv4 4.4.4.4 Link rt2-eth1 15 ipv6 1.1.1.1 Link rt2-eth0 15 ipv6 3.3.3.3 Link rt2-eth1 15 ipv6 3.3.3.3 Link rt2-eth2 15 ipv6 4.4.4.4 Link rt2-eth1 15 Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
99cfc17f76
commit
f272562731
@ -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));
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
|
||||
source.link.src_addr = *src;
|
||||
}
|
||||
|
||||
adj = adj_find(&source);
|
||||
adj = adj_find(lsr_id, &source);
|
||||
nbr = nbr_find_ldpid(lsr_id.s_addr);
|
||||
|
||||
/* check dual-stack tlv */
|
||||
|
@ -232,7 +232,7 @@ in_addr_t if_get_ipv4_addr(struct iface *);
|
||||
struct adj *adj_new(struct in_addr, struct hello_source *,
|
||||
union ldpd_addr *);
|
||||
void adj_del(struct adj *, uint32_t);
|
||||
struct adj *adj_find(struct hello_source *);
|
||||
struct adj *adj_find(struct in_addr, struct hello_source *);
|
||||
int adj_get_af(struct adj *adj);
|
||||
void adj_start_itimer(struct adj *);
|
||||
void adj_stop_itimer(struct adj *);
|
||||
|
Loading…
Reference in New Issue
Block a user