OpenSDN source code
ksync_vxlan_route.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef vnsw_agent_ksync_vxlan_route_h
7 #define vnsw_agent_ksync_vxlan_route_h
8 
11 
12 /****************************************************************************
13  * File contains KSync objects to manage FDB Route table for Vxlan bridge.
14  ****************************************************************************/
15 
16 /****************************************************************************
17  * In Contrail, each Virtual-Network defines a broadcast domain. Each
18  * Virtual-Network has a VRF associated with it. The FDB Table for a
19  * Virtual-Network is got from the VRF for it.
20  *
21  * KSyncVxlanVrfObject listens to VRF entries being created and in-turn
22  * create a KSyncVxlanRouteObject for Bridge Route Table in the VRF
23  ****************************************************************************/
25 public:
26  typedef std::map<uint32_t, KSyncVxlanRouteObject *> VrfRouteObjectMap;
27  struct VrfState : DBState {
28  VrfState() : DBState(), seen_(false) {};
29  bool seen_;
30  };
31 
33  virtual ~KSyncVxlanVrfObject();
34 
35  void Init();
36  void Shutdown();
37  void RegisterDBClients();
38 
39  // Virtual Method to allocate KSync Object KSyncVxlanRouteObject for every
40  // Bridge Route Table.
41  // This API is invoked when Vxlan Agent sees Bridge Route Table in a new VRF
43  = 0;
44  KSyncVxlan *ksync() const { return ksync_; }
45 
46  void VrfNotify(DBTablePartBase *partition, DBEntryBase *e);
47  void AddToVrfMap(uint32_t vrf_id, KSyncVxlanRouteObject *);
49  KSyncVxlanRouteObject *GetRouteKSyncObject(uint32_t vrf_id) const;
50 private:
55 };
56 
57 /****************************************************************************
58  * KSync Object to manage Vxlan FDB Table. A KSyncVxlanRouteObject is created
59  * for every Bridge Route Table.
60  *
61  * Registers as client to Bridge Route DBTable
62  ****************************************************************************/
64 public:
66  virtual ~KSyncVxlanRouteObject();
67 
68  // Method to allocate the inherited KSyncVxlanFdbEntry
69  // Must populate the KSyncEntry from DBEntry passed
70  // DBEntry will be of type BridgeRouteEntry
71  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e) = 0;
72 
73  // Method to allocate the inherited KSyncVxlanFdbEntry
74  // The fields in "key" must be copied into newly allocated object
75  virtual KSyncEntry *Alloc(const KSyncEntry *key, uint32_t index) = 0;
76 
77  void ManagedDelete();
78  void Unregister();
79  virtual void EmptyTable();
80 
81  KSyncVxlan *ksync() const { return ksync_; }
82  const AgentRouteTable *route_table() const { return rt_table_; }
83 private:
89 };
90 
91 /****************************************************************************
92  * An abstract class for all Route Entries.
93  * Can potentially be used later to support Inet Unicast/Multicast route tables
94  ****************************************************************************/
96 public:
98  const KSyncVxlanRouteEntry *entry);
100  virtual ~KSyncVxlanRouteEntry();
101 
102  virtual bool IsLess(const KSyncEntry &rhs) const;
103  virtual bool CompareRoute(const KSyncVxlanRouteEntry &rhs) const = 0;
104 
105  KSyncDBObject *GetObject() const;
106  uint32_t vrf_id() const { return vrf_id_; }
108 private:
109  uint32_t vrf_id_;
112 };
113 
114 /****************************************************************************
115  * KSync representation of every FDB entry in a Vxlan Bridge
116  *
117  * A KSyncVxlanFdbEntry is created for every entry in Bridge Route Table
118  ****************************************************************************/
120 public:
122  const KSyncVxlanFdbEntry *entry);
124  const BridgeRouteEntry *route);
125  virtual ~KSyncVxlanFdbEntry();
126 
127  virtual bool CompareRoute(const KSyncVxlanRouteEntry &rhs) const;
128  virtual std::string ToString() const;
129  virtual bool Sync(DBEntry *e);
130  virtual KSyncEntry *UnresolvedReference();
131 
132  // Virtual method invoked when a FDB entry is to be created
133  virtual bool Add() = 0;
134  // Virtual method invoked when a FDB entry is to be modified
135  virtual bool Change() = 0;
136  // Virtual method invoked when a FDB entry is to be Deleted
137  virtual bool Delete() = 0;
138 
139  const MacAddress &mac() const { return mac_; }
140  const KSyncVxlanBridgeEntry *bridge() const { return bridge_; }
141  const KSyncVxlanPortEntry *port() const { return port_; }
142  const Ip4Address &tunnel_dest() const { return tunnel_dest_; }
143 private:
149 };
150 
151 #endif // vnsw_agent_ksync_vxlan_route_h
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:15
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge,...
Definition: agent_route.h:110
Base class for all Route entries in agent.
Definition: agent_route.h:225
int ListenerId
Definition: db_table.h:63
KSyncVxlanFdbEntry(KSyncVxlanRouteObject *obj, const KSyncVxlanFdbEntry *entry)
virtual bool Change()=0
virtual bool Add()=0
virtual std::string ToString() const
DISALLOW_COPY_AND_ASSIGN(KSyncVxlanFdbEntry)
virtual bool CompareRoute(const KSyncVxlanRouteEntry &rhs) const
KSyncVxlanBridgeEntry * bridge_
KSyncVxlanPortEntry * port_
const Ip4Address & tunnel_dest() const
virtual bool Delete()=0
virtual bool Sync(DBEntry *e)
const KSyncVxlanBridgeEntry * bridge() const
virtual KSyncEntry * UnresolvedReference()
const KSyncVxlanPortEntry * port() const
const MacAddress & mac() const
DISALLOW_COPY_AND_ASSIGN(KSyncVxlanRouteEntry)
uint32_t vrf_id() const
KSyncDBObject * GetObject() const
KSyncVxlanRouteObject * ksync_obj_
KSyncVxlanRouteObject * ksync_object() const
virtual bool CompareRoute(const KSyncVxlanRouteEntry &rhs) const =0
virtual bool IsLess(const KSyncEntry &rhs) const
KSyncVxlanRouteEntry(KSyncVxlanRouteObject *obj, const KSyncVxlanRouteEntry *entry)
AgentRouteTable * rt_table_
LifetimeRef< KSyncVxlanRouteObject > table_delete_ref_
KSyncVxlan * ksync() const
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)=0
virtual KSyncEntry * Alloc(const KSyncEntry *key, uint32_t index)=0
KSyncVxlanRouteObject(KSyncVxlanVrfObject *vrf, AgentRouteTable *rt_table)
DISALLOW_COPY_AND_ASSIGN(KSyncVxlanRouteObject)
const AgentRouteTable * route_table() const
void AddToVrfMap(uint32_t vrf_id, KSyncVxlanRouteObject *)
DISALLOW_COPY_AND_ASSIGN(KSyncVxlanVrfObject)
KSyncVxlanVrfObject(KSyncVxlan *ksync)
KSyncVxlan * ksync() const
void DelFromVrfMap(KSyncVxlanRouteObject *)
DBTableBase::ListenerId vrf_listener_id_
std::map< uint32_t, KSyncVxlanRouteObject * > VrfRouteObjectMap
void VrfNotify(DBTablePartBase *partition, DBEntryBase *e)
VrfRouteObjectMap vrf_fdb_object_map_
KSyncVxlanRouteObject * GetRouteKSyncObject(uint32_t vrf_id) const
virtual KSyncVxlanRouteObject * AllocBridgeRouteTable(const VrfEntry *entry)=0
Definition: vrf.h:90