diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-05-19 19:30:21 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2020-05-29 17:48:14 -0300 |
| commit | 18322efd130a7ce60a2c8b731494d12edb1c937e (patch) | |
| tree | 061f5f5c1c4549e9a22361e71c08024823366d6c /bfdd/ptm_adapter.c | |
| parent | 276b698a43050393a2f73c24e254581b37cf7bbf (diff) | |
bfdd,lib: implement protocol profile selection
Implement the infrastructure for other protocols daemon (e.g. `bgpd`,
`ospfd`, `isisd` etc...) to communicate to BFD daemon which profile
they want to use with their peers.
It was also added the ability for protocols to change profile while
running (no need to remove the registration and then register again).
The protocols message building function was rewritten to support
multiple arguments through `struct bfd_session_arg`, so we can
implement new features without the need of changing function
prototypes. The old function was also rewritten to keep
compatibility.
The profile message part is only available for BFD daemon at the
moment.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/ptm_adapter.c')
| -rw-r--r-- | bfdd/ptm_adapter.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index 25938dd9f5..0abbdf3dcb 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -85,6 +85,7 @@ static void debug_printbpc(const struct bfd_peer_cfg *bpc, const char *fmt, ...) { char timers[3][128] = {}; char addr[3][128] = {}; + char profile[128] = {}; char cbit_str[32]; char msgbuf[256]; va_list vl; @@ -119,13 +120,17 @@ static void debug_printbpc(const struct bfd_peer_cfg *bpc, const char *fmt, ...) snprintf(cbit_str, sizeof(cbit_str), " cbit:0x%02x", bpc->bpc_cbit); + if (bpc->bpc_has_profile) + snprintf(profile, sizeof(profile), " profile:%s", + bpc->bpc_profile); + va_start(vl, fmt); vsnprintf(msgbuf, sizeof(msgbuf), fmt, vl); va_end(vl); - zlog_debug("%s [mhop:%s %s%s%s%s%s%s%s]", msgbuf, + zlog_debug("%s [mhop:%s %s%s%s%s%s%s%s%s]", msgbuf, bpc->bpc_mhop ? "yes" : "no", addr[0], addr[1], addr[2], - timers[0], timers[1], timers[2], cbit_str); + timers[0], timers[1], timers[2], cbit_str, profile); } static int _ptm_msg_address(struct stream *msg, int family, const void *addr) @@ -301,6 +306,8 @@ static int _ptm_msg_read(struct stream *msg, int command, vrf_id_t vrf_id, * - c: ifname length * - X bytes: interface name * - c: bfd_cbit + * - c: profile name length. + * - X bytes: profile name. * * q(64), l(32), w(16), c(8) */ @@ -381,6 +388,14 @@ static int _ptm_msg_read(struct stream *msg, int command, vrf_id_t vrf_id, STREAM_GETC(msg, bpc->bpc_cbit); + /* Handle profile names. */ + STREAM_GETC(msg, ifnamelen); + bpc->bpc_has_profile = ifnamelen > 0; + if (bpc->bpc_has_profile) { + STREAM_GET(bpc->bpc_profile, msg, ifnamelen); + bpc->bpc_profile[ifnamelen] = 0; + } + /* Sanity check: peer and local address must match IP types. */ if (bpc->bpc_local.sa_sin.sin_family != 0 && (bpc->bpc_local.sa_sin.sin_family @@ -421,10 +436,18 @@ static void bfdd_dest_register(struct stream *msg, vrf_id_t vrf_id) /* Protocol created peers are 'no shutdown' by default. */ bs->peer_profile.admin_shutdown = false; } else { - /* Don't try to change echo/shutdown state. */ - bpc.bpc_echo = CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO); - bpc.bpc_shutdown = - CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN); + /* + * BFD session was already created, we are just updating the + * current peer. + * + * `ptm-bfd` (or `HAVE_BFDD == 0`) is the only implementation + * that allow users to set peer specific timers via protocol. + * BFD daemon (this code) on the other hand only supports + * changing peer configuration manually (through `peer` node) + * or via profiles. + */ + if (bpc.bpc_has_profile) + bfd_profile_apply(bpc.bpc_profile, bs); } /* Create client peer notification register. */ |
