summaryrefslogtreecommitdiff
path: root/bfdd/bfd.h
diff options
context:
space:
mode:
Diffstat (limited to 'bfdd/bfd.h')
-rw-r--r--bfdd/bfd.h86
1 files changed, 77 insertions, 9 deletions
diff --git a/bfdd/bfd.h b/bfdd/bfd.h
index d4d14ffce6..d9119d16c2 100644
--- a/bfdd/bfd.h
+++ b/bfdd/bfd.h
@@ -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)
@@ -86,6 +87,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,7 +152,6 @@ struct bfd_echo_pkt {
uint64_t time_sent_usec;
};
-
/* Macros for manipulating control packets */
#define BFD_VERMASK 0x07
#define BFD_DIAGMASK 0x1F
@@ -194,6 +198,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. */
@@ -235,6 +241,12 @@ enum bfd_session_flags {
BFD_SESS_FLAG_MAC_SET = 1 << 11, /* MAC of peer known */
};
+enum bfd_mode_type {
+ BFD_MODE_TYPE_BFD = 0,
+ BFD_MODE_TYPE_SBFD_ECHO = 1,
+ BFD_MODE_TYPE_SBFD_INIT = 2,
+};
+
/*
* BFD session hash key.
*
@@ -254,6 +266,7 @@ struct bfd_key {
struct in6_addr local;
char ifname[IFNAMSIZ];
char vrfname[VRF_NAMSIZ];
+ char bfdname[BFD_NAME_SIZE + 1];
} __attribute__((packed));
struct bfd_session_stats {
@@ -264,6 +277,7 @@ struct bfd_session_stats {
uint64_t session_up;
uint64_t session_down;
uint64_t znotification;
+ uint64_t tx_fail_pkt;
};
/**
@@ -375,6 +389,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[SRV6_MAX_SEGS];
};
struct bfd_diag_str_list {
@@ -396,6 +416,11 @@ 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
@@ -413,6 +438,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 (1000 * 1000) /* microseconds. */
/** Minimum multi hop TTL. */
#define BFD_DEF_MHOP_TTL 254
#define BFD_PKT_LEN 24 /* Length of control packet */
@@ -427,7 +453,9 @@ 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
/*
* bfdd.c
@@ -441,9 +469,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 +548,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 +558,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 +580,21 @@ 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 +617,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,
@@ -598,16 +644,16 @@ void bs_observer_del(struct bfd_session_observer *bso);
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);
+void gen_bfd_key(struct bfd_key *key, struct sockaddr_any *peer, struct sockaddr_any *local,
+ bool mhop, const char *ifname, const char *vrfname, const char *bfdname);
+struct bfd_session *bfd_session_new(enum bfd_mode_type mode);
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);
+const struct bfd_session *bfd_session_next(const struct bfd_session *bs, 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 +699,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 +724,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 +864,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_ */