Skip to content

Commit

Permalink
bfdd: format code style
Browse files Browse the repository at this point in the history
Signed-off-by: wumu.zsl <[email protected]>
  • Loading branch information
forrestchu committed Jan 7, 2025
1 parent dbcdd72 commit 95d9081
Show file tree
Hide file tree
Showing 15 changed files with 889 additions and 1,155 deletions.
211 changes: 90 additions & 121 deletions bfdd/bfd.c

Large diffs are not rendered by default.

49 changes: 24 additions & 25 deletions bfdd/bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ 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;
vrf_id_t vrf_id;
char bfd_name[BFD_NAME_SIZE + 1];
uint8_t bfd_name_len;
};

/* bfd Authentication Type. */
Expand Down Expand Up @@ -154,7 +154,7 @@ struct bfd_echo_pkt {
uint64_t time_sent_usec;
};

#define BFD_XMTDEL_DELAY_TIMER 5
#define BFD_XMTDEL_DELAY_TIMER 5

/* Macros for manipulating control packets */
#define BFD_VERMASK 0x07
Expand Down Expand Up @@ -202,8 +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)
#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. */
Expand All @@ -230,21 +230,21 @@ enum bfd_diagnosticis {
/* BFD session flags */
enum bfd_session_flags {
BFD_SESS_FLAG_NONE = 0,
BFD_SESS_FLAG_ECHO = 1 << 0, /* BFD Echo functionality */
BFD_SESS_FLAG_ECHO_ACTIVE = 1 << 1, /* BFD Echo Packets are being sent
BFD_SESS_FLAG_ECHO = 1 << 0, /* BFD Echo functionality */
BFD_SESS_FLAG_ECHO_ACTIVE = 1 << 1, /* BFD Echo Packets are being sent
* actively
*/
BFD_SESS_FLAG_MH = 1 << 2, /* BFD Multi-hop session */
BFD_SESS_FLAG_IPV6 = 1 << 4, /* BFD IPv6 session */
BFD_SESS_FLAG_MH = 1 << 2, /* BFD Multi-hop session */
BFD_SESS_FLAG_IPV6 = 1 << 4, /* BFD IPv6 session */
BFD_SESS_FLAG_SEND_EVT_ACTIVE = 1 << 5, /* send event timer active */
BFD_SESS_FLAG_SEND_EVT_IGNORE = 1 << 6, /* ignore send event when timer
* 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_PASSIVE = 1 << 10, /* Passive mode */
BFD_SESS_FLAG_MAC_SET = 1 << 11, /* MAC of peer known */
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 */
BFD_SESS_FLAG_REM_ADMIN_DOWN = 1 << 13, /* remote notify admindown */
};

Expand Down Expand Up @@ -396,7 +396,7 @@ 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];
char bfd_name[BFD_NAME_SIZE + 1];

uint32_t bfd_mode;
uint8_t segnum;
Expand Down Expand Up @@ -424,7 +424,7 @@ struct bfd_session_observer {
TAILQ_HEAD(obslist, bfd_session_observer);

/*sbfd reflector struct*/
struct sbfd_reflector{
struct sbfd_reflector {
uint32_t discr;
struct in6_addr local;
};
Expand All @@ -445,7 +445,7 @@ struct sbfd_reflector{
#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. */
#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 */
Expand All @@ -462,9 +462,9 @@ struct sbfd_reflector{
#define BFD_DEF_MHOP_DEST_PORT 4784
#define BFD_DEF_SBFD_DEST_PORT 7784

#define BFD_SBFD_INITIATOR_DEMAND 1
#define BFD_SBFD_INITIATOR_DEMAND 1
#define BFD_IPV6_UDP_DISABLE_CHECKSUM 1
#define UDP_NO_CHECK6_RX 102
#define UDP_NO_CHECK6_RX 102

/*
* bfdd.c
Expand Down Expand Up @@ -655,16 +655,15 @@ 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, const char *bfdname);
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, 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, uint32_t bfd_mode);
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);
Expand Down Expand Up @@ -890,5 +889,5 @@ 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);
struct bfd_session *bfd_session_get_by_name(const char *name);
#endif /* _BFD_H_ */
Loading

0 comments on commit 95d9081

Please sign in to comment.