Line data Source code
1 : /*
2 : * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3 : * Copyright Contributors to the OpenSDN project
4 : */
5 :
6 : #include "bgp/routing-policy/routing_policy.h"
7 :
8 : #include <boost/assign/list_of.hpp>
9 : #include <boost/foreach.hpp>
10 :
11 : #include "base/task_annotations.h"
12 : #include "base/task_trigger.h"
13 : #include "bgp/bgp_config.h"
14 : #include "bgp/bgp_factory.h"
15 : #include "bgp/bgp_server.h"
16 : #include "bgp/bgp_table.h"
17 : #include "bgp/routing-instance/routing_instance.h"
18 : #include "bgp/routing-policy/routing_policy_action.h"
19 : #include "bgp/routing-policy/routing_policy_match.h"
20 :
21 :
22 : class RoutingPolicyMgr::DeleteActor : public LifetimeActor {
23 : public:
24 20 : explicit DeleteActor(RoutingPolicyMgr *manager)
25 20 : : LifetimeActor(manager->server_->lifetime_manager()),
26 20 : manager_(manager) {
27 20 : }
28 20 : virtual bool MayDelete() const {
29 20 : return true;
30 : }
31 20 : virtual void Shutdown() {
32 20 : }
33 20 : virtual void Destroy() {
34 : // memory is deallocated by BgpServer scoped_ptr.
35 20 : manager_->server_delete_ref_.Reset(NULL);
36 20 : }
37 :
38 : private:
39 : RoutingPolicyMgr *manager_;
40 : };
41 :
42 20 : RoutingPolicyMgr::RoutingPolicyMgr(BgpServer *server) :
43 20 : server_(server),
44 20 : deleter_(new DeleteActor(this)),
45 20 : server_delete_ref_(this, server->deleter()),
46 40 : trace_buf_(SandeshTraceBufferCreate("RoutingPolicyMgr", 500)) {
47 20 : }
48 :
49 40 : RoutingPolicyMgr::~RoutingPolicyMgr() {
50 40 : }
51 :
52 20 : void RoutingPolicyMgr::ManagedDelete() {
53 20 : deleter_->Delete();
54 20 : }
55 :
56 0 : LifetimeActor *RoutingPolicyMgr::deleter() {
57 0 : return deleter_.get();
58 : }
59 :
60 0 : bool RoutingPolicyMgr::deleted() {
61 0 : return deleter()->IsDeleted();
62 : }
63 :
64 0 : RoutingPolicy *RoutingPolicyMgr::CreateRoutingPolicy(
65 : const BgpRoutingPolicyConfig *config) {
66 0 : RoutingPolicy *policy = GetRoutingPolicy(config->name());
67 :
68 0 : if (policy) {
69 0 : if (policy->deleted()) {
70 0 : return NULL;
71 : }
72 0 : return policy;
73 : }
74 :
75 0 : policy = BgpStaticObjectFactory::Create<RoutingPolicy>(
76 0 : config->name(), server_, this, config);
77 0 : routing_policies_.insert(std::make_pair(config->name(), policy));
78 0 : policy->ProcessConfig();
79 :
80 0 : return policy;
81 : }
82 :
83 0 : void RoutingPolicyMgr::UpdateRoutingPolicy(
84 : const BgpRoutingPolicyConfig *config) {
85 0 : CHECK_CONCURRENCY("bgp::Config");
86 :
87 0 : RoutingPolicy *policy = GetRoutingPolicy(config->name());
88 0 : if (policy && policy->deleted()) {
89 0 : return;
90 0 : } else if (!policy) {
91 0 : return;
92 : }
93 :
94 0 : policy->UpdateConfig(config);
95 : }
96 :
97 : //
98 : // Concurrency: BGP Config task
99 : //
100 : // Trigger deletion of a particular routing-policy
101 : //
102 0 : void RoutingPolicyMgr::DeleteRoutingPolicy(const std::string &name) {
103 0 : CHECK_CONCURRENCY("bgp::Config");
104 :
105 0 : RoutingPolicy *policy = GetRoutingPolicy(name);
106 :
107 0 : if (policy && policy->deleted()) {
108 0 : return;
109 0 : } else if (!policy) {
110 0 : return;
111 : }
112 :
113 0 : policy->ClearConfig();
114 :
115 0 : policy->ManagedDelete();
116 : }
117 :
118 : //
119 : // Concurrency: Called from BGP config task manager
120 : //
121 0 : void RoutingPolicyMgr::DestroyRoutingPolicy(RoutingPolicy *policy) {
122 0 : CHECK_CONCURRENCY("bgp::Config");
123 :
124 0 : const std::string name = policy->name();
125 0 : routing_policies_.erase(name);
126 0 : delete policy;
127 :
128 0 : if (deleted()) return;
129 :
130 : const BgpRoutingPolicyConfig *config
131 0 : = server()->config_manager()->FindRoutingPolicy(name);
132 0 : if (config) {
133 0 : CreateRoutingPolicy(config);
134 0 : return;
135 : }
136 0 : }
137 :
138 : // Given a routing instance re-evaluate routes/paths by applying routing policy
139 : // Walks all the tables of the given routing instance and apply the policy
140 : // This function puts the table into the walk request queue and triggers the
141 : // task to start the actual walk
142 0 : void RoutingPolicyMgr::ApplyRoutingPolicy(RoutingInstance *instance) {
143 0 : CHECK_CONCURRENCY("bgp::Config", "bgp::ConfigHelper");
144 :
145 0 : std::scoped_lock lock(mutex_);
146 0 : BOOST_FOREACH(RoutingInstance::RouteTableList::value_type &entry,
147 : instance->GetTables()) {
148 0 : BgpTable *table = entry.second;
149 0 : if (table->IsRoutingPolicySupported())
150 0 : RequestWalk(table);
151 : }
152 0 : }
153 :
154 : // On a given path of the route, apply the policy
155 0 : RoutingPolicy::PolicyResult RoutingPolicyMgr::ExecuteRoutingPolicy(
156 : const RoutingPolicy *policy, const BgpRoute *route,
157 : const BgpPath *path, BgpAttr *attr) const {
158 0 : return (*policy)(route, path, attr);
159 : }
160 :
161 : //
162 : // Concurrency: Called in the context of the DB partition task.
163 : // On a given route, apply routing policy
164 : // Walk through all the paths of the given route, and evaluate the result of the
165 : // routing policy
166 : //
167 0 : bool RoutingPolicyMgr::EvaluateRoutingPolicy(DBTablePartBase *root,
168 : DBEntryBase *entry) {
169 0 : CHECK_CONCURRENCY("db::DBTable");
170 :
171 0 : BgpTable *table = static_cast<BgpTable *>(root->parent());
172 0 : BgpRoute *route = static_cast<BgpRoute *>(entry);
173 0 : const RoutingInstance *rtinstance = table->routing_instance();
174 0 : if (route->IsDeleted()) return true;
175 :
176 0 : bool sort_and_notify = false;
177 0 : const Path *prev_front = route->front();
178 0 : for (Route::PathList::iterator it = route->GetPathList().begin();
179 0 : it != route->GetPathList().end(); ++it) {
180 0 : BgpPath *path = static_cast<BgpPath *>(it.operator->());
181 0 : uint32_t old_flags = path->GetFlags();
182 0 : const BgpAttr *old_attr = path->GetAttr();
183 0 : rtinstance->ProcessRoutingPolicy(route, path);
184 0 : if ((sort_and_notify == false) &&
185 0 : (old_flags != path->GetFlags() || old_attr != path->GetAttr())) {
186 0 : sort_and_notify = true;
187 : }
188 : }
189 :
190 0 : if (sort_and_notify) {
191 0 : route->Sort(&BgpTable::PathSelection, prev_front);
192 0 : root->Notify(entry);
193 : }
194 0 : return true;
195 : }
196 :
197 : //
198 : //
199 1 : bool RoutingPolicyMgr::UpdateRoutingPolicyList(
200 : const RoutingPolicyConfigList &cfg_list,
201 : RoutingPolicyAttachList *oper_list) {
202 1 : CHECK_CONCURRENCY("bgp::Config", "bgp::ConfigHelper");
203 :
204 1 : std::scoped_lock lock(mutex_);
205 1 : bool update_policy = false;
206 : // Number of routing policies is different
207 1 : if (oper_list->size() != cfg_list.size())
208 0 : update_policy = true;
209 :
210 1 : RoutingPolicyAttachList::iterator oper_it = oper_list->begin(), oper_next;
211 1 : RoutingPolicyConfigList::const_iterator config_it = cfg_list.begin();
212 1 : while (oper_it != oper_list->end() &&
213 1 : config_it != cfg_list.end()) {
214 : // Compare the configured routing policies on the routing-instance
215 : // with operational data.
216 0 : if (oper_it->first->name() == config_it->routing_policy_) {
217 0 : if (oper_it->second != oper_it->first->generation()) {
218 : // Policy content is updated
219 0 : oper_it->second = oper_it->first->generation();
220 0 : update_policy = true;
221 : }
222 0 : ++oper_it;
223 0 : ++config_it;
224 : } else {
225 : // Policy Order is updated or new policy is added
226 : // or policy is deleted
227 : RoutingPolicy *policy =
228 0 : GetRoutingPolicy(config_it->routing_policy_);
229 0 : if (policy) {
230 0 : *oper_it = std::make_pair(policy, policy->generation());
231 0 : ++oper_it;
232 0 : ++config_it;
233 0 : update_policy = true;
234 : } else {
235 : // points to routing policy that doesn't exists
236 : // will revisit in next config notification
237 0 : ++config_it;
238 : }
239 : }
240 : }
241 1 : for (oper_next = oper_it; oper_it != oper_list->end();
242 0 : oper_it = oper_next) {
243 : // Existing policy(ies) are removed
244 0 : ++oper_next;
245 0 : oper_list->erase(oper_it);
246 0 : update_policy = true;
247 : }
248 1 : for (; config_it != cfg_list.end(); ++config_it) {
249 : // new policy(ies) are added
250 0 : RoutingPolicy *policy = GetRoutingPolicy(config_it->routing_policy_);
251 0 : if (policy) {
252 0 : oper_list->push_back(std::make_pair(policy, policy->generation()));
253 : }
254 0 : update_policy = true;
255 : }
256 :
257 1 : return update_policy;
258 1 : }
259 :
260 : void
261 0 : RoutingPolicyMgr::RequestWalk(BgpTable *table) {
262 0 : CHECK_CONCURRENCY("bgp::Config", "bgp::ConfigHelper");
263 0 : RoutingPolicyWalkRequests::iterator it = routing_policy_sync_.find(table);
264 0 : if (it == routing_policy_sync_.end()) {
265 : DBTable::DBTableWalkRef walk_ref = table->AllocWalker(
266 : boost::bind(&RoutingPolicyMgr::EvaluateRoutingPolicy, this, _1, _2),
267 0 : boost::bind(&RoutingPolicyMgr::WalkDone, this, _2));
268 0 : table->WalkTable(walk_ref);
269 0 : routing_policy_sync_.insert(std::make_pair(table, walk_ref));
270 0 : } else {
271 0 : table->WalkAgain(it->second);
272 : }
273 0 : }
274 :
275 : void
276 0 : RoutingPolicyMgr::WalkDone(DBTableBase *dbtable) {
277 0 : CHECK_CONCURRENCY("db::Walker");
278 0 : BgpTable *table = static_cast<BgpTable *>(dbtable);
279 0 : RoutingPolicyWalkRequests::iterator it = routing_policy_sync_.find(table);
280 0 : assert(it != routing_policy_sync_.end());
281 0 : DBTable::DBTableWalkRef walk_ref = it->second;
282 0 : routing_policy_sync_.erase(it);
283 0 : table->ReleaseWalker(walk_ref);
284 0 : }
285 :
286 : class RoutingPolicy::DeleteActor : public LifetimeActor {
287 : public:
288 0 : DeleteActor(BgpServer *server, RoutingPolicy *parent)
289 0 : : LifetimeActor(server->lifetime_manager()), parent_(parent) {
290 0 : }
291 0 : virtual bool MayDelete() const {
292 0 : return parent_->MayDelete();
293 : }
294 0 : virtual void Shutdown() {
295 0 : parent_->Shutdown();
296 0 : }
297 0 : virtual void Destroy() {
298 0 : parent_->mgr_->DestroyRoutingPolicy(parent_);
299 0 : }
300 :
301 : private:
302 : RoutingPolicy *parent_;
303 : };
304 :
305 0 : RoutingPolicy::RoutingPolicy(std::string name, BgpServer *server,
306 : RoutingPolicyMgr *mgr,
307 0 : const BgpRoutingPolicyConfig *config)
308 0 : : name_(name), server_(server), mgr_(mgr), config_(config),
309 0 : deleter_(new DeleteActor(server, this)),
310 0 : manager_delete_ref_(this, mgr->deleter()), generation_(0) {
311 0 : refcount_ = 0;
312 0 : }
313 :
314 0 : RoutingPolicy::~RoutingPolicy() {
315 0 : terms_.clear();
316 0 : }
317 :
318 0 : RoutingPolicy::PolicyTermPtr RoutingPolicy::BuildTerm(
319 : const RoutingPolicyTermConfig &cfg_term) {
320 0 : PolicyTerm::ActionList actions;
321 0 : PolicyTerm::MatchList matches;
322 :
323 0 : if (!cfg_term.match.community_match.empty()) {
324 : MatchCommunity *community = new MatchCommunity(
325 0 : cfg_term.match.community_match,
326 0 : cfg_term.match.community_match_all);
327 0 : matches.push_back(community);
328 : }
329 :
330 0 : if (!cfg_term.match.ext_community_match.empty()) {
331 : MatchExtCommunity *ext_community = new MatchExtCommunity(
332 0 : cfg_term.match.ext_community_match,
333 0 : cfg_term.match.ext_community_match_all);
334 0 : matches.push_back(ext_community);
335 : }
336 :
337 0 : if (!cfg_term.match.protocols_match.empty()) {
338 : MatchProtocol *protocol =
339 0 : new MatchProtocol(cfg_term.match.protocols_match);
340 0 : matches.push_back(protocol);
341 : }
342 :
343 0 : if (!cfg_term.match.prefixes_to_match.empty()) {
344 0 : PrefixMatchConfigList inet_prefix_list;
345 0 : PrefixMatchConfigList inet6_prefix_list;
346 0 : BOOST_FOREACH(PrefixMatchConfig match,
347 : cfg_term.match.prefixes_to_match) {
348 0 : boost::system::error_code ec;
349 0 : Ip4Address ip4;
350 : int plen;
351 0 : ec = Ip4PrefixParse(match.prefix_to_match, &ip4, &plen);
352 0 : if (ec.value() == 0) {
353 0 : inet_prefix_list.push_back(match);
354 : } else {
355 0 : Ip6Address ip6;
356 0 : ec = Inet6PrefixParse(match.prefix_to_match, &ip6, &plen);
357 0 : if (ec.value() == 0) {
358 0 : inet6_prefix_list.push_back(match);
359 : }
360 : }
361 0 : }
362 0 : if (!inet_prefix_list.empty()) {
363 0 : MatchPrefixInet *prefix = new MatchPrefixInet(inet_prefix_list);
364 0 : matches.push_back(prefix);
365 : }
366 0 : if (!inet6_prefix_list.empty()) {
367 0 : MatchPrefixInet6 *prefix = new MatchPrefixInet6(inet6_prefix_list);
368 0 : matches.push_back(prefix);
369 : }
370 0 : }
371 :
372 : // Build the Action object
373 0 : if (cfg_term.action.action == RoutingPolicyActionConfig::REJECT) {
374 0 : RoutingPolicyRejectAction *action = new RoutingPolicyRejectAction();
375 0 : actions.push_back(action);
376 0 : } else if (cfg_term.action.action == RoutingPolicyActionConfig::NEXT_TERM) {
377 0 : RoutingPolicyNexTermAction *action = new RoutingPolicyNexTermAction();
378 0 : actions.push_back(action);
379 0 : } else if (cfg_term.action.action == RoutingPolicyActionConfig::ACCEPT) {
380 0 : RoutingPolicyAcceptAction *action = new RoutingPolicyAcceptAction();
381 0 : actions.push_back(action);
382 : }
383 :
384 0 : if (!cfg_term.action.update.aspath_expand.empty()) {
385 : UpdateAsPath *expand_aspath =
386 0 : new UpdateAsPath(cfg_term.action.update.aspath_expand);
387 0 : actions.push_back(expand_aspath);
388 : }
389 :
390 0 : if (!cfg_term.action.update.community_set.empty()) {
391 : UpdateCommunity *set_comm =
392 0 : new UpdateCommunity(cfg_term.action.update.community_set, "set");
393 0 : actions.push_back(set_comm);
394 : }
395 :
396 0 : if (!cfg_term.action.update.community_remove.empty()) {
397 : UpdateCommunity *remove_comm =
398 0 : new UpdateCommunity(cfg_term.action.update.community_remove, "remove");
399 0 : actions.push_back(remove_comm);
400 : }
401 :
402 0 : if (!cfg_term.action.update.community_add.empty()) {
403 : UpdateCommunity *add_comm =
404 0 : new UpdateCommunity(cfg_term.action.update.community_add, "add");
405 0 : actions.push_back(add_comm);
406 : }
407 :
408 0 : if (!cfg_term.action.update.ext_community_set.empty()) {
409 : UpdateExtCommunity *set_comm = new UpdateExtCommunity(
410 0 : cfg_term.action.update.ext_community_set, "set");
411 0 : actions.push_back(set_comm);
412 : }
413 :
414 0 : if (!cfg_term.action.update.ext_community_remove.empty()) {
415 : UpdateExtCommunity *remove_comm = new UpdateExtCommunity(
416 0 : cfg_term.action.update.ext_community_remove, "remove");
417 0 : actions.push_back(remove_comm);
418 : }
419 :
420 0 : if (!cfg_term.action.update.ext_community_add.empty()) {
421 : UpdateExtCommunity *add_comm = new UpdateExtCommunity(
422 0 : cfg_term.action.update.ext_community_add, "add");
423 0 : actions.push_back(add_comm);
424 : }
425 :
426 0 : if (cfg_term.action.update.local_pref) {
427 : UpdateLocalPref *local_pref =
428 0 : new UpdateLocalPref(cfg_term.action.update.local_pref);
429 0 : actions.push_back(local_pref);
430 : }
431 :
432 0 : if (cfg_term.action.update.med) {
433 : UpdateMed *med =
434 0 : new UpdateMed(cfg_term.action.update.med);
435 0 : actions.push_back(med);
436 : }
437 :
438 0 : PolicyTermPtr ret_term;
439 0 : if (!actions.empty() || !matches.empty()) {
440 0 : ret_term = PolicyTermPtr(new PolicyTerm());
441 0 : ret_term->set_actions(actions);
442 0 : ret_term->set_matches(matches);
443 : }
444 :
445 0 : return ret_term;
446 0 : }
447 :
448 0 : void RoutingPolicy::ProcessConfig() {
449 0 : BOOST_FOREACH(const RoutingPolicyTermConfig cfg_term, config_->terms()) {
450 : // Build each terms and insert to operational data
451 0 : PolicyTermPtr term = BuildTerm(cfg_term);
452 0 : if (term)
453 0 : add_term(term);
454 0 : }
455 0 : }
456 :
457 : //
458 : // Reprogram policy terms based on new config.
459 : // If the policy term has changed (number of terms got updated, or new term is
460 : // added or earlier term is deleted or existing term is updated), increment the
461 : // generation number to indicate the update
462 : //
463 0 : void RoutingPolicy::UpdateConfig(const BgpRoutingPolicyConfig *cfg) {
464 0 : CHECK_CONCURRENCY("bgp::Config");
465 0 : config_ = cfg;
466 0 : bool update_policy = false;
467 0 : if (terms()->size() != config_->terms().size())
468 0 : update_policy = true;
469 :
470 0 : RoutingPolicyTermList::iterator oper_it = terms()->begin(), oper_next;
471 : BgpRoutingPolicyConfig::RoutingPolicyTermList::const_iterator
472 0 : config_it = config_->terms().begin();
473 0 : while (oper_it != terms()->end() && config_it != config_->terms().end()) {
474 0 : PolicyTermPtr term = BuildTerm(*config_it);
475 0 : if (**oper_it == *term) {
476 0 : ++oper_it;
477 0 : ++config_it;
478 : } else {
479 0 : if (term) {
480 0 : *oper_it = term;
481 0 : update_policy = true;
482 0 : ++oper_it;
483 0 : ++config_it;
484 : } else {
485 0 : ++config_it;
486 : }
487 : }
488 0 : }
489 0 : for (oper_next = oper_it; oper_it != terms()->end(); oper_it = oper_next) {
490 0 : ++oper_next;
491 0 : terms()->erase(oper_it);
492 0 : update_policy = true;
493 : }
494 0 : for (; config_it != config_->terms().end(); ++config_it) {
495 0 : PolicyTermPtr term = BuildTerm(*config_it);
496 0 : if (term)
497 0 : add_term(term);
498 0 : update_policy = true;
499 0 : }
500 :
501 0 : if (update_policy) generation_++;
502 0 : }
503 :
504 0 : void RoutingPolicy::ClearConfig() {
505 0 : CHECK_CONCURRENCY("bgp::Config");
506 0 : config_ = NULL;
507 0 : }
508 :
509 0 : void RoutingPolicy::ManagedDelete() {
510 0 : deleter_->Delete();
511 0 : }
512 :
513 0 : void RoutingPolicy::Shutdown() {
514 0 : CHECK_CONCURRENCY("bgp::Config");
515 0 : ClearConfig();
516 0 : }
517 :
518 0 : bool RoutingPolicy::MayDelete() const {
519 0 : return (refcount_ == 0);
520 : }
521 :
522 0 : LifetimeActor *RoutingPolicy::deleter() {
523 0 : return deleter_.get();
524 : }
525 :
526 0 : const LifetimeActor *RoutingPolicy::deleter() const {
527 0 : return deleter_.get();
528 : }
529 :
530 0 : bool RoutingPolicy::deleted() const {
531 0 : return deleter()->IsDeleted();
532 : }
533 :
534 : //
535 : // Attempt to enqueue a delete for the RoutingPolicy.
536 : //
537 0 : void RoutingPolicy::RetryDelete() {
538 0 : if (!deleter_->IsDeleted())
539 0 : return;
540 0 : deleter_->RetryDelete();
541 : }
542 :
543 0 : RoutingPolicy::PolicyResult RoutingPolicy::operator()(const BgpRoute *route,
544 : const BgpPath *path, BgpAttr *attr) const {
545 0 : BOOST_FOREACH(PolicyTermPtr term, terms()) {
546 0 : bool terminal = term->terminal();
547 0 : bool matched = term->ApplyTerm(route, path, attr);
548 0 : if (matched && terminal) {
549 0 : return std::make_pair(terminal,
550 0 : (*term->actions().begin())->accept());
551 : }
552 0 : }
553 0 : return std::make_pair(false, true);
554 : }
555 :
556 0 : PolicyTerm::PolicyTerm() {
557 0 : }
558 :
559 0 : PolicyTerm::~PolicyTerm() {
560 0 : STLDeleteValues(&actions_);
561 0 : STLDeleteValues(&matches_);
562 0 : }
563 :
564 0 : bool PolicyTerm::terminal() const {
565 0 : if (!actions().empty())
566 0 : return (*actions().begin())->terminal();
567 0 : return false;
568 : }
569 :
570 0 : bool PolicyTerm::ApplyTerm(const BgpRoute *route, const BgpPath *path,
571 : BgpAttr *attr) const {
572 0 : bool matched = true;
573 0 : BOOST_FOREACH(RoutingPolicyMatch *match, matches()) {
574 0 : if (!(*match)(route, path, attr)) {
575 0 : matched = false;
576 0 : break;
577 : }
578 : }
579 0 : if (matched) {
580 0 : bool first = true;
581 0 : BOOST_FOREACH(RoutingPolicyAction *action, actions()) {
582 : // First action defines what to do with the route
583 : // accept/reject/next-term
584 0 : if (first) {
585 0 : if (action->terminal()) {
586 0 : if (!action->accept()) {
587 : // out_attr is unaltered
588 0 : break;
589 : }
590 : }
591 0 : first = false;
592 : } else {
593 0 : RoutingPolicyUpdateAction *update =
594 : static_cast<RoutingPolicyUpdateAction *>(action);
595 0 : (*update)(attr);
596 : }
597 : }
598 : }
599 0 : return matched;
600 : }
601 :
602 : // Compare two terms
603 0 : bool PolicyTerm::operator==(const PolicyTerm &rhs) const {
604 : // Different number of match conditions
605 0 : if (matches().size() != rhs.matches().size()) return false;
606 : // Different number of actions conditions
607 0 : if (actions().size() != rhs.actions().size()) return false;
608 :
609 : // Walk the list of match conditions and compare each match
610 0 : for (MatchList::const_iterator rhs_matches_cit = rhs.matches().begin(),
611 0 : lhs_matches_cit = matches().begin();
612 0 : lhs_matches_cit != matches().end();
613 0 : lhs_matches_cit++, rhs_matches_cit++) {
614 0 : if (**rhs_matches_cit != **lhs_matches_cit)
615 0 : return false;
616 : }
617 :
618 : // Walk the list of actions and compare each action
619 0 : for (ActionList::const_iterator lhs_actions_cit = actions().begin(),
620 0 : rhs_actions_cit = rhs.actions().begin();
621 0 : lhs_actions_cit != actions().end();
622 0 : lhs_actions_cit++, rhs_actions_cit++) {
623 0 : if (**rhs_actions_cit != **lhs_actions_cit)
624 0 : return false;
625 : }
626 0 : return true;
627 : }
|