diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-06-10 14:34:41 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-12-22 13:23:52 +0100 |
commit | ec5e5d23faa482495c84163c4ae38d9a31bdc00f (patch) | |
tree | db050c0a90a18b4452630b2929d97d1a9ebe19ef /nest/route.h | |
parent | 5b208e296fed0beddce16188478c5119df610d89 (diff) |
Nexthop: Support for label stack in nest
Diffstat (limited to 'nest/route.h')
-rw-r--r-- | nest/route.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nest/route.h b/nest/route.h index 154e027e..d9a1737b 100644 --- a/nest/route.h +++ b/nest/route.h @@ -338,6 +338,8 @@ struct nexthop { struct iface *iface; /* Outgoing interface */ struct nexthop *next; byte weight; + byte labels; /* Number of labels appended */ + u32 label[0]; }; struct rte_src { @@ -510,16 +512,21 @@ uint ea_hash(ea_list *e); /* Calculate 16-bit hash value */ ea_list *ea_append(ea_list *to, ea_list *what); void ea_format_bitfield(struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max); +#define NEXTHOP_MAX_LABEL_STACK 8 + +static inline size_t nexthop_size(const struct nexthop *nh) +{ return sizeof(struct nexthop) + sizeof(u32)*nh->labels; } int nexthop__same(struct nexthop *x, struct nexthop *y); /* Compare multipath nexthops */ static inline int nexthop_same(struct nexthop *x, struct nexthop *y) { return (x == y) || nexthop__same(x, y); } struct nexthop *nexthop_merge(struct nexthop *x, struct nexthop *y, int rx, int ry, int max, linpool *lp); static inline void nexthop_link(struct rta *a, struct nexthop *from) -{ a->nh.gw = from->gw; a->nh.iface = from->iface; a->nh.weight = from->weight; a->nh.next = from->next; } +{ memcpy(&a->nh, from, nexthop_size(from)); } void nexthop_insert(struct nexthop *n, struct nexthop *y); int nexthop_is_sorted(struct nexthop *x); void rta_init(void); +static inline size_t rta_size(const rta *a) { return sizeof(rta) + sizeof(u32)*a->nh.labels; } rta *rta_lookup(rta *); /* Get rta equivalent to this one, uc++ */ static inline int rta_is_cached(rta *r) { return r->aflags & RTAF_CACHED; } static inline rta *rta_clone(rta *r) { r->uc++; return r; } |