summaryrefslogtreecommitdiffstats
path: root/bfdd/ptm_adapter.c
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2020-08-11 19:43:56 +0200
committerRafael Zalamena <rzalamena@opensourcerouting.org>2020-08-12 02:22:39 +0200
commit262e1d2528e866d5608a3cf337c7761e35160926 (patch)
treeba8a99ce918626978c4c99d7ffe8ecaf7f58dd0b /bfdd/ptm_adapter.c
parentdoc: add BFD passive mode documentation (diff)
downloadfrr-262e1d2528e866d5608a3cf337c7761e35160926.tar.xz
frr-262e1d2528e866d5608a3cf337c7761e35160926.zip
bfdd: implement minimum TTL
Initial BFD protocol implementation had a hard coded value of maximum 5 hops, now we have a configurable hop amount with a safe default of 1 hop. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/ptm_adapter.c')
-rw-r--r--bfdd/ptm_adapter.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c
index 8134807a1..48e55bce3 100644
--- a/bfdd/ptm_adapter.c
+++ b/bfdd/ptm_adapter.c
@@ -303,7 +303,6 @@ static int _ptm_msg_read(struct stream *msg, int command, vrf_id_t vrf_id,
struct bfd_peer_cfg *bpc, struct ptm_client **pc)
{
uint32_t pid;
- uint8_t ttl __attribute__((unused));
size_t ifnamelen;
/*
@@ -375,7 +374,18 @@ static int _ptm_msg_read(struct stream *msg, int command, vrf_id_t vrf_id,
if (bpc->bpc_mhop) {
/* Read multihop source address and TTL. */
_ptm_msg_read_address(msg, &bpc->bpc_local);
- STREAM_GETC(msg, ttl);
+ STREAM_GETC(msg, bpc->bpc_minimum_ttl);
+ if (bpc->bpc_minimum_ttl >= BFD_TTL_VAL
+ || bpc->bpc_minimum_ttl == 0) {
+ zlog_warn("%s: received invalid TTL configuration %d",
+ __func__, bpc->bpc_has_minimum_ttl);
+ bpc->bpc_minimum_ttl = BFD_DEF_MHOP_TTL;
+ bpc->bpc_has_minimum_ttl = false;
+ } else {
+ bpc->bpc_minimum_ttl =
+ (BFD_TTL_VAL + 1) - bpc->bpc_minimum_ttl;
+ bpc->bpc_has_minimum_ttl = true;
+ }
} else {
/* If target is IPv6, then we must obtain local address. */
if (bpc->bpc_ipv4 == false)