diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-05-01 05:17:55 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-06-18 13:31:39 +0000 |
commit | 097fa66b986f06281f603767d321ab13ab6c88c3 (patch) | |
tree | ed052819615d08ee4bd0afbc34de7e64e4598105 /extras/vom/vom/api_types.cpp | |
parent | 39baa32186fd3e4b20d9f58afbbfe7b8daebed62 (diff) |
fib: fib api updates
Enhance the route add/del APIs to take a set of paths rather than just one.
Most unicast routing protocols calcualte all the available paths in one
run of the algorithm so updating all the paths at once is beneficial for the client.
two knobs control the behaviour:
is_multipath - if set the the set of paths passed will be added to those
that already exist, otherwise the set will replace them.
is_add - add or remove the set
is_add=0, is_multipath=1 and an empty set, results in deleting the route.
It is also considerably faster to add multiple paths at once, than one at a time:
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.11
100000 routes in .572240 secs, 174751.80 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.12
100000 routes in .528383 secs, 189256.54 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.13
100000 routes in .757131 secs, 132077.52 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.14
100000 routes in .878317 secs, 113854.12 routes/sec
vat# ip_route_add_del 1.1.1.1/32 count 100000 multipath via 10.10.10.11 via 10.10.10.12 via 10.10.10.13 via 10.10.10.14
100000 routes in .900212 secs, 111084.93 routes/sec
Change-Id: I416b93f7684745099c1adb0b33edac58c9339c1a
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'extras/vom/vom/api_types.cpp')
-rw-r--r-- | extras/vom/vom/api_types.cpp | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/extras/vom/vom/api_types.cpp b/extras/vom/vom/api_types.cpp index ea75d7fd8ee..721034fc810 100644 --- a/extras/vom/vom/api_types.cpp +++ b/extras/vom/vom/api_types.cpp @@ -45,6 +45,11 @@ from_api(vapi_enum_ip_neighbor_flags f) return out; } +invalid_decode::invalid_decode(const std::string reason) + : reason(reason) +{ +} + void to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v) { @@ -82,6 +87,16 @@ to_api(const ip_address_t& a, } } +void +to_api(const ip_address_t& a, vapi_union_address_union& u) +{ + if (a.is_v4()) { + memcpy(u.ip4, a.to_v4().to_bytes().data(), 4); + } else { + memcpy(u.ip6, a.to_v6().to_bytes().data(), 16); + } +} + boost::asio::ip::address_v6 from_api(const vapi_type_ip6_address& v) { @@ -123,6 +138,26 @@ from_api(const vapi_type_address& v) } ip_address_t +from_api(const vapi_union_address_union& u, vapi_enum_fib_path_nh_proto proto) +{ + boost::asio::ip::address addr; + + if (FIB_API_PATH_NH_PROTO_IP6 == proto) { + std::array<uint8_t, 16> a; + std::copy(u.ip6, u.ip6 + 16, std::begin(a)); + boost::asio::ip::address_v6 v6(a); + addr = v6; + } else if (FIB_API_PATH_NH_PROTO_IP4 == proto) { + std::array<uint8_t, 4> a; + std::copy(u.ip6, u.ip6 + 4, std::begin(a)); + boost::asio::ip::address_v4 v4(a); + addr = v4; + } + + return addr; +} + +ip_address_t from_api(const vapi_union_address_union& u, vapi_enum_address_family af) { boost::asio::ip::address addr; @@ -187,7 +222,42 @@ to_api(const route::mprefix_t& p) v.af = af; return v; } -}; + +vapi_enum_fib_path_nh_proto +to_api(const nh_proto_t& p) +{ + if (p == nh_proto_t::IPV4) { + return FIB_API_PATH_NH_PROTO_IP4; + } else if (p == nh_proto_t::IPV6) { + return FIB_API_PATH_NH_PROTO_IP6; + } else if (p == nh_proto_t::ETHERNET) { + return FIB_API_PATH_NH_PROTO_ETHERNET; + } else if (p == nh_proto_t::MPLS) { + return FIB_API_PATH_NH_PROTO_MPLS; + } + + return FIB_API_PATH_NH_PROTO_IP4; +} +const nh_proto_t& +from_api(vapi_enum_fib_path_nh_proto p) +{ + switch (p) { + case FIB_API_PATH_NH_PROTO_IP4: + return nh_proto_t::IPV4; + case FIB_API_PATH_NH_PROTO_IP6: + return nh_proto_t::IPV6; + case FIB_API_PATH_NH_PROTO_ETHERNET: + return nh_proto_t::ETHERNET; + case FIB_API_PATH_NH_PROTO_MPLS: + return nh_proto_t::MPLS; + case FIB_API_PATH_NH_PROTO_BIER: + break; + } + + return nh_proto_t::IPV4; +} + +}; // VOM /* * fd.io coding-style-patch-verification: ON |