Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bfdd: add IPv4 BFD Echo support that loops pkts in forwarding plane #11371

Merged
merged 2 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 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,12 @@ 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));
rzalamena marked this conversation as resolved.
Show resolved Hide resolved
/* reset local address ,it might has been be changed after bfd is up*/
memset(&bfd->local_address, 0, sizeof(bfd->local_address));
}

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