summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/rde.h
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-08-06 12:04:09 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-08-06 12:04:09 +0000
commit1702f711eb5a6da7d226fd633c14c8a22cc5c448 (patch)
treef5642b4adf97d5d2f86ff168b7bbb9855f6a18b1 /usr.sbin/bgpd/rde.h
parent232c877040ea69df2d195a2de71e66da045030f0 (diff)
Monster diff to get one step closer to IPv6 support.
Cleanup path attribute handling. First of all kill struct attr_flags, all those infos are now in struct rde_aspath. Second move attribute parser functions into rde.c, rde_attr.c is shared between bgpd and bgpctl. Third reimplementation of the nexthop handling. Make it IPv6 ready and fix some major bug relating to "set nexthop". henning@ OK if it breaks nothing
Diffstat (limited to 'usr.sbin/bgpd/rde.h')
-rw-r--r--usr.sbin/bgpd/rde.h127
1 files changed, 69 insertions, 58 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 17007e6cc8d..16612845a3b 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.50 2004/08/05 20:56:12 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.51 2004/08/06 12:04:08 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -63,6 +63,8 @@ struct rde_peer {
struct uptree_attr up_attrs;
struct uplist_attr updates;
struct uplist_prefix withdraws;
+ struct uplist_attr updates6;
+ struct uplist_prefix withdraws6;
};
#define AS_SET 1
@@ -105,32 +107,64 @@ enum attrtypes {
#define ATTR_WELL_KNOWN ATTR_TRANSITIVE
struct attr {
+ TAILQ_ENTRY(attr) entry;
u_int8_t flags;
u_int8_t type;
u_int16_t len;
u_char *data;
- TAILQ_ENTRY(attr) entry;
+};
+
+struct mpattr {
+ void *reach;
+ u_int16_t reach_len;
+ void *unreach;
+ u_int16_t unreach_len;
};
TAILQ_HEAD(attr_list, attr);
+struct path_table {
+ struct aspath_head *path_hashtbl;
+ u_int32_t path_hashmask;
+};
+
+LIST_HEAD(prefix_head, prefix);
+
+#define F_ATTR_ORIGIN 0x001
+#define F_ATTR_ASPATH 0x002
+#define F_ATTR_NEXTHOP 0x004
+#define F_ATTR_LOCALPREF 0x008
+#define F_ATTR_MED 0x010
+#define F_ATTR_MP_REACH 0x020
+#define F_ATTR_MP_UNREACH 0x040
+#define F_PREFIX_ANNOUNCED 0x080
+#define F_NEXTHOP_REJECT 0x100
+#define F_NEXTHOP_BLACKHOLE 0x200
+#define F_ATTR_LINKED 0x400
+
#define ORIGIN_IGP 0
#define ORIGIN_EGP 1
#define ORIGIN_INCOMPLETE 2
#define DEFAULT_LPREF 100
-struct attr_flags {
+struct rde_aspath {
+ LIST_ENTRY(rde_aspath) path_l, peer_l, nexthop_l;
+ struct prefix_head prefix_h;
+ struct rde_peer *peer;
+
+ /* path attributes */
struct aspath *aspath;
- struct in_addr nexthop; /* exit nexthop */
- u_int8_t nexthop_reject;
- u_int8_t nexthop_blackhole;
- char pftable[PFTABLE_LEN];
+ struct nexthop *nexthop; /* may be NULL */
+ struct attr_list others;
u_int32_t med; /* multi exit disc */
u_int32_t lpref; /* local pref */
u_int8_t origin;
- u_int8_t wflags; /* internally used */
- struct attr_list others;
+
+ u_int16_t flags; /* internally used */
+ u_int16_t prefix_cnt; /* # of prefixes */
+ u_int16_t active_cnt; /* # of active prefixes */
+ char pftable[PFTABLE_LEN];
};
enum nexthop_state {
@@ -141,7 +175,7 @@ enum nexthop_state {
struct nexthop {
LIST_ENTRY(nexthop) nexthop_l;
- enum nexthop_state state;
+ struct aspath_head path_h;
#if 0
/*
* currently we use the boolean nexthop state, this could be exchanged
@@ -149,31 +183,14 @@ struct nexthop {
*/
u_int32_t costs;
#endif
- struct aspath_head path_h;
+ enum nexthop_state state;
struct bgpd_addr exit_nexthop;
struct bgpd_addr true_nexthop;
struct bgpd_addr nexthop_net;
u_int8_t nexthop_netlen;
u_int8_t flags;
-#define NEXTHOP_CONNECTED 0x1
-#define NEXTHOP_ANNOUNCE 0x2
-};
-
-struct path_table {
- struct aspath_head *path_hashtbl;
- u_int32_t path_hashmask;
-};
-
-LIST_HEAD(prefix_head, prefix);
-
-struct rde_aspath {
- LIST_ENTRY(rde_aspath) peer_l, path_l, nexthop_l;
- struct prefix_head prefix_h;
- struct rde_peer *peer;
- struct nexthop *nexthop;
- u_int16_t prefix_cnt; /* # of prefixes */
- u_int16_t active_cnt; /* # of active prefixes */
- struct attr_flags flags;
+#define NEXTHOP_CONNECTED 0x01
+#define NEXTHOP_LINKLOCAL 0x02
};
/* generic entry without address specific part */
@@ -214,14 +231,12 @@ struct prefix {
struct pt_entry *prefix;
struct rde_peer *peer;
time_t lastchange;
-/* currently I can't think of additional prefix flags.
- * NOTE: the selected route is stored in prefix->active */
};
/* prototypes */
/* rde.c */
void rde_send_kroute(struct prefix *, struct prefix *);
-void rde_send_nexthop(struct bgpd_addr *, int);
+void rde_send_nexthop(struct bgpd_addr *, struct bgpd_addr *, int);
void rde_send_pftable(const char *, struct bgpd_addr *,
u_int8_t, int);
void rde_send_pftable_commit(void);
@@ -231,25 +246,15 @@ u_int16_t rde_local_as(void);
int rde_noevaluate(void);
/* rde_attr.c */
-void attr_init(struct attr_flags *);
-int attr_parse(u_char *, u_int16_t, struct attr_flags *, int,
- enum enforce_as, u_int16_t);
-u_char *attr_error(u_char *, u_int16_t, struct attr_flags *,
- u_int8_t *, u_int16_t *);
-u_int8_t attr_missing(struct attr_flags *, int);
-int attr_compare(struct attr_flags *, struct attr_flags *);
-void attr_copy(struct attr_flags *, struct attr_flags *);
-void attr_move(struct attr_flags *, struct attr_flags *);
-void attr_free(struct attr_flags *);
int attr_write(void *, u_int16_t, u_int8_t, u_int8_t, void *,
u_int16_t);
-int attr_optadd(struct attr_flags *, u_int8_t, u_int8_t,
+void attr_optcopy(struct rde_aspath *, struct rde_aspath *);
+int attr_optadd(struct rde_aspath *, u_int8_t, u_int8_t,
void *, u_int16_t);
-struct attr *attr_optget(const struct attr_flags *, u_int8_t);
-void attr_optfree(struct attr_flags *);
-int attr_ismp(const struct attr_flags *);
-int attr_mp_nexthop_check(u_char *, u_int16_t, u_int16_t);
-struct bgpd_addr *attr_mp_nexthop(const struct attr_flags *);
+struct attr *attr_optget(const struct rde_aspath *, u_int8_t);
+void attr_optfree(struct rde_aspath *);
+int attr_mp_nexthop(u_char *, u_int16_t, u_int16_t,
+ struct rde_aspath *);
int aspath_verify(void *, u_int16_t);
#define AS_ERR_LEN -1
@@ -277,18 +282,21 @@ int community_set(struct attr *, int, int);
/* rde_rib.c */
void path_init(u_int32_t);
void path_shutdown(void);
-void path_update(struct rde_peer *, struct attr_flags *,
+void path_update(struct rde_peer *, struct rde_aspath *,
struct bgpd_addr *, int);
-struct rde_aspath *path_get(struct aspath *, struct rde_peer *);
-struct rde_aspath *path_add(struct rde_peer *, struct attr_flags *);
+int path_compare(struct rde_aspath *, struct rde_aspath *);
+struct rde_aspath *path_lookup(struct rde_aspath *, struct rde_peer *);
void path_remove(struct rde_aspath *);
void path_updateall(struct rde_aspath *, enum nexthop_state);
void path_destroy(struct rde_aspath *);
int path_empty(struct rde_aspath *);
+struct rde_aspath *path_copy(struct rde_aspath *);
+struct rde_aspath *path_get(void);
+void path_put(struct rde_aspath *);
int prefix_compare(const struct bgpd_addr *,
const struct bgpd_addr *, int);
-struct prefix *prefix_get(struct rde_aspath *, struct bgpd_addr *, int);
+struct prefix *prefix_get(struct rde_peer *, struct bgpd_addr *, int);
struct pt_entry *prefix_add(struct rde_aspath *, struct bgpd_addr *, int);
struct pt_entry *prefix_move(struct rde_aspath *, struct prefix *);
void prefix_remove(struct rde_peer *, struct bgpd_addr *, int);
@@ -299,9 +307,12 @@ void prefix_network_clean(struct rde_peer *, time_t);
void nexthop_init(u_int32_t);
void nexthop_shutdown(void);
-void nexthop_add(struct rde_aspath *);
-void nexthop_remove(struct rde_aspath *);
+void nexthop_modify(struct rde_aspath *, struct bgpd_addr *, int);
+void nexthop_link(struct rde_aspath *);
+void nexthop_unlink(struct rde_aspath *);
void nexthop_update(struct kroute_nexthop *);
+struct nexthop *nexthop_get(struct bgpd_addr *, struct bgpd_addr *);
+int nexthop_compare(struct nexthop *, struct nexthop *);
/* rde_decide.c */
void prefix_evaluate(struct prefix *, struct pt_entry *);
@@ -328,9 +339,9 @@ void pt_dump(void (*)(struct pt_entry *, void *), void *,
sa_family_t);
/* rde_filter.c */
-enum filter_actions rde_filter(struct rde_peer *, struct attr_flags *,
+enum filter_actions rde_filter(struct rde_peer *, struct rde_aspath *,
struct bgpd_addr *, u_int8_t, enum directions);
-void rde_apply_set(struct attr_flags *, struct filter_set *);
-int rde_filter_community(struct attr_flags *, int, int);
+void rde_apply_set(struct rde_aspath *, struct filter_set *);
+int rde_filter_community(struct rde_aspath *, int, int);
#endif /* __RDE_H__ */