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