|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
27 singular_db<ip_route::key_t, ip_route> ip_route::m_db;
28 singular_db<ip_mroute::key_t, ip_mroute> ip_mroute::m_db;
36 path::special_t::special_t(
int v,
const std::string& s)
37 : enum_base<
path::special_t>(v, s)
41 const path::flags_t path::flags_t::NONE(0,
"none");
42 const path::flags_t path::flags_t::DVR((1 << 0),
"dvr");
45 : enum_base<
path::flags_t>(v, s)
49 const itf_flags_t itf_flags_t::NONE(0,
"none");
50 const itf_flags_t itf_flags_t::ACCEPT((1 << 1),
"accept");
51 const itf_flags_t itf_flags_t::FORWARD((1 << 2),
"forward");
53 itf_flags_t::itf_flags_t(
int v,
const std::string& s)
54 : enum_base<itf_flags_t>(v, s)
64 , m_interface(nullptr)
94 , m_interface(nullptr)
118 , m_nh_proto(p.m_nh_proto)
122 , m_interface(p.m_interface)
123 , m_weight(p.m_weight)
124 , m_preference(p.m_preference)
131 if (m_nh_proto < p.m_nh_proto)
133 if (m_flags < p.m_flags)
135 if (m_type < p.m_type)
141 if (m_rd && p.m_rd) {
142 if (m_rd->table_id() < p.m_rd->table_id())
144 else if (m_rd->table_id() > p.m_rd->table_id())
149 if (m_interface && !p.m_interface)
151 if (!m_interface && p.m_interface)
153 if (m_interface && p.m_interface) {
154 if (m_interface->handle() < p.m_interface->handle())
156 if (p.m_interface->handle() < m_interface->handle())
176 result &= (*m_rd == *p.m_rd);
177 if (m_interface && !p.m_interface)
179 if (!m_interface && p.m_interface)
181 if (m_interface && p.m_interface)
182 result &= (*m_interface == *p.m_interface);
183 return (result && (m_type == p.m_type) && (m_nh == p.m_nh) &&
184 (m_nh_proto == p.m_nh_proto) && (m_flags == p.m_flags));
190 std::ostringstream s;
194 <<
" flags:" << m_flags.
to_string() <<
" neighbour:" << m_nh.to_string();
196 s <<
" " << m_rd->to_string();
199 s <<
" " << m_interface->to_string();
201 s <<
" weight:" <<
static_cast<int>(m_weight)
202 <<
" preference:" <<
static_cast<int>(m_preference) <<
"]";
231 std::shared_ptr<route_domain>
237 std::shared_ptr<interface>
274 , m_prefix(
r.m_prefix)
281 , m_rd(rd.singular())
291 , m_rd(rd.singular())
302 m_db.release(
key(),
this);
309 return (std::make_pair(m_rd->table_id(), m_prefix));
315 return ((
key() ==
i.key()) && (m_paths ==
i.m_paths));
321 m_paths.insert(
path);
351 std::ostringstream s;
352 s <<
"route:[" << m_rd->to_string() <<
", " << m_prefix.
to_string() <<
" ["
367 std::shared_ptr<ip_route>
368 ip_route::find_or_add(
const ip_route& temp)
370 return (m_db.find_or_add(temp.key(), temp));
373 std::shared_ptr<ip_route>
376 return (m_db.find(k));
379 std::shared_ptr<ip_route>
382 return find_or_add(*
this);
398 ip_route::event_handler::handle_replay()
413 for (
auto l3 : l3s) {
414 std::shared_ptr<ip_route_cmds::dump_cmd> cmd =
415 std::make_shared<ip_route_cmds::dump_cmd>(
it->second.lock()->table_id(),
421 for (
auto& record : *cmd) {
422 auto& payload = record.get_payload();
424 std::shared_ptr<route_domain> rd =
431 prefix_t pfx =
from_api(payload.route.prefix);
434 for (
unsigned int i = 0;
i < payload.route.n_paths;
i++) {
435 ip_r.add(
from_api(payload.route.paths[
i]));
453 ip_route::event_handler::order()
const
475 , m_mprefix(
r.m_mprefix)
482 , m_rd(rd.singular())
491 m_paths.insert(std::make_pair(
path, flag));
497 m_db.release(
key(),
this);
503 return (std::make_pair(m_rd->table_id(), m_mprefix));
509 return ((
key() ==
i.key()) && (m_paths ==
i.m_paths));
516 for (
auto& p : m_paths)
518 m_mprefix, p.first, p.second));
527 for (
auto& p : m_paths)
529 m_mprefix, p.first, p.second));
535 std::ostringstream s;
536 s <<
"route:[" << m_rd->to_string() <<
", " << m_mprefix.
to_string() <<
" ["
547 for (
auto& p : m_paths)
549 m_mprefix, p.first, p.second));
553 std::shared_ptr<ip_mroute>
554 ip_mroute::find_or_add(
const ip_mroute& temp)
556 return (m_db.find_or_add(temp.key(), temp));
559 std::shared_ptr<ip_mroute>
562 return (m_db.find(k));
565 std::shared_ptr<ip_mroute>
568 return find_or_add(*
this);
581 "ip multicast route configurations",
this);
585 ip_mroute::event_handler::handle_replay()
600 for (
auto l3 : l3s) {
601 std::shared_ptr<ip_mroute_cmds::dump_cmd> cmd =
602 std::make_shared<ip_mroute_cmds::dump_cmd>(
603 it->second.lock()->table_id(), l3);
610 for (
auto& record : *cmd) {
611 auto& payload = record.get_payload();
613 std::shared_ptr<route_domain> rd =
620 mprefix_t pfx =
from_api(payload.route.prefix);
623 for (
unsigned int i = 0;
i < payload.route.n_paths;
i++) {
624 ip_r.add(
from_api(payload.route.paths[
i].path),
625 from_api(payload.route.paths[
i].itf_flags));
643 ip_mroute::event_handler::order()
const
657 os <<
"[" <<
key.first <<
", " <<
key.second.to_string() <<
"]";
665 os <<
"[" <<
key.first <<
", " <<
key.second.to_string() <<
"]";
675 os << k.to_string() <<
" ";
687 os <<
"[" << k.first.to_string() <<
", " << k.second.to_string() <<
"]";
A cmd class that deletes a route.
const key_t key() const
Get the route's key.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
const static special_t PROHIBIT
a path will return ICMP prohibit
The VPP Object Model (VOM) library.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
const static rc_t OK
The HW write was successfull.
std::set< path > path_list_t
A path-list is a set of paths.
const boost::asio::ip::address & nh() const
std::shared_ptr< route_domain > rd() const
const static l3_proto_t IPV4
static std::shared_ptr< ip_route > find(const ip_route &temp)
Find the instnace of the route domain in the OM.
std::string to_string() const
convert to string format for debug purposes
vnet_hw_if_output_node_runtime_t * r
typedef ip_route
An IP route.
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
bool operator==(const ip_route &i) const
Comparison operator.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
void replay(void)
replay the object to create it in hardware
std::string to_string() const
convert to string format for debug purposes
std::shared_ptr< ip_route > singular() const
Return the matching 'singular instance'.
bool operator==(const path &p) const
comparison operator
bool operator==(const ip_mroute &i) const
Comparison operator.
static bool register_listener(listener *listener)
Register a listener of events.
A command class that creates or updates the route.
void add(const path &path, const itf_flags_t &flag)
uint8_t preference() const
typedef ip_mroute
Add / del route request.
A representation of an interface in VPP.
const typedef std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
A cmd class that deletes a route.
special_t type() const
Getters.
bool operator<(const path &p) const
Less than operator for set insertion.
static void enqueue(cmd *f)
Enqueue A command for execution.
manual_print typedef address
std::pair< route::table_id_t, prefix_t > key_t
The key for a route.
save_rewrite_length must be aligned so that reass doesn t overwrite it
void remove(const path &path)
remove a path.
std::ostream & operator<<(std::ostream &os, const ip_route::key_t &key)
const static log_level_t DEBUG
@ TABLE
Tables in which entries are added, e.g bridge/route-domains.
const static special_t STANDARD
A standard path type.
std::set< std::pair< path, itf_flags_t > > mpath_list_t
A mpath-list is a set of paths and interface flags.
const static special_t LOCAL
A local/for-us/recieve.
static std::shared_ptr< ip_mroute > find(const ip_mroute &temp)
Find the instnace of the route domain in the OM.
ip_route(const prefix_t &prefix)
Construct a route in the default table.
const static special_t DROP
drop path
const std::string & to_string() const
convert to string format for debug purposes
rc_t rc() const
Get the HW return code.
std::string to_string() const
Convert to string for debugging.
std::string to_string() const
Convert to string for debugging.
Types belonging to Routing.
ip_mroute(const mprefix_t &mprefix)
Construct a route in the default table.
void add(const path &path)
Add a path.
const static special_t UNREACH
a path will return ICMP unreachables
nh_proto_t nh_proto() const
static const_iterator_t cbegin()
path(special_t special, const nh_proto_t &proto=nh_proto_t::IPV4)
constructor for special paths
static const_iterator_t cend()
A path for IP or MPLS routes.
std::shared_ptr< interface > itf() const
void event_handler(void *tls_async)
const key_t key() const
Get the route's key.
void replay(void)
replay the object to create it in hardware
const neighbour::flags_t from_api(vapi_enum_ip_neighbor_flags f)
A command class that creates or updates the route.
std::pair< route::table_id_t, mprefix_t > key_t
The key for a route.
static std::shared_ptr< route_domain > find(const key_t &temp)
Find the instnace of the route domain in the OM.
std::string to_string() const
convert to string format for debug purposes
std::shared_ptr< ip_mroute > singular() const
Return the matching 'singular instance'.
static void dump(std::ostream &os)
Dump all route-doamin into the stream provided.
vl_api_wireguard_peer_flags_t flags