23 singular_db<gbp_contract::key_t, gbp_contract> gbp_contract::m_db;
33 , m_src_epg_id(src_epg_id)
34 , m_dst_epg_id(dst_epg_id)
35 , m_acl(acl.singular())
37 , m_allowed_ethertypes(allowed_ethertypes)
43 , m_src_epg_id(gbpc.m_src_epg_id)
44 , m_dst_epg_id(gbpc.m_dst_epg_id)
46 , m_gbp_rules(gbpc.m_gbp_rules)
47 , m_allowed_ethertypes(gbpc.m_allowed_ethertypes)
56 m_db.release(
key(),
this);
62 return (std::make_pair(m_src_epg_id, m_dst_epg_id));
68 return ((
key() == gbpc.
key()) && (m_acl->handle() == gbpc.m_acl->handle()));
86 m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle(), m_gbp_rules,
87 m_allowed_ethertypes));
95 s <<
"gbp-contract:[{" << m_src_epg_id <<
", " << m_dst_epg_id <<
"}, " 96 << m_acl->to_string();
97 if (m_gbp_rules.size()) {
98 auto it = m_gbp_rules.cbegin();
99 while (it != m_gbp_rules.cend()) {
100 s << it->to_string();
117 m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle(), m_gbp_rules,
118 m_allowed_ethertypes));
122 std::shared_ptr<gbp_contract>
125 return (m_db.find_or_add(temp.
key(), temp));
128 std::shared_ptr<gbp_contract>
131 return (m_db.find(k));
134 std::shared_ptr<gbp_contract>
137 return find_or_add(*
this);
153 gbp_contract::event_handler::handle_replay()
161 std::shared_ptr<gbp_contract_cmds::dump_cmd>
cmd =
162 std::make_shared<gbp_contract_cmds::dump_cmd>();
167 for (
auto& record : *cmd) {
168 auto& payload = record.get_payload();
170 std::shared_ptr<ACL::l3_list> acl =
176 for (uint8_t
i = 0;
i < payload.contract.n_rules;
i++) {
180 payload.contract.rules[
i].nh_set.hash_mode);
182 for (
u8 j = 0; j < payload.contract.rules[
i].nh_set.n_nhs; j++) {
184 from_api(payload.contract.rules[
i].nh_set.nhs[j].ip),
185 from_api(payload.contract.rules[
i].nh_set.nhs[j].mac),
186 payload.contract.rules[
i].nh_set.nhs[j].bd_id,
187 payload.contract.rules[
i].nh_set.nhs[j].rd_id);
199 data = (((
u8*)&payload.contract.n_ether_types) +
200 (
sizeof(payload.contract.rules[0]) * payload.contract.n_rules));
204 for (uint8_t
i = 0;
i < n_et;
i++) {
208 gbp_contract gbpc(payload.contract.src_epg, payload.contract.dst_epg,
209 *acl, rules, allowed_ethertypes);
220 gbp_contract::event_handler::order()
const 234 os <<
"{ " << key.first <<
"," << key.second <<
"}";
const key_t key() const
Return the object's key.
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.
An ACL list comprises a set of match actions rules to be applied to packets.
uint32_t epg_id_t
EPG IDs are 32 bit integers.
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const log_level_t DEBUG
static const ethertype_t & from_numeric_val(uint16_t numeric)
Get the ethertype from the numeric value.
ip_address_t from_api(const vapi_type_address &v)
static std::shared_ptr< list > find(const handle_t &handle)
std::set< ethertype_t > ethertype_set_t
A set of allowed ethertypes.
std::shared_ptr< gbp_contract > singular() const
Return the matching 'singular instance'.
u16 allowed_ethertypes[n_ether_types]
rc_t rc() const
Get the HW return code.
bool operator==(const gbp_contract &bdae) const
comparison operator
void replay(void)
replay the object to create it in hardware
Representation of set of next hops and associated hash mode profile.
gbp_contract(epg_id_t src_epg_id, epg_id_t dst_epg_id, const ACL::l3_list &acl, const gbp_rules_t &gpb_rules, const ethertype_set_t &allowed_ethertypes)
Construct a GBP contract.
vl_api_gbp_next_hop_t nhs[8]
A entry in the ARP termination table of a Bridge Domain.
~gbp_contract()
Destructor.
std::pair< epg_id_t, epg_id_t > key_t
The key for a contract is the pari of EPG-IDs.
std::string to_string() const
Convert to string for debugging.
A command class that creates or updates the GBP contract.
vl_api_gbp_rule_t rules[n_rules]
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Representation of next hop.
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
static const log_level_t ERROR
std::set< gbp_rule > gbp_rules_t
set of gbp rules
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
The VPP Object Model (VOM) library.
A representation of a method call to VPP.
std::set< next_hop_t > next_hops_t
unordered set of next hops
static std::shared_ptr< gbp_contract > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
A cmd class that deletes a GBP contract.
static const hash_mode_t & from_int(vapi_enum_gbp_hash_mode i)
create the hash mode from int value
static bool register_listener(listener *listener)
Register a listener of events.
static const action_t & from_int(vapi_enum_gbp_rule_action i)
create the action from int value