mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 09:40:14 +00:00
isisd: add send_hello_sched function
Add a function send_hello_sched so that the logic for scheduling a hello is not replicated inconsistently into different locations. Signed-off-by: Christian Franke <chris@opensourcerouting.org>
This commit is contained in:
parent
78ca034252
commit
a0a707ee6c
@ -619,9 +619,7 @@ int isis_circuit_up(struct isis_circuit *circuit)
|
|||||||
if (!(circuit->is_type & level))
|
if (!(circuit->is_type & level))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
thread_add_event(master, send_hello_cb,
|
send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY);
|
||||||
&circuit->level_arg[level - 1], 0,
|
|
||||||
&circuit->u.bc.t_send_lan_hello[level - 1]);
|
|
||||||
circuit->u.bc.lan_neighs[level - 1] = list_new();
|
circuit->u.bc.lan_neighs[level - 1] = list_new();
|
||||||
|
|
||||||
thread_add_timer(master, isis_run_dr,
|
thread_add_timer(master, isis_run_dr,
|
||||||
@ -637,9 +635,7 @@ int isis_circuit_up(struct isis_circuit *circuit)
|
|||||||
* for a ptp IF
|
* for a ptp IF
|
||||||
*/
|
*/
|
||||||
circuit->u.p2p.neighbor = NULL;
|
circuit->u.p2p.neighbor = NULL;
|
||||||
thread_add_event(master, send_hello_cb,
|
send_hello_sched(circuit, 0, TRIGGERED_IIH_DELAY);
|
||||||
&circuit->level_arg[0], 0,
|
|
||||||
&circuit->u.p2p.t_send_p2p_hello);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initializing PSNP timers */
|
/* initializing PSNP timers */
|
||||||
|
@ -75,6 +75,8 @@
|
|||||||
|
|
||||||
#define MIN_LSP_RETRANS_INTERVAL 5 /* Seconds */
|
#define MIN_LSP_RETRANS_INTERVAL 5 /* Seconds */
|
||||||
|
|
||||||
|
#define TRIGGERED_IIH_DELAY 50 /* msec */
|
||||||
|
|
||||||
#define MIN_CSNP_INTERVAL 1
|
#define MIN_CSNP_INTERVAL 1
|
||||||
#define MAX_CSNP_INTERVAL 600
|
#define MAX_CSNP_INTERVAL 600
|
||||||
#define DEFAULT_CSNP_INTERVAL 10
|
#define DEFAULT_CSNP_INTERVAL 10
|
||||||
|
@ -97,12 +97,7 @@ static void circuit_commence_level(struct isis_circuit *circuit, int level)
|
|||||||
2 * circuit->hello_interval[level - 1],
|
2 * circuit->hello_interval[level - 1],
|
||||||
&circuit->u.bc.t_run_dr[level - 1]);
|
&circuit->u.bc.t_run_dr[level - 1]);
|
||||||
|
|
||||||
thread_add_timer(master, send_hello_cb,
|
send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY);
|
||||||
&circuit->level_arg[level - 1],
|
|
||||||
isis_jitter(circuit->hello_interval[level - 1],
|
|
||||||
IIH_JITTER),
|
|
||||||
&circuit->u.bc.t_send_lan_hello[level - 1]);
|
|
||||||
|
|
||||||
circuit->u.bc.lan_neighs[level - 1] = list_new();
|
circuit->u.bc.lan_neighs[level - 1] = list_new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1742,7 +1742,7 @@ int send_hello(struct isis_circuit *circuit, int level)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int send_hello_cb(struct thread *thread)
|
static int send_hello_cb(struct thread *thread)
|
||||||
{
|
{
|
||||||
struct isis_circuit_arg *arg = THREAD_ARG(thread);
|
struct isis_circuit_arg *arg = THREAD_ARG(thread);
|
||||||
|
|
||||||
@ -1755,12 +1755,9 @@ int send_hello_cb(struct thread *thread)
|
|||||||
|
|
||||||
if (circuit->circ_type == CIRCUIT_T_P2P) {
|
if (circuit->circ_type == CIRCUIT_T_P2P) {
|
||||||
circuit->u.p2p.t_send_p2p_hello = NULL;
|
circuit->u.p2p.t_send_p2p_hello = NULL;
|
||||||
|
|
||||||
send_hello(circuit, 1);
|
send_hello(circuit, 1);
|
||||||
|
send_hello_sched(circuit, ISIS_LEVEL1,
|
||||||
thread_add_timer(master, send_hello_cb, arg,
|
1000 * circuit->hello_interval[1]);
|
||||||
isis_jitter(circuit->hello_interval[1], IIH_JITTER),
|
|
||||||
&circuit->u.p2p.t_send_p2p_hello);
|
|
||||||
return ISIS_OK;
|
return ISIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1783,13 +1780,56 @@ int send_hello_cb(struct thread *thread)
|
|||||||
int rv = send_hello(circuit, level);
|
int rv = send_hello(circuit, level);
|
||||||
|
|
||||||
/* set next timer thread */
|
/* set next timer thread */
|
||||||
thread_add_timer(master, send_hello_cb, arg,
|
send_hello_sched(circuit, level, 1000 * circuit->hello_interval[level - 1]);
|
||||||
isis_jitter(circuit->hello_interval[level - 1], IIH_JITTER),
|
|
||||||
&circuit->u.bc.t_send_lan_hello[level - 1]);
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _send_hello_sched(struct isis_circuit *circuit,
|
||||||
|
struct thread **threadp,
|
||||||
|
int level, long delay)
|
||||||
|
{
|
||||||
|
if (*threadp) {
|
||||||
|
if (thread_timer_remain_msec(*threadp) < (unsigned long)delay)
|
||||||
|
return;
|
||||||
|
|
||||||
|
thread_cancel(*threadp);
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_add_timer_msec(master, send_hello_cb,
|
||||||
|
&circuit->level_arg[level - 1],
|
||||||
|
isis_jitter(delay, IIH_JITTER),
|
||||||
|
threadp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_hello_sched(struct isis_circuit *circuit, int level, long delay)
|
||||||
|
{
|
||||||
|
if (circuit->circ_type == CIRCUIT_T_P2P) {
|
||||||
|
_send_hello_sched(circuit, &circuit->u.p2p.t_send_p2p_hello,
|
||||||
|
ISIS_LEVEL1, delay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (circuit->circ_type != CIRCUIT_T_BROADCAST) {
|
||||||
|
zlog_warn("%s: encountered unknown circuit type %d on %s",
|
||||||
|
__func__, circuit->circ_type,
|
||||||
|
circuit->interface->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int loop_level = ISIS_LEVEL1; loop_level <= ISIS_LEVEL2; loop_level++) {
|
||||||
|
if (!(loop_level & level))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_send_hello_sched(
|
||||||
|
circuit,
|
||||||
|
&circuit->u.bc.t_send_lan_hello[loop_level - 1],
|
||||||
|
loop_level,
|
||||||
|
delay
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count the maximum number of lsps that can be accomodated by a given size.
|
* Count the maximum number of lsps that can be accomodated by a given size.
|
||||||
*/
|
*/
|
||||||
|
@ -208,7 +208,7 @@ int isis_receive(struct thread *thread);
|
|||||||
/*
|
/*
|
||||||
* Sending functions
|
* Sending functions
|
||||||
*/
|
*/
|
||||||
int send_hello_cb(struct thread *thread);
|
void send_hello_sched(struct isis_circuit *circuit, int level, long delay);
|
||||||
int send_csnp(struct isis_circuit *circuit, int level);
|
int send_csnp(struct isis_circuit *circuit, int level);
|
||||||
int send_l1_csnp(struct thread *thread);
|
int send_l1_csnp(struct thread *thread);
|
||||||
int send_l2_csnp(struct thread *thread);
|
int send_l2_csnp(struct thread *thread);
|
||||||
|
Loading…
Reference in New Issue
Block a user