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