Line data Source code
1 : /* 2 : * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef __src_vnsw_agent_vrouter_ksync_ksync_flow_memory_h 7 : #define __src_vnsw_agent_vrouter_ksync_ksync_flow_memory_h 8 : 9 : /* 10 : * Module responsible to manage the VRouter memory mapped to agent 11 : */ 12 : #include <list> 13 : #include <base/address.h> 14 : #include <vrouter/ksync/ksync_memory.h> 15 : 16 : class Timer; 17 : class KSync; 18 : struct FlowKey; 19 : struct vr_flow_entry; 20 : struct vr_flow_stats; 21 : struct KFlowData; 22 : 23 : class KSyncFlowMemory : public KSyncMemory { 24 : public: 25 : KSyncFlowMemory(KSync *ksync, uint32_t minor_id); 26 4 : virtual ~KSyncFlowMemory() {} 27 : 28 : virtual void Init(); 29 : 30 : static void VrFlowToIp(const vr_flow_entry *kflow, IpAddress *sip, 31 : IpAddress *dip); 32 : const vr_flow_entry *GetKernelFlowEntry(uint32_t idx, 33 : bool ignore_active_status) const; 34 : const vr_flow_entry *GetValidKFlowEntry(const FlowKey &key, 35 : uint32_t idx, uint8_t gen_id) const; 36 : const vr_flow_entry *GetKFlowStats(const FlowKey &key, uint32_t idx, 37 : uint8_t gen_id, 38 : vr_flow_stats *stats) const; 39 : const vr_flow_entry *GetKFlowStatsAndInfo(const FlowKey &key, 40 : uint32_t idx, 41 : uint8_t gen_id, 42 : vr_flow_stats *stats, 43 : KFlowData *info) const; 44 : bool GetFlowKey(uint32_t index, FlowKey *key, bool *is_nat_flow); 45 : 46 : bool IsEvictionMarked(const vr_flow_entry *entry, uint16_t flags) const; 47 : 48 : virtual int get_entry_size(); 49 : virtual bool IsInactiveEntry(uint32_t idx, uint8_t &gen_id); 50 : virtual void SetTableSize(); 51 : virtual int EncodeReq(nl_client *nl, uint32_t attr_len); 52 : virtual void CreateProtoAuditEntry(uint32_t index, uint8_t gen_id); 53 : virtual void InitTest(); 54 : virtual void Shutdown(); 55 : void DecrementHoldFlowCounter(); 56 : void IncrementHoldFlowCounter(); 57 : void UpdateAgentHoldFlowCounter(); 58 : 59 : private: 60 : uint32_t hold_flow_counter_; 61 : void KFlow2FlowKey(const vr_flow_entry *entry, FlowKey *key) const; 62 : void ReadFlowInfo(const vr_flow_entry *k_flow, vr_flow_stats *stats, 63 : KFlowData *info) const; 64 : const vr_flow_entry *flow_table_; 65 : }; 66 : 67 : #endif // __src_vnsw_agent_vrouter_ksync_ksync_flow_memory_h