Skip to content

Commit

Permalink
Tilfa fix - Corner scenario missed.
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinites committed Jan 28, 2020
1 parent 4cb4e96 commit 17c20d3
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 14 deletions.
42 changes: 42 additions & 0 deletions sr-lea.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* =====================================================================================
*
* Filename: sr-lea.c
*
* Description:
*
* Version: 1.0
* Created: 01/28/2020 03:50:54 AM
* Revision: none
* Compiler: gcc
*
* Author: Er. Abhishek Sagar, Juniper Networks (https://csepracticals.wixsite.com/csepracticals), sachinites@gmail.com
* Company: Juniper Networks
*
* This file is part of the SPFComputation distribution (https://github.com/sachinites)
* Copyright (c) 2019 Abhishek Sagar.
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* visit website : https://csepracticals.wixsite.com/csepracticals for more courses and projects
*
* =====================================================================================
*/

/* Implementation of Segment Routing Label Enocding
* Algorithm - SR-LEA
* 2016 IEEE 15th International Symposium on Network Computing and Applications
* Rabah Guedrez Olivier Dugeon Samer Lahoud G´eraldine Texier Orange Labs
* */
#ifndef __SR_LEA__
#define __SR_LEA__




#endif /* __SR_LEA__ */
6 changes: 4 additions & 2 deletions testapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ extern instance_t * tilfa_topo_one_hop_test();
extern instance_t * tilfa_topo_p_q_distance_1();
extern instance_t * tilfa_topo_page_408_node_protection();
extern instance_t * tilfa_topo_2_adj_segment_example();
extern instance_t * tilfa_ecmp_topology();

/*Globals */
instance_t *instance = NULL;
Expand Down Expand Up @@ -88,10 +89,11 @@ main(int argc, char **argv){
//instance = multi_primary_nxt_hops();
//instance = one_hop_backup();
//instance = tilfa_topo_parallel_links();
instance = tilfa_topo_one_hop_test();
//instance = tilfa_topo_one_hop_test();
//instance = tilfa_topo_p_q_distance_1();
//instance = tilfa_topo_page_408_node_protection();
//instance = tilfa_topo_2_adj_segment_example();
instance = tilfa_topo_2_adj_segment_example();
//instance = tilfa_ecmp_topology();
start_shell();
return 0;
}
36 changes: 24 additions & 12 deletions tilfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,10 +1750,10 @@ tilfa_examine_tilfa_path_for_segment_list(
node_t *spf_root =
GET_PRED_INFO_NODE_FROM_GLTHREAD(spf_root_entry);

glthread_t *first_hop_node_entry = path->right->right;
glthread_t *first_hop_node_thread = path->right->right;

node_t *first_hop_node =
GET_PRED_INFO_NODE_FROM_GLTHREAD(first_hop_node_entry);
GET_PRED_INFO_NODE_FROM_GLTHREAD(first_hop_node_thread);

glthread_t *last_entry;
ITERATE_GLTHREAD_BEGIN(path, curr){
Expand Down Expand Up @@ -1783,7 +1783,7 @@ tilfa_examine_tilfa_path_for_segment_list(

curr_node = GET_PRED_INFO_NODE_FROM_GLTHREAD(last_entry);

while(last_entry != first_hop_node_entry){
while(last_entry != first_hop_node_thread){

if(search_for_q_node == TRUE &&
search_for_p_node == TRUE){
Expand Down Expand Up @@ -1909,29 +1909,41 @@ tilfa_examine_tilfa_path_for_segment_list(
}
else{
/* The direct nbr is not a p-node because Dest
* pre-c primary nexthop overlap with p-node's
* post-c primary nexthops*/
* pre-c primary nexthop overlap with p-node's
* post-c primary nexthops*/
pq_distance = -1;
}
}
else{
/*now test the current node for p-node*/
search_for_q_node = FALSE;
search_for_p_node = TRUE;
/*First hop node is not a q-node, step-back
* and test the last explored q node whether it
* was p-node or not*/
if(tilfa_p_node_qualification_test_wrt_root(
spf_root, curr_node, first_hop_node,
spf_root, GET_PRED_INFO_NODE_FROM_GLTHREAD(q_node),
first_hop_node,
dst_node, pr_res, level,
first_hop_segments)){

p_node = last_entry;
p_node = q_node;
search_for_p_node = FALSE;
pq_distance = 1;
pq_distance = 0;
goto TILFA_FOUND;
}
else{
/* The direct nbr is not a p-node because Dest
* pre-c primary nexthop overlap with p-node's
* post-c primary nexthops*/
pq_distance = -1;
/* Now we have to test if first_hop_node has a
* valid first hop segments or not*/
if(tilfa_p_node_qualification_test_wrt_root(
spf_root, first_hop_node, first_hop_node,
dst_node, pr_res,
level, first_hop_segments)){
search_for_p_node = FALSE;
pq_distance = 1;
p_node = first_hop_node_thread;
goto TILFA_FOUND;
}
}
}
}
Expand Down
128 changes: 128 additions & 0 deletions topo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,134 @@ tilfa_topo_2_adj_segment_example(){
return instance;
}

/* +---------+
* | |
* | R2 |
* +---------------------------------------------------------------+ 192.1.1.2+---------------------------------------------++-----------+
* | | | |
* | +---------+ |
* | |
* | |
* | |
* | |
* | +---------+ |
* | | R5 +---------------+ |
* | +------------------------+192.1.1.5| | |
* | | | | | |
* | | +---------+ | |
* | | +----+-----+-----+ ++---+--+--+
* +----+---+ +---+-------+ | R7 | | |
* | | | R4 | +- 192.1.1.7 +-----------+------------| R3 |
* | R1 +-------------------------------+192.168.1.4| | | |192.1.1.3 |
* |192.1.1.1| | | +----+----+---+--+ | |
* +----+---+ +---+------++ | | +-------+--+
* | | +--------+ | |
* | | | R6 | | |
* | | |192.1.1.6---------------+ |
* | +-------------------------+ | |
* | | | |
* | +--------+ |
* | |
* | |
* | |
* | |
* | |
* | +---------+ +---------+ |
* | | R8 | | R9 | |
* | |192.1.1.8| |192.1.1.9+---------+---+
* +--------------------------------------------+ +--------------------| |
* | | | |
* +---------+ +---------+
*/

instance_t *
tilfa_ecmp_topology(){

instance_t *instance = get_new_instance();

node_t *R1 = create_new_node(instance, "R1", AREA1, "192.1.1.1");
node_t *R2 = create_new_node(instance, "R2", AREA1, "192.1.1.2");
node_t *R3 = create_new_node(instance, "R3", AREA1, "192.1.1.3");
node_t *R4 = create_new_node(instance, "R4", AREA1, "192.1.1.4");
node_t *R5 = create_new_node(instance, "R5", AREA1, "192.1.1.5");
node_t *R6 = create_new_node(instance, "R6", AREA1, "192.1.1.6");
node_t *R7 = create_new_node(instance, "R7", AREA1, "192.1.1.7");
node_t *R8 = create_new_node(instance, "R8", AREA1, "192.1.1.8");
node_t *R9 = create_new_node(instance, "R9", AREA1, "192.1.1.9");


prefix_t *prefix_10_1_1_1_24 = create_new_prefix("10.1.1.1", 24, LEVEL1);
prefix_t *prefix_10_1_1_2_24 = create_new_prefix("10.1.1.2", 24, LEVEL1);
prefix_t *prefix_20_1_1_1_24 = create_new_prefix("20.1.1.1", 24, LEVEL1);
prefix_t *prefix_20_1_1_2_24 = create_new_prefix("20.1.1.2", 24, LEVEL1);
prefix_t *prefix_30_1_1_1_24 = create_new_prefix("30.1.1.1", 24, LEVEL1);
prefix_t *prefix_30_1_1_2_24 = create_new_prefix("30.1.1.2", 24, LEVEL1);
prefix_t *prefix_40_1_1_1_24 = create_new_prefix("40.1.1.1", 24, LEVEL1);
prefix_t *prefix_40_1_1_2_24 = create_new_prefix("40.1.1.2", 24, LEVEL1);
prefix_t *prefix_50_1_1_1_24 = create_new_prefix("50.1.1.1", 24, LEVEL1);
prefix_t *prefix_50_1_1_2_24 = create_new_prefix("50.1.1.2", 24, LEVEL1);
prefix_t *prefix_60_1_1_1_24 = create_new_prefix("60.1.1.1", 24, LEVEL1);
prefix_t *prefix_60_1_1_2_24 = create_new_prefix("60.1.1.2", 24, LEVEL1);
prefix_t *prefix_70_1_1_1_24 = create_new_prefix("70.1.1.1", 24, LEVEL1);
prefix_t *prefix_70_1_1_2_24 = create_new_prefix("70.1.1.2", 24, LEVEL1);
prefix_t *prefix_80_1_1_1_24 = create_new_prefix("80.1.1.1", 24, LEVEL1);
prefix_t *prefix_80_1_1_2_24 = create_new_prefix("80.1.1.2", 24, LEVEL1);
prefix_t *prefix_90_1_1_1_24 = create_new_prefix("90.1.1.1", 24, LEVEL1);
prefix_t *prefix_90_1_1_2_24 = create_new_prefix("90.1.1.2", 24, LEVEL1);
prefix_t *prefix_100_1_1_1_24 = create_new_prefix("100.1.1.1", 24, LEVEL1);
prefix_t *prefix_100_1_1_2_24 = create_new_prefix("100.1.1.2", 24, LEVEL1);
prefix_t *prefix_110_1_1_1_24 = create_new_prefix("110.1.1.1", 24, LEVEL1);
prefix_t *prefix_110_1_1_2_24 = create_new_prefix("110.1.1.2", 24, LEVEL1);

edge_t *R1_R2_edge = create_new_edge("eth0/1", "eth0/2", 10,
prefix_10_1_1_1_24, prefix_10_1_1_2_24, LEVEL1);

edge_t *R2_R3_edge = create_new_edge("eth0/3", "eth0/4", 10,
prefix_20_1_1_1_24, prefix_20_1_1_2_24, LEVEL1);

edge_t *R1_R4_edge = create_new_edge("eth0/5", "eth0/6", 10,
prefix_30_1_1_1_24, prefix_30_1_1_2_24, LEVEL1);

edge_t *R1_R8_edge = create_new_edge("eth0/7", "eth0/8", 10,
prefix_40_1_1_1_24, prefix_40_1_1_2_24, LEVEL1);

edge_t *R4_R5_edge = create_new_edge("eth0/9", "eth0/10", 10,
prefix_50_1_1_1_24, prefix_50_1_1_2_24, LEVEL1);

edge_t *R4_R6_edge = create_new_edge("eth0/11", "eth0/12", 10,
prefix_60_1_1_1_24, prefix_60_1_1_2_24, LEVEL1);

edge_t *R5_R7_edge = create_new_edge("eth0/13", "eth0/14", 10,
prefix_70_1_1_1_24, prefix_70_1_1_2_24, LEVEL1);

edge_t *R6_R7_edge = create_new_edge("eth0/15", "eth0/16", 10,
prefix_80_1_1_1_24, prefix_80_1_1_2_24, LEVEL1);

edge_t *R7_R3_edge = create_new_edge("eth0/17", "eth0/18", 10,
prefix_90_1_1_1_24, prefix_90_1_1_2_24, LEVEL1);

edge_t *R8_R9_edge = create_new_edge("eth0/19", "eth0/20", 10,
prefix_100_1_1_1_24, prefix_100_1_1_2_24, LEVEL1);

edge_t *R9_R7_edge = create_new_edge("eth0/21", "eth0/22", 10,
prefix_110_1_1_1_24, prefix_110_1_1_2_24, LEVEL1);

insert_edge_between_2_nodes(R1_R2_edge, R1, R2, BIDIRECTIONAL);
insert_edge_between_2_nodes(R2_R3_edge, R2, R3, BIDIRECTIONAL);
insert_edge_between_2_nodes(R1_R4_edge, R1, R4, BIDIRECTIONAL);
insert_edge_between_2_nodes(R1_R8_edge, R1, R8, BIDIRECTIONAL);
insert_edge_between_2_nodes(R4_R5_edge, R4, R5, BIDIRECTIONAL);
insert_edge_between_2_nodes(R4_R6_edge, R4, R6, BIDIRECTIONAL);
insert_edge_between_2_nodes(R5_R7_edge, R5, R7, BIDIRECTIONAL);
insert_edge_between_2_nodes(R6_R7_edge, R6, R7, BIDIRECTIONAL);
insert_edge_between_2_nodes(R7_R3_edge, R7, R3, BIDIRECTIONAL);
insert_edge_between_2_nodes(R8_R9_edge, R8, R9, BIDIRECTIONAL);
insert_edge_between_2_nodes(R9_R7_edge, R9, R7, BIDIRECTIONAL);

set_instance_root(instance, R1);
return instance;
}

static instance_t *old_instance = NULL;

int
Expand Down

0 comments on commit 17c20d3

Please sign in to comment.