Line data Source code
1 : /*
2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3 : */
4 :
5 : #ifndef vnsw_agent_path_hpp
6 : #define vnsw_agent_path_hpp
7 :
8 : #include <cmn/agent_cmn.h>
9 : #include <cmn/agent.h>
10 : #include <route/path.h>
11 : #include <oper/nexthop.h>
12 : #include <oper/agent_route.h>
13 : #include <oper/mpls.h>
14 : #include <oper/vxlan.h>
15 : //Forward declaration
16 : class AgentXmppChannel;
17 : struct InterfaceKey;
18 : class PhysicalInterface;
19 : class Peer;
20 : class EvpnPeer;
21 : class EcmpLoadBalance;
22 : class TsnElector;
23 :
24 : class PathPreference {
25 : public:
26 : enum Preference {
27 : INVALID = 0,
28 : HA_STALE = 1,
29 : LOW = 100,
30 : HIGH = 200
31 : };
32 865 : PathPreference(): loc_sequence_(0), sequence_(0), preference_(LOW),
33 865 : wait_for_traffic_(true), ecmp_(false), static_preference_(false),
34 865 : dependent_ip_(Ip4Address(0)) {}
35 199 : PathPreference(uint32_t sequence, uint32_t preference,
36 199 : bool wait_for_traffic, bool ecmp): loc_sequence_(0), sequence_(sequence),
37 199 : preference_(preference), wait_for_traffic_(wait_for_traffic),
38 199 : ecmp_(ecmp), static_preference_(false), dependent_ip_(Ip4Address(0)) {}
39 981 : uint32_t loc_sequence() const {return loc_sequence_;}
40 817 : uint32_t sequence() const { return sequence_;}
41 477 : uint32_t preference() const { return preference_;}
42 1705 : bool wait_for_traffic() const {
43 1705 : return wait_for_traffic_;
44 : }
45 1744 : bool ecmp() const {
46 1744 : return ecmp_;
47 : }
48 :
49 372 : bool is_ecmp() const {
50 372 : if ((preference_ == HIGH && sequence_ == 0)) {
51 17 : return true;
52 : }
53 :
54 355 : if (static_preference_) {
55 0 : return false;
56 : }
57 :
58 355 : if (ecmp_ == true) {
59 0 : return true;
60 : }
61 355 : return false;
62 : }
63 :
64 258 : bool static_preference() const {
65 258 : return static_preference_;
66 : }
67 :
68 390 : const IpAddress& dependent_ip() const {
69 390 : return dependent_ip_;
70 : }
71 :
72 13 : const std::string& vrf() const {
73 13 : return vrf_;
74 : }
75 :
76 0 : void set_loc_sequence(uint32_t loc_sequence) {
77 0 : loc_sequence_ = loc_sequence;
78 0 : }
79 13 : void set_sequence(uint32_t sequence) {
80 13 : sequence_ = sequence;
81 13 : }
82 15 : void set_preference(uint32_t preference) {
83 15 : preference_ = preference;
84 15 : }
85 13 : void set_wait_for_traffic(bool wait_for_traffic) {
86 13 : wait_for_traffic_ = wait_for_traffic;
87 13 : }
88 195 : void set_ecmp(bool ecmp) {
89 195 : ecmp_ = ecmp;
90 195 : }
91 :
92 0 : void set_static_preference(bool static_pref) {
93 0 : static_preference_ = static_pref;
94 0 : }
95 :
96 442 : void set_dependent_ip(const IpAddress &ip) {
97 442 : dependent_ip_ = ip;
98 442 : }
99 :
100 184 : void set_vrf(const std::string &vrf) {
101 184 : vrf_ = vrf;
102 184 : }
103 :
104 216 : bool operator!=(const PathPreference &rhs) const {
105 216 : return (loc_sequence_ != rhs.loc_sequence_
106 216 : || sequence_ != rhs.sequence_
107 184 : || preference_ != rhs.preference_
108 182 : || wait_for_traffic_ != rhs.wait_for_traffic_
109 432 : || ecmp_ != rhs.ecmp_);
110 : }
111 :
112 5 : bool operator<(const PathPreference &rhs) const {
113 5 : if (preference_ < rhs.preference_) {
114 0 : return true;
115 : }
116 :
117 5 : if (sequence_ < rhs.sequence_) {
118 0 : return true;
119 : }
120 :
121 5 : if (loc_sequence_ < rhs.loc_sequence_) {
122 0 : return true;
123 : }
124 5 : return false;
125 : }
126 :
127 : bool operator==(const PathPreference &rhs) const {
128 : if (loc_sequence_ == rhs.loc_sequence_ &&
129 : preference_ == rhs.preference_ &&
130 : sequence_ == rhs.sequence_) {
131 : return true;
132 : }
133 :
134 : return false;
135 : }
136 :
137 :
138 : //Check if any configuration values have changed
139 : //ecmp flag and static preference are updated from
140 : //configuration, if static preference flag is set,
141 : //then preference also would be picked from configuration
142 219 : bool ConfigChanged(const PathPreference &rhs) const {
143 219 : bool ret = false;
144 219 : if (ecmp_ != rhs.ecmp_) {
145 2 : ret = true;
146 217 : } else if (static_preference_ != rhs.static_preference_) {
147 0 : ret = true;
148 217 : } else if (static_preference_ && preference_ != rhs.preference_) {
149 0 : ret = true;
150 217 : } else if (dependent_ip_ != rhs.dependent_ip_) {
151 0 : ret = true;
152 : }
153 219 : return ret;
154 : }
155 :
156 445 : bool IsDependentRt(void) const {
157 445 : if (dependent_ip_.is_v4()) {
158 445 : if (dependent_ip_ != Ip4Address(0)) {
159 0 : return true;
160 : }
161 0 : } else if (dependent_ip_.is_v6()) {
162 0 : if (!dependent_ip_.is_unspecified()) {
163 0 : return true;
164 : }
165 : }
166 445 : return false;
167 : }
168 :
169 :
170 : private:
171 : uint32_t loc_sequence_;
172 : uint32_t sequence_;
173 : uint32_t preference_;
174 : bool wait_for_traffic_;
175 : bool ecmp_;
176 : bool static_preference_;
177 : IpAddress dependent_ip_;
178 : std::string vrf_;
179 : };
180 :
181 : //Route data to change preference and sequence number of path
182 : struct PathPreferenceData : public AgentRouteData {
183 13 : PathPreferenceData(const PathPreference &path_preference):
184 : AgentRouteData(ROUTE_PREFERENCE_CHANGE, false, 0),
185 13 : path_preference_(path_preference) { }
186 0 : virtual std::string ToString() const {
187 0 : return "";
188 : }
189 : virtual bool AddChangePathExtended(Agent*, AgentPath*, const AgentRoute*);
190 : PathPreference path_preference_;
191 : };
192 :
193 : class AgentPathEcmpComponent {
194 : public:
195 : AgentPathEcmpComponent(IpAddress addr, uint32_t label, AgentRoute *rt);
196 0 : virtual ~AgentPathEcmpComponent() { }
197 : bool Unresolved() {return unresolved;}
198 :
199 : bool operator == (const AgentPathEcmpComponent &rhs) const {
200 : if (addr_ == rhs.addr_ && label_ == rhs.label_) {
201 : return true;
202 : }
203 :
204 : return false;
205 : }
206 0 : IpAddress GetGwIpAddr() { return addr_;}
207 0 : uint32_t GetLabel() {return label_;}
208 0 : void UpdateDependentRoute(AgentRoute *rt) {
209 0 : if (rt) {
210 0 : dependent_rt_.reset(rt);
211 : } else {
212 0 : dependent_rt_.clear();
213 : }
214 0 : }
215 :
216 0 : void SetUnresolved(bool flag) {
217 0 : unresolved = flag;
218 0 : }
219 :
220 : private:
221 : IpAddress addr_;
222 : uint32_t label_;
223 : DependencyRef<AgentRoute, AgentRoute> dependent_rt_;
224 : bool unresolved;
225 : DISALLOW_COPY_AND_ASSIGN(AgentPathEcmpComponent);
226 : };
227 :
228 : typedef boost::shared_ptr<AgentPathEcmpComponent> AgentPathEcmpComponentPtr;
229 : typedef std::vector<AgentPathEcmpComponentPtr> AgentPathEcmpComponentPtrList;
230 : // A common class for all different type of paths
231 : class AgentPath : public Path {
232 : public:
233 : AgentPath(const Peer *peer, AgentRoute *rt);
234 : virtual ~AgentPath();
235 :
236 : virtual const NextHop *ComputeNextHop(Agent *agent) const;
237 : virtual bool IsLess(const AgentPath &right) const;
238 : //UsablePath
239 : //This happens when a route is dependant on other route to get the path and
240 : //in these cases active path of other route will be usable path.
241 : //If there is no dependant route then it returns self.
242 : virtual const AgentPath *UsablePath() const;
243 : //Syncs path parameters. Parent route is also used to pick params.
244 : virtual bool Sync(AgentRoute *sync_route);
245 : void ImportPrevActiveNH(Agent *agent, NextHop *nh);
246 : virtual bool PostChangeNH(Agent *agent, NextHop *nh);
247 :
248 2602 : const SecurityGroupList &sg_list() const {return sg_list_;}
249 2482 : const TagList &tag_list() const {return tag_list_;}
250 917 : const CommunityList &communities() const {return communities_;}
251 189 : const std::string &dest_vn_name() const {
252 189 : assert(dest_vn_list_.size() <= 1);
253 189 : if (dest_vn_list_.size())
254 189 : return *dest_vn_list_.begin();
255 : else
256 0 : return Agent::NullString();
257 : }
258 5761 : const VnListType &dest_vn_list() const {return dest_vn_list_;}
259 360 : const std::string &origin_vn() const {return origin_vn_;}
260 : void GetDestinationVnList(std::vector<std::string> *vn_list) const;
261 : uint32_t GetActiveLabel() const;
262 : NextHop *nexthop() const;
263 26910 : const Peer *peer() const {return peer_.get();}
264 939 : uint32_t label() const {return label_;}
265 644 : uint32_t vxlan_id() const {return vxlan_id_;}
266 823 : TunnelType::Type tunnel_type() const {return tunnel_type_;}
267 2312 : uint32_t tunnel_bmap() const {return tunnel_bmap_;}
268 77 : const IpAddress& gw_ip() const {return gw_ip_;}
269 0 : const std::string &vrf_name() const {return vrf_name_;}
270 0 : bool force_policy() const {return force_policy_;}
271 2103 : const bool unresolved() const {return unresolved_;}
272 118 : const Ip4Address& tunnel_dest() const {return tunnel_dest_;}
273 459 : bool is_subnet_discard() const {return is_subnet_discard_;}
274 358 : const IpAddress subnet_service_ip() const { return subnet_service_ip_;}
275 :
276 3454 : TunnelType::Type GetTunnelType() const {
277 3454 : return TunnelType::ComputeType(tunnel_bmap_);
278 : }
279 :
280 : void set_nexthop(NextHop *nh);
281 198 : void set_vxlan_id(uint32_t vxlan_id) {vxlan_id_ = vxlan_id;}
282 350 : void set_label(uint32_t label) {label_ = label;}
283 503 : void set_dest_vn_list(const VnListType &dest_vn_list) {dest_vn_list_ = dest_vn_list;}
284 0 : void set_origin_vn(const std::string &origin_vn) {origin_vn_ = origin_vn;}
285 701 : void set_unresolved(bool unresolved) {unresolved_ = unresolved;};
286 33 : void set_gw_ip(const IpAddress &addr) {gw_ip_ = addr;}
287 171 : void set_force_policy(bool force_policy) {force_policy_ = force_policy;}
288 5 : void set_vrf_name(const std::string &vrf_name) {vrf_name_ = vrf_name;}
289 304 : void set_tunnel_bmap(TunnelType::TypeBmap bmap) {tunnel_bmap_ = bmap;}
290 28 : void set_tunnel_type(TunnelType::Type type) {tunnel_type_ = type;}
291 41 : void set_sg_list(const SecurityGroupList &sg) {sg_list_ = sg;}
292 0 : void set_tag_list(const TagList &tag) {tag_list_ = tag;}
293 0 : void set_communities(const CommunityList &communities) {communities_ = communities;}
294 495 : void clear_sg_list() { sg_list_.clear(); }
295 : void clear_tag_list() { tag_list_.clear(); }
296 : void clear_communities() { communities_.clear(); }
297 127 : void set_tunnel_dest(const Ip4Address &tunnel_dest) {
298 127 : tunnel_dest_ = tunnel_dest;
299 127 : }
300 17 : void set_is_subnet_discard(bool discard) {
301 17 : is_subnet_discard_= discard;
302 17 : }
303 50 : void set_subnet_service_ip(const IpAddress &ip) {
304 50 : subnet_service_ip_ = ip;
305 50 : }
306 :
307 1 : void set_copy_local_path(bool copy_local_path) {
308 1 : copy_local_path_ = copy_local_path;
309 1 : }
310 :
311 : void set_local_ecmp_mpls_label(MplsLabel *mpls);
312 : bool dest_vn_match(const std::string &vn) const;
313 : const MplsLabel* local_ecmp_mpls_label() const;
314 6 : void ClearDependantRoute() {dependant_rt_.clear();}
315 27 : void ResetDependantRoute(AgentRoute *rt) {dependant_rt_.reset(rt);}
316 352 : const AgentRoute *dependant_rt() const {return dependant_rt_.get();}
317 : bool ChangeNH(Agent *agent, NextHop *nh);
318 171 : void SyncRoute(bool sync) {sync_ = sync;}
319 749 : bool RouteNeedsSync() {return sync_;}
320 : uint32_t GetTunnelBmap() const;
321 : bool UpdateNHPolicy(Agent *agent);
322 : bool UpdateTunnelType(Agent *agent, const AgentRoute *sync_route);
323 : bool ResolveGwNextHops(Agent *agent, const AgentRoute *sync_route);
324 : bool RebakeAllTunnelNHinCompositeNH(const AgentRoute *sync_route);
325 0 : virtual std::string ToString() const { return "AgentPath"; }
326 : void SetSandeshData(PathSandeshData &data) const;
327 : uint32_t preference() const { return path_preference_.preference();}
328 129 : uint32_t sequence() const { return path_preference_.sequence();}
329 6170 : const PathPreference& path_preference() const { return path_preference_;}
330 0 : PathPreference& path_preference_non_const() { return path_preference_;}
331 27 : void set_path_preference(const PathPreference &rp) { path_preference_ = rp;}
332 1 : void set_composite_nh_key(CompositeNHKey *key) {
333 1 : composite_nh_key_.reset(key);
334 1 : }
335 9 : CompositeNHKey* composite_nh_key() {
336 9 : return composite_nh_key_.get();
337 : }
338 : bool ReorderCompositeNH(Agent *agent, CompositeNHKey *nh,
339 : bool &comp_nh_policy,
340 : const AgentPath *local_path);
341 : bool ChangeCompositeNH(Agent *agent, CompositeNHKey *nh);
342 : // Get nexthop-ip address to be used for path
343 : const Ip4Address *NexthopIp(Agent *agent) const;
344 :
345 31 : MacAddress arp_mac() const {return arp_mac_;}
346 0 : void set_arp_mac(const MacAddress &mac) {
347 0 : arp_mac_ = mac;
348 0 : }
349 31 : const Interface* arp_interface() const {return arp_interface_.get();}
350 4 : void set_arp_interface(const Interface *intf) {
351 4 : arp_interface_ = intf;
352 4 : }
353 :
354 31 : bool arp_valid() const { return arp_valid_;}
355 0 : void set_arp_valid(bool valid) { arp_valid_ = valid;}
356 :
357 127 : bool ecmp_suppressed() const { return ecmp_suppressed_;}
358 0 : void set_ecmp_suppressed(bool suppresed) { ecmp_suppressed_ = suppresed;}
359 :
360 : bool CopyArpData();
361 : bool CopyNdpData();
362 119 : const IpAddress& GetFixedIp() const {
363 119 : return path_preference_.dependent_ip();
364 : }
365 1793 : const EcmpLoadBalance &ecmp_load_balance() const {
366 1793 : return ecmp_load_balance_;
367 : }
368 0 : void set_ecmp_load_balance(const EcmpLoadBalance &ecmp_load_balance) {
369 0 : ecmp_load_balance_ = ecmp_load_balance;
370 0 : }
371 :
372 283 : bool is_local() const {
373 283 : return is_local_;
374 : }
375 :
376 0 : void set_is_local(bool is_local) {
377 0 : is_local_ = is_local;
378 0 : }
379 :
380 440 : bool is_health_check_service() const {
381 440 : return is_health_check_service_;
382 : }
383 :
384 0 : void set_is_health_check_service(bool val) {
385 0 : is_health_check_service_ = val;
386 0 : }
387 :
388 570 : bool etree_leaf() const {
389 570 : return etree_leaf_;
390 : }
391 :
392 0 : void set_etree_leaf(bool leaf) {
393 0 : etree_leaf_ = leaf;
394 0 : }
395 :
396 1310 : bool layer2_control_word() const {
397 1310 : return layer2_control_word_;
398 : }
399 :
400 0 : void set_layer2_control_word(bool layer2_control_word) {
401 0 : layer2_control_word_ = layer2_control_word;
402 0 : }
403 :
404 87 : void set_native_vrf_id(uint32_t vrf_id) {
405 87 : native_vrf_id_ = vrf_id;
406 87 : }
407 :
408 236 : uint32_t native_vrf_id() const {
409 236 : return native_vrf_id_;
410 : }
411 :
412 : void UpdateEcmpHashFields(const Agent *agent,
413 : const EcmpLoadBalance &ecmp_load_balance,
414 : DBRequest &nh_req);
415 0 : uint64_t peer_sequence_number() const {return peer_sequence_number_;}
416 772 : void set_peer_sequence_number(uint64_t sequence_number) {
417 772 : peer_sequence_number_ = sequence_number;
418 772 : }
419 : bool ResyncControlWord(const AgentRoute *rt);
420 1561 : bool inactive() const {return inactive_;}
421 0 : void set_inactive(bool inactive) {
422 0 : inactive_ = inactive;
423 0 : }
424 :
425 : void ResetEcmpHashFields();
426 : void CopyLocalPath(CompositeNHKey *composite_nh_key,
427 : const AgentPath *local_path);
428 0 : AgentRoute *GetParentRoute() {return parent_rt_;}
429 0 : void ResetEcmpMemberList(AgentPathEcmpComponentPtrList list) {
430 0 : ecmp_member_list_ = list;
431 0 : }
432 58 : AgentRouteTable *GetDependentTable() const {return dependent_table_;}
433 0 : void SetDependentTable(AgentRouteTable *table) {
434 0 : dependent_table_ = table;
435 0 : }
436 171 : void SetDynamicLearntRouteFlag(bool is_learnt_route) {
437 171 : is_learnt_route_ = is_learnt_route;
438 171 : }
439 32 : bool IsDynamicLearntRoute() {
440 32 : return is_learnt_route_;
441 : }
442 :
443 : private:
444 : PeerConstPtr peer_;
445 : // Nexthop for route. Not used for gateway routes
446 : NextHopRef nh_;
447 : // MPLS Label sent by control-node
448 : uint32_t label_;
449 : // VXLAN-ID sent by control-node
450 : uint32_t vxlan_id_;
451 : // destination vn-name used in policy lookups
452 : VnListType dest_vn_list_;
453 : // Origin VN name to be populated in flows
454 : std::string origin_vn_;
455 :
456 : // sync_ flag says that any change in this path sholud result in re-sync
457 : // of all paths in the route. This can be used in cases where some
458 : // properties are inherited from one path to other
459 : bool sync_;
460 :
461 : // When force_policy_ is not set,
462 : // Use nexthop with policy if policy enabled on interface
463 : // Use nexthop without policy if policy is disabled on interface
464 : // When force_policy_ is set
465 : // Use nexthop with policy irrespective of interface configuration
466 : bool force_policy_;
467 : SecurityGroupList sg_list_;
468 : TagList tag_list_;
469 : CommunityList communities_;
470 :
471 : // tunnel destination address
472 : Ip4Address tunnel_dest_;
473 : // tunnel_bmap_ sent by control-node
474 : TunnelType::TypeBmap tunnel_bmap_;
475 : // tunnel-type computed for the path
476 : TunnelType::Type tunnel_type_;
477 :
478 : // VRF for gw_ip_ in gateway route
479 : std::string vrf_name_;
480 : // gateway for the route
481 : IpAddress gw_ip_;
482 : // gateway route is unresolved if,
483 : // - no route present for gw_ip_
484 : // - ARP not resolved for gw_ip_
485 : bool unresolved_;
486 : // subnet route with discard nexthop.
487 : bool is_subnet_discard_;
488 : // route for the gateway
489 : DependencyRef<AgentRoute, AgentRoute> dependant_rt_;
490 : PathPreference path_preference_;
491 : //Local MPLS label path is dependent on
492 : DependencyRef<AgentRoute, MplsLabel> local_ecmp_mpls_label_;
493 : //CompositeNH key for resync
494 : boost::scoped_ptr<CompositeNHKey> composite_nh_key_;
495 : //Gateway address of the subnet this route belong to.
496 : //This IP address gets used in sending arp query to the VM
497 : //helping in deciding the priority during live migration and
498 : //allowed address pair
499 : IpAddress subnet_service_ip_;
500 : //Mac address of ARP NH, used to notify change
501 : //to routes dependent on mac change, or ageout of ARP
502 : MacAddress arp_mac_;
503 : //Interface on which ARP would be resolved
504 : InterfaceConstRef arp_interface_;
505 : bool arp_valid_;
506 : // set true if path was supposed to be ecmp, however ecmp was suppressed
507 : // by taking only one of the nexthop from the path
508 : bool ecmp_suppressed_;
509 : EcmpLoadBalance ecmp_load_balance_;
510 : // if the path is marked local do no export it to BGP and do not
511 : // program it to vrouter
512 : bool is_local_;
513 : // if the path is marked service health check set vrouter to do proxy arp
514 : // TODO(prabhjot) need to find more genric solution for marking proxy arp
515 : // to move all the logic of identifing proxy arp in one place
516 : bool is_health_check_service_;
517 : // These Ecmp fields will hold the corresponding composite nh ecmp fields reference
518 : // if the path's ecmp load balance field is not set
519 : EcmpHashFields ecmp_hash_fields_;
520 : uint64_t peer_sequence_number_;
521 : //Is the path an etree leaf or root
522 : bool etree_leaf_;
523 : //Should control word of 4 bytes be inserted while egressing the
524 : //packet, which could be used by receiving router to determine
525 : //if its a l2 packet or l3 packet.
526 : bool layer2_control_word_;
527 : bool inactive_;
528 : bool copy_local_path_;
529 : //Valid for routes exported in ip-fabric:__default__ VRF
530 : //Indicates the VRF from which routes was originated
531 : uint32_t native_vrf_id_;
532 : AgentRoute *parent_rt_;
533 : AgentPathEcmpComponentPtrList ecmp_member_list_;
534 : AgentRouteTable *dependent_table_;
535 : bool is_learnt_route_;
536 : DISALLOW_COPY_AND_ASSIGN(AgentPath);
537 : };
538 :
539 : /*
540 : * EvpnDerivedPath
541 : *
542 : * Used by bridge routes. This path is derived from AgentPath as
543 : * common route code expects type AgentPath. Also EvpnDerivedPath
544 : * keeps reference path from Evpn route.
545 : * evpn_peer_ref is unique peer generated for each evpn route.
546 : * ip_addr is the IP taken from parent evpn route.
547 : * parent is for debugging to know which evpn route added the path.
548 : */
549 : class EvpnDerivedPath : public AgentPath {
550 : public:
551 : EvpnDerivedPath(const EvpnPeer *evpn_peer,
552 : const IpAddress &ip_addr,
553 : uint32_t ethernet_tag,
554 : const std::string &parent);
555 112 : virtual ~EvpnDerivedPath() { }
556 :
557 : virtual const NextHop *ComputeNextHop(Agent *agent) const;
558 : virtual bool IsLess(const AgentPath &right) const;
559 :
560 : //Data get/set
561 416 : const IpAddress &ip_addr() const {return ip_addr_;}
562 : void set_ip_addr(const IpAddress &ip_addr) {ip_addr_ = ip_addr;}
563 0 : const std::string &parent() const {return parent_;}
564 : void set_parent(const std::string &parent) {parent_ = parent;}
565 186 : uint32_t ethernet_tag() const {return ethernet_tag_;}
566 : void set_ethernet_tag(uint32_t ethernet_tag) {ethernet_tag_ = ethernet_tag;}
567 :
568 : private:
569 : //Key parameters for comparision
570 : IpAddress ip_addr_;
571 : uint32_t ethernet_tag_;
572 : //Data
573 : std::string parent_;
574 : DISALLOW_COPY_AND_ASSIGN(EvpnDerivedPath);
575 : };
576 :
577 : /*
578 : * EvpnDerivedPathData
579 : * Route data used to transfer information from Evpn route for bridge rute
580 : * creation.
581 : * path_parameters_changed - Telss if some parameters changed in reference path.
582 : * Currently its always true as any change in path attributes results in
583 : * notification of evpn route and thats when bridge route is also updated.
584 : */
585 : class EvpnDerivedPathData : public AgentRouteData {
586 : public:
587 : EvpnDerivedPathData(const EvpnRouteEntry *evpn_rt);
588 348 : virtual ~EvpnDerivedPathData() { }
589 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
590 : const AgentRoute *rt);
591 0 : virtual std::string ToString() const {return "EvpnDerivedPathData";}
592 : virtual AgentPath *CreateAgentPath(const Peer *peer, AgentRoute *rt) const;
593 :
594 : EvpnPeer *evpn_peer() const;
595 186 : const IpAddress &ip_addr() const {return ip_addr_;}
596 : const std::string &parent() const {return parent_;}
597 : void set_parent(const std::string &parent) {parent_ = parent;}
598 : void set_ethernet_tag(uint32_t ethernet_tag) {ethernet_tag_ = ethernet_tag;}
599 186 : uint32_t ethernet_tag() const {return ethernet_tag_;}
600 : const AgentPath *reference_path() const {return reference_path_;}
601 :
602 : virtual bool CanDeletePath(Agent *agent, AgentPath *path,
603 : const AgentRoute *rt) const;
604 : private:
605 : void CopyData(const AgentPath *path);
606 :
607 : uint32_t ethernet_tag_;
608 : IpAddress ip_addr_;
609 : std::string parent_;
610 : //reference_path holds good if route request is inline i.e. via Process
611 : //and not via Enqueue.
612 : const AgentPath *reference_path_;
613 : bool ecmp_suppressed_;
614 : DISALLOW_COPY_AND_ASSIGN(EvpnDerivedPathData);
615 : };
616 :
617 : class ResolveRoute : public AgentRouteData {
618 : public:
619 11 : ResolveRoute(const InterfaceKey *key, bool policy, const uint32_t label,
620 : const std::string &vn_name, const SecurityGroupList &sg_list,
621 11 : const TagList &tag_list) :
622 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
623 11 : intf_key_(key->Clone()), policy_(policy),
624 11 : label_(label), dest_vn_name_(vn_name), path_sg_list_(sg_list),
625 22 : path_tag_list_(tag_list) {}
626 22 : virtual ~ResolveRoute() { }
627 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
628 : const AgentRoute *rt);
629 0 : virtual std::string ToString() const {return "Resolve";}
630 : private:
631 : boost::scoped_ptr<const InterfaceKey> intf_key_;
632 : bool policy_;
633 : uint32_t label_;
634 : const std::string dest_vn_name_;
635 : const SecurityGroupList path_sg_list_;
636 : const TagList path_tag_list_;
637 : DISALLOW_COPY_AND_ASSIGN(ResolveRoute);
638 : };
639 :
640 : class LocalVmRoute : public AgentRouteData {
641 : public:
642 171 : LocalVmRoute(const VmInterfaceKey &intf, uint32_t mpls_label,
643 : uint32_t vxlan_id, bool force_policy, const VnListType &vn_list,
644 : uint8_t flags, const SecurityGroupList &sg_list,
645 : const TagList &tag_list,
646 : const CommunityList &communities,
647 : const PathPreference &path_preference,
648 : const IpAddress &subnet_service_ip,
649 : const EcmpLoadBalance &ecmp_load_balance, bool is_local,
650 : bool is_health_check_service, uint64_t sequence_number,
651 : bool etree_leaf, bool native_encap,
652 : const std::string &intf_route_type = "",
653 171 : bool is_learnt_route = false):
654 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, sequence_number),
655 342 : intf_(intf), mpls_label_(mpls_label),
656 171 : vxlan_id_(vxlan_id), force_policy_(force_policy),
657 171 : dest_vn_list_(vn_list), proxy_arp_(false), sync_route_(false),
658 171 : flags_(flags), sg_list_(sg_list), tag_list_(tag_list),
659 171 : communities_(communities),
660 171 : tunnel_bmap_(TunnelType::MplsType()),
661 171 : path_preference_(path_preference),
662 171 : subnet_service_ip_(subnet_service_ip),
663 171 : ecmp_load_balance_(ecmp_load_balance), is_local_(is_local),
664 171 : is_health_check_service_(is_health_check_service),
665 171 : etree_leaf_(etree_leaf), native_encap_(native_encap),
666 171 : intf_route_type_(intf_route_type),
667 171 : native_vrf_id_(VrfEntry::kInvalidIndex),
668 171 : is_learnt_route_(is_learnt_route) {
669 171 : }
670 342 : virtual ~LocalVmRoute() { }
671 : void DisableProxyArp() {proxy_arp_ = false;}
672 0 : virtual std::string ToString() const {return "local VM";}
673 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
674 : const AgentRoute *rt);
675 : virtual bool UpdateRoute(AgentRoute *rt);
676 : const CommunityList &communities() const {return communities_;}
677 : const SecurityGroupList &sg_list() const {return sg_list_;}
678 : const TagList &tag_list() const {return tag_list_;}
679 80 : void set_tunnel_bmap(TunnelType::TypeBmap bmap) {tunnel_bmap_ = bmap;}
680 : const PathPreference& path_preference() const { return path_preference_;}
681 : void set_path_preference(const PathPreference &path_preference) {
682 : path_preference_ = path_preference;
683 : }
684 : uint32_t vxlan_id() const {return vxlan_id_;}
685 : uint32_t tunnel_bmap() const {return tunnel_bmap_;}
686 : bool proxy_arp() const {return proxy_arp_;}
687 : bool etree_leaf() const { return etree_leaf_;}
688 132 : const std::string &intf_route_type() const { return intf_route_type_; }
689 0 : void set_native_vrf_id(uint32_t vrf_id) {
690 0 : native_vrf_id_ = vrf_id;
691 0 : }
692 : uint32_t native_vrf_id() const {
693 : return native_vrf_id_;
694 : }
695 : private:
696 : VmInterfaceKey intf_;
697 : uint32_t mpls_label_;
698 : uint32_t vxlan_id_;
699 : bool force_policy_;
700 : VnListType dest_vn_list_;
701 : bool proxy_arp_;
702 : bool sync_route_;
703 : uint8_t flags_;
704 : SecurityGroupList sg_list_;
705 : TagList tag_list_;
706 : CommunityList communities_;
707 : TunnelType::TypeBmap tunnel_bmap_;
708 : PathPreference path_preference_;
709 : IpAddress subnet_service_ip_;
710 : EcmpLoadBalance ecmp_load_balance_;
711 : bool is_local_;
712 : bool is_health_check_service_;
713 : bool etree_leaf_;
714 : bool native_encap_;
715 : std::string intf_route_type_;
716 : uint32_t native_vrf_id_;
717 : bool is_learnt_route_;
718 : DISALLOW_COPY_AND_ASSIGN(LocalVmRoute);
719 : };
720 :
721 : class PBBRoute : public AgentRouteData {
722 : public:
723 8 : PBBRoute(const VrfKey &vrf_key, const MacAddress &mac, uint32_t isid,
724 : const VnListType &vn_list, const SecurityGroupList &sg_list,
725 8 : const TagList &tag_list):
726 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
727 8 : vrf_key_(vrf_key), dmac_(mac), isid_(isid),
728 16 : dest_vn_list_(vn_list), sg_list_(sg_list), tag_list_(tag_list) {
729 8 : }
730 :
731 0 : virtual ~PBBRoute() { }
732 0 : virtual std::string ToString() const {return "PBB route";}
733 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
734 : const AgentRoute *rt);
735 : const SecurityGroupList &sg_list() const {return sg_list_;}
736 : const TagList &tag_list() const {return tag_list_;}
737 :
738 : private:
739 : VrfKey vrf_key_;
740 : MacAddress dmac_;
741 : uint32_t isid_;
742 : VnListType dest_vn_list_;
743 : SecurityGroupList sg_list_;
744 : TagList tag_list_;
745 : PathPreference path_preference_;
746 : DISALLOW_COPY_AND_ASSIGN(PBBRoute);
747 : };
748 :
749 : class InetInterfaceRoute : public AgentRouteData {
750 : public:
751 0 : InetInterfaceRoute(const InetInterfaceKey &intf, uint32_t label,
752 : int tunnel_bmap, const VnListType &dest_vn_list,
753 0 : uint64_t sequence_number):
754 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, sequence_number),
755 0 : intf_(intf), label_(label), tunnel_bmap_(tunnel_bmap),
756 0 : dest_vn_list_(dest_vn_list) {
757 0 : }
758 0 : virtual ~InetInterfaceRoute() { }
759 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
760 : const AgentRoute *rt);
761 0 : virtual std::string ToString() const {return "host";}
762 : virtual bool UpdateRoute(AgentRoute *rt);
763 :
764 : private:
765 : InetInterfaceKey intf_;
766 : uint32_t label_;
767 : int tunnel_bmap_;
768 : VnListType dest_vn_list_;
769 : DISALLOW_COPY_AND_ASSIGN(InetInterfaceRoute);
770 : };
771 :
772 : class HostRoute : public AgentRouteData {
773 : public:
774 133 : HostRoute(const PacketInterfaceKey &intf, const std::string &dest_vn_name):
775 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
776 133 : intf_(intf), dest_vn_name_(dest_vn_name),
777 133 : proxy_arp_(false), policy_(false) {
778 133 : }
779 266 : virtual ~HostRoute() { }
780 : void set_proxy_arp() {proxy_arp_ = true;}
781 85 : void set_policy(bool policy) {
782 85 : policy_ = policy;
783 85 : }
784 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
785 : const AgentRoute *rt);
786 0 : virtual std::string ToString() const {return "host";}
787 : virtual bool UpdateRoute(AgentRoute *rt);
788 :
789 : private:
790 : PacketInterfaceKey intf_;
791 : std::string dest_vn_name_;
792 : bool proxy_arp_;
793 : bool policy_;
794 : DISALLOW_COPY_AND_ASSIGN(HostRoute);
795 : };
796 :
797 : class L2ReceiveRoute : public AgentRouteData {
798 : public:
799 48 : L2ReceiveRoute(const std::string &dest_vn_name, uint32_t vxlan_id,
800 : uint32_t mpls_label, const PathPreference &pref,
801 48 : uint64_t sequence_number) :
802 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, sequence_number),
803 96 : dest_vn_name_(dest_vn_name), vxlan_id_(vxlan_id),
804 48 : mpls_label_(mpls_label), path_preference_(pref) {
805 48 : }
806 96 : virtual ~L2ReceiveRoute() { }
807 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
808 : const AgentRoute *rt);
809 0 : virtual std::string ToString() const {return "l2-receive";}
810 48 : virtual bool UpdateRoute(AgentRoute *rt) {return false;}
811 :
812 : private:
813 : std::string dest_vn_name_;
814 : uint32_t vxlan_id_;
815 : uint32_t mpls_label_;
816 : const PathPreference path_preference_;
817 : DISALLOW_COPY_AND_ASSIGN(L2ReceiveRoute);
818 : };
819 :
820 : class VlanNhRoute : public AgentRouteData {
821 : public:
822 0 : VlanNhRoute(const VmInterfaceKey &intf, uint16_t tag, uint32_t label,
823 : const VnListType &dest_vn_list, const SecurityGroupList &sg_list,
824 : const TagList &tag_list,
825 0 : const PathPreference &path_preference, uint64_t sequence_number) :
826 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, sequence_number),
827 0 : intf_(intf), tag_(tag), label_(label),
828 0 : dest_vn_list_(dest_vn_list), sg_list_(sg_list), tag_list_(tag_list),
829 0 : path_preference_(path_preference), tunnel_bmap_(TunnelType::MplsType()) {
830 0 : }
831 0 : virtual ~VlanNhRoute() { }
832 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
833 : const AgentRoute *rt);
834 0 : virtual std::string ToString() const {return "vlannh";}
835 :
836 : private:
837 : VmInterfaceKey intf_;
838 : uint16_t tag_;
839 : uint32_t label_;
840 : VnListType dest_vn_list_;
841 : SecurityGroupList sg_list_;
842 : TagList tag_list_;
843 : PathPreference path_preference_;
844 : TunnelType::TypeBmap tunnel_bmap_;
845 : DISALLOW_COPY_AND_ASSIGN(VlanNhRoute);
846 : };
847 :
848 : class MulticastRoutePath : public AgentPath {
849 : public:
850 : MulticastRoutePath(const Peer *peer);
851 106 : virtual ~MulticastRoutePath() { }
852 :
853 : virtual bool PostChangeNH(Agent *agent, NextHop *nh);
854 0 : void set_original_nh(NextHopRef nh) {
855 0 : original_nh_ = nh;
856 0 : }
857 0 : NextHopRef original_nh() const {
858 0 : return original_nh_;
859 : }
860 : NextHop *UpdateNH(Agent *agent, CompositeNH *cnh,
861 : const TsnElector *te);
862 49 : void UpdateLabels(uint32_t evpn_label, uint32_t fabric_label) {
863 49 : evpn_label_ = evpn_label;
864 49 : fabric_label_ = fabric_label;
865 49 : }
866 :
867 : private:
868 : NextHopRef original_nh_;
869 : uint32_t evpn_label_;
870 : uint32_t fabric_label_;
871 : DISALLOW_COPY_AND_ASSIGN(MulticastRoutePath);
872 : };
873 :
874 : class MulticastRoute : public AgentRouteData {
875 : public:
876 101 : MulticastRoute(const string &vn_name, uint32_t label, int vxlan_id,
877 : uint32_t tunnel_type, DBRequest &nh_req,
878 : COMPOSITETYPE comp_nh_type, uint64_t sequence_number,
879 101 : bool ha_stale = false):
880 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, true, sequence_number),
881 202 : vn_name_(vn_name), label_(label), vxlan_id_(vxlan_id),
882 202 : tunnel_type_(tunnel_type), comp_nh_type_(comp_nh_type),
883 101 : ha_stale_(ha_stale) {
884 101 : composite_nh_req_.Swap(&nh_req);
885 101 : }
886 202 : virtual ~MulticastRoute() { }
887 : virtual AgentPath *CreateAgentPath(const Peer *peer, AgentRoute *rt) const;
888 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
889 : const AgentRoute *rt);
890 0 : virtual std::string ToString() const {return "multicast";}
891 0 : uint32_t vxlan_id() const {return vxlan_id_;}
892 0 : COMPOSITETYPE comp_nh_type() const {return comp_nh_type_;}
893 : static bool CopyPathParameters(Agent *agent,
894 : AgentPath *path,
895 : const std::string &dest_vn_name,
896 : bool unresolved,
897 : uint32_t vxlan_id,
898 : uint32_t label,
899 : uint32_t tunnel_type,
900 : NextHop *nh,
901 : const AgentRoute *rt,
902 : bool ha_stale = false);
903 : virtual bool CanDeletePath(Agent *agent, AgentPath *path,
904 : const AgentRoute *rt) const;
905 : private:
906 : string vn_name_;
907 : uint32_t label_;
908 : uint32_t vxlan_id_;
909 : uint32_t tunnel_type_;
910 : DBRequest composite_nh_req_;
911 : COMPOSITETYPE comp_nh_type_;
912 : bool ha_stale_;
913 : DISALLOW_COPY_AND_ASSIGN(MulticastRoute);
914 : };
915 :
916 : class IpamSubnetRoute : public AgentRouteData {
917 : public:
918 : IpamSubnetRoute(DBRequest &nh_req, const std::string &dest_vn_name);
919 34 : virtual ~IpamSubnetRoute() {}
920 0 : virtual string ToString() const {return "subnet route";}
921 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
922 : const AgentRoute *rt);
923 : virtual bool UpdateRoute(AgentRoute *rt);
924 :
925 : private:
926 : DBRequest nh_req_;
927 : std::string dest_vn_name_;
928 : DISALLOW_COPY_AND_ASSIGN(IpamSubnetRoute);
929 : };
930 :
931 : class ReceiveRoute : public AgentRouteData {
932 : public:
933 60 : ReceiveRoute(const InterfaceKey &intf_key, uint32_t label,
934 60 : uint32_t tunnel_bmap, bool policy, const std::string &vn) :
935 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
936 60 : label_(label), tunnel_bmap_(tunnel_bmap),
937 60 : policy_(policy), proxy_arp_(false), ipam_host_route_(false), vn_(vn), sg_list_(), tag_list_() {
938 60 : intf_.reset(intf_key.Clone());
939 60 : }
940 120 : virtual ~ReceiveRoute() { }
941 :
942 58 : void SetProxyArp(bool proxy_arp) { proxy_arp_ = proxy_arp; }
943 58 : void SetIpamHostRoute(bool ipam_host_route) { ipam_host_route_ = ipam_host_route; }
944 :
945 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
946 : const AgentRoute *rt);
947 0 : virtual std::string ToString() const {return "receive";}
948 : virtual bool UpdateRoute(AgentRoute *rt);
949 :
950 : private:
951 : boost::scoped_ptr<InterfaceKey> intf_;
952 : uint32_t label_;
953 : int tunnel_bmap_;
954 : bool policy_;
955 : bool proxy_arp_;
956 : bool ipam_host_route_;
957 : std::string vn_;
958 : SecurityGroupList sg_list_;
959 : TagList tag_list_;
960 : DISALLOW_COPY_AND_ASSIGN(ReceiveRoute);
961 : };
962 :
963 : class Inet4UnicastArpRoute : public AgentRouteData {
964 : public:
965 10 : Inet4UnicastArpRoute(const std::string &vrf_name,
966 : const Ip4Address &addr, bool policy,
967 : const VnListType &vn_list, const SecurityGroupList &sg,
968 10 : const TagList &tag) :
969 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
970 10 : vrf_name_(vrf_name), addr_(addr), policy_(policy),
971 20 : vn_list_(vn_list), sg_list_(sg), tag_list_(tag) {
972 10 : }
973 20 : virtual ~Inet4UnicastArpRoute() { }
974 :
975 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
976 : const AgentRoute *rt);
977 0 : virtual std::string ToString() const {return "arp";}
978 : private:
979 : std::string vrf_name_;
980 : Ip4Address addr_;
981 : bool policy_;
982 : VnListType vn_list_;
983 : SecurityGroupList sg_list_;
984 : TagList tag_list_;
985 : DISALLOW_COPY_AND_ASSIGN(Inet4UnicastArpRoute);
986 : };
987 :
988 : class InetUnicastNdpRoute : public AgentRouteData {
989 : public:
990 0 : InetUnicastNdpRoute(const std::string &vrf_name,
991 : const IpAddress &addr, bool policy,
992 : const VnListType &vn_list, const SecurityGroupList &sg,
993 0 : const TagList &tag) :
994 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
995 0 : vrf_name_(vrf_name), addr_(addr), policy_(policy),
996 0 : vn_list_(vn_list), sg_list_(sg), tag_list_(tag) {
997 0 : }
998 0 : virtual ~InetUnicastNdpRoute() { }
999 :
1000 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1001 : const AgentRoute *rt);
1002 0 : virtual std::string ToString() const {return "ndp";}
1003 : private:
1004 : std::string vrf_name_;
1005 : IpAddress addr_;
1006 : bool policy_;
1007 : VnListType vn_list_;
1008 : SecurityGroupList sg_list_;
1009 : TagList tag_list_;
1010 : DISALLOW_COPY_AND_ASSIGN(InetUnicastNdpRoute);
1011 : };
1012 :
1013 : class Inet4UnicastGatewayRoute : public AgentRouteData {
1014 : public:
1015 4 : Inet4UnicastGatewayRoute(const AddressList &gw_list,
1016 : const std::string &vrf_name,
1017 : const VnListType &vn_list,
1018 : uint32_t label, const SecurityGroupList &sg,
1019 : const TagList &tag,
1020 : const CommunityList &communities,
1021 4 : bool native_encap):
1022 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
1023 4 : gw_list_(gw_list), vrf_name_(vrf_name), vn_list_(vn_list),
1024 4 : mpls_label_(label), sg_list_(sg), tag_list_(tag), communities_(communities),
1025 4 : native_encap_(native_encap) {
1026 4 : }
1027 8 : virtual ~Inet4UnicastGatewayRoute() { }
1028 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1029 : const AgentRoute *rt);
1030 0 : virtual std::string ToString() const {return "gateway";}
1031 :
1032 : private:
1033 : AddressList gw_list_;
1034 : std::string vrf_name_;
1035 : VnListType vn_list_;
1036 : uint32_t mpls_label_;
1037 : const SecurityGroupList sg_list_;
1038 : const TagList tag_list_;
1039 : const CommunityList communities_;
1040 : bool native_encap_;
1041 : DISALLOW_COPY_AND_ASSIGN(Inet4UnicastGatewayRoute);
1042 : };
1043 :
1044 : class DropRoute : public AgentRouteData {
1045 : public:
1046 0 : DropRoute(const string &vn_name) :
1047 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
1048 0 : vn_(vn_name) { }
1049 0 : virtual ~DropRoute() { }
1050 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1051 : const AgentRoute *rt);
1052 0 : virtual std::string ToString() const {return "drop";}
1053 : private:
1054 : std::string vn_;
1055 : DISALLOW_COPY_AND_ASSIGN(DropRoute);
1056 : };
1057 :
1058 : class Inet4UnicastInterfaceRoute : public AgentRouteData {
1059 : public:
1060 : Inet4UnicastInterfaceRoute(const PhysicalInterface *intrface,
1061 : const std::string &vn_name);
1062 0 : virtual ~Inet4UnicastInterfaceRoute() { }
1063 :
1064 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1065 : const AgentRoute *rt);
1066 0 : virtual std::string ToString() const {return "Interface";}
1067 :
1068 : private:
1069 : std::unique_ptr<InterfaceKey> interface_key_;
1070 : std::string vn_name_;
1071 : DISALLOW_COPY_AND_ASSIGN(Inet4UnicastInterfaceRoute);
1072 : };
1073 :
1074 : //MacVmBindingPath is used to store VM interface from which
1075 : //this route was added. This helps in retrieving the
1076 : //VM using MAC in a VRF. Also it stores the flood dhcp
1077 : //flag which is used to decide if DHCP request are to
1078 : //be answered by agent or external DHCP server.
1079 : class MacVmBindingPath : public AgentPath {
1080 : public:
1081 : MacVmBindingPath(const Peer *peer);
1082 56 : virtual ~MacVmBindingPath() { }
1083 :
1084 : virtual const NextHop *ComputeNextHop(Agent *agent) const;
1085 : virtual bool IsLess(const AgentPath &right) const;
1086 :
1087 : //Data get/set
1088 44 : const VmInterface *vm_interface() const {
1089 44 : return dynamic_cast<const VmInterface *>(vm_interface_.get());
1090 : }
1091 29 : void set_vm_interface(const VmInterface *vm_interface) {
1092 29 : vm_interface_ = vm_interface;
1093 29 : }
1094 128 : virtual bool flood_dhcp() const {return flood_dhcp_;}
1095 15 : void set_flood_dhcp(bool flood_dhcp) {flood_dhcp_ = flood_dhcp;}
1096 :
1097 : private:
1098 : //Key parameters for comparision
1099 : InterfaceConstRef vm_interface_;
1100 : // should vrouter flood the DHCP request coming from this source route
1101 : bool flood_dhcp_;
1102 : DISALLOW_COPY_AND_ASSIGN(MacVmBindingPath);
1103 : };
1104 :
1105 : //MacVmBindingPathData is expected to be used only in
1106 : //inline calls as it is carrying interface pointer.
1107 : //In case request is required key will have to be
1108 : //provided.
1109 : class MacVmBindingPathData : public AgentRouteData {
1110 : public:
1111 74 : MacVmBindingPathData(const VmInterface *vm_intf, bool flood_dhcp) :
1112 : AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
1113 74 : vm_intf_(vm_intf), flood_dhcp_(flood_dhcp) { }
1114 148 : virtual ~MacVmBindingPathData() { }
1115 : virtual AgentPath *CreateAgentPath(const Peer *peer, AgentRoute *rt) const;
1116 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1117 : const AgentRoute *rt);
1118 0 : virtual std::string ToString() const {return "MacVmBindingPathData";}
1119 :
1120 : private:
1121 : const VmInterface *vm_intf_;
1122 : bool flood_dhcp_;
1123 : DISALLOW_COPY_AND_ASSIGN(MacVmBindingPathData);
1124 : };
1125 :
1126 : /*
1127 : * InetEvpnRoutePath/InetEvpnRouteData
1128 : *
1129 : * InetEvpnRoute is derived from evpn route.
1130 : * Installation of evpn route initiates addition of inet route as well.
1131 : * This is done inline and request contains parent evpn route.
1132 : * Nexthop derivation: NH is not picked from EVPN route for this path.
1133 : * LPM search is done on the inet route prefix and whatever is the supernet
1134 : * route, NH is picked from there. In case host route is available the path from
1135 : * same takes higher precedence than InetEvpnRoute path.
1136 : */
1137 : class InetEvpnRoutePath : public AgentPath {
1138 : public:
1139 : InetEvpnRoutePath(const Peer *peer,
1140 : const MacAddress &mac,
1141 : const std::string &parent,
1142 : AgentRoute *rt);
1143 54 : virtual ~InetEvpnRoutePath() { }
1144 0 : virtual std::string ToString() const { return "InetEvpnRoutePath"; }
1145 : virtual const AgentPath *UsablePath() const;
1146 : virtual const NextHop *ComputeNextHop(Agent *agent) const;
1147 : //Syncs path parameters. Parent route is used for setting dependant rt.
1148 : virtual bool Sync(AgentRoute *sync_route);
1149 : bool SyncDependantRoute(const AgentRoute *sync_route);
1150 : virtual bool IsLess(const AgentPath &rhs) const;
1151 :
1152 84 : const MacAddress &MacAddr() const {return mac_;}
1153 : void SetMacAddr(const MacAddress &mac) {mac_ = mac;}
1154 : const std::string &Parent() const {return parent_;}
1155 : void SetParent(const std::string &parent) {parent_ = parent;}
1156 :
1157 :
1158 : private:
1159 : MacAddress mac_;
1160 : std::string parent_;
1161 : DISALLOW_COPY_AND_ASSIGN(InetEvpnRoutePath);
1162 : };
1163 :
1164 : class InetEvpnRouteData : public AgentRouteData {
1165 : public:
1166 : InetEvpnRouteData(const EvpnRouteEntry *evpn_rt);
1167 248 : virtual ~InetEvpnRouteData() { }
1168 : virtual AgentPath *CreateAgentPath(const Peer *peer, AgentRoute *rt) const;
1169 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1170 : const AgentRoute *rt);
1171 0 : virtual std::string ToString() const {return "Derived Inet route from Evpn";}
1172 68 : const MacAddress &MacAddr() const {return mac_;}
1173 : const std::string &parent() const {return parent_;}
1174 : virtual bool CanDeletePath(Agent *agent, AgentPath *path,
1175 : const AgentRoute *rt) const;
1176 :
1177 : private:
1178 : const MacAddress mac_;
1179 : std::string parent_;
1180 : DISALLOW_COPY_AND_ASSIGN(InetEvpnRouteData);
1181 : };
1182 :
1183 : // EvpnRoutingData
1184 : // Used to do vxlan routing, will be used for following-
1185 : // 1) Adding inet route to L2 VRF inet table.
1186 : // 2) Adding evpn route(type 5) in routing vrf
1187 : // 3) Adding inet route to routing vrf inet table.
1188 : class EvpnRoutingData : public AgentRouteData {
1189 : public:
1190 : EvpnRoutingData(DBRequest &nh_req,
1191 : const SecurityGroupList &sg_list,
1192 : const CommunityList &communities,
1193 : const PathPreference &path_preference,
1194 : const EcmpLoadBalance &ecmp_load_balance,
1195 : const TagList &tag_list,
1196 : VrfEntryConstRef vrf_entry,
1197 : uint32_t vxlan_id,
1198 : const VnListType& vn_list,
1199 : const std::string& origin_vn = "");
1200 0 : virtual ~EvpnRoutingData() { }
1201 : virtual AgentPath *CreateAgentPath(const Peer *peer, AgentRoute *rt) const;
1202 : virtual bool AddChangePathExtended(Agent *agent, AgentPath *path,
1203 : const AgentRoute *rt);
1204 0 : virtual std::string ToString() const {return "Evpn routing data";}
1205 : //Checks if path is evpnrouting path and deletes leak route before path gets
1206 : //destroyed.
1207 : virtual bool CanDeletePath(Agent *agent, AgentPath *path,
1208 : const AgentRoute *rt) const;
1209 : virtual bool UpdateRoute(AgentRoute *rt);
1210 :
1211 : private:
1212 : DBRequest nh_req_;
1213 : const SecurityGroupList sg_list_;
1214 : const CommunityList communities_;
1215 : const PathPreference path_preference_;
1216 : const EcmpLoadBalance ecmp_load_balance_;
1217 : const TagList tag_list_;
1218 : VrfEntryConstRef routing_vrf_;
1219 : uint32_t vxlan_id_;
1220 : const VnListType dest_vn_list_;
1221 : const std::string origin_vn_;
1222 : DISALLOW_COPY_AND_ASSIGN(EvpnRoutingData);
1223 : };
1224 :
1225 : class EvpnRoutingPath : public AgentPath {
1226 : public:
1227 : EvpnRoutingPath(const Peer *peer, AgentRoute *rt,
1228 : VrfEntryConstRef routing_vrf);
1229 : virtual ~EvpnRoutingPath();
1230 :
1231 : const VrfEntry *routing_vrf() const;
1232 : void set_routing_vrf(const VrfEntry *vrf);
1233 : void DeleteEvpnType5Route(Agent *agent, const AgentRoute *rt) const;
1234 :
1235 : private:
1236 : VrfEntryConstRef routing_vrf_;
1237 : uint32_t l3_vrf_vxlan_id_;
1238 : DISALLOW_COPY_AND_ASSIGN(EvpnRoutingPath);
1239 : };
1240 :
1241 : #endif // vnsw_agent_path_hpp
|