From: Jan Maria Matejka Date: Wed, 4 Apr 2018 08:42:54 +0000 (+0200) Subject: Merge branch 'int-new' into show-route X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92bccd4ccdb8047f4721808c090508d51de13aa0;p=thirdparty%2Fbird.git Merge branch 'int-new' into show-route Updated static flowspec action definition to the new filter syntax. --- 92bccd4ccdb8047f4721808c090508d51de13aa0 diff --cc lib/net.c index 09e5354a5,976ddbcc7..a73b9ce5d --- a/lib/net.c +++ b/lib/net.c @@@ -99,9 -103,11 +103,11 @@@ net_format(const net_addr *N, char *buf case NET_ROA6: return bsnprintf(buf, buflen, "%I6/%u-%u AS%u", n->roa6.prefix, n->roa6.pxlen, n->roa6.max_pxlen, n->roa6.asn); case NET_FLOW4: - return flow4_net_format(buf, buflen, &n->flow4); + return flow4_net_format(buf, buflen, &n->flow4, " "); case NET_FLOW6: - return flow6_net_format(buf, buflen, &n->flow6); + return flow6_net_format(buf, buflen, &n->flow6, " "); + case NET_IP6_SADR: + return bsnprintf(buf, buflen, "%I6/%d from %I6/%d", n->ip6_sadr.dst_prefix, n->ip6_sadr.dst_pxlen, n->ip6_sadr.src_prefix, n->ip6_sadr.src_pxlen); case NET_MPLS: return bsnprintf(buf, buflen, "%u", n->mpls.label); } diff --cc lib/printf.c index d160dc150,533a1300b..8077b0cbd --- a/lib/printf.c +++ b/lib/printf.c @@@ -365,12 -362,50 +367,57 @@@ int bvsnprintf(char *buf, int size, con s = ipbuf; goto str; + /* float number formats delegated to stdio */ + case 'f': + memcpy(fmtbuf, percent, (fmt - percent) + 1); + snprintf(ipbuf, sizeof(ipbuf), fmtbuf, va_arg(args, double)); + s = ipbuf; + goto str; ++ + case 't': + t = va_arg(args, btime); + t1 = t TO_S; + t2 = t - t1 S; + + if (precision < 0) + precision = 3; + + if (precision > 6) + precision = 6; + + /* Compute field_width for second part */ + if ((precision > 0) && (field_width > 0)) + field_width -= (1 + precision); + + if (field_width < 0) + field_width = 0; + + /* Print seconds */ + flags |= SIGN; + str = number(str, t1, 10, field_width, 0, flags, size); + if (!str) + return -1; + + if (precision > 0) + { + size -= (str-start); + start = str; + + if ((1 + precision) > size) + return -1; + + /* Convert microseconds to requested precision */ + for (i = precision; i < 6; i++) + t2 /= 10; + + /* Print sub-seconds */ + *str++ = '.'; + str = number(str, t2, 10, precision, 0, ZEROPAD, size - 1); + if (!str) + return -1; + } + goto done; + /* integer number formats - set up the flags and "break" */ case 'o': base = 8; diff --cc nest/rt-show.c index 74de837b9,1f1b73d20..94e1a73e7 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@@ -81,15 -39,7 +81,15 @@@ rt_show_rte(struct cli *c, byte *ia, rt void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); struct nexthop *nh; + byte ai[1024] = {0}; + switch (e->net->n.addr->type) { + case NET_FLOW4: + case NET_FLOW6: + rt_flow_action_format(ai, sizeof(ai) - 1, e); + break; + } + - tm_format_datetime(tm, &config->tf_route, e->lastmod); + tm_format_time(tm, &config->tf_route, e->lastmod); if (ipa_nonzero(a->from) && !ipa_equal(a->from, a->nh.gw)) bsprintf(from, " from %I", a->from); else @@@ -113,7 -63,7 +113,7 @@@ if (d->last_table != d->tab) rt_show_table(c, d); - cli_printf(c, -1007, "%-18s%s %s [%s %s%s]%s%s", ia, ai, rta_dest_name(a->dest), - cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s", ia, rta_dest_name(a->dest), ++ cli_printf(c, -1007, "%-20s%s %s [%s %s%s]%s%s", ia, ai, rta_dest_name(a->dest), a->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info); if (a->dest == RTD_UNICAST) diff --cc proto/static/config.Y index 9f092c1fa,66e5ea4c2..1df12561a --- a/proto/static/config.Y +++ b/proto/static/config.Y @@@ -52,30 -41,10 +52,30 @@@ static_route_finish(void cf_error("Unexpected or missing nexthop/type"); } +static void +static_flow_action(u64 ec) +{ + NEW_F_VAL; + + val->type = T_EC; val->val.ec = ec; - struct f_inst *fic = f_new_inst(); - fic->code = 'C'; fic->a1.p = val; ++ struct f_inst *fic = f_new_inst(FI_CONSTANT_INDIRECT); ++ fic->a1.p = val; + *this_srt_last_cmd = f_generate_complex( - P('C','a'), 'a', ++ FI_CLIST_ADD_DEL, 'a', + f_new_dynamic_attr(EAF_TYPE_EC_SET, T_ECLIST, EA_CODE(EAP_BGP, BA_EXT_COMMUNITY)), + fic + ); + this_srt_last_cmd = &((*this_srt_last_cmd)->next); +} + CF_DECLS +%type float_rate + CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK) CF_KEYWORDS(ONLINK, WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS) +CF_KEYWORDS(RATE, SAMPLE, LAST, DSCP) +CF_KEYWORDS_CS(mBps, mbps, Bps, bps, kBps, kbps, MBps, Mbps, GBps, Gbps, TBps, Tbps) CF_GRAMMAR