Commit d262695d authored by Maria Matejka's avatar Maria Matejka
Browse files

BFD: direct notifications to protocol loops

parent 09380db5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ static inline void ev_init_cork(struct event_cork *ec, const char *name)
};

void ev_send(event_list *, event *);
#define ev_send_self(e)	({ ASSERT_DIE((e)->list); ev_send((e)->list, (e)); })
#define ev_send_loop(l, e) ev_send(birdloop_event_list((l)), (e))

#define ev_schedule(e) ({ ASSERT_THE_BIRD_LOCKED; if (!ev_active((e))) ev_send(&global_event_list, (e)); })
+8 −4
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ struct bfd_options {
  u8 mode;
};

struct bfd_session_state {
  u8 state;
  u8 diag;
};

struct bfd_request {
  resource r;
  node n;
@@ -35,12 +40,12 @@ struct bfd_request {

  void (*hook)(struct bfd_request *);
  void *data;
  event event;

  struct bfd_session *session;

  struct bfd_session_state old_state;
  u8 state;
  u8 diag;
  u8 old_state;
  u8 down;
};

@@ -51,13 +56,12 @@ struct bfd_request {
#define BFD_STATE_INIT		2
#define BFD_STATE_UP		3


static inline struct bfd_options * bfd_new_options(void)
{ return cfg_allocz(sizeof(struct bfd_options)); }

#ifdef CONFIG_BFD

struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, struct iface *vrf, void (*hook)(struct bfd_request *), void *data, const struct bfd_options *opts);
struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, struct iface *vrf, void (*hook)(struct bfd_request *), void *data, struct event_list *list, const struct bfd_options *opts);
void bfd_update_request(struct bfd_request *req, const struct bfd_options *opts);

static inline void cf_check_bfd(int use UNUSED) { }
+8 −2
Original line number Diff line number Diff line
@@ -1762,8 +1762,14 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty
	nc->proto = p;

	/* We will try to reconfigure protocol p */
	if (! force_reconfig && proto_reconfigure(p, oc, nc, type))
	if (!force_reconfig)
	{
	  int ok;
	  PROTO_LOCKED_FROM_MAIN(p)
	    ok = proto_reconfigure(p, oc, nc, type);
	  if (ok)
	    continue;
	}

	if (nc->parent)
	{
+145 −241

File changed.

Preview size limit exceeded, changes collapsed.

+7 −16
Original line number Diff line number Diff line
@@ -88,18 +88,12 @@ struct bfd_proto
{
  struct proto p;

  pthread_spinlock_t lock;

  node bfd_node;

  slab *session_slab;
  HASH(struct bfd_session) session_hash_id;
  HASH(struct bfd_session) session_hash_ip;

  sock *notify_rs;
  sock *notify_ws;
  list notify_list;

  sock *rx4_1;
  sock *rx6_1;
  sock *rx4_m;
@@ -122,7 +116,6 @@ struct bfd_iface

struct bfd_session
{
  node n;
  ip_addr addr;				/* Address of session */
  struct bfd_iface *ifa;		/* Iface associated with session */
  struct bfd_session *next_id;		/* Next in bfd.session_hash_id */
@@ -133,14 +126,15 @@ struct bfd_session
  u8 poll_active;
  u8 poll_scheduled;

  u8 loc_state;
  u8 rem_state;
  u8 loc_diag;
  u8 rem_diag;
  _Atomic struct bfd_session_state loc;
  struct bfd_session_state rem;
#define BFD_LOC_STATE(s)	atomic_load_explicit(&(s)->loc, memory_order_relaxed)

  u32 loc_id;				/* Local session ID (local discriminator) */
  u32 rem_id;				/* Remote session ID (remote discriminator) */

  struct bfd_session_config cf;		/* Static configuration parameters */
  struct bfd_session_config cf;		/* Static configuration parameers */
  event update_event;			/* Reconfiguration requested */

  u32 des_min_tx_int;			/* Desired min rx interval, local option */
  u32 des_min_tx_new;			/* Used for des_min_tx_int change */
@@ -162,6 +156,7 @@ struct bfd_session

  list request_list;			/* List of client requests (struct bfd_request) */
  btime last_state_change;		/* Time of last state change */
  btime last_reqlist_check;		/* Time of last check whether the request list is not empty */
  u8 notify_running;			/* 1 if notify hooks are running */

  u8 rx_csn_known;			/* Received crypto sequence number is known */
@@ -208,10 +203,6 @@ extern const char *bfd_state_names[];

extern const u8 bfd_auth_type_to_hash_alg[];


static inline void bfd_lock_sessions(struct bfd_proto *p) { pthread_spin_lock(&p->lock); }
static inline void bfd_unlock_sessions(struct bfd_proto *p) { pthread_spin_unlock(&p->lock); }

/* bfd.c */
struct bfd_session * bfd_find_session_by_id(struct bfd_proto *p, u32 id);
struct bfd_session * bfd_find_session_by_addr(struct bfd_proto *p, ip_addr addr, uint ifindex);
Loading