]>
git.proxmox.com Git - mirror_frr.git/blob - bfdd/event.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*********************************************************************
3 * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF")
5 * event.c: implements the BFD loop event handlers.
9 * Rafael Zalamena <rzalamena@opensourcerouting.org>
16 void tv_normalize(struct timeval
*tv
);
18 void tv_normalize(struct timeval
*tv
)
20 /* Remove seconds part from microseconds. */
21 tv
->tv_sec
= tv
->tv_usec
/ 1000000;
22 tv
->tv_usec
= tv
->tv_usec
% 1000000;
25 void bfd_recvtimer_update(struct bfd_session
*bs
)
27 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= bs
->detect_TO
};
29 /* Remove previous schedule if any. */
30 bfd_recvtimer_delete(bs
);
32 /* Don't add event if peer is deactivated. */
33 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
39 event_add_timer_tv(master
, bfd_recvtimer_cb
, bs
, &tv
,
43 void bfd_echo_recvtimer_update(struct bfd_session
*bs
)
45 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= bs
->echo_detect_TO
};
47 /* Remove previous schedule if any. */
48 bfd_echo_recvtimer_delete(bs
);
50 /* Don't add event if peer is deactivated. */
51 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
57 event_add_timer_tv(master
, bfd_echo_recvtimer_cb
, bs
, &tv
,
58 &bs
->echo_recvtimer_ev
);
61 void bfd_xmttimer_update(struct bfd_session
*bs
, uint64_t jitter
)
63 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= jitter
};
65 /* Remove previous schedule if any. */
66 bfd_xmttimer_delete(bs
);
68 /* Don't add event if peer is deactivated. */
69 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
75 event_add_timer_tv(master
, bfd_xmt_cb
, bs
, &tv
, &bs
->xmttimer_ev
);
78 void bfd_echo_xmttimer_update(struct bfd_session
*bs
, uint64_t jitter
)
80 struct timeval tv
= {.tv_sec
= 0, .tv_usec
= jitter
};
82 /* Remove previous schedule if any. */
83 bfd_echo_xmttimer_delete(bs
);
85 /* Don't add event if peer is deactivated. */
86 if (CHECK_FLAG(bs
->flags
, BFD_SESS_FLAG_SHUTDOWN
) ||
92 event_add_timer_tv(master
, bfd_echo_xmt_cb
, bs
, &tv
,
93 &bs
->echo_xmttimer_ev
);
96 void bfd_recvtimer_delete(struct bfd_session
*bs
)
98 EVENT_OFF(bs
->recvtimer_ev
);
101 void bfd_echo_recvtimer_delete(struct bfd_session
*bs
)
103 EVENT_OFF(bs
->echo_recvtimer_ev
);
106 void bfd_xmttimer_delete(struct bfd_session
*bs
)
108 EVENT_OFF(bs
->xmttimer_ev
);
111 void bfd_echo_xmttimer_delete(struct bfd_session
*bs
)
113 EVENT_OFF(bs
->echo_xmttimer_ev
);