OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flow_mgmt_entry.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __AGENT_PKT_FLOW_MGMT_ENTRY_H__
6 #define __AGENT_PKT_FLOW_MGMT_ENTRY_H__
7 
8 #include <string>
9 #include <map>
10 #include <boost/intrusive/list.hpp>
11 #include <base/util.h>
13 #include <filter/acl_entry.h>
14 
15 class Agent;
16 class FlowEntry;
17 class FlowMgmtManager;
18 class FlowMgmtRequest;
19 class VrfFlowMgmtTree;
20 
21 class FlowMgmtKey;
25 
26 class AclDBEntry;
27 class AclFlowResp;
28 class AclFlowCountResp;
29 
31 public:
32  // Flow management state of the entry
33  enum State {
38  };
39 
40  typedef boost::intrusive::member_hook<FlowMgmtKeyNode,
41  boost::intrusive::list_member_hook<>,
43  typedef boost::intrusive::list<FlowMgmtKeyNode, Node> FlowList;
44 
45  static const int MaxResponses = 100;
46 
48  }
49  virtual ~FlowMgmtEntry() {
50  assert(flow_list_.size() == 0);
51  }
52 
53  uint32_t Size() const { return flow_list_.size(); }
54  // Make flow dependent on the DBEntry
55  virtual bool Add(FlowEntry *flow, FlowMgmtKeyNode *node);
56  // Remove flow from dependency tree
57  virtual bool Delete(FlowEntry *flow, FlowMgmtKeyNode *node);
58 
59  // Handle Add/Change event for DBEntry
60  virtual bool OperEntryAdd(FlowMgmtManager *mgr, const FlowMgmtRequest *req,
61  FlowMgmtKey *key);
62  virtual bool OperEntryChange(FlowMgmtManager *mgr,
63  const FlowMgmtRequest *req, FlowMgmtKey *key);
64  // Handle Delete event for DBEntry
65  virtual bool OperEntryDelete(FlowMgmtManager *mgr,
66  const FlowMgmtRequest *req, FlowMgmtKey *key);
67  // Handle Delete event for Non-DBEntry
69  const FlowMgmtRequest *req,
70  FlowMgmtKey *key) { return true; }
71  // Can the entry be deleted?
72  virtual bool CanDelete() const;
73 
74  void set_oper_state(State state) { oper_state_ = state; }
75  State oper_state() const { return oper_state_; }
76  uint32_t gen_id() const { return gen_id_; }
77  const FlowList &flow_list() const { return flow_list_; }
78 
79 protected:
80  // Add seen from OperDB entry
82  uint32_t gen_id_;
84 
85 private:
87 };
88 
90 public:
91  typedef std::map<std::string, int> AceIdFlowCntMap;
93  virtual ~AclFlowMgmtEntry() { }
94  void FillAclFlowSandeshInfo(const AclDBEntry *acl, AclFlowResp &data,
95  const int last_count, Agent *agent);
96  void FillAceFlowSandeshInfo(const AclDBEntry *acl, AclFlowCountResp &data,
97  const std::string &ace_id);
98  bool Add(const AclEntryIDList *ace_id_list, FlowEntry *flow,
99  const AclEntryIDList *old_id_list, FlowMgmtKeyNode *node);
100  bool Delete(const AclEntryIDList *ace_id_list, FlowEntry *flow,
101  FlowMgmtKeyNode *node);
102  void DecrementAceIdCountMap(const AclEntryIDList *id_list);
103 
104 private:
105  std::string GetAceSandeshDataKey(const AclDBEntry *acl,
106  const std::string &ace_id);
107  std::string GetAclFlowSandeshDataKey(const AclDBEntry *acl,
108  const int last_count) const;
109  uint32_t flow_miss_;
112 };
113 
115 public:
118  }
119  virtual ~VnFlowMgmtEntry() { }
120 
121  void UpdateCounterOnAdd(FlowEntry *flow, bool add_flow, bool local_flow,
122  bool old_ingress);
123  void UpdateCounterOnDel(FlowEntry *flow, bool local_flow, bool old_ingress);
124  uint32_t ingress_flow_count() const { return ingress_flow_count_; }
125  uint32_t egress_flow_count() const { return egress_flow_count_; }
126 
127 private:
131 };
132 
134 public:
136  flow_aged_(0) { }
138 
139  bool Add(FlowEntry *flow, FlowMgmtKeyNode *node);
140  bool Delete(FlowEntry *flow, FlowMgmtKeyNode *node);
141  uint64_t flow_created() const { return flow_created_; }
142  uint64_t flow_aged() const { return flow_aged_; }
143 
144 private:
145  uint64_t flow_created_;
146  uint64_t flow_aged_;
148 };
149 
151 public:
153  virtual ~NhFlowMgmtEntry() { }
154 
155 private:
157 };
158 
160 public:
162  virtual ~RouteFlowMgmtEntry() { }
163 
164 private:
166 };
167 
169 public:
172  // Handle covering routeEntry
174  InetRouteFlowMgmtKey *covering_route,
175  InetRouteFlowMgmtKey *key);
176  bool HandleNhChange(FlowMgmtManager *mgr, const FlowMgmtRequest *req,
177  FlowMgmtKey *key);
178 
179 private:
181 };
182 
184 public:
187 
188 private:
190 };
191 
193 public:
194  struct Data {
195  Data(VrfFlowMgmtEntry *vrf_mgmt_entry, const VrfEntry *vrf,
196  AgentRouteTable *table);
197  virtual ~Data();
198  void ManagedDelete();
199  bool deleted() const { return deleted_; }
200 
201  bool deleted_;
204  const VrfEntry *vrf_;
205  };
206 
208  virtual ~VrfFlowMgmtEntry() { }
209  bool CanDelete() const;
210  VrfFlowMgmtTree *vrf_tree() const { return vrf_tree_; }
211  uint32_t vrf_id() const { return vrf_id_; }
212 
213 private:
214  friend class VrfFlowMgmtTree;
215  const VrfEntry *vrf_;
216  uint32_t vrf_id_;
220  // Back reference for the tree
223 };
224 
226 public:
229  virtual bool NonOperEntryDelete(FlowMgmtManager *mgr,
230  const FlowMgmtRequest *req,
231  FlowMgmtKey *key);
232  virtual bool HealthCheckUpdate(Agent *agent, FlowMgmtManager *mgr,
235 
236 private:
238 };
239 
240 #endif // __AGENT_PKT_FLOW_MGMT_ENTRY_H__
uint32_t ingress_flow_count() const
uint64_t flow_aged() const
boost::intrusive::member_hook< FlowMgmtKeyNode, boost::intrusive::list_member_hook<>,&FlowMgmtKeyNode::hook_ > Node
uint32_t egress_flow_count_
DISALLOW_COPY_AND_ASSIGN(VrfFlowMgmtEntry)
virtual bool OperEntryChange(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
Data(VrfFlowMgmtEntry *vrf_mgmt_entry, const VrfEntry *vrf, AgentRouteTable *table)
virtual bool OperEntryDelete(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
bool HandleNhChange(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
Definition: vrf.h:86
virtual bool HealthCheckUpdate(Agent *agent, FlowMgmtManager *mgr, BgpAsAServiceFlowMgmtKey &key, BgpAsAServiceFlowMgmtRequest *req)
virtual bool OperEntryAdd(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
Definition: agent_route.h:109
uint32_t vrf_id() const
uint32_t gen_id() const
bool Delete(const AclEntryIDList *ace_id_list, FlowEntry *flow, FlowMgmtKeyNode *node)
std::vector< AclEntryID > AclEntryIDList
Definition: acl_entry.h:85
DISALLOW_COPY_AND_ASSIGN(NhFlowMgmtEntry)
void set_oper_state(State state)
DISALLOW_COPY_AND_ASSIGN(BridgeRouteFlowMgmtEntry)
virtual ~AclFlowMgmtEntry()
DISALLOW_COPY_AND_ASSIGN(InetRouteFlowMgmtEntry)
void UpdateCounterOnDel(FlowEntry *flow, bool local_flow, bool old_ingress)
static const int MaxResponses
bool Delete(FlowEntry *flow, FlowMgmtKeyNode *node)
State oper_state() const
uint32_t Size() const
virtual bool Delete(FlowEntry *flow, FlowMgmtKeyNode *node)
virtual bool CanDelete() const
DISALLOW_COPY_AND_ASSIGN(RouteFlowMgmtEntry)
Definition: agent.h:358
boost::intrusive::list< FlowMgmtKeyNode, Node > FlowList
const VrfEntry * vrf_
virtual ~FlowMgmtEntry()
FlowList flow_list_
virtual ~VnFlowMgmtEntry()
boost::intrusive::list_member_hook hook_
virtual ~NhFlowMgmtEntry()
const VrfEntry * vrf_
VrfFlowMgmtEntry(VrfFlowMgmtTree *vrf_tree, const VrfEntry *vrf)
const FlowList & flow_list() const
DISALLOW_COPY_AND_ASSIGN(VnFlowMgmtEntry)
DISALLOW_COPY_AND_ASSIGN(FlowMgmtEntry)
std::string GetAceSandeshDataKey(const AclDBEntry *acl, const std::string &ace_id)
std::string GetAclFlowSandeshDataKey(const AclDBEntry *acl, const int last_count) const
VrfFlowMgmtEntry * vrf_mgmt_entry_
virtual ~VrfFlowMgmtEntry()
VrfFlowMgmtTree * vrf_tree() const
virtual bool NonOperEntryDelete(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
virtual bool NonOperEntryDelete(FlowMgmtManager *mgr, const FlowMgmtRequest *req, FlowMgmtKey *key)
void UpdateCounterOnAdd(FlowEntry *flow, bool add_flow, bool local_flow, bool old_ingress)
virtual ~RouteFlowMgmtEntry()
LifetimeRef< Data > table_ref_
uint32_t ingress_flow_count_
uint32_t egress_flow_count() const
DISALLOW_COPY_AND_ASSIGN(AclFlowMgmtEntry)
void FillAceFlowSandeshInfo(const AclDBEntry *acl, AclFlowCountResp &data, const std::string &ace_id)
bool RecomputeCoveringRouteEntry(FlowMgmtManager *mgr, InetRouteFlowMgmtKey *covering_route, InetRouteFlowMgmtKey *key)
std::map< std::string, int > AceIdFlowCntMap
void FillAclFlowSandeshInfo(const AclDBEntry *acl, AclFlowResp &data, const int last_count, Agent *agent)
void DecrementAceIdCountMap(const AclEntryIDList *id_list)
DISALLOW_COPY_AND_ASSIGN(InterfaceFlowMgmtEntry)
virtual bool Add(FlowEntry *flow, FlowMgmtKeyNode *node)
VrfFlowMgmtTree * vrf_tree_
AceIdFlowCntMap aceid_cnt_map_
DISALLOW_COPY_AND_ASSIGN(BgpAsAServiceFlowMgmtEntry)
uint32_t gen_id_
bool Add(FlowEntry *flow, FlowMgmtKeyNode *node)
Definition: acl.h:92
bool Add(const AclEntryIDList *ace_id_list, FlowEntry *flow, const AclEntryIDList *old_id_list, FlowMgmtKeyNode *node)
uint64_t flow_created() const
bool CanDelete() const