Skip to content

Commit

Permalink
bfdd: add IPv4 BFD Echo support that matches RFC
Browse files Browse the repository at this point in the history
Modify the existing BFD Echo code to send an Echo message that will
be looped in the peers forwarding plane.   The existing Echo code
only works with other FRR implementations because the Echo packet
must go up to BFD to be turned around and forwarded back to the
local router.    The new BFD Echo code sets the src/dst IP of the
packet to be the local router's IP and sets the dest MAC to be the
peers MAC address.    The peer receives the packet and because it
is not it's IP address it forwards it back to the local router.

Signed-off-by: Lynne Morrison <lynne.morrison@ibm.com>
  • Loading branch information
lynnemorrison committed Jun 9, 2022
1 parent 1bf4e04 commit 753da8d
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 12 deletions.
16 changes: 15 additions & 1 deletion bfdd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,17 @@ void ptm_bfd_start_xmt_timer(struct bfd_session *bfd, bool is_echo)
static void ptm_bfd_echo_xmt_TO(struct bfd_session *bfd)
{
/* Send the scheduled echo packet */
ptm_bfd_echo_snd(bfd);
/* if ipv4 use the new echo implementation that causes
* the packet to be looped in forwarding plane of peer
*/
if (CHECK_FLAG(bfd->flags, BFD_SESS_FLAG_IPV6) == 0)
#ifdef BFD_LINUX
ptm_bfd_echo_fp_snd(bfd);
#else
ptm_bfd_echo_snd(bfd);
#endif
else
ptm_bfd_echo_snd(bfd);

/* Restart the timer for next time */
ptm_bfd_start_xmt_timer(bfd, true);
Expand Down Expand Up @@ -558,6 +568,10 @@ void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag)
state_list[bfd->ses_state].str,
get_diag_str(bfd->local_diag));
}

/* clear peer's mac address */
UNSET_FLAG(bfd->flags, BFD_SESS_FLAG_MAC_SET);
memset(bfd->peer_hw_addr, 0, sizeof(bfd->peer_hw_addr));
}

static struct bfd_session *bfd_find_disc(struct sockaddr_any *sa,
Expand Down
8 changes: 6 additions & 2 deletions bfdd/bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ enum bfd_session_flags {
* expires
*/
BFD_SESS_FLAG_SHUTDOWN = 1 << 7, /* disable BGP peer function */
BFD_SESS_FLAG_CONFIG = 1 << 8, /* Session configured with bfd NB API */
BFD_SESS_FLAG_CBIT = 1 << 9, /* CBIT is set */
BFD_SESS_FLAG_CONFIG = 1 << 8, /* Session configured with bfd NB API */
BFD_SESS_FLAG_CBIT = 1 << 9, /* CBIT is set */
BFD_SESS_FLAG_PASSIVE = 1 << 10, /* Passive mode */
BFD_SESS_FLAG_MAC_SET = 1 << 11, /* MAC of peer known */
};

/*
Expand Down Expand Up @@ -290,6 +291,8 @@ struct bfd_session {
struct peer_label *pl;

struct bfd_dplane_ctx *bdc;
struct sockaddr_any local_address;
uint8_t peer_hw_addr[ETH_ALEN];
struct interface *ifp;
struct vrf *vrf;

Expand Down Expand Up @@ -554,6 +557,7 @@ int bp_echov6_socket(const struct vrf *vrf);

void ptm_bfd_snd(struct bfd_session *bfd, int fbit);
void ptm_bfd_echo_snd(struct bfd_session *bfd);
void ptm_bfd_echo_fp_snd(struct bfd_session *bfd);

void bfd_recv_cb(struct thread *t);

Expand Down
Loading

0 comments on commit 753da8d

Please sign in to comment.