|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
39 std::map<handle_t, std::weak_ptr<interface>> interface::m_hdl_db;
46 std::shared_ptr<interface_cmds::events_cmd> interface::m_events_cmd;
64 , m_oper(oper_state_t::DOWN)
84 , m_oper(oper_state_t::DOWN)
95 , m_table_id(o.m_table_id)
96 , m_l2_address(o.m_l2_address)
97 , m_stats_type(o.m_stats_type)
99 , m_listener(o.m_listener)
108 return ((
key() ==
i.key()) &&
109 (m_l2_address.
data() ==
i.m_l2_address.data()) &&
110 (m_state ==
i.m_state) && (m_rd ==
i.m_rd) && (m_type ==
i.m_type) &&
111 (m_oper ==
i.m_oper));
115 : m_status(
rc_t::NOOP)
126 : m_status(
rc_t::NOOP)
152 interface::handle_i()
const
160 return (m_l2_address.
data());
166 return (m_state.data());
203 std::queue<cmd*> cmds;
213 std::queue<cmd*> cmds;
243 m_db.release(m_name,
this);
249 std::ostringstream s;
250 s <<
"interface:[" << m_name <<
" type:" << m_type.
to_string()
255 s <<
" rd:" << m_rd->to_string();
258 s <<
" admin-state:" << m_state.to_string()
261 if (!m_tag.empty()) {
262 s <<
" tag:[" << m_tag <<
"]";
329 interface::update(
const interface& desired)
335 std::queue<cmd*> cmds;
352 if (m_state.update(desired.m_state)) {
359 if (m_l2_address.
update(desired.m_l2_address)) {
367 if (m_rd != desired.m_rd) {
375 if (
it->second.lock()->itf().key() ==
key())
376 it->second.lock()->sweep();
389 if (
it->second.lock()->itf().key() ==
key())
390 it->second.lock()->replay();
393 }
else if (!m_table_id && m_rd) {
434 if (
"rx" == stat_type)
436 else if (
"tx" == stat_type)
438 else if (
"drops" == stat_type)
440 else if (
"rx-unicast" == stat_type)
442 else if (
"tx-unicast" == stat_type)
444 else if (
"rx-multicast" == stat_type)
446 else if (
"tx-multicast" == stat_type)
448 else if (
"rx-broadcast" == stat_type)
450 else if (
"tx-broadcast" == stat_type)
454 const interface::stats_t&
461 interface::publish_stats()
470 <<
"rx " <<
stats.m_rx <<
" rx-unicast " <<
stats.m_rx_unicast
471 <<
" rx-multicast " <<
stats.m_rx_multicast <<
" rx-broadcast "
472 <<
stats.m_rx_broadcast <<
" tx " <<
stats.m_tx <<
" tx-unicast "
473 <<
stats.m_tx_unicast <<
" tx-multicast " <<
stats.m_tx_multicast
474 <<
" tx-broadcast " <<
stats.m_tx_broadcast <<
" drops " <<
stats.m_drop
481 interface::enable_stats_i(interface::stat_listener* el,
const stats_type_t& st)
486 HW::enqueue(
new interface_cmds::collect_detail_stats_change_cmd(
487 m_stats_type, handle_i(),
true));
489 stat_reader::registers(*
this);
501 interface::disable_stats_i()
503 if (m_listener != NULL) {
506 m_stats_type, handle_i(),
false));
508 stat_reader::unregisters(*
this);
519 std::shared_ptr<interface>
522 return (
m_db.find_or_add(
key(), *
this));
525 std::shared_ptr<interface>
531 std::shared_ptr<interface>
534 return (
m_db.find(k));
537 std::shared_ptr<interface>
540 return (m_hdl_db[
handle].lock());
546 std::shared_ptr<interface> sp =
find(
key);
549 m_hdl_db[
item.data()] = sp;
556 m_hdl_db.erase(
item.data());
568 m_events_cmd = std::make_shared<interface_cmds::events_cmd>(el);
576 m_events_cmd.reset();
585 std::shared_ptr<interface_cmds::vhost_dump_cmd> vcmd =
586 std::make_shared<interface_cmds::vhost_dump_cmd>();
591 for (
auto& vhost_itf_record : *vcmd) {
592 std::shared_ptr<interface> vitf =
594 vhost_itf_record.get_payload());
602 std::shared_ptr<interface_cmds::af_packet_dump_cmd> afcmd =
603 std::make_shared<interface_cmds::af_packet_dump_cmd>();
608 for (
auto& af_packet_itf_record : *afcmd) {
609 std::shared_ptr<interface> afitf =
611 af_packet_itf_record.get_payload());
619 std::shared_ptr<tap_interface_cmds::tapv2_dump_cmd> tapv2cmd =
620 std::make_shared<tap_interface_cmds::tapv2_dump_cmd>();
625 for (
auto& tapv2_record : *tapv2cmd) {
626 std::shared_ptr<tap_interface> tapv2itf =
641 std::shared_ptr<interface_cmds::dump_cmd> cmd =
642 std::make_shared<interface_cmds::dump_cmd>();
647 for (
auto& itf_record : *cmd) {
648 auto payload = itf_record.get_payload();
650 <<
" name:" << (
char*)payload.interface_name
651 <<
" tag:" << (
char*)payload.tag <<
"]";
667 std::shared_ptr<l3_binding_cmds::dump_v4_cmd> dcmd =
668 std::make_shared<l3_binding_cmds::dump_v4_cmd>(
669 l3_binding_cmds::dump_v4_cmd(itf->handle()));
674 for (
auto& l3_record : *dcmd) {
675 auto& payload = l3_record.get_payload();
676 const route::prefix_t pfx =
from_api(payload.prefix);
689 std::shared_ptr<bond_interface_cmds::dump_cmd> bcmd =
690 std::make_shared<bond_interface_cmds::dump_cmd>();
695 for (
auto& bond_itf_record : *bcmd) {
696 std::shared_ptr<bond_interface> bond_itf =
708 std::shared_ptr<bond_group_binding_cmds::dump_cmd> scmd =
709 std::make_shared<bond_group_binding_cmds::dump_cmd>(
710 bond_group_binding_cmds::dump_cmd(bond_itf->handle()));
717 for (
auto& slave_itf_record : *scmd) {
719 slave_itf_record.get_payload());
729 enslaved_itfs.insert(slave_itf);
732 if (!enslaved_itfs.empty()) {
733 bond_group_binding bid(*bond_itf, enslaved_itfs);
751 interface::event_handler::handle_replay()
757 interface::event_handler::order()
const
const stats_t & get_stats(void) const
Get the interface stats.
const l2_address_t & l2_address() const
Return the L2 Address.
A command class that binds an interface to an L3 table.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const_iterator_t cend()
static const_iterator_t cbegin()
static std::shared_ptr< tap_interface > new_tap_interface(const vapi_payload_sw_interface_tap_v2_details &vd)
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 type_t BVI
A brideged Virtual interface (aka SVI or IRB)
static void remove(const HW::item< handle_t > &item)
remove an interface from the DB keyed on handle
A command class to create Loopback interfaces in VPP.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
A command class to set tag on interfaces.
void enable_stats(stat_listener *el, const stats_type_t &st=stats_type_t::NORMAL)
Enable stats for this interface.
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.
A command class to create af_packet interfaces in VPP.
static const_iterator_t cend()
A command class that enables detailed stats collection on an interface.
static singular_db< key_t, interface > m_db
A map of all interfaces key against the interface's name.
A functor class that creates an interface.
static std::shared_ptr< interface > new_af_packet_interface(const vapi_payload_af_packet_details &vd)
HW::item< handle_t > m_hdl
The SW interface handle VPP has asigned to the interface.
const static l3_proto_t IPV4
static void dump(std::ostream &os)
Dump all interfaces into the stream provided.
singular_db< const std::string, interface >::const_iterator const_iterator_t
The iterator type.
static void add(const key_t &name, const HW::item< handle_t > &item)
Add an interface to the DB keyed on handle.
virtual bool operator==(const interface &i) const
Comparison operator - only used for UT.
A class that listens to interface Events.
vl_api_dhcp_client_state_t state
vl_api_ikev2_sa_stats_t stats
static void enable_events(interface::event_listener &el)
Enable the reception of events of all interfaces.
static std::shared_ptr< interface > new_vhost_user_interface(const vapi_payload_sw_interface_vhost_user_details &vd)
const std::string & name() const
Return the interface type.
const static type_t LOCAL
Local interface type (specific to VPP)
static void disable_events()
disable the reception of events of all interfaces
A command class to delete af-packet interfaces in VPP.
HW::item< bool > & status()
Return the HW::item representing the status.
const type_t & type() const
Return the interface type.
A command class to delete loopback interfaces in VPP.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
virtual std::string to_string(void) const
convert to string format for debug purposes
const static type_t LOOPBACK
loopback interface type
virtual ~interface()
Destructor.
binding< l3_list > l3_binding
Typedef the L3 binding type.
void disable_stats()
Disable stats for this interface.
static bool register_listener(listener *listener)
Register a listener of events.
event_listener()
Default Constructor.
const static stats_type_t DETAILED
virtual void handle_interface_stat(const interface &)=0
Virtual function called on the listener when the command has data ready to process.
const key_t & key() const
Return the interface type.
const admin_state_t & admin_state() const
Return the admin state.
virtual void sweep(void)
Sweep/reap the object if still stale.
A representation of an interface in VPP.
const static rc_t NOOP
The HW write/update action was/has not been attempted.
const static type_t AFPACKET
AF-Packet interface type.
const typedef std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
const static type_t VHOST
vhost-user interface type
void set(const admin_state_t &state)
Set the admin state of the interface.
std::shared_ptr< interface > singular() const
Return the matching'singular' of the interface.
A type declaration of an interface handle in VPP.
static void enqueue(cmd *f)
Enqueue A command for execution.
save_rewrite_length must be aligned so that reass doesn t overwrite it
std::string to_string() const
convert to string format for debug purposes
const static log_level_t DEBUG
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
A command class to create bvi interfaces in VPP.
A class that listens to interface Stats.
const std::string & to_string() const
convert to string format for debug purposes
interface(const std::string &name, type_t type, admin_state_t state, const std::string &tag="")
Construct a new object matching the desried state.
const handle_t & handle() const
Return VPP's handle to this object.
const static type_t TAPV2
TAPv2 interface type.
rc_t rc() const
Get the HW return code.
Type def of a L2 address as read from VPP.
T & data()
Return the data read/written.
const static admin_state_t DOWN
Admin DOWN state.
HW::item< bool > & status()
Return the HW::item representing the status.
virtual std::queue< cmd * > & mk_delete_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface delete commands.
A command class to delete bvi interfaces in VPP.
@ INTERFACE
interfaces are the root of the dependency graph
The oper state of the interface.
static bond_member new_bond_member_interface(const vapi_payload_sw_interface_slave_details &vd)
virtual std::shared_ptr< interface > singular_i() const
Return the matching 'singular' of the interface.
The admin state of the interface.
static const_iterator_t cbegin()
static std::shared_ptr< interface > new_interface(const vapi_payload_sw_interface_details &vd)
Factory method to construct a new interface from the VPP record.
stat_listener()
Default Constructor.
static std::shared_ptr< bond_interface > new_bond_interface(const vapi_payload_sw_interface_bond_details &vd)
A cmd class that changes the admin state.
bool update(const item &desired)
update the item to the desired state.
Error codes that VPP will return during a HW write.
std::string key_t
The key for interface's key.
const static table_id_t DEFAULT_TABLE
The table-id for the default table.
void release()
release/remove an interface form the singular store
void event_handler(void *tls_async)
std::set< bond_member > enslaved_itf_t
The container type for enslaved itfs.
const neighbour::flags_t from_api(vapi_enum_ip_neighbor_flags f)
const static admin_state_t UP
Admin UP state.
const static l3_proto_t IPV6
A functor class that deletes a Vhost interface.
virtual std::queue< cmd * > & mk_create_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface create commands.
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.