summaryrefslogtreecommitdiff
path: root/nest/iface.h
diff options
context:
space:
mode:
Diffstat (limited to 'nest/iface.h')
-rw-r--r--nest/iface.h95
1 files changed, 78 insertions, 17 deletions
diff --git a/nest/iface.h b/nest/iface.h
index 87ad86cf..05898a55 100644
--- a/nest/iface.h
+++ b/nest/iface.h
@@ -9,20 +9,11 @@
#ifndef _BIRD_IFACE_H_
#define _BIRD_IFACE_H_
+#include "lib/locking.h"
#include "lib/event.h"
#include "lib/lists.h"
+#include "lib/tlists.h"
#include "lib/ip.h"
-#include "lib/locking.h"
-
-DEFINE_DOMAIN(attrs);
-extern list global_iface_list;
-extern DOMAIN(attrs) iface_domain;
-
-#define IFACE_LEGACY_ACCESS ASSERT_DIE(birdloop_inside(&main_birdloop))
-
-#define IFACE_LOCK LOCK_DOMAIN(attrs, iface_domain)
-#define IFACE_UNLOCK UNLOCK_DOMAIN(attrs, iface_domain)
-#define ASSERT_IFACE_LOCKED ASSERT_DIE(DOMAIN_IS_LOCKED(attrs, iface_domain))
struct proto;
struct pool;
@@ -36,6 +27,7 @@ struct ifa { /* Interface address */
ip_addr opposite; /* Opposite end of a point-to-point link */
unsigned scope; /* Interface address scope */
unsigned flags; /* Analogous to iface->flags */
+ unsigned uc; /* Use (link) count */
};
extern struct iface default_vrf;
@@ -54,6 +46,7 @@ struct iface {
struct ifa *llv6; /* Primary link-local address for IPv6 */
ip4_addr sysdep; /* Arbitrary IPv4 address for internal sysdep use */
list neighbors; /* All neighbors on this interface */
+ unsigned uc; /* Use (link) count */
};
#define IF_UP 1 /* Currently just IF_ADMIN_UP */
@@ -118,49 +111,59 @@ void ifa_dump(struct ifa *);
void if_show(void);
void if_show_summary(void);
struct iface *if_update(struct iface *);
+struct iface *if_update_locked(struct iface *);
void if_delete(struct iface *old);
struct ifa *ifa_update(struct ifa *);
void ifa_delete(struct ifa *);
void if_start_update(void);
void if_end_partial_update(struct iface *);
void if_end_update(void);
-void if_flush_ifaces(struct proto *p);
-void if_feed_baby(struct proto *);
struct iface *if_find_by_index(unsigned);
+struct iface *if_find_by_index_locked(unsigned);
struct iface *if_find_by_name(const char *);
struct iface *if_get_by_name(const char *);
void if_recalc_all_preferred_addresses(void);
+struct iface *if_walk_first(void);
+struct iface *if_walk_next(struct iface *);
+void if_walk_done(void);
+
+#define IFACE_WALK(_i) for (struct iface *_i = if_walk_first(); _i || (if_walk_done(), 0); _i = if_walk_next(_i))
/* The Neighbor Cache */
typedef struct neighbor {
node n; /* Node in neighbor hash table chain */
node if_n; /* Node in per-interface neighbor list */
+ TLIST_NODE(proto_neigh, struct neighbor) proto_n;
ip_addr addr; /* Address of the neighbor */
struct ifa *ifa; /* Ifa on related iface */
struct iface *iface; /* Interface it's connected to */
struct iface *ifreq; /* Requested iface, NULL for any */
- struct event event; /* Notification event */
struct proto *proto; /* Protocol this belongs to */
void *data; /* Protocol-specific data */
uint aux; /* Protocol-specific data */
u16 flags; /* NEF_* flags */
s16 scope; /* Address scope, -1 for unreachable neighbors,
SCOPE_HOST when it's our own address */
+ uint uc; /* Use (link) count */
} neighbor;
+#define TLIST_PREFIX proto_neigh
+#define TLIST_TYPE struct neighbor
+#define TLIST_ITEM proto_n
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+#include "lib/tlists.h"
+
#define NEF_STICKY 1
#define NEF_ONLINK 2
#define NEF_IFACE 4 /* Entry for whole iface */
-#define NEF_NOTIFY_MAIN 0x100 /* Notify from main_birdloop context */
neighbor *neigh_find(struct proto *p, ip_addr a, struct iface *ifa, uint flags);
-void neigh_dump(neighbor *);
void neigh_dump_all(void);
-void neigh_prune(struct proto *p);
void neigh_if_up(struct iface *);
void neigh_if_down(struct iface *);
void neigh_if_link(struct iface *);
@@ -168,6 +171,64 @@ void neigh_ifa_up(struct ifa *a);
void neigh_ifa_down(struct ifa *a);
void neigh_init(struct pool *);
+void neigh_link(neighbor *);
+void neigh_unlink(neighbor *);
+
+/*
+ * Notification mechanism
+ */
+
+#define TLIST_PREFIX ifnot
+#define TLIST_TYPE struct iface_notification
+#define TLIST_ITEM nn
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+
+struct iface_notification {
+ TLIST_DEFAULT_NODE;
+ enum {
+ IFNOT_INVALID,
+ IFNOT_ADDRESS,
+ IFNOT_INTERFACE,
+ IFNOT_NEIGHBOR,
+ } type;
+ unsigned flags;
+ union {
+ struct ifa *a;
+ struct iface *i;
+ neighbor *n;
+ };
+};
+
+#include "lib/tlists.h"
+
+#define TLIST_PREFIX ifsub
+#define TLIST_TYPE struct iface_subscription
+#define TLIST_ITEM n
+#define TLIST_WANT_WALK
+#define TLIST_WANT_ADD_TAIL
+
+struct iface_subscription {
+ TLIST_DEFAULT_NODE;
+
+ event event;
+ event_list *target;
+ TLIST_LIST(ifnot) queue;
+
+ void (*if_notify)(struct proto *, unsigned flags, struct iface *i);
+ void (*ifa_notify)(struct proto *, unsigned flags, struct ifa *a);
+ void (*neigh_notify)(struct neighbor *neigh);
+};
+
+#include "lib/tlists.h"
+
+void if_enqueue_notify(struct iface_notification);
+void if_enqueue_notify_to(struct iface_notification x, struct iface_subscription *s);
+
+void iface_flush_notifications(struct iface_subscription *);
+void iface_subscribe(struct iface_subscription *);
+void iface_unsubscribe(struct iface_subscription *);
+
/*
* Interface Pattern Lists
*/