diff options
author | Sander Vrijders <[email protected]> | 2017-09-27 15:33:39 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-09-29 15:12:36 +0200 |
commit | e3dba5812b1422a79e6e77ce9f923bade5a480e4 (patch) | |
tree | ca538ff9fd4887a17f85556e8207412d9699c833 /src/ipcpd/normal/pol/link_state.c | |
parent | ddba836eb79ace3bd80ea6af69801f402cbffd20 (diff) | |
download | ouroboros-e3dba5812b1422a79e6e77ce9f923bade5a480e4.tar.gz ouroboros-e3dba5812b1422a79e6e77ce9f923bade5a480e4.zip |
ipcpd: normal: Add Loop-Free Alternates routing
This adds the Loop-Free Alternates (LFA) policy. In case a link goes
down a LFA may be selected to route the SDUs on without causing loops
instead of the main hop that just went down.
Diffstat (limited to 'src/ipcpd/normal/pol/link_state.c')
-rw-r--r-- | src/ipcpd/normal/pol/link_state.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c index 51d317bc..6330cf81 100644 --- a/src/ipcpd/normal/pol/link_state.c +++ b/src/ipcpd/normal/pol/link_state.c @@ -89,6 +89,10 @@ struct nb { enum nb_type type; }; +typedef int (* rtable_fn_t)(struct graph * graph, + uint64_t s_addr, + struct list_head * table); + struct { struct list_head nbs; fset_t * mgmt_set; @@ -103,6 +107,8 @@ struct { pthread_t lsupdate; pthread_t lsreader; pthread_t listener; + + rtable_fn_t rtable; } ls; struct pol_routing_ops link_state_ops = { @@ -388,7 +394,7 @@ static void * calculate_pff(void * o) instance = (struct routing_i *) o; while (true) { - if (graph_routing_table(ls.graph, ipcpi.dt_addr, &table)) { + if (ls.rtable(ls.graph, ipcpi.dt_addr, &table)) { sleep(RECALC_TIME); continue; } @@ -664,7 +670,7 @@ void link_state_routing_i_destroy(struct routing_i * instance) free(instance); } -int link_state_init(void) +int link_state_init(enum pol_routing pr) { struct conn_info info; @@ -676,6 +682,17 @@ int link_state_init(void) info.pref_syntax = PROTO_GPB; info.addr = ipcpi.dt_addr; + switch (pr) { + case ROUTING_LINK_STATE: + ls.rtable = graph_routing_table; + break; + case ROUTING_LINK_STATE_LFA: + ls.rtable = graph_routing_table_lfa; + break; + default: + goto fail_graph; + } + ls.graph = graph_create(); if (ls.graph == NULL) goto fail_graph; |