Skip to content

Commit

Permalink
Merge pull request #11371 from rampxxxx/feat_bfd_ipv4_echo_fwd_path
Browse files Browse the repository at this point in the history
bfdd: add IPv4 BFD Echo support that loops pkts in forwarding plane
  • Loading branch information
rzalamena authored Jul 5, 2022
2 parents 87101cd + 0fb24aa commit da82615
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 14 deletions.
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));
/* 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

0 comments on commit da82615

Please sign in to comment.