summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/pol
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-05-03 14:33:46 +0200
committerDimitri Staessens <dimitri.staessens@ugent.be>2018-05-03 17:53:09 +0200
commit8295c3628f70c1db342860ff1e79fc7056557739 (patch)
tree96327895f17f4a528020f31e7410d57f4588037d /src/ipcpd/normal/pol
parent04aa4e185cbd7d165bcd2f5855f624bc0569d24b (diff)
downloadouroboros-8295c3628f70c1db342860ff1e79fc7056557739.tar.gz
ouroboros-8295c3628f70c1db342860ff1e79fc7056557739.zip
ipcpd: Recalculate PFF upon adding new neighbor
This recalculates the PFF upon adding a new neighbor, so that the network reconverges faster. It is safe to do so since it is only done by the two IPCPs that established the new flow. The PFF is also recalculated every 4 seconds. Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be> Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Diffstat (limited to 'src/ipcpd/normal/pol')
-rw-r--r--src/ipcpd/normal/pol/link_state.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c
index cfe4faff..91c18a9d 100644
--- a/src/ipcpd/normal/pol/link_state.c
+++ b/src/ipcpd/normal/pol/link_state.c
@@ -459,50 +459,49 @@ static int nbr_to_fd(uint64_t addr)
return -1;
}
-static void * calculate_pff(void * o)
+static void calculate_pff(struct routing_i * instance)
{
- struct routing_i * instance;
int fd;
struct list_head table;
struct list_head * p;
struct list_head * q;
int fds[PROG_MAX_FLOWS];
- instance = (struct routing_i *) o;
+ if (ls.rtable(ls.graph, ipcpi.dt_addr, &table))
+ return;
- while (true) {
- if (ls.rtable(ls.graph, ipcpi.dt_addr, &table)) {
- sleep(RECALC_TIME);
- continue;
- }
-
- pff_lock(instance->pff);
-
- pff_flush(instance->pff);
+ pff_lock(instance->pff);
- list_for_each(p, &table) {
- int i = 0;
- struct routing_table * t =
- list_entry(p, struct routing_table, next);
+ pff_flush(instance->pff);
- list_for_each(q, &t->nhops) {
- struct nhop * n =
- list_entry(q, struct nhop, next);
+ /* Calulcate forwarding table from routing table. */
+ list_for_each(p, &table) {
+ int i = 0;
+ struct routing_table * t =
+ list_entry(p, struct routing_table, next);
- fd = nbr_to_fd(n->nhop);
- if (fd == -1)
- continue;
+ list_for_each(q, &t->nhops) {
+ struct nhop * n = list_entry(q, struct nhop, next);
- fds[i++] = fd;
- }
+ fd = nbr_to_fd(n->nhop);
+ if (fd == -1)
+ continue;
- pff_add(instance->pff, t->dst, fds, i);
+ fds[i++] = fd;
}
- pff_unlock(instance->pff);
+ pff_add(instance->pff, t->dst, fds, i);
+ }
- graph_free_routing_table(ls.graph, &table);
+ pff_unlock(instance->pff);
+ graph_free_routing_table(ls.graph, &table);
+}
+
+static void * periodic_recalc_pff(void * o)
+{
+ while (true) {
+ calculate_pff((struct routing_i *) o);
sleep(RECALC_TIME);
}
@@ -723,9 +722,10 @@ static void handle_event(void * self,
const void * o)
{
/* FIXME: Apply correct QoS on graph */
- struct conn * c;
- qosspec_t qs;
- int flags;
+ struct conn * c;
+ qosspec_t qs;
+ int flags;
+ struct list_head * p;
(void) self;
@@ -740,7 +740,17 @@ static void handle_event(void * self,
if (lsdb_add_link(ipcpi.dt_addr, c->conn_info.addr, &qs))
log_dbg("Failed to add adjacency to LSDB.");
+
send_lsm(ipcpi.dt_addr, c->conn_info.addr);
+
+ pthread_mutex_lock(&ls.routing_i_lock);
+ list_for_each(p, &ls.routing_instances) {
+ struct routing_i * instance =
+ list_entry(p, struct routing_i, next);
+ calculate_pff(instance);
+ }
+ pthread_mutex_unlock(&ls.routing_i_lock);
+
break;
case NOTIFY_DT_CONN_DEL:
flow_event(c->flow_info.fd, false);
@@ -792,7 +802,8 @@ struct routing_i * link_state_routing_i_create(struct pff * pff)
tmp->pff = pff;
- if (pthread_create(&tmp->calculator, NULL, calculate_pff, tmp)) {
+ if (pthread_create(&tmp->calculator, NULL,
+ periodic_recalc_pff, tmp)) {
free(tmp);
return NULL;
}