summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-03-30 11:37:16 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-04 17:00:58 +0200
commit98f69aa4190d31f749ac4999cab9700850da15a9 (patch)
tree12fe6cc21538293df98e118ae54ee84567fdaf45 /nest
parent3a53a12af4fb300ab18052ec485e2b825808f670 (diff)
Propagated const through route feed routines
Diffstat (limited to 'nest')
-rw-r--r--nest/rt-show.c6
-rw-r--r--nest/rt-table.c30
-rw-r--r--nest/rt.h12
3 files changed, 24 insertions, 24 deletions
diff --git a/nest/rt-show.c b/nest/rt-show.c
index d8eb2174..40202ef6 100644
--- a/nest/rt-show.c
+++ b/nest/rt-show.c
@@ -40,7 +40,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
byte tm[TM_DATETIME_BUFFER_SIZE], info[256];
ea_list *a = e->attrs;
int sync_error = d->tab->kernel ? krt_get_sync_error(d->tab->kernel, e) : 0;
- void (*get_route_info)(struct rte *, byte *buf);
+ void (*get_route_info)(const rte *, byte *buf);
eattr *nhea = net_type_match(e->net, NB_DEST) ?
ea_find(a, &ea_gen_nexthop) : NULL;
struct nexthop_adata *nhad = nhea ? (struct nexthop_adata *) nhea->u.ptr : NULL;
@@ -93,7 +93,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
}
static void
-rt_show_net(struct rt_show_data *d, const net_addr *n, rte **feed, uint count)
+rt_show_net(struct rt_show_data *d, const net_addr *n, const rte **feed, uint count)
{
struct cli *c = d->cli;
byte ia[NET_MAX_TEXT_LENGTH+1];
@@ -211,7 +211,7 @@ rt_show_net(struct rt_show_data *d, const net_addr *n, rte **feed, uint count)
static void
rt_show_net_export_bulk(struct rt_export_request *req, const net_addr *n,
- struct rt_pending_export *rpe UNUSED, rte **feed, uint count)
+ struct rt_pending_export *rpe UNUSED, const rte **feed, uint count)
{
struct rt_show_data *d = SKIP_BACK(struct rt_show_data, req, req);
return rt_show_net(d, n, feed, count);
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 8b9b2017..d52131c3 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -670,9 +670,9 @@ rte_free(struct rte_storage *e)
}
static int /* Actually better or at least as good as */
-rte_better(rte *new, rte *old)
+rte_better(const rte *new, const rte *old)
{
- int (*better)(rte *, rte *);
+ int (*better)(const rte *, const rte *);
if (!rte_is_valid(old))
return 1;
@@ -701,9 +701,9 @@ rte_better(rte *new, rte *old)
}
static int
-rte_mergable(rte *pri, rte *sec)
+rte_mergable(const rte *pri, const rte *sec)
{
- int (*mergable)(rte *, rte *);
+ int (*mergable)(const rte *, const rte *);
if (!rte_is_valid(pri) || !rte_is_valid(sec))
return 0;
@@ -771,7 +771,7 @@ rte_feed_count(net *n)
}
static void
-rte_feed_obtain(net *n, struct rte **feed, uint count)
+rte_feed_obtain(net *n, const rte **feed, uint count)
{
uint i = 0;
for (struct rte_storage *e = n->routes; e; e = e->next)
@@ -921,7 +921,7 @@ channel_rpe_mark_seen(struct rt_export_request *req, struct rt_pending_export *r
void
rt_notify_accepted(struct rt_export_request *req, const net_addr *n, struct rt_pending_export *first,
- struct rte **feed, uint count)
+ const rte **feed, uint count)
{
struct channel *c = SKIP_BACK(struct channel, out_req, req);
@@ -985,13 +985,13 @@ done:
}
rte *
-rt_export_merged(struct channel *c, struct rte **feed, uint count, linpool *pool, int silent)
+rt_export_merged(struct channel *c, const rte **feed, uint count, linpool *pool, int silent)
{
_Thread_local static rte rloc;
// struct proto *p = c->proto;
struct nexthop_adata *nhs = NULL;
- rte *best0 = feed[0];
+ const rte *best0 = feed[0];
rte *best = NULL;
if (!rte_is_valid(best0))
@@ -1048,7 +1048,7 @@ rt_export_merged(struct channel *c, struct rte **feed, uint count, linpool *pool
void
rt_notify_merged(struct rt_export_request *req, const net_addr *n, struct rt_pending_export *first,
- struct rte **feed, uint count)
+ const rte **feed, uint count)
{
struct channel *c = SKIP_BACK(struct channel, out_req, req);
@@ -1063,7 +1063,7 @@ rt_notify_merged(struct rt_export_request *req, const net_addr *n, struct rt_pen
return;
#endif
- rte *old_best = NULL;
+ const rte *old_best = NULL;
/* Find old best route */
for (uint i = 0; i < count; i++)
if (bmap_test(&c->export_map, feed[i]->id))
@@ -1140,7 +1140,7 @@ rt_notify_any(struct rt_export_request *req, const net_addr *net, struct rt_pend
}
void
-rt_feed_any(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe UNUSED, rte **feed, uint count)
+rt_feed_any(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe UNUSED, const rte **feed, uint count)
{
struct channel *c = SKIP_BACK(struct channel, out_req, req);
@@ -1223,7 +1223,7 @@ rte_export(struct rt_table_export_hook *th, struct rt_pending_export *rpe)
net *net = SKIP_BACK(struct network, n.addr, (net_addr (*)[0]) n);
RT_LOCK(tab);
uint count = rte_feed_count(net);
- rte **feed = NULL;
+ const rte **feed = NULL;
if (count)
{
feed = alloca(count * sizeof(rte *));
@@ -4204,7 +4204,7 @@ typedef struct {
union {
struct rt_pending_export *rpe;
struct {
- rte **feed;
+ const rte **feed;
uint *start;
};
};
@@ -4257,7 +4257,7 @@ rt_process_feed(struct rt_table_export_hook *c, rt_feed_block *b)
b->start[b->pos] = b->cnt;
for (uint p = 0; p < b->pos; p++)
{
- rte **feed = &b->feed[b->start[p]];
+ const rte **feed = &b->feed[b->start[p]];
c->h.req->export_bulk(c->h.req, feed[0]->net, NULL, feed, b->start[p+1] - b->start[p]);
}
}
@@ -4403,7 +4403,7 @@ rt_feed_for(void *data)
* Import table
*/
-void channel_reload_export_bulk(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe UNUSED, rte **feed, uint count)
+void channel_reload_export_bulk(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe UNUSED, const rte **feed, uint count)
{
struct channel *c = SKIP_BACK(struct channel, reload_req, req);
diff --git a/nest/rt.h b/nest/rt.h
index 9a149bfc..857ed2ca 100644
--- a/nest/rt.h
+++ b/nest/rt.h
@@ -303,7 +303,7 @@ struct rt_export_request {
* and for RA_ANY, both are set to accomodate for feeding all routes but receiving single changes
*/
void (*export_one)(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe);
- void (*export_bulk)(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
+ void (*export_bulk)(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, const rte **feed, uint count);
void (*dump_req)(struct rt_export_request *req);
void (*log_state_change)(struct rt_export_request *req, u8);
@@ -444,13 +444,13 @@ void rt_exporter_init(struct rt_exporter *re);
int channel_preimport(struct rt_import_request *req, rte *new, rte *old);
-void channel_reload_export_bulk(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
+void channel_reload_export_bulk(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, const rte **feed, uint count);
void rt_notify_optimal(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe);
void rt_notify_any(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe);
-void rt_feed_any(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
-void rt_notify_accepted(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
-void rt_notify_merged(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, rte **feed, uint count);
+void rt_feed_any(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, const rte **feed, uint count);
+void rt_notify_accepted(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, const rte **feed, uint count);
+void rt_notify_merged(struct rt_export_request *req, const net_addr *net, struct rt_pending_export *rpe, const rte **feed, uint count);
@@ -576,7 +576,7 @@ static inline net *net_find_valid(struct rtable_private *tab, const net_addr *ad
static inline net *net_get(struct rtable_private *tab, const net_addr *addr) { return (net *) fib_get(&tab->fib, addr); }
net *net_route(struct rtable_private *tab, const net_addr *n);
int rt_examine(rtable *t, net_addr *a, struct channel *c, const struct filter *filter);
-rte *rt_export_merged(struct channel *c, rte ** feed, uint count, linpool *pool, int silent);
+rte *rt_export_merged(struct channel *c, const rte ** feed, uint count, linpool *pool, int silent);
void rt_refresh_begin(struct rt_import_request *);
void rt_refresh_end(struct rt_import_request *);
void rt_modify_stale(rtable *t, struct rt_import_request *);