OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flow_mgmt_dbclient.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 #ifndef __AGENT_FLOW_MGMT_DBCLIENT_H__
5 #define __AGENT_FLOW_MGMT_DBCLIENT_H__
6 
7 #include "pkt/flow_event.h"
8 
9 class EcmpLoadBalance;
11 // Request to the Flow Management module
14 public:
15  struct FlowMgmtState : public DBState {
16  FlowMgmtState() : gen_id_(0), deleted_(false) { }
17  virtual ~FlowMgmtState() { }
18 
19  void IncrementGenId() { gen_id_++; }
20  uint32_t gen_id_;
21  bool deleted_;
22  };
23 
31  const AclDBEntry *macl,
32  const AclDBEntry *mcacl, bool enable_rpf,
33  bool flood_unknown_unicast) :
34  acl_(acl), macl_(macl), mcacl_(mcacl), enable_rpf_(enable_rpf),
35  flood_unknown_unicast_(flood_unknown_unicast){ }
36  virtual ~VnFlowHandlerState() { }
37  };
38 
41  vrf_assign_acl_(NULL), is_vn_qos_config_(false),
42  forwarding_vrf_id_(VrfEntry::kInvalidIndex) { }
44 
46  bool policy_;
54  };
55 
58  virtual ~VrfFlowHandlerState() {}
59 
60  // Register to all the route tables of intrest
61  void Register(FlowMgmtDbClient *client, VrfEntry *vrf);
62  void Unregister(FlowMgmtDbClient *client, VrfEntry *vrf);
63 
64  // Unregister from the route tables
65  bool Unregister(VrfEntry *vrf);
66 
68  if (type == Agent::INET4_UNICAST)
69  return inet_listener_id_;
70  if (type == Agent::INET6_UNICAST)
71  return inet6_listener_id_;
72  if (type == Agent::BRIDGE)
73  return bridge_listener_id_;
74 
75  assert(0);
76  return -1;
77  }
81  bool deleted_;
82  };
83 
87  virtual ~RouteFlowHandlerState() { }
88  typedef std::map<InterfaceConstRef, IpAddress> FixedIpMap;
89  typedef std::pair<InterfaceConstRef, IpAddress> FixedIpEntry;
90 
98  };
99 
101  NhFlowHandlerState(uint8_t valid_encap_size) : valid_encap_size_(valid_encap_size) { }
103  virtual ~NhFlowHandlerState() { }
104  };
105 
108  virtual ~AclFlowHandlerState() { }
109  };
110 
111  FlowMgmtDbClient(Agent *agent, FlowMgmtManager *mgr);
112  virtual ~FlowMgmtDbClient();
113 
114  void Init();
115  void Shutdown();
116  bool FreeDBState(const DBEntry *entry, uint32_t gen_id);
117  void FreeVrfState(VrfEntry *vrf, uint32_t gen_id);
118 
119 private:
120  friend class FlowMgmtRouteTest;
121  void AddEvent(const DBEntry *entry, FlowMgmtState *state);
122  void DeleteEvent(const DBEntry *entry, FlowMgmtState *state);
123  void DeleteAllFlow(const DBEntry *entry, FlowMgmtState *state);
124  void ChangeEvent(const DBEntry *entry, FlowMgmtState *state);
125  void RouteNHChangeEvent(const DBEntry *entry, FlowMgmtState *state);
126 
127  void FreeInterfaceState(Interface *intf, uint32_t gen_id);
129 
130  void FreeVnState(VnEntry *vn, uint32_t gen_id);
131  void VnNotify(DBTablePartBase *part, DBEntryBase *e);
132 
133  void FreeAclState(AclDBEntry *acl, uint32_t gen_id);
134  void AclNotify(DBTablePartBase *part, DBEntryBase *e);
135 
136  void FreeNhState(NextHop *nh, uint32_t gen_id);
137  void NhNotify(DBTablePartBase *part, DBEntryBase *e);
138 
139  void VrfNotify(DBTablePartBase *part, DBEntryBase *e);
140 
141  void TraceMsg(AgentRoute *entry, const AgentPath *path,
142  const SecurityGroupList &sg_list, bool deleted);
143  void FreeRouteState(AgentRoute *route, uint32_t gen_id);
145  DBTablePartBase *partition, DBEntryBase *e);
146  bool HandleTrackingIpChange(const AgentRoute *rt,
147  RouteFlowHandlerState *state);
150 
158 };
159 
160 #endif // __AGENT_FLOW_MGMT_DBCLIENT_H__
uint32_t TypeBmap
Definition: nexthop.h:248
boost::intrusive_ptr< const AclDBEntry > AclDBEntryConstRef
Definition: agent.h:143
FlowMgmtDbClient(Agent *agent, FlowMgmtManager *mgr)
NhFlowHandlerState(uint8_t valid_encap_size)
std::pair< InterfaceConstRef, IpAddress > FixedIpEntry
DBTableBase::ListenerId inet6_listener_id_
Definition: vrf.h:86
void FreeVrfState(VrfEntry *vrf, uint32_t gen_id)
void DeleteEvent(const DBEntry *entry, FlowMgmtState *state)
void InterfaceNotify(DBTablePartBase *part, DBEntryBase *e)
VnFlowHandlerState(const AclDBEntry *acl, const AclDBEntry *macl, const AclDBEntry *mcacl, bool enable_rpf, bool flood_unknown_unicast)
std::vector< int > SecurityGroupList
Definition: agent.h:201
int ListenerId
Definition: db_table.h:62
void FreeNhState(NextHop *nh, uint32_t gen_id)
void Register(FlowMgmtDbClient *client, VrfEntry *vrf)
void FreeRouteState(AgentRoute *route, uint32_t gen_id)
Base class for all Route entries in agent.
Definition: agent_route.h:224
std::vector< AclDBEntryConstRef > FirewallPolicyList
Definition: vm_interface.h:107
DBTableBase::ListenerId bridge_listener_id_
void DeleteAllFlow(const DBEntry *entry, FlowMgmtState *state)
DISALLOW_COPY_AND_ASSIGN(FlowMgmtDbClient)
void AclNotify(DBTablePartBase *part, DBEntryBase *e)
bool HandleTrackingIpChange(const AgentRoute *rt, RouteFlowHandlerState *state)
DBTableBase::ListenerId GetListenerId(Agent::RouteTableType type)
void Unregister(FlowMgmtDbClient *client, VrfEntry *vrf)
uint8_t type
Definition: load_balance.h:109
Definition: agent.h:358
VmInterface::SecurityGroupEntryList sg_l_
DBTableBase::ListenerId vn_listener_id_
boost::intrusive_ptr< const AgentQosConfig > AgentQosConfigConstRef
Definition: agent.h:178
DBTableBase::ListenerId vm_listener_id_
DBTableBase::ListenerId interface_listener_id_
void VnNotify(DBTablePartBase *part, DBEntryBase *e)
friend class FlowMgmtRouteTest
void FreeVnState(VnEntry *vn, uint32_t gen_id)
Definition: vn.h:151
bool FreeDBState(const DBEntry *entry, uint32_t gen_id)
void FreeAclState(AclDBEntry *acl, uint32_t gen_id)
void VrfNotify(DBTablePartBase *part, DBEntryBase *e)
std::map< InterfaceConstRef, IpAddress > FixedIpMap
DBTableBase::ListenerId vrf_listener_id_
DBTableBase::ListenerId nh_listener_id_
void FreeInterfaceState(Interface *intf, uint32_t gen_id)
DBTableBase::ListenerId acl_listener_id_
DBTableBase::ListenerId inet_listener_id_
void ChangeEvent(const DBEntry *entry, FlowMgmtState *state)
void NhNotify(DBTablePartBase *part, DBEntryBase *e)
void RouteNHChangeEvent(const DBEntry *entry, FlowMgmtState *state)
FlowMgmtManager * mgr_
RouteTableType
Definition: agent.h:415
boost::intrusive_ptr< const VnEntry > VnEntryConstRef
Definition: agent.h:70
void RouteNotify(VrfFlowHandlerState *vrf_state, Agent::RouteTableType type, DBTablePartBase *partition, DBEntryBase *e)
void AddEvent(const DBEntry *entry, FlowMgmtState *state)
Definition: acl.h:92
void TraceMsg(AgentRoute *entry, const AgentPath *path, const SecurityGroupList &sg_list, bool deleted)
std::vector< int > TagList
Definition: agent.h:202