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