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