-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
implement SBFD #17336
base: master
Are you sure you want to change the base?
implement SBFD #17336
Changes from 12 commits
32705fe
6648243
3796741
b4d2550
14cebb4
7d06317
f7e761c
074710b
2bda257
1c46d9b
f055db1
23a05ed
11a7582
533940e
3da528e
07332d9
6daa1ee
35dc4a4
a6270ec
dbcdd72
dbde9e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include "lib/qobj.h" | ||
#include "lib/queue.h" | ||
#include "lib/vrf.h" | ||
#include "lib/bfd.h" | ||
|
||
#ifdef BFD_DEBUG | ||
#define BFDD_JSON_CONV_OPTIONS (JSON_C_TO_STRING_PRETTY) | ||
|
@@ -27,9 +28,11 @@ | |
#endif | ||
|
||
#ifndef MAXNAMELEN | ||
#define MAXNAMELEN 32 | ||
#define MAXNAMELEN 128 | ||
#endif | ||
|
||
#define MAXALIASNAMELEN 256 | ||
|
||
#define BPC_DEF_DETECTMULTIPLIER 3 | ||
#define BPC_DEF_RECEIVEINTERVAL 300 /* milliseconds */ | ||
#define BPC_DEF_TRANSMITINTERVAL 300 /* milliseconds */ | ||
|
@@ -86,6 +89,10 @@ struct bfd_peer_cfg { | |
|
||
bool bpc_has_profile; | ||
char bpc_profile[64]; | ||
|
||
vrf_id_t vrf_id; | ||
char bfd_name[BFD_NAME_SIZE +1]; | ||
uint8_t bfd_name_len; | ||
}; | ||
|
||
/* bfd Authentication Type. */ | ||
|
@@ -147,6 +154,7 @@ struct bfd_echo_pkt { | |
uint64_t time_sent_usec; | ||
}; | ||
|
||
#define BFD_XMTDEL_DELAY_TIMER 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useless define. remove it. |
||
|
||
/* Macros for manipulating control packets */ | ||
#define BFD_VERMASK 0x07 | ||
|
@@ -194,6 +202,8 @@ struct bfd_echo_pkt { | |
#define BFD_ECHO_VERSION 1 | ||
#define BFD_ECHO_PKT_LEN sizeof(struct bfd_echo_pkt) | ||
|
||
#define RTH_BASE_HEADER_LEN 8 | ||
#define GET_RTH_HDR_LEN(size) (((size)>>3) - 1) | ||
enum bfd_diagnosticis { | ||
BD_OK = 0, | ||
/* Control Detection Time Expired. */ | ||
|
@@ -212,6 +222,8 @@ enum bfd_diagnosticis { | |
BD_ADMIN_DOWN = 7, | ||
/* Reverse Concatenated Path Down. */ | ||
BD_REVCONCATPATH_DOWN = 8, | ||
/* Sbfd Detect Function Failed. */ | ||
BD_SBFD_DETECT_FAILED = 9, | ||
/* 9..31: reserved. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment : RFC6428 to inform the user that this value is defined by this RFC. |
||
}; | ||
|
||
|
@@ -233,6 +245,13 @@ enum bfd_session_flags { | |
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 */ | ||
BFD_SESS_FLAG_REM_ADMIN_DOWN = 1 << 13, /* remote notify admindown */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nowhere in the code this value is set. is it really used? |
||
}; | ||
|
||
enum bfd_mode_type { | ||
BFD_MODE_TYPE_BFD = 0, | ||
BFD_MODE_TYPE_SBFD_ECHO = 1, | ||
BFD_MODE_TYPE_SBFD_INIT = 2, | ||
}; | ||
|
||
/* | ||
|
@@ -254,6 +273,7 @@ struct bfd_key { | |
struct in6_addr local; | ||
char ifname[IFNAMSIZ]; | ||
char vrfname[VRF_NAMSIZ]; | ||
char bfdname[MAXNAMELEN]; | ||
} __attribute__((packed)); | ||
|
||
struct bfd_session_stats { | ||
|
@@ -264,6 +284,7 @@ struct bfd_session_stats { | |
uint64_t session_up; | ||
uint64_t session_down; | ||
uint64_t znotification; | ||
uint64_t tx_fail_pkt; | ||
}; | ||
|
||
/** | ||
|
@@ -375,6 +396,12 @@ struct bfd_session { | |
uint8_t rtt_valid; /* number of valid samples */ | ||
uint8_t rtt_index; /* last index added */ | ||
uint64_t rtt[BFD_RTT_SAMPLE]; /* RRT in usec for echo to be looped */ | ||
char bfd_name[BFD_NAME_SIZE +1]; | ||
|
||
uint32_t bfd_mode; | ||
uint8_t segnum; | ||
struct in6_addr out_sip6; | ||
struct in6_addr seg_list[0]; | ||
}; | ||
|
||
struct bfd_diag_str_list { | ||
|
@@ -396,12 +423,18 @@ struct bfd_session_observer { | |
}; | ||
TAILQ_HEAD(obslist, bfd_session_observer); | ||
|
||
/*sbfd reflector struct*/ | ||
struct sbfd_reflector{ | ||
uint32_t discr; | ||
struct in6_addr local; | ||
}; | ||
|
||
/* States defined per 4.1 */ | ||
#define PTM_BFD_ADM_DOWN 0 | ||
#define PTM_BFD_DOWN 1 | ||
#define PTM_BFD_INIT 2 | ||
#define PTM_BFD_UP 3 | ||
#define PTM_BFD_DEL 4 | ||
|
||
|
||
/* Various constants */ | ||
|
@@ -413,6 +446,7 @@ TAILQ_HEAD(obslist, bfd_session_observer); | |
#define BFD_DEF_DES_MIN_ECHO_TX (50 * 1000) /* microseconds. */ | ||
#define BFD_DEF_REQ_MIN_ECHO_RX (50 * 1000) /* microseconds. */ | ||
#define BFD_DEF_SLOWTX (1000 * 1000) /* microseconds. */ | ||
#define SBFD_ECHO_DEF_SLOWTX (3000 * 1000) /* microseconds. */ | ||
/** Minimum multi hop TTL. */ | ||
#define BFD_DEF_MHOP_TTL 254 | ||
#define BFD_PKT_LEN 24 /* Length of control packet */ | ||
|
@@ -427,7 +461,11 @@ TAILQ_HEAD(obslist, bfd_session_observer); | |
#define BFD_DEFDESTPORT 3784 | ||
#define BFD_DEF_ECHO_PORT 3785 | ||
#define BFD_DEF_MHOP_DEST_PORT 4784 | ||
#define BFD_DEF_SBFD_DEST_PORT 7784 | ||
|
||
#define BFD_SBFD_INITIATOR_DEMAND 1 | ||
#define BFD_IPV6_UDP_DISABLE_CHECKSUM 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused define. please remove. |
||
#define UDP_NO_CHECK6_RX 102 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused define. please remove. |
||
|
||
/* | ||
* bfdd.c | ||
|
@@ -441,9 +479,10 @@ struct bfd_vrf_global { | |
int bg_mhop6; | ||
int bg_echo; | ||
int bg_echov6; | ||
int bg_initv6; | ||
struct vrf *vrf; | ||
|
||
struct event *bg_ev[6]; | ||
struct event *bg_ev[7]; | ||
}; | ||
|
||
/* Forward declaration of data plane context struct. */ | ||
|
@@ -519,6 +558,7 @@ int bp_set_ttl(int sd, uint8_t value); | |
int bp_set_tosv6(int sd, uint8_t value); | ||
int bp_set_tos(int sd, uint8_t value); | ||
int bp_bind_dev(int sd, const char *dev); | ||
void bp_set_prio(int sd, int value); | ||
|
||
int bp_udp_shop(const struct vrf *vrf); | ||
int bp_udp_mhop(const struct vrf *vrf); | ||
|
@@ -528,10 +568,15 @@ int bp_peer_socket(const struct bfd_session *bs); | |
int bp_peer_socketv6(const struct bfd_session *bs); | ||
int bp_echo_socket(const struct vrf *vrf); | ||
int bp_echov6_socket(const struct vrf *vrf); | ||
int bp_peer_srh_socketv6(struct bfd_session *bs); | ||
int bp_sbfd_socket(const struct vrf *vrf); | ||
int bp_initv6_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 ptm_sbfd_echo_snd(struct bfd_session *bfd); | ||
void ptm_sbfd_initiator_snd(struct bfd_session *bfd, int fbit); | ||
|
||
void bfd_recv_cb(struct event *t); | ||
|
||
|
@@ -545,13 +590,23 @@ typedef void (*bfd_ev_cb)(struct event *t); | |
|
||
void bfd_recvtimer_update(struct bfd_session *bs); | ||
void bfd_echo_recvtimer_update(struct bfd_session *bs); | ||
void sbfd_init_recvtimer_update(struct bfd_session *bs); | ||
void sbfd_echo_recvtimer_update(struct bfd_session *bs); | ||
|
||
void bfd_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | ||
void bfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | ||
void sbfd_init_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | ||
void sbfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | ||
|
||
void bfd_xmttimer_delete(struct bfd_session *bs); | ||
void bfd_echo_xmttimer_delete(struct bfd_session *bs); | ||
void sbfd_init_xmttimer_delete(struct bfd_session *bs); | ||
void sbfd_echo_xmttimer_delete(struct bfd_session *bs); | ||
|
||
void bfd_recvtimer_delete(struct bfd_session *bs); | ||
void bfd_echo_recvtimer_delete(struct bfd_session *bs); | ||
void sbfd_init_recvtimer_delete(struct bfd_session *bs); | ||
void sbfd_echo_recvtimer_delete(struct bfd_session *bs); | ||
|
||
void bfd_recvtimer_assign(struct bfd_session *bs, bfd_ev_cb cb, int sd); | ||
void bfd_echo_recvtimer_assign(struct bfd_session *bs, bfd_ev_cb cb, int sd); | ||
|
@@ -574,6 +629,9 @@ void ptm_bfd_echo_stop(struct bfd_session *bfd); | |
void ptm_bfd_echo_start(struct bfd_session *bfd); | ||
void ptm_bfd_xmt_TO(struct bfd_session *bfd, int fbit); | ||
void ptm_bfd_start_xmt_timer(struct bfd_session *bfd, bool is_echo); | ||
void ptm_sbfd_init_xmt_TO(struct bfd_session *bfd, int fbit); | ||
void ptm_sbfd_init_reset(struct bfd_session *bfd); | ||
void ptm_sbfd_echo_reset(struct bfd_session *bfd); | ||
struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp, | ||
struct sockaddr_any *peer, | ||
struct sockaddr_any *local, | ||
|
@@ -600,14 +658,17 @@ void bs_to_bpc(struct bfd_session *bs, struct bfd_peer_cfg *bpc); | |
|
||
void gen_bfd_key(struct bfd_key *key, struct sockaddr_any *peer, | ||
struct sockaddr_any *local, bool mhop, const char *ifname, | ||
const char *vrfname); | ||
struct bfd_session *bfd_session_new(void); | ||
const char *vrfname, const char *bfdname); | ||
|
||
struct bfd_session *bfd_session_new(enum bfd_mode_type mode, uint8_t segnum); | ||
|
||
struct bfd_session *bs_registrate(struct bfd_session *bs); | ||
void bfd_session_free(struct bfd_session *bs); | ||
const struct bfd_session *bfd_session_next(const struct bfd_session *bs, | ||
bool mhop); | ||
bool mhop, uint32_t bfd_mode); | ||
void bfd_sessions_remove_manual(void); | ||
void bfd_profiles_remove(void); | ||
void bs_sbfd_echo_timer_handler(struct bfd_session *bs); | ||
void bfd_rtt_init(struct bfd_session *bfd); | ||
|
||
extern void bfd_vrf_toggle_echo(struct bfd_vrf_global *bfd_vrf); | ||
|
@@ -653,18 +714,22 @@ void bfd_vrf_terminate(void); | |
struct bfd_vrf_global *bfd_vrf_look_by_session(struct bfd_session *bfd); | ||
struct bfd_session *bfd_id_lookup(uint32_t id); | ||
struct bfd_session *bfd_key_lookup(struct bfd_key key); | ||
|
||
struct sbfd_reflector *sbfd_discr_lookup(uint32_t discr); | ||
struct bfd_session *bfd_id_delete(uint32_t id); | ||
struct bfd_session *bfd_key_delete(struct bfd_key key); | ||
struct sbfd_reflector *sbfd_discr_delete(uint32_t discr); | ||
|
||
bool bfd_id_insert(struct bfd_session *bs); | ||
bool bfd_key_insert(struct bfd_session *bs); | ||
bool sbfd_discr_insert(struct sbfd_reflector *sr); | ||
|
||
typedef void (*hash_iter_func)(struct hash_bucket *hb, void *arg); | ||
void bfd_id_iterate(hash_iter_func hif, void *arg); | ||
void bfd_key_iterate(hash_iter_func hif, void *arg); | ||
void sbfd_discr_iterate(hash_iter_func hif, void *arg); | ||
|
||
unsigned long bfd_get_session_count(void); | ||
unsigned long sbfd_discr_get_count(void); | ||
|
||
/* Export callback functions for `event.c`. */ | ||
extern struct event_loop *master; | ||
|
@@ -674,6 +739,11 @@ void bfd_echo_recvtimer_cb(struct event *t); | |
void bfd_xmt_cb(struct event *t); | ||
void bfd_echo_xmt_cb(struct event *t); | ||
|
||
void sbfd_init_recvtimer_cb(struct event *t); | ||
void sbfd_echo_recvtimer_cb(struct event *t); | ||
void sbfd_init_xmt_cb(struct event *t); | ||
void sbfd_echo_xmt_cb(struct event *t); | ||
|
||
extern struct in6_addr zero_addr; | ||
|
||
/** | ||
|
@@ -809,4 +879,17 @@ int bfd_dplane_update_session_counters(struct bfd_session *bs); | |
|
||
void bfd_dplane_show_counters(struct vty *vty); | ||
|
||
/*sbfd relfector*/ | ||
struct sbfd_reflector *sbfd_reflector_new(const uint32_t discr, struct in6_addr *sip); | ||
void sbfd_reflector_free(const uint32_t discr); | ||
void sbfd_reflector_flush(void); | ||
|
||
/*sbfd*/ | ||
void ptm_sbfd_echo_sess_dn(struct bfd_session *bfd, uint8_t diag); | ||
void ptm_sbfd_init_sess_dn(struct bfd_session *bfd, uint8_t diag); | ||
void ptm_sbfd_sess_up(struct bfd_session *bfd); | ||
void sbfd_echo_state_handler(struct bfd_session *bs, int nstate); | ||
void sbfd_initiator_state_handler(struct bfd_session *bs, int nstate); | ||
|
||
struct bfd_session * bfd_session_get_by_name(const char * name); | ||
#endif /* _BFD_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we keep 32 ? what is the limit on the configuration perspective?