summaryrefslogtreecommitdiff
path: root/nest/iface.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-02-07 14:27:23 +0100
committerMaria Matejka <mq@ucw.cz>2023-02-07 14:27:23 +0100
commita2fd889a3b95960311560a3796be5cdf92affcfc (patch)
treea2a1a2fbe6a957a37e0b6e2241d072555e07b95a /nest/iface.h
parentf7c2a886c9fb73b2749d5e270f15b79c44e72a62 (diff)
parent0bb04d5390f21b0c96fc4894ba5d5510c541f0ef (diff)
Merge commit '0bb04d5390f21b0c96fc4894ba5d5510c541f0ef' into HEAD
Diffstat (limited to 'nest/iface.h')
-rw-r--r--nest/iface.h78
1 files changed, 75 insertions, 3 deletions
diff --git a/nest/iface.h b/nest/iface.h
index 13f3bd12..a3f4f30a 100644
--- a/nest/iface.h
+++ b/nest/iface.h
@@ -9,7 +9,9 @@
#ifndef _BIRD_IFACE_H_
#define _BIRD_IFACE_H_
+#include "lib/event.h"
#include "lib/lists.h"
+#include "lib/tlists.h"
#include "lib/ip.h"
extern list iface_list;
@@ -26,6 +28,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;
@@ -44,6 +47,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 */
@@ -114,19 +118,22 @@ 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_name(const char *);
struct iface *if_get_by_name(const char *);
void if_recalc_all_preferred_addresses(void);
+void if_link(struct iface *);
+void if_unlink(struct iface *);
+void ifa_link(struct ifa *);
+void ifa_unlink(struct ifa *);
/* 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 */
@@ -137,8 +144,16 @@ typedef struct neighbor {
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 */
@@ -148,7 +163,7 @@ 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(void);
+void neigh_prune(struct proto *);
void neigh_if_up(struct iface *);
void neigh_if_down(struct iface *);
void neigh_if_link(struct iface *);
@@ -156,6 +171,63 @@ 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;
+ 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
*/