diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-09-12 16:33:29 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-09-12 16:33:29 +0200 |
commit | f2dd602fef2ecf0a6598b817d71ce2ee8fadd5cc (patch) | |
tree | 5f6a44704530554148565c7f0a563ad124bd79c3 | |
parent | 9f4908fe78cb3e5191bca721588ee1acb10876e3 (diff) |
Backport some minor changes from int-new
-rw-r--r-- | lib/birdlib.h | 3 | ||||
-rw-r--r-- | nest/protocol.h | 12 | ||||
-rw-r--r-- | nest/route.h | 5 | ||||
-rw-r--r-- | nest/rt-table.c | 16 | ||||
-rw-r--r-- | proto/bgp/attrs.c | 2 |
5 files changed, 22 insertions, 16 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h index d21cdf1f..aaa7a0a3 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -37,6 +37,9 @@ struct align_probe { char x; long int y; }; #define ABS(a) ((a)>=0 ? (a) : -(a)) #define DELTA(a,b) (((a)>=(b))?(a)-(b):(b)-(a)) #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) +#define BYTES(n) ((((uint) (n)) + 7) / 8) +#define CALL(fn, args...) ({ if (fn) fn(args); }) +#define ADVANCE(w, r, l) ({ r -= l; w += l; }) /* Bitfield macros */ diff --git a/nest/protocol.h b/nest/protocol.h index 3c30a581..18dfbd6f 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -12,6 +12,7 @@ #include "lib/lists.h" #include "lib/resource.h" #include "lib/timer.h" +#include "nest/route.h" #include "conf/conf.h" struct iface; @@ -287,6 +288,17 @@ proto_get_router_id(struct proto_config *pc) return pc->router_id ? pc->router_id : pc->global->router_id; } +static inline struct ea_list * +rte_make_tmp_attrs(struct rte *rt, struct linpool *pool) +{ + struct ea_list *(*mta)(struct rte *rt, struct linpool *pool); + mta = rt->attrs->src->proto->make_tmp_attrs; + return mta ? mta(rt, pool) : NULL; +} + +/* Moved from route.h to avoid dependency conflicts */ +static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_ahook, net, new, p->main_source); } + extern list active_proto_list; /* diff --git a/nest/route.h b/nest/route.h index 383f4def..2e6ae5bf 100644 --- a/nest/route.h +++ b/nest/route.h @@ -12,10 +12,11 @@ #include "lib/lists.h" #include "lib/resource.h" #include "lib/timer.h" -#include "nest/protocol.h" +struct ea_list; struct protocol; struct proto; +struct rte_src; struct symbol; struct filter; struct cli; @@ -273,7 +274,7 @@ static inline net *net_get(rtable *tab, ip_addr addr, unsigned len) { return (ne rte *rte_find(net *net, struct rte_src *src); rte *rte_get_temp(struct rta *); void rte_update2(struct announce_hook *ah, net *net, rte *new, struct rte_src *src); -static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_ahook, net, new, p->main_source); } +/* rte_update() moved to protocol.h to avoid dependency conflicts */ int rt_examine(rtable *t, ip_addr prefix, int pxlen, struct proto *p, struct filter *filter); rte *rt_export_merged(struct announce_hook *ah, net *net, rte **rt_free, struct ea_list **tmpa, linpool *pool, int silent); void rt_refresh_begin(rtable *t, struct announce_hook *ah); diff --git a/nest/rt-table.c b/nest/rt-table.c index c6e48c38..bcb48b53 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -60,14 +60,6 @@ static inline void rt_schedule_gc(rtable *tab); static inline void rt_schedule_prune(rtable *tab); -static inline struct ea_list * -make_tmp_attrs(struct rte *rt, struct linpool *pool) -{ - struct ea_list *(*mta)(struct rte *rt, struct linpool *pool); - mta = rt->attrs->src->proto->make_tmp_attrs; - return mta ? mta(rt, pool) : NULL; -} - /* Like fib_route(), but skips empty net entries */ static net * net_route(rtable *tab, ip_addr a, int len) @@ -260,7 +252,7 @@ export_filter_(struct announce_hook *ah, rte *rt0, rte **rt_free, ea_list **tmpa if (!tmpa) tmpa = &tmpb; - *tmpa = make_tmp_attrs(rt, pool); + *tmpa = rte_make_tmp_attrs(rt, pool); v = p->import_control ? p->import_control(p, &rt, tmpa, pool) : 0; if (v < 0) @@ -1223,7 +1215,7 @@ rte_update2(struct announce_hook *ah, net *net, rte *new, struct rte_src *src) } else { - tmpa = make_tmp_attrs(new, rte_update_pool); + tmpa = rte_make_tmp_attrs(new, rte_update_pool); if (filter && (filter != FILTER_REJECT)) { ea_list *old_tmpa = tmpa; @@ -1303,7 +1295,7 @@ rt_examine(rtable *t, ip_addr prefix, int pxlen, struct proto *p, struct filter rte_update_lock(); /* Rest is stripped down export_filter() */ - ea_list *tmpa = make_tmp_attrs(rt, rte_update_pool); + ea_list *tmpa = rte_make_tmp_attrs(rt, rte_update_pool); int v = p->import_control ? p->import_control(p, &rt, &tmpa, rte_update_pool) : 0; if (v == RIC_PROCESS) v = (f_run(filter, &rt, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) <= F_ACCEPT); @@ -2470,7 +2462,7 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d) ee = e; rte_update_lock(); /* We use the update buffer for filtering */ - tmpa = make_tmp_attrs(e, rte_update_pool); + tmpa = rte_make_tmp_attrs(e, rte_update_pool); /* Special case for merged export */ if ((d->export_mode == RSEM_EXPORT) && (d->export_protocol->accept_ra_types == RA_MERGED)) diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index b9e2490d..73eb4040 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -469,8 +469,6 @@ bgp_get_attr_len(eattr *a) return len; } -#define ADVANCE(w, r, l) do { r -= l; w += l; } while (0) - /** * bgp_encode_attrs - encode BGP attributes * @p: BGP instance |