Skip to content

Commit

Permalink
Issue #83: Add first iteration of debugging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ydahhrk committed Jul 21, 2022
1 parent 03d5536 commit dfc2955
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/rtr/db/db_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ add_roa_deltas(struct hashable_roa *roas1, struct hashable_roa *roas2,
return 0;
}

void
find_bad_vrp(char const *prefix, struct db_table *table)
{
struct hashable_roa *cursor;
struct hashable_roa *tmp;
uint8_t family;

if (table == NULL)
return;

HASH_ITER(hh, table->roas, cursor, tmp) {
family = cursor->data.addr_fam;
if (family != AF_INET && family != AF_INET6) {
pr_val_err("%s: VRP corrupted!", prefix);
return;
}
}
}

static int
add_router_key_delta(struct deltas *deltas, struct hashable_key *key, int op)
{
Expand Down
2 changes: 2 additions & 0 deletions src/rtr/db/db_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ int rtrhandler_handle_router_key(struct db_table *, unsigned char const *,
uint32_t, unsigned char const *);
int compute_deltas(struct db_table *, struct db_table *, struct deltas **);

void find_bad_vrp(char const *, struct db_table *);

#endif /* SRC_RTR_DB_DB_TABLE_H_ */
9 changes: 8 additions & 1 deletion src/rtr/db/delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ deltas_add_roa(struct deltas *deltas, struct vrp const *vrp, int op)
struct delta_v4 v4;
struct delta_v6 v6;
} delta;
char buffer[INET6_ADDRSTRLEN];

switch (vrp->addr_fam) {
case AF_INET:
Expand All @@ -139,7 +140,13 @@ deltas_add_roa(struct deltas *deltas, struct vrp const *vrp, int op)
return deltas_v6_add(get_deltas_array6(deltas, op), &delta.v6);
}

pr_crit("Unknown protocol: %d", vrp->addr_fam);
pr_val_err("Unknown protocol: [%u %s/%u-%u %u]",
vrp->asn,
addr2str6(&vrp->prefix.v6, buffer),
vrp->prefix_length,
vrp->max_prefix_length,
vrp->addr_fam);
return 0;
}

int
Expand Down
5 changes: 5 additions & 0 deletions src/rtr/db/vrps.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,20 @@ __vrps_update(bool *notify_clients)
if (notify_clients)
*notify_clients = false;
old_base = state.base;
find_bad_vrp("Old base", old_base);
new_base = NULL;

error = __perform_standalone_validation(&new_base);
if (error)
return error;
find_bad_vrp("After standalone", new_base);

error = slurm_apply(new_base, &state.slurm);
if (error) {
db_table_destroy(new_base);
return error;
}
find_bad_vrp("After SLURM", new_base);

/*
* At this point, new_base is completely valid. Even if we error out
Expand All @@ -280,6 +284,7 @@ __vrps_update(bool *notify_clients)
* duplicate ROAs.
*/
output_print_data(new_base);
find_bad_vrp("After CSV", new_base);

error = __compute_deltas(old_base, new_base, notify_clients,
&new_deltas);
Expand Down

0 comments on commit dfc2955

Please sign in to comment.