summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/pol/link_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/normal/pol/link_state.c')
-rw-r--r--src/ipcpd/normal/pol/link_state.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c
index 26370682..51d317bc 100644
--- a/src/ipcpd/normal/pol/link_state.c
+++ b/src/ipcpd/normal/pol/link_state.c
@@ -378,19 +378,17 @@ static int nbr_to_fd(uint64_t addr)
static void * calculate_pff(void * o)
{
- struct routing_i * instance;
- struct routing_table ** table;
- ssize_t n_table;
- int i;
- int fd;
+ struct routing_i * instance;
+ int fd;
+ struct list_head table;
+ struct list_head * p;
+ struct list_head * q;
+ int fds[AP_MAX_FLOWS];
instance = (struct routing_i *) o;
while (true) {
- table = NULL;
- n_table = graph_routing_table(ls.graph,
- ipcpi.dt_addr, &table);
- if (n_table < 0) {
+ if (graph_routing_table(ls.graph, ipcpi.dt_addr, &table)) {
sleep(RECALC_TIME);
continue;
}
@@ -399,17 +397,29 @@ static void * calculate_pff(void * o)
pff_flush(instance->pff);
- for (i = 0; i < n_table; i++) {
- fd = nbr_to_fd(table[i]->nhop);
- if (fd == -1)
- continue;
+ list_for_each(p, &table) {
+ int i = 0;
+ struct routing_table * t =
+ list_entry(p, struct routing_table, next);
+
+ list_for_each(q, &t->nhops) {
+ struct nhop * n =
+ list_entry(q, struct nhop, next);
+
+ fd = nbr_to_fd(n->nhop);
+ if (fd == -1)
+ continue;
- pff_add(instance->pff, table[i]->dst, &fd, 1);
+ fds[i++] = fd;
+ }
+
+ pff_add(instance->pff, t->dst, fds, i);
}
pff_unlock(instance->pff);
- freepp(struct routing_table, table, n_table);
+ graph_free_routing_table(ls.graph, &table);
+
sleep(RECALC_TIME);
}
@@ -465,7 +475,7 @@ static void * lsupdate(void * o)
adj->src, adj->dst);
if (graph_del_edge(ls.graph, adj->src,
adj->dst))
- log_dbg("Failed to delete edge.");
+ log_err("Failed to del edge.");
free(adj);
continue;
}