OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flow_mgmt_request.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_REQUEST_H__
5 #define __AGENT_FLOW_MGMT_REQUEST_H__
6 
7 #include "pkt/flow_table.h"
8 #include "pkt/flow_event.h"
9 
11 // Request to the Flow Management module
14 public:
15  enum Event {
29 
30  };
31 
33  event_(event), flow_(flow), db_entry_(NULL), vrf_id_(0), gen_id_(),
34  bytes_(), packets_(), oflow_bytes_(), params_() {
35  if (event == RETRY_DELETE_VRF)
36  assert(vrf_id_);
37  }
38 
40  const RevFlowDepParams &params) :
41  event_(event), flow_(flow), db_entry_(NULL), vrf_id_(0), gen_id_(),
42  bytes_(), packets_(), oflow_bytes_(), params_(params) {
43  }
44 
46  uint32_t packets, uint32_t oflow_bytes,
47  const boost::uuids::uuid &u) :
48  event_(event), flow_(flow), db_entry_(NULL), vrf_id_(0), gen_id_(),
49  bytes_(bytes), packets_(packets), oflow_bytes_(oflow_bytes), params_(),
50  flow_uuid_(u) {
51  if (event == RETRY_DELETE_VRF)
52  assert(vrf_id_);
53  }
54 
56  event_(event), flow_(NULL), db_entry_(db_entry), vrf_id_(0),
57  gen_id_(gen_id), bytes_(), packets_(), oflow_bytes_(), params_() {
58  if (event == RETRY_DELETE_VRF) {
59  const VrfEntry *vrf = dynamic_cast<const VrfEntry *>(db_entry);
60  assert(vrf);
61  vrf_id_ = vrf->vrf_id();
62  }
63  }
64 
66  event_(event), flow_(NULL), db_entry_(NULL), vrf_id_(),
68  }
69 
70  virtual ~FlowMgmtRequest() { }
71 
72  // At the end of Flow Management Request, we may enqueue a response message
73  // back to FlowTable module. Compute the message type to be enqueued in
74  // response. Returns INVALID if no message to be enqueued
79 
81  resp_event = FlowEvent::RECOMPUTE_FLOW;
82  }
83 
84  if (db_entry_ == NULL)
85  return resp_event;
86 
87  if (dynamic_cast<const VrfEntry *>(db_entry_)) {
88  return resp_event;
89  }
90 
91  if (event_ == ADD_DBENTRY || event_ == CHANGE_DBENTRY) {
92  resp_event = FlowEvent::REVALUATE_DBENTRY;
93  } else if (event_ == DELETE_DBENTRY) {
94  resp_event = FlowEvent::DELETE_DBENTRY;
95  }
96 
97  // Add/Change in route needs complete recomputation of flows
98  // 1. Bridge route change can be result of MAC-Move. This will need
99  // recomputing rpf-nh also.
100  // 2. Add/Delete of inet-uc route can result in change of route used
101  // used for flow
102  const AgentRoute *rt =
103  dynamic_cast<const AgentRoute *>(db_entry_);
104  if (rt) {
105  resp_event = FlowEvent::RECOMPUTE_FLOW;
106  }
107 
108  return resp_event;
109  }
110 
111  Event event() const { return event_; }
112  FlowEntryPtr &flow() { return flow_; }
113  void set_flow(FlowEntry *flow) { flow_.reset(flow); }
114  const DBEntry *db_entry() const { return db_entry_; }
116  uint32_t vrf_id() const { return vrf_id_; }
117  uint32_t gen_id() const { return gen_id_; }
118  uint32_t bytes() const { return bytes_;}
119  uint32_t packets() const { return packets_;}
120  uint32_t oflow_bytes() const { return oflow_bytes_;}
121  const RevFlowDepParams& params() const { return params_; }
123  params_ = params;
124  }
126 
127 private:
129  // FlowEntry pointer to hold flow reference till message is processed
131  // DBEntry pointer. The DBState from FlowTable module ensures DBEntry is
132  // not deleted while message holds pointer
134  uint32_t vrf_id_;
135  uint32_t gen_id_;
136  uint32_t bytes_;
137  uint32_t packets_;
138  uint32_t oflow_bytes_;
141 
143 };
144 
146 public:
147  enum Type {
152  };
153 
157  source_port_(), index_(index), health_check_uuid_() { }
159  uint32_t source_port) :
162  source_port_(source_port), index_(), health_check_uuid_() { }
164  uint32_t source_port,
165  const boost::uuids::uuid &hc_uuid,
166  Type type) :
168  type_(type), vm_uuid_(vm_uuid), source_port_(source_port), index_(),
169  health_check_uuid_(hc_uuid) { }
172  const boost::uuids::uuid &vm_uuid() const { return vm_uuid_; }
173  uint32_t source_port() const { return source_port_; }
174  uint8_t index() const { return index_; }
176  return health_check_uuid_;
177  }
178 
179 private:
182  uint32_t source_port_;
183  uint8_t index_;
186 };
187 #endif // __AGENT_FLOW_MGMT_REQUEST_H__
uint32_t oflow_bytes() const
const DBEntry * db_entry() const
BgpAsAServiceFlowMgmtRequest(const boost::uuids::uuid &vm_uuid, uint32_t source_port)
FlowMgmtRequest(Event event)
Definition: vrf.h:86
BgpAsAServiceFlowMgmtRequest(const boost::uuids::uuid &vm_uuid, uint32_t source_port, const boost::uuids::uuid &hc_uuid, Type type)
uint32_t bytes() const
boost::uuids::uuid flow_uuid() const
const RevFlowDepParams & params() const
BgpAsAServiceFlowMgmtRequest(uint8_t index)
FlowMgmtRequest(Event event, FlowEntry *flow)
boost::uuids::uuid uuid
Base class for all Route entries in agent.
Definition: agent_route.h:224
FlowMgmtRequest(Event event, FlowEntry *flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
DISALLOW_COPY_AND_ASSIGN(BgpAsAServiceFlowMgmtRequest)
const boost::uuids::uuid & vm_uuid() const
boost::uuids::uuid health_check_uuid_
FlowMgmtRequest(Event event, const DBEntry *db_entry, uint32_t gen_id)
virtual ~FlowMgmtRequest()
BgpAsAServiceFlowMgmtRequest::Type type_
uint32_t packets() const
FlowEvent::Event GetResponseEvent() const
boost::uuids::uuid flow_uuid_
DISALLOW_COPY_AND_ASSIGN(FlowMgmtRequest)
FlowMgmtRequest(Event event, FlowEntry *flow, const RevFlowDepParams &params)
FlowEntryPtr & flow()
FlowEntryPtr flow_
const DBEntry * db_entry_
const uint32_t vrf_id() const
Definition: vrf.h:99
uint32_t vrf_id() const
Event event() const
void set_flow(FlowEntry *flow)
void set_params(const RevFlowDepParams &params)
uint32_t gen_id() const
const boost::uuids::uuid & health_check_uuid() const
void set_db_entry(const DBEntry *db_entry)
BgpAsAServiceFlowMgmtRequest::Type type() const
RevFlowDepParams params_
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
Definition: flow_entry.h:125