From 5a03fc4fa4a9a7d4b8e8d821c8a786939be9605e Mon Sep 17 00:00:00 2001 From: Nicolas Rybowski Date: Thu, 31 Oct 2024 17:06:33 +0100 Subject: [PATCH] bierroutetable: batch route addition --- elements/bier/bierroutetable.cc | 34 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/elements/bier/bierroutetable.cc b/elements/bier/bierroutetable.cc index a2ade5dd1..00644fed4 100644 --- a/elements/bier/bierroutetable.cc +++ b/elements/bier/bierroutetable.cc @@ -44,29 +44,39 @@ int BierRouteTable::add_route_handler(const String &conf, Element *e, void *, Er Vector words; cp_spacevec(conf, words); - bfrid dst; - IP6Address bfr_prefix; bitstring fbm; IP6Address nxt; int output; String ifname; + String raw_bfrs; - int ok; - - // TODO: read_all for BFRID and define dst as an array for route addition batching - ok = Args(words, r, errh) - .read_mp("BFRID", dst) - .read_mp("BFRPREFIX", bfr_prefix) + if ( + Args(words, r, errh) .read_mp("BITSTRING", fbm) .read_mp("NXT", nxt) .read_mp("IFIDX", output) .read_mp("IFNAME", ifname) - .complete(); + .read_mp("BFR", raw_bfrs) + .complete() < 0 + ) + return -1; + + Vector bfrs; + cp_argvec(raw_bfrs, bfrs); - if (ok >= 0) - ok = r->add_route(dst, bfr_prefix, fbm, nxt, output, ifname, errh); + for (int i=0; i bfr = bfrs[i].split('_'); + if (bfr.size() != 2) { + click_chatter("Invalid BFR specification. Should be \"BFR _\""); + continue; + } + if (r->add_route((bfrid) atoi(bfr[0].c_str()), IP6Address(bfr[1]), fbm, nxt, output, ifname, errh)) { + click_chatter("Failed to add BIFT entry. Ignoring."); + continue; + } + } - return ok; + return 0; } String BierRouteTable::table_handler(Element *e, void *) {