static void channel_init_limit(struct channel *c, struct limit *l, int dir, struct channel_limit *cf);
static void channel_update_limit(struct channel *c, struct limit *l, int dir, struct channel_limit *cf);
static void channel_reset_limit(struct channel *c, struct limit *l, int dir);
+static int channel_refeed_prefilter(const struct rt_prefilter *p, const net_addr *n);
static void channel_feed_end(struct channel *c);
static void channel_stop_export(struct channel *c);
static void channel_export_stopped(struct rt_export_request *req);
c->refeed_req.dump_req = channel_dump_refeed_req;
c->refeed_req.log_state_change = channel_refeed_log_state_change;
c->refeed_req.mark_seen = channel_rpe_mark_seen_refeed;
+ c->refeed_req.prefilter.hook = channel_refeed_prefilter;
DBG("%s.%s: Channel start export req=%p\n", c->proto->name, c->name, &c->out_req);
rt_request_export(c->table, &c->out_req);
c->refeeding = c->refeed_pending;
c->refeed_pending = NULL;
c->refeed_trie = f_new_trie(lp_new(c->proto->pool), 0);
+
rt_request_export(c->table, &c->refeed_req);
}
+static int
+channel_refeed_prefilter(const struct rt_prefilter *p, const net_addr *n)
+{
+ const struct channel *c =
+ SKIP_BACK(struct channel, refeed_req,
+ SKIP_BACK(struct rt_export_request, prefilter, p)
+ );
+
+ for (struct channel_feeding_request *cfr = c->refeeding; cfr; cfr = cfr->next)
+ if (!cfr->trie || trie_match_net(cfr->trie, n))
+ return 1;
+
+ return 0;
+}
+
+
static void
channel_feed_end(struct channel *c)
{
/* fall through */
case TE_ADDR_NONE:
case TE_ADDR_TRIE:
+ case TE_ADDR_HOOK:
FIB_ITERATE_INIT(&hook->feed_fit, &tab->fib);
hook->h.event.hook = rt_feed_by_fib;
break;
}
/* fall through */
case TE_ADDR_NONE:
+ case TE_ADDR_HOOK:
case TE_ADDR_TRIE:
fit_get(&tab->fib, &hook->feed_fit);
break;
return;
}
}
+ else
+ req_trace(c->h.req, D_ROUTES, "Feeding %N rejected by prefilter", n->n.addr);
}
FIB_ITERATE_END;
}
union {
const struct f_trie *trie;
const net_addr *addr; /* Network prefilter address */
+ int (*hook)(const struct rt_prefilter *, const net_addr *);
};
/* Network prefilter mode (TE_ADDR_*) */
enum {
TE_ADDR_FOR, /* Longest prefix match - show route for <addr> */
TE_ADDR_IN, /* Interval query - show route in <addr> */
TE_ADDR_TRIE, /* Query defined by trie */
+ TE_ADDR_HOOK, /* Query processed by supplied custom hook */
} mode;
} PACKED;
case TE_ADDR_EQUAL: return net_equal(n, p->addr);
case TE_ADDR_FOR: return net_in_netX(p->addr, n);
case TE_ADDR_TRIE: return trie_match_net(p->trie, n);
+ case TE_ADDR_HOOK: return p->hook(p, n);
}
bug("Crazy prefilter application attempt failed wildly.");