Add prior hop SID to route print output

This commit is contained in:
Jeremy Lakeman 2016-03-02 10:33:19 +10:30
parent 518740bcf2
commit c1947cf774
7 changed files with 28 additions and 8 deletions

View File

@ -104,7 +104,9 @@ struct overlay_route_record{
sid_t sid;
char interface_name[256];
int reachable;
int hop_count;
sid_t neighbour;
sid_t prior_hop;
};
struct overlay_mdp_scan{

View File

@ -449,9 +449,10 @@ static int app_route_print(const struct cli_parsed *parsed, struct cli_context *
"Subscriber id",
"Routing flags",
"Interface",
"Next hop"
"Next hop",
"Prior hop"
};
cli_columns(context, 4, names);
cli_columns(context, 5, names);
size_t rowcount=0;
while(overlay_mdp_client_poll(mdp_sockfd, 200)){
@ -490,7 +491,14 @@ static int app_route_print(const struct cli_parsed *parsed, struct cli_context *
}
cli_put_string(context, strbuf_str(b), ":");
cli_put_string(context, p->interface_name, ":");
cli_put_string(context, alloca_tohex_sid_t(p->neighbour), "\n");
if (is_sid_t_any(p->neighbour))
cli_put_string(context, "", ":");
else
cli_put_string(context, alloca_tohex_sid_t(p->neighbour), ":");
if (is_sid_t_any(p->prior_hop))
cli_put_string(context, "", "\n");
else
cli_put_string(context, alloca_tohex_sid_t(p->prior_hop), "\n");
rowcount++;
}
}

View File

@ -72,6 +72,8 @@ struct subscriber{
// if indirect, who is the next hop?
struct subscriber *next_hop;
int hop_count;
struct subscriber *prior_hop;
// if direct, or unicast, where do we send packets?
struct network_destination *destination;
@ -117,7 +119,7 @@ struct subscriber *_find_subscriber(struct __sourceloc, const unsigned char *sid
#define find_subscriber(sid, len, create) _find_subscriber(__WHENCE__, sid, len, create)
void enum_subscribers(struct subscriber *start, int(*callback)(struct subscriber *, void *), void *context);
int set_reachable(struct subscriber *subscriber, struct network_destination *destination, struct subscriber *next_hop);
int set_reachable(struct subscriber *subscriber, struct network_destination *destination, struct subscriber *next_hop, int hop_count, struct subscriber *prior_hop);
struct network_destination *load_subscriber_address(struct subscriber *subscriber);
int process_explain(struct overlay_frame *frame);

View File

@ -30,7 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "route_link.h"
int set_reachable(struct subscriber *subscriber,
struct network_destination *destination, struct subscriber *next_hop){
struct network_destination *destination, struct subscriber *next_hop,
int hop_count, struct subscriber *prior_hop){
int reachable = REACHABLE_NONE;
if (destination)
@ -38,6 +39,9 @@ int set_reachable(struct subscriber *subscriber,
else if(next_hop)
reachable = REACHABLE_INDIRECT;
subscriber->hop_count = hop_count;
subscriber->prior_hop = prior_hop;
if (subscriber->reachable==reachable
&& subscriber->next_hop==next_hop
&& subscriber->destination == destination)

View File

@ -1142,9 +1142,13 @@ static int routing_table(struct subscriber *subscriber, void *context)
reply.out.payload_length=sizeof(struct overlay_route_record);
r->sid = subscriber->sid;
r->reachable = subscriber->reachable;
r->hop_count = subscriber->hop_count;
if (subscriber->reachable==REACHABLE_INDIRECT && subscriber->next_hop)
if (subscriber->next_hop)
r->neighbour = subscriber->next_hop->sid;
if (subscriber->prior_hop)
r->prior_hop = subscriber->prior_hop->sid;
if (subscriber->reachable & REACHABLE_DIRECT
&& subscriber->destination
&& subscriber->destination->interface)

View File

@ -455,7 +455,7 @@ next:
if (next_hop == subscriber)
next_hop = NULL;
if (set_reachable(subscriber, destination, next_hop))
if (set_reachable(subscriber, destination, next_hop, best_hop_count, transmitter))
changed = 1;
if (subscriber->identity && subscriber->reachable == REACHABLE_NONE){

View File

@ -44,7 +44,7 @@ link_matches() {
done
sid="$1"
tfw_log "Looking for link ${sid}, ${link_type}, ${interface_ex}, ${via}"
if ! $GREP "^${sid}:${link_type}:${interface_ex}:${via}\$" $_tfw_tmp/stdout; then
if ! $GREP "^${sid}:${link_type}:${interface_ex}:${via}:" $_tfw_tmp/stdout; then
tfw_log "Link not found"
return 1
fi