diff options
author | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-09-28 02:14:22 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-12-22 02:26:10 +0100 |
commit | 0d4f730c5877c3f71395055f19f2672197b5af48 (patch) | |
tree | 4680a456f622e918d10cb5783046e589f05154b9 | |
parent | pimd: Add debug wrapping around rp nexthop lookup (diff) | |
download | frr-0d4f730c5877c3f71395055f19f2672197b5af48.tar.xz frr-0d4f730c5877c3f71395055f19f2672197b5af48.zip |
pimd: sort qpim_channel_oil_list and qpim_upstream_list
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
This allows "show ip mroute" and "show ip pim upstream" to display the
groups in order.
-rw-r--r-- | pimd/pim_oil.c | 2 | ||||
-rw-r--r-- | pimd/pim_upstream.c | 2 | ||||
-rw-r--r-- | pimd/pimd.c | 38 |
3 files changed, 40 insertions, 2 deletions
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index e09dc3f08..9728d6304 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -77,7 +77,7 @@ pim_add_channel_oil (struct prefix_sg *sg, c_oil->oil_ref_count = 1; c_oil->installed = 0; - listnode_add(qpim_channel_oil_list, c_oil); + listnode_add_sort(qpim_channel_oil_list, c_oil); return c_oil; } diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 64fffa385..eb69f6345 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -520,7 +520,7 @@ static struct pim_upstream *pim_upstream_new(struct prefix_sg *sg, return NULL; } - listnode_add(qpim_upstream_list, up); + listnode_add_sort(qpim_upstream_list, up); return up; } diff --git a/pimd/pimd.c b/pimd/pimd.c index dff3f75ae..3a010e81a 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -98,6 +98,42 @@ static void pim_free() pim_route_map_terminate(); } +static int +pim_channel_oil_compare (struct channel_oil *c1, struct channel_oil *c2) +{ + if (ntohl(c1->oil.mfcc_mcastgrp.s_addr) < ntohl(c2->oil.mfcc_mcastgrp.s_addr)) + return -1; + + if (ntohl(c1->oil.mfcc_mcastgrp.s_addr) > ntohl(c2->oil.mfcc_mcastgrp.s_addr)) + return 1; + + if (ntohl(c1->oil.mfcc_origin.s_addr) < ntohl(c2->oil.mfcc_origin.s_addr)) + return -1; + + if (ntohl(c1->oil.mfcc_origin.s_addr) > ntohl(c2->oil.mfcc_origin.s_addr)) + return 1; + + return 0; +} + +static int +pim_upstream_compare (struct pim_upstream *up1, struct pim_upstream *up2) +{ + if (ntohl(up1->sg.grp.s_addr) < ntohl(up2->sg.grp.s_addr)) + return -1; + + if (ntohl(up1->sg.grp.s_addr) > ntohl(up2->sg.grp.s_addr)) + return 1; + + if (ntohl(up1->sg.src.s_addr) < ntohl(up2->sg.src.s_addr)) + return -1; + + if (ntohl(up1->sg.src.s_addr) > ntohl(up2->sg.src.s_addr)) + return 1; + + return 0; +} + void pim_init() { srandom(time(NULL)); @@ -121,6 +157,7 @@ void pim_init() return; } qpim_channel_oil_list->del = (void (*)(void *)) pim_channel_oil_free; + qpim_channel_oil_list->cmp = (int (*)(void *, void *)) pim_channel_oil_compare; qpim_upstream_list = list_new(); if (!qpim_upstream_list) { @@ -130,6 +167,7 @@ void pim_init() return; } qpim_upstream_list->del = (void (*)(void *)) pim_upstream_free; + qpim_upstream_list->cmp = (int (*)(void *, void *)) pim_upstream_compare; qpim_static_route_list = list_new(); if (!qpim_static_route_list) { |