FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
gbp_vxlan.hpp
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 #ifndef __VOM_GBP_VXLAN_H__
17 #define __VOM_GBP_VXLAN_H__
18 
20 #include "vom/gbp_route_domain.hpp"
21 #include "vom/hw.hpp"
22 #include "vom/inspect.hpp"
23 #include "vom/interface.hpp"
24 #include "vom/singular_db.hpp"
25 
26 namespace VOM {
27 /**
28  * A representation of a GBP_VXLAN Tunnel in VPP
29  */
30 class gbp_vxlan : public interface
31 {
32 public:
33  /**
34  * The VNI is the key
35  */
36  typedef uint32_t key_t;
37 
38  /**
39  * Construct a new object matching the desried state
40  */
41  gbp_vxlan(uint32_t vni,
42  const gbp_bridge_domain& gbd,
43  const boost::asio::ip::address_v4& src);
44  gbp_vxlan(uint32_t vni,
45  const gbp_route_domain& grd,
46  const boost::asio::ip::address_v4& src);
47 
48  /*
49  * Destructor
50  */
51  ~gbp_vxlan();
52 
53  /**
54  * Copy constructor
55  */
56  gbp_vxlan(const gbp_vxlan& o);
57 
58  bool operator==(const gbp_vxlan& vt) const;
59 
60  /**
61  * Return the matching 'singular instance'
62  */
63  std::shared_ptr<gbp_vxlan> singular() const;
64 
65  /**
66  * Return the object's key
67  */
68  const key_t key() const;
69 
70  /**
71  * Debug rpint function
72  */
73  virtual std::string to_string() const;
74 
75  /**
76  * Return VPP's handle to this object
77  */
78  const handle_t& handle() const;
79 
80  /**
81  * Dump all L3Configs into the stream provided
82  */
83  static void dump(std::ostream& os);
84 
85  /**
86  * Find the GBP_VXLAN tunnel in the OM
87  */
88  static std::shared_ptr<gbp_vxlan> find(const key_t k);
89 
90 private:
91  /**
92  * Class definition for listeners to OM events
93  */
95  {
96  public:
97  event_handler();
98  virtual ~event_handler() = default;
99 
100  /**
101  * Handle a populate event
102  */
103  void handle_populate(const client_db::key_t& key);
104 
105  /**
106  * Handle a replay event
107  */
108  void handle_replay();
109 
110  /**
111  * Show the object in the Singular DB
112  */
113  void show(std::ostream& os);
114 
115  /**
116  * Get the sortable Id of the listener
117  */
118  dependency_t order() const;
119  };
120 
121  /**
122  * Event handle to register with OM
123  */
124  static event_handler m_evh;
125 
126  /**
127  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
128  */
129  void update(const gbp_vxlan& obj);
130 
131  /**
132  * Return the matching 'instance' of the sub-interface
133  * over-ride from the base class
134  */
135  std::shared_ptr<interface> singular_i() const;
136 
137  /**
138  * Find the GBP_VXLAN tunnel in the OM
139  */
140  static std::shared_ptr<gbp_vxlan> find_or_add(const gbp_vxlan& temp);
141 
142  /*
143  * It's the VPPHW class that updates the objects in HW
144  */
145  friend class OM;
146 
147  /**
148  * It's the singular_db class that calls replay()
149  */
150  friend class singular_db<key_t, gbp_vxlan>;
151 
152  /**
153  * Sweep/reap the object if still stale
154  */
155  void sweep(void);
156 
157  /**
158  * replay the object to create it in hardware
159  */
160  void replay(void);
161 
162  /**
163  * Tunnel VNI/key
164  */
165  uint32_t m_vni;
166  std::shared_ptr<gbp_bridge_domain> m_gbd;
167  std::shared_ptr<gbp_route_domain> m_grd;
168  boost::asio::ip::address_v4 m_src;
169 
170  /**
171  * A map of all VLAN tunnela against thier key
172  */
173  static singular_db<key_t, gbp_vxlan> m_db;
174 
175  /**
176  * Construct a unique name for the tunnel
177  */
178  static std::string mk_name(uint32_t vni);
179 };
180 
181 }; // namespace VOM
182 
183 /*
184  * fd.io coding-style-patch-verification: OFF
185  *
186  * Local Variables:
187  * eval: (c-set-style "mozilla")
188  * End:
189  */
190 
191 #endif
VOM::gbp_vxlan::gbp_vxlan
gbp_vxlan(uint32_t vni, const gbp_bridge_domain &gbd, const boost::asio::ip::address_v4 &src)
Construct a new object matching the desried state.
Definition: gbp_vxlan.cpp:45
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::gbp_bridge_domain
A entry in the ARP termination table of a Bridge Domain.
Definition: gbp_bridge_domain.hpp:29
VOM::dependency_t
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
VOM::gbp_vxlan::dump
static void dump(std::ostream &os)
Dump all L3Configs into the stream provided.
Definition: gbp_vxlan.cpp:167
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
vni
u32 vni
Definition: flow_types.api:160
VOM::inspect::command_handler
inspect command handler Handler
Definition: inspect.hpp:54
gbp_bridge_domain.hpp
VOM::gbp_vxlan::operator==
bool operator==(const gbp_vxlan &vt) const
Definition: gbp_vxlan.cpp:84
VOM::gbp_vxlan::key_t
uint32_t key_t
The VNI is the key.
Definition: gbp_vxlan.hpp:36
VOM::OM::listener
Class definition for listeners to OM events.
Definition: om.hpp:284
VOM::gbp_vxlan::find
static std::shared_ptr< gbp_vxlan > find(const key_t k)
Find the GBP_VXLAN tunnel in the OM.
Definition: gbp_vxlan.cpp:127
VOM::gbp_vxlan::key
const key_t key() const
Return the object's key.
Definition: gbp_vxlan.cpp:78
VOM::gbp_vxlan::to_string
virtual std::string to_string() const
Debug rpint function.
Definition: gbp_vxlan.cpp:118
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
hw.hpp
VOM::client_db::key_t
const typedef 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
VOM::handle_t
A type declaration of an interface handle in VPP.
Definition: types.hpp:233
src
vl_api_address_t src
Definition: gre.api:54
VOM::gbp_vxlan::~gbp_vxlan
~gbp_vxlan()
Definition: gbp_vxlan.cpp:111
inspect.hpp
singular_db.hpp
interface.hpp
VOM::gbp_route_domain
A entry in the ARP termination table of a Route Domain.
Definition: gbp_route_domain.hpp:30
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
show
void show(char *chroot_path, int verbose)
Definition: svmtool.c:104
event_handler
void event_handler(void *tls_async)
Definition: tls_async.c:334
gbp_route_domain.hpp
VOM::gbp_vxlan::handle
const handle_t & handle() const
Return VPP's handle to this object.
VOM::gbp_vxlan
A representation of a GBP_VXLAN Tunnel in VPP.
Definition: gbp_vxlan.hpp:30
VOM::gbp_vxlan::singular
std::shared_ptr< gbp_vxlan > singular() const
Return the matching 'singular instance'.
Definition: gbp_vxlan.cpp:155
string
const char *const string
Definition: cJSON.h:172