FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
interface.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "vom/interface.hpp"
20 #include "vom/interface_cmds.hpp"
22 #include "vom/l3_binding_cmds.hpp"
23 #include "vom/logger.hpp"
24 #include "vom/prefix.hpp"
26 #include "vom/stat_reader.hpp"
28 
29 namespace VOM {
30 /**
31  * A DB of all the interfaces, key on the name
32  */
33 singular_db<interface::key_t, interface> interface::m_db;
34 
35 /**
36  * A DB of all the interfaces, key on VPP's handle
37  */
38 std::map<handle_t, std::weak_ptr<interface>> interface::m_hdl_db;
39 
40 interface::event_handler interface::m_evh;
41 
42 /**
43  * the event enable command.
44  */
45 std::shared_ptr<interface_cmds::events_cmd> interface::m_events_cmd;
46 
47 /**
48  * Construct a new object matching the desried state
49  */
50 interface::interface(const std::string& name,
51  interface::type_t itf_type,
52  interface::admin_state_t itf_state,
53  const std::string& tag)
54  : m_hdl(handle_t::INVALID)
55  , m_name(name)
56  , m_type(itf_type)
57  , m_state(itf_state)
58  , m_table_id(route::DEFAULT_TABLE)
59  , m_l2_address(l2_address_t::ZERO, rc_t::UNSET)
60  , m_stats_type(stats_type_t::NORMAL)
61  , m_stats({})
62  , m_listener(nullptr)
63  , m_oper(oper_state_t::DOWN)
64  , m_tag(tag)
65 {
66 }
67 
68 interface::interface(const std::string& name,
69  interface::type_t itf_type,
70  interface::admin_state_t itf_state,
71  const route_domain& rd,
72  const std::string& tag)
73  : m_hdl(handle_t::INVALID)
74  , m_name(name)
75  , m_type(itf_type)
76  , m_rd(rd.singular())
77  , m_state(itf_state)
78  , m_table_id(m_rd->table_id())
79  , m_l2_address(l2_address_t::ZERO, rc_t::UNSET)
80  , m_stats_type(stats_type_t::NORMAL)
81  , m_stats({})
82  , m_listener(nullptr)
83  , m_oper(oper_state_t::DOWN)
84  , m_tag(tag)
85 {
86 }
87 
89  : m_hdl(o.m_hdl)
90  , m_name(o.m_name)
91  , m_type(o.m_type)
92  , m_rd(o.m_rd)
93  , m_state(o.m_state)
94  , m_table_id(o.m_table_id)
95  , m_l2_address(o.m_l2_address)
96  , m_stats_type(o.m_stats_type)
97  , m_stats(o.m_stats)
98  , m_listener(o.m_listener)
99  , m_oper(o.m_oper)
100  , m_tag(o.m_tag)
101 {
102 }
103 
104 bool
106 {
107  return ((key() == i.key()) &&
108  (m_l2_address.data() == i.m_l2_address.data()) &&
109  (m_state == i.m_state) && (m_rd == i.m_rd) && (m_type == i.m_type) &&
110  (m_oper == i.m_oper));
111 }
112 
114  : m_status(rc_t::NOOP)
115 {
116 }
117 
120 {
121  return (m_status);
122 }
123 
125  : m_status(rc_t::NOOP)
126 {
127 }
128 
131 {
132  return (m_status);
133 }
134 
135 /**
136  * Return the interface type
137  */
138 const interface::type_t&
140 {
141  return (m_type);
142 }
143 
144 const handle_t&
146 {
147  return (singular()->handle_i());
148 }
149 
150 const handle_t&
151 interface::handle_i() const
152 {
153  return (m_hdl.data());
154 }
155 
156 const l2_address_t&
158 {
159  return (m_l2_address.data());
160 }
161 
164 {
165  return m_db.begin();
166 }
167 
170 {
171  return m_db.end();
172 }
173 
174 void
176 {
177  if (m_table_id && (m_table_id.data() != route::DEFAULT_TABLE)) {
178  m_table_id.data() = route::DEFAULT_TABLE;
179  HW::enqueue(
181  HW::enqueue(
183  }
184 
185  if (m_listener) {
186  disable_stats_i();
187  }
188 
189  // If the interface is up, bring it down
190  if (m_state && interface::admin_state_t::UP == m_state.data()) {
191  m_state.data() = interface::admin_state_t::DOWN;
193  }
194 
195  if (m_hdl) {
196  std::queue<cmd*> cmds;
197  HW::enqueue(mk_delete_cmd(cmds));
198  }
199  HW::write();
200 }
201 
202 void
203 interface::replay()
204 {
205  if (m_hdl) {
206  std::queue<cmd*> cmds;
207  HW::enqueue(mk_create_cmd(cmds));
208  }
209 
210  if (m_state && interface::admin_state_t::UP == m_state.data()) {
212  }
213 
214  if (m_listener) {
215  enable_stats(m_listener, m_stats_type.data());
216  }
217 
218  if (m_table_id && (m_table_id.data() != route::DEFAULT_TABLE)) {
219  HW::enqueue(
221  HW::enqueue(
223  }
224 }
225 
227 {
228  sweep();
229  release();
230 }
231 
232 void
234 {
235  // not in the DB anymore.
236  m_db.release(m_name, this);
237 }
238 
239 std::string
241 {
242  std::ostringstream s;
243  s << "interface:[" << m_name << " type:" << m_type.to_string()
244  << " hdl:" << m_hdl.to_string() << " l2-address:["
245  << m_l2_address.to_string() << "]";
246 
247  if (m_rd) {
248  s << " rd:" << m_rd->to_string();
249  }
250 
251  s << " admin-state:" << m_state.to_string()
252  << " oper-state:" << m_oper.to_string();
253 
254  if (!m_tag.empty()) {
255  s << " tag:[" << m_tag << "]";
256  }
257 
258  s << "]";
259 
260  return (s.str());
261 }
262 
263 const std::string&
265 {
266  return (m_name);
267 }
268 
269 const interface::key_t&
271 {
272  return (name());
273 }
274 
275 std::queue<cmd*>&
276 interface::mk_create_cmd(std::queue<cmd*>& q)
277 {
278  if (type_t::LOOPBACK == m_type) {
279  q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
280  q.push(new interface_cmds::set_tag(m_hdl, m_name));
281  /*
282  * set the m_tag for pretty-print
283  */
284  m_tag = m_name;
285  } else if (type_t::BVI == m_type) {
286  q.push(new interface_cmds::bvi_create_cmd(m_hdl, m_name));
287  q.push(new interface_cmds::set_tag(m_hdl, m_name));
288  m_tag = m_name;
289  } else if (type_t::AFPACKET == m_type) {
290  q.push(new interface_cmds::af_packet_create_cmd(m_hdl, m_name));
291  if (!m_tag.empty())
292  q.push(new interface_cmds::set_tag(m_hdl, m_tag));
293  } else if (type_t::TAPV2 == m_type) {
294  if (!m_tag.empty())
295  q.push(new interface_cmds::set_tag(m_hdl, m_tag));
296  } else if (type_t::VHOST == m_type) {
297  q.push(new interface_cmds::vhost_create_cmd(m_hdl, m_name, m_tag));
298  } else {
299  m_hdl.set(rc_t::OK);
300  }
301 
302  return (q);
303 }
304 
305 std::queue<cmd*>&
306 interface::mk_delete_cmd(std::queue<cmd*>& q)
307 {
308  if (type_t::LOOPBACK == m_type) {
310  } else if (type_t::BVI == m_type) {
312  } else if (type_t::AFPACKET == m_type) {
313  q.push(new interface_cmds::af_packet_delete_cmd(m_hdl, m_name));
314  } else if (type_t::VHOST == m_type) {
315  q.push(new interface_cmds::vhost_delete_cmd(m_hdl, m_name));
316  }
317 
318  return (q);
319 }
320 
321 void
322 interface::update(const interface& desired)
323 {
324  /*
325  * the desired state is always that the interface should be created
326  */
327  if (rc_t::OK != m_hdl.rc()) {
328  std::queue<cmd*> cmds;
329  HW::enqueue(mk_create_cmd(cmds));
330  /*
331  * interface create now, so we can barf early if it fails
332  */
333  HW::write();
334  }
335 
336  /*
337  * If the interface is not created do other commands should be issued
338  */
339  if (rc_t::OK != m_hdl.rc())
340  return;
341 
342  /*
343  * change the interface state to that which is deisred
344  */
345  if (m_state.update(desired.m_state)) {
347  }
348 
349  /*
350  * change the interface state to that which is deisred
351  */
352  if (m_l2_address.update(desired.m_l2_address)) {
353  HW::enqueue(new interface_cmds::set_mac_cmd(m_l2_address, m_hdl));
354  }
355 
356  /*
357  * If the interface is mapped into a route domain, set VPP's
358  * table ID
359  */
360  if (m_rd != desired.m_rd) {
361  /*
362  * changing route domains. need to remove all L3 bindings, swap the table
363  * then reapply the bindings.
364  */
365  auto it = l3_binding::cbegin();
366 
367  while (it != l3_binding::cend()) {
368  if (it->second.lock()->itf().key() == key())
369  it->second.lock()->sweep();
370  ++it;
371  }
372  m_rd = desired.m_rd;
373  m_table_id.update(m_rd ? m_rd->table_id() : route::DEFAULT_TABLE);
374  HW::enqueue(
376  HW::enqueue(
378  HW::write();
379 
380  it = l3_binding::cbegin();
381  while (it != l3_binding::cend()) {
382  if (it->second.lock()->itf().key() == key())
383  it->second.lock()->replay(); //(*it->second.lock());
384  ++it;
385  }
386  } else if (!m_table_id && m_rd) {
387  HW::enqueue(
389  HW::enqueue(
391  }
392 }
393 
394 void
396 {
397  m_state = state;
398 }
399 
400 void
402 {
403  m_l2_address = { addr, rc_t::NOOP };
404 }
405 
406 void
408 {
409  m_hdl = hdl;
410 }
411 
412 void
414 {
415  m_oper = state;
416 }
417 
418 void
419 interface::set(const std::string& tag)
420 {
421  m_tag = tag;
422 }
423 
424 void
425 interface::set(const counter_t& count, const std::string& stat_type)
426 {
427  if ("rx" == stat_type)
428  m_stats.m_rx = count;
429  else if ("tx" == stat_type)
430  m_stats.m_tx = count;
431  else if ("drops" == stat_type)
432  m_stats.m_drop = count;
433  else if ("rx-unicast" == stat_type)
434  m_stats.m_rx_unicast = count;
435  else if ("tx-unicast" == stat_type)
436  m_stats.m_tx_unicast = count;
437  else if ("rx-multicast" == stat_type)
438  m_stats.m_rx_multicast = count;
439  else if ("tx-multicast" == stat_type)
440  m_stats.m_tx_multicast = count;
441  else if ("rx-broadcast" == stat_type)
442  m_stats.m_rx_broadcast = count;
443  else if ("tx-broadcast" == stat_type)
444  m_stats.m_rx_broadcast = count;
445 }
446 
447 const interface::stats_t&
449 {
450  return m_stats;
451 }
452 
453 void
454 interface::publish_stats()
455 {
456  m_listener->handle_interface_stat(*this);
457 }
458 
459 std::ostream&
460 operator<<(std::ostream& os, const interface::stats_t& stats)
461 {
462  os << "["
463  << "rx " << stats.m_rx << " rx-unicast " << stats.m_rx_unicast
464  << " rx-multicast " << stats.m_rx_multicast << " rx-broadcast "
465  << stats.m_rx_broadcast << " tx " << stats.m_tx << " tx-unicast "
466  << stats.m_tx_unicast << " tx-multicast " << stats.m_tx_multicast
467  << " tx-broadcast " << stats.m_tx_broadcast << " drops " << stats.m_drop
468  << "]" << std::endl;
469 
470  return (os);
471 }
472 
473 void
474 interface::enable_stats_i(interface::stat_listener* el, const stats_type_t& st)
475 {
476  if (el != NULL) {
477  if (stats_type_t::DETAILED == st) {
478  m_stats_type.set(rc_t::NOOP);
480  m_stats_type, handle_i(), true));
481  }
482  stat_reader::registers(*this);
483  m_listener = el;
484  }
485 }
486 
487 void
489 {
490  singular()->enable_stats_i(el, st);
491 }
492 
493 void
494 interface::disable_stats_i()
495 {
496  if (m_listener != NULL) {
497  if (stats_type_t::DETAILED == m_stats_type) {
499  m_stats_type, handle_i(), false));
500  }
501  stat_reader::unregisters(*this);
502  m_listener = NULL;
503  }
504 }
505 
506 void
508 {
509  singular()->disable_stats_i();
510 }
511 
512 std::shared_ptr<interface>
514 {
515  return (m_db.find_or_add(key(), *this));
516 }
517 
518 std::shared_ptr<interface>
520 {
521  return singular_i();
522 }
523 
524 std::shared_ptr<interface>
526 {
527  return (m_db.find(k));
528 }
529 
530 std::shared_ptr<interface>
532 {
533  return (m_hdl_db[handle].lock());
534 }
535 
536 void
538 {
539  std::shared_ptr<interface> sp = find(key);
540 
541  if (sp && item) {
542  m_hdl_db[item.data()] = sp;
543  }
544 }
545 
546 void
548 {
549  m_hdl_db.erase(item.data());
550 }
551 
552 void
553 interface::dump(std::ostream& os)
554 {
555  db_dump(m_db, os);
556 }
557 
558 void
560 {
561  m_events_cmd = std::make_shared<interface_cmds::events_cmd>(el);
562  HW::enqueue(m_events_cmd);
563  HW::write();
564 }
565 
566 void
568 {
569  m_events_cmd.reset();
570 }
571 
572 void
573 interface::event_handler::handle_populate(const client_db::key_t& key)
574 {
575  /*
576  * dump VPP vhost-user interfaces
577  */
578  std::shared_ptr<interface_cmds::vhost_dump_cmd> vcmd =
579  std::make_shared<interface_cmds::vhost_dump_cmd>();
580 
581  HW::enqueue(vcmd);
582  HW::write();
583 
584  for (auto& vhost_itf_record : *vcmd) {
585  std::shared_ptr<interface> vitf =
587  vhost_itf_record.get_payload());
588  VOM_LOG(log_level_t::DEBUG) << " vhost-dump: " << vitf->to_string();
589  OM::commit(key, *vitf);
590  }
591 
592  /*
593  * dump VPP af-packet interfaces
594  */
595  std::shared_ptr<interface_cmds::af_packet_dump_cmd> afcmd =
596  std::make_shared<interface_cmds::af_packet_dump_cmd>();
597 
598  HW::enqueue(afcmd);
599  HW::write();
600 
601  for (auto& af_packet_itf_record : *afcmd) {
602  std::shared_ptr<interface> afitf =
604  af_packet_itf_record.get_payload());
605  VOM_LOG(log_level_t::DEBUG) << " af_packet-dump: " << afitf->to_string();
606  OM::commit(key, *afitf);
607  }
608 
609  /*
610  * dump VPP tapv2 interfaces
611  */
612  std::shared_ptr<tap_interface_cmds::tapv2_dump_cmd> tapv2cmd =
613  std::make_shared<tap_interface_cmds::tapv2_dump_cmd>();
614 
615  HW::enqueue(tapv2cmd);
616  HW::write();
617 
618  for (auto& tapv2_record : *tapv2cmd) {
619  std::shared_ptr<tap_interface> tapv2itf =
620  interface_factory::new_tap_interface(tapv2_record.get_payload());
621  VOM_LOG(log_level_t::DEBUG) << "tapv2-dump: " << tapv2itf->to_string();
622 
623  /*
624  * Write each of the discovered interfaces into the OM,
625  * but disable the HW Command q whilst we do, so that no
626  * commands are sent to VPP
627  */
628  OM::commit(key, *tapv2itf);
629  }
630 
631  /*
632  * dump VPP interfaces
633  */
634  std::shared_ptr<interface_cmds::dump_cmd> cmd =
635  std::make_shared<interface_cmds::dump_cmd>();
636 
637  HW::enqueue(cmd);
638  HW::write();
639 
640  for (auto& itf_record : *cmd) {
641  auto payload = itf_record.get_payload();
642  VOM_LOG(log_level_t::DEBUG) << "dump: [" << payload.sw_if_index
643  << " name:" << (char*)payload.interface_name
644  << " tag:" << (char*)payload.tag << "]";
645 
646  std::shared_ptr<interface> itf = interface_factory::new_interface(payload);
647 
648  if (itf && interface::type_t::LOCAL != itf->type()) {
649  VOM_LOG(log_level_t::DEBUG) << "dump: " << itf->to_string();
650  /*
651  * Write each of the discovered interfaces into the OM,
652  * but disable the HW Command q whilst we do, so that no
653  * commands are sent to VPP
654  */
655  OM::commit(key, *itf);
656 
657  /**
658  * Get the address configured on the interface
659  */
660  std::shared_ptr<l3_binding_cmds::dump_v4_cmd> dcmd =
661  std::make_shared<l3_binding_cmds::dump_v4_cmd>(
662  l3_binding_cmds::dump_v4_cmd(itf->handle()));
663 
664  HW::enqueue(dcmd);
665  HW::write();
666 
667  for (auto& l3_record : *dcmd) {
668  auto& payload = l3_record.get_payload();
669  const route::prefix_t pfx(payload.is_ipv6, payload.ip,
670  payload.prefix_length);
671 
672  VOM_LOG(log_level_t::DEBUG) << "dump: " << pfx.to_string();
673 
674  l3_binding l3(*itf, pfx);
675  OM::commit(key, l3);
676  }
677  }
678  }
679 
680  /*
681  * dump VPP bond interfaces
682  */
683  std::shared_ptr<bond_interface_cmds::dump_cmd> bcmd =
684  std::make_shared<bond_interface_cmds::dump_cmd>();
685 
686  HW::enqueue(bcmd);
687  HW::write();
688 
689  for (auto& bond_itf_record : *bcmd) {
690  std::shared_ptr<bond_interface> bond_itf =
691  interface_factory::new_bond_interface(bond_itf_record.get_payload());
692 
693  VOM_LOG(log_level_t::DEBUG) << " bond-dump:" << bond_itf->to_string();
694 
695  /*
696  * Write each of the discovered interfaces into the OM,
697  * but disable the HW Command q whilst we do, so that no
698  * commands are sent to VPP
699  */
700  OM::commit(key, *bond_itf);
701 
702  std::shared_ptr<bond_group_binding_cmds::dump_cmd> scmd =
703  std::make_shared<bond_group_binding_cmds::dump_cmd>(
704  bond_group_binding_cmds::dump_cmd(bond_itf->handle()));
705 
706  HW::enqueue(scmd);
707  HW::write();
708 
710 
711  for (auto& slave_itf_record : *scmd) {
713  slave_itf_record.get_payload());
714 
715  VOM_LOG(log_level_t::DEBUG) << " slave-dump:" << slave_itf.to_string();
716 
717  /*
718  * Write each of the discovered interfaces into the OM,
719  * but disable the HW Command q whilst we do, so that no
720  * commands are sent to VPP
721  */
722  // OM::commit(slave_itf->key(), *slave_itf);
723  enslaved_itfs.insert(slave_itf);
724  }
725 
726  if (!enslaved_itfs.empty()) {
727  bond_group_binding bid(*bond_itf, enslaved_itfs);
728  /*
729  * Write each of the discovered interfaces into the OM,
730  * but disable the HW Command q whilst we do, so that no
731  * commands are sent to VPP
732  */
733  OM::commit(key, bid);
734  }
735  }
736 }
737 
739 {
740  OM::register_listener(this);
741  inspect::register_handler({ "interface", "intf" }, "interfaces", this);
742 }
743 
744 void
745 interface::event_handler::handle_replay()
746 {
747  m_db.replay();
748 }
749 
751 interface::event_handler::order() const
752 {
753  return (dependency_t::INTERFACE);
754 }
755 
756 void
757 interface::event_handler::show(std::ostream& os)
758 {
759  db_dump(m_db, os);
760 }
761 
762 } // namespace VOM
763 
764 /*
765  * fd.io coding-style-patch-verification: ON
766  *
767  * Local Variables:
768  * eval: (c-set-style "mozilla")
769  * End:
770  */
static const rc_t NOOP
The HW write/update action was/has not been attempted.
Definition: types.hpp:104
void release()
release/remove an interface form the singular store
Definition: interface.cpp:233
virtual ~interface()
Destructor.
Definition: interface.cpp:226
static void dump(std::ostream &os)
Dump all interfaces into the stream provided.
Definition: interface.cpp:553
void disable_stats()
Disable stats for this interface.
Definition: interface.cpp:507
interface(const std::string &name, type_t type, admin_state_t state, const std::string &tag="")
Construct a new object matching the desried state.
Definition: interface.cpp:50
#define VOM_LOG(lvl)
Definition: logger.hpp:181
static void disable_events()
disable the reception of events of all interfaces
Definition: interface.cpp:567
static const type_t AFPACKET
AF-Packet interface type.
Definition: interface.hpp:88
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
Definition: interface.cpp:531
HW::item< handle_t > m_hdl
The SW interface handle VPP has asigned to the interface.
Definition: interface.hpp:535
#define NULL
Definition: clib.h:58
virtual void sweep(void)
Sweep/reap the object if still stale.
Definition: interface.cpp:175
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
Definition: inspect.cpp:85
void enable_stats(stat_listener *el, const stats_type_t &st=stats_type_t::NORMAL)
Enable stats for this interface.
Definition: interface.cpp:488
int i
void set(const admin_state_t &state)
Set the admin state of the interface.
Definition: interface.cpp:395
static rc_t write()
Write/Execute all commands hitherto enqueued.
Definition: hw.cpp:255
HW::item< bool > & status()
Return the HW::item representing the status.
Definition: interface.cpp:119
A command class to set tag on interfaces.
Error codes that VPP will return during a HW write.
Definition: types.hpp:89
static const log_level_t DEBUG
Definition: logger.hpp:32
static const_iterator_t cbegin()
Definition: l3_binding.cpp:94
static const stats_type_t DETAILED
Definition: interface.hpp:46
A representation of bond interface binding.
A cmd class that Dumps slave itfs.
vhost_vring_addr_t addr
Definition: vhost_user.h:121
A bond-member.
Definition: bond_member.hpp:26
A command class that enables detailed stats collection on an interface.
std::string to_string() const
convert to string format for debug purposes
Definition: hw.hpp:161
const handle_t & handle() const
Return VPP&#39;s handle to this object.
Definition: interface.cpp:145
The oper state of the interface.
Definition: interface.hpp:164
Type def of a L2 address as read from VPP.
Definition: types.hpp:339
A route-domain is a VRF.
T & data()
Return the data read/written.
Definition: hw.hpp:109
static const_iterator_t cbegin()
Definition: interface.cpp:163
static singular_db< key_t, interface > m_db
A map of all interfaces key against the interface&#39;s name.
Definition: interface.hpp:567
static std::shared_ptr< interface > new_af_packet_interface(const vapi_payload_af_packet_details &vd)
static const type_t LOCAL
Local interface type (specific to VPP)
Definition: interface.hpp:96
vhost_vring_state_t state
Definition: vhost_user.h:120
A command class that changes the MAC address on an interface.
rc_t rc() const
Get the HW return code.
Definition: hw.hpp:119
static const l3_proto_t IPV4
Definition: prefix.hpp:55
static const_iterator_t cend()
Definition: l3_binding.cpp:100
static const l3_proto_t IPV6
Definition: prefix.hpp:56
HW::item< bool > m_status
The status of the subscription.
Definition: interface.hpp:454
static const table_id_t DEFAULT_TABLE
The table-id for the default table.
Definition: prefix.hpp:87
virtual std::queue< cmd * > & mk_create_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface create commands.
Definition: interface.cpp:276
std::string to_string() const
convert to string format for debug purposes
Definition: prefix.cpp:183
static void remove(const HW::item< handle_t > &item)
remove an interface from the DB keyed on handle
Definition: interface.cpp:547
static const oper_state_t DOWN
Operational DOWN state.
Definition: interface.hpp:169
event_listener()
Default Constructor.
Definition: interface.cpp:113
const l2_address_t & l2_address() const
Return the L2 Address.
Definition: interface.cpp:157
A class that listens to interface Stats.
Definition: interface.hpp:460
stat_listener()
Default Constructor.
Definition: interface.cpp:124
virtual bool operator==(const interface &i) const
Comparison operator - only used for UT.
Definition: interface.cpp:105
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.
A class that listens to interface Events.
Definition: interface.hpp:431
u8 name[64]
Definition: memclnt.api:152
A command class to create Loopback interfaces in VPP.
static std::shared_ptr< interface > new_vhost_user_interface(const vapi_payload_sw_interface_vhost_user_details &vd)
A command class to create bvi interfaces in VPP.
A cmd class that changes the admin state.
static void add(const key_t &name, const HW::item< handle_t > &item)
Add an interface to the DB keyed on handle.
Definition: interface.cpp:537
std::set< bond_member > enslaved_itf_t
The container type for enslaved itfs.
A command class that binds an interface to an L3 table.
static bond_member new_bond_member_interface(const vapi_payload_sw_interface_slave_details &vd)
The admin state of the interface.
Definition: interface.hpp:138
static std::shared_ptr< tap_interface > new_tap_interface(const vapi_payload_sw_interface_tap_v2_details &vd)
A representation of an interface in VPP.
Definition: interface.hpp:41
HW::item< bool > & status()
Return the HW::item representing the status.
Definition: interface.cpp:130
A command class to create af_packet interfaces in VPP.
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
A functor class that deletes a Vhost interface.
std::shared_ptr< interface > singular() const
Return the matching&#39;singular&#39; of the interface.
Definition: interface.cpp:519
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
Definition: om.hpp:202
void event_handler(void *tls_async)
Definition: tls_async.c:340
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
static const rc_t OK
The HW write was successfull.
Definition: types.hpp:109
const std::string & name() const
Return the interface type.
Definition: interface.cpp:264
static void enqueue(cmd *f)
Enqueue A command for execution.
Definition: hw.cpp:212
virtual std::shared_ptr< interface > singular_i() const
Return the matching &#39;singular&#39; of the interface.
Definition: interface.cpp:513
A cmd class that Dumps all the IPv4 L3 configs.
size_t count
Definition: vapi.c:47
An interface type.
Definition: interface.hpp:67
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
virtual std::queue< cmd * > & mk_delete_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface delete commands.
Definition: interface.cpp:306
A command class to delete bvi interfaces in VPP.
A command class to delete af-packet interfaces in VPP.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
A command class to delete loopback interfaces in VPP.
static const admin_state_t UP
Admin UP state.
Definition: interface.hpp:147
A representation of a method call to VPP.
Definition: cmd.hpp:32
const stats_t & get_stats(void) const
Get the interface stats.
Definition: interface.cpp:448
Definition: hash.c:490
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
Definition: hw.hpp:125
static const type_t BVI
A brideged Virtual interface (aka SVI or IRB)
Definition: interface.hpp:76
HW::item< bool > m_status
The status of the subscription.
Definition: interface.hpp:485
A functor class that creates an interface.
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static const admin_state_t DOWN
Admin DOWN state.
Definition: interface.hpp:143
A representation of L3 configuration on an interface.
Definition: l3_binding.hpp:30
static const_iterator_t cend()
Definition: interface.cpp:169
std::string to_string(void) const
convert to string
Definition: bond_member.cpp:49
singular_db< const std::string, interface >::const_iterator const_iterator_t
The iterator type.
Definition: interface.hpp:62
static const type_t TAPV2
TAPv2 interface type.
Definition: interface.hpp:101
virtual std::string to_string(void) const
convert to string format for debug purposes
Definition: interface.cpp:240
static const type_t LOOPBACK
loopback interface type
Definition: interface.hpp:92
std::string key_t
The key for interface&#39;s key.
Definition: interface.hpp:56
static const type_t VHOST
vhost-user interface type
Definition: interface.hpp:106
const type_t & type() const
Return the interface type.
Definition: interface.cpp:139
static bool register_listener(listener *listener)
Register a listener of events.
Definition: om.cpp:127
static void enable_events(interface::event_listener &el)
Enable the reception of events of all interfaces.
Definition: interface.cpp:559
A prefix defintion.
Definition: prefix.hpp:92
const key_t & key() const
Return the interface type.
Definition: interface.cpp:270
static std::shared_ptr< bond_interface > new_bond_interface(const vapi_payload_sw_interface_bond_details &vd)
interfaces are the root of the dependency graph