From e8c489d1586673922744dd261e8c629472588abe Mon Sep 17 00:00:00 2001 From: Prakash M Bailkeri Date: Fri, 29 Jan 2016 23:18:23 +0530 Subject: [PATCH] Add path source as match condition 1. control-node changes 2. Unit tests for matching protocols Change-Id: I406f20762498be79c43ec2c8d2dde46af1c55467 Related-bug: #1500698 --- src/bgp/bgp_config.cc | 8 + src/bgp/bgp_config.h | 2 + src/bgp/bgp_config_ifmap.cc | 1 + src/bgp/routing-instance/routing_instance.cc | 3 +- src/bgp/routing-policy/routing_policy.cc | 19 ++- src/bgp/routing-policy/routing_policy.h | 9 +- .../routing-policy/routing_policy_match.cc | 122 ++++++++++++- src/bgp/routing-policy/routing_policy_match.h | 39 ++++- src/bgp/test/routing_policy_test.cc | 160 ++++++++++++++++++ src/bgp/testdata/routing_policy_0e.xml | 23 +++ src/bgp/testdata/routing_policy_0f.xml | 43 +++++ src/bgp/testdata/routing_policy_0g.xml | 18 ++ src/bgp/testdata/routing_policy_0h.xml | 32 ++++ 13 files changed, 457 insertions(+), 22 deletions(-) create mode 100644 src/bgp/testdata/routing_policy_0e.xml create mode 100644 src/bgp/testdata/routing_policy_0f.xml create mode 100644 src/bgp/testdata/routing_policy_0g.xml create mode 100644 src/bgp/testdata/routing_policy_0h.xml diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index 08a844aa7d6..2f987efa178 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -330,6 +330,14 @@ void BgpRoutingPolicyConfig::Clear() { std::string RoutingPolicyMatchConfig::ToString() const { ostringstream oss; oss << "from {" << std::endl; + if (!protocols_match.empty()) { + oss << " protocol [ "; + BOOST_FOREACH(const string &protocol, protocols_match) { + oss << protocol << ","; + } + oss.seekp(-1, oss.cur); + oss << " ]"; + } if (!community_match.empty()) { oss << " community " << community_match << std::endl; } diff --git a/src/bgp/bgp_config.h b/src/bgp/bgp_config.h index 31f8285f8d6..5fd7edb1166 100644 --- a/src/bgp/bgp_config.h +++ b/src/bgp/bgp_config.h @@ -298,6 +298,7 @@ struct StaticRouteConfig { }; typedef std::vector CommunityList; +typedef std::vector ProtocolList; struct PrefixMatchConfig { std::string prefix_to_match; @@ -307,6 +308,7 @@ struct PrefixMatchConfig { typedef std::vector PrefixMatchConfigList; struct RoutingPolicyMatchConfig { + ProtocolList protocols_match; std::string community_match; PrefixMatchConfigList prefixes_to_match; std::string ToString() const; diff --git a/src/bgp/bgp_config_ifmap.cc b/src/bgp/bgp_config_ifmap.cc index c32f59c2319..b6717aa70b1 100644 --- a/src/bgp/bgp_config_ifmap.cc +++ b/src/bgp/bgp_config_ifmap.cc @@ -1569,6 +1569,7 @@ void BgpIfmapRoutingPolicyConfig::RemoveInstance(BgpIfmapInstanceConfig *rti) { static void BuildPolicyTerm(autogen::PolicyTerm cfg_term, RoutingPolicyTerm *term) { + term->match.protocols_match = cfg_term.fromxx.protocol; term->match.community_match = cfg_term.fromxx.community; BOOST_FOREACH(const autogen::PrefixMatch &prefix_match, cfg_term.fromxx.prefix) { diff --git a/src/bgp/routing-instance/routing_instance.cc b/src/bgp/routing-instance/routing_instance.cc index d1180ed8f2e..2452ae5d507 100644 --- a/src/bgp/routing-instance/routing_instance.cc +++ b/src/bgp/routing-instance/routing_instance.cc @@ -1175,7 +1175,8 @@ bool RoutingInstance::ProcessRoutingPolicy(const BgpRoute *route, // Update of the attribute based on routing policy action is done // on the snapshot of original attribute passed to this function RoutingPolicy::PolicyResult result = - policy_mgr->ExecuteRoutingPolicy(policy.get(), route, out_attr); + policy_mgr->ExecuteRoutingPolicy(policy.get(), route, + path, out_attr); if (result.first) { // Hit a terminal policy if (!result.second) { diff --git a/src/bgp/routing-policy/routing_policy.cc b/src/bgp/routing-policy/routing_policy.cc index 4b2d09c1e9f..57860e3788b 100644 --- a/src/bgp/routing-policy/routing_policy.cc +++ b/src/bgp/routing-policy/routing_policy.cc @@ -153,8 +153,8 @@ void RoutingPolicyMgr::ApplyRoutingPolicy(RoutingInstance *instance) { // On a given path of the route, apply the policy RoutingPolicy::PolicyResult RoutingPolicyMgr::ExecuteRoutingPolicy( const RoutingPolicy *policy, const BgpRoute *route, - BgpAttr *attr) const { - return (*policy)(route, attr); + const BgpPath *path, BgpAttr *attr) const { + return (*policy)(route, path, attr); } // @@ -359,6 +359,12 @@ RoutingPolicy::PolicyTermPtr RoutingPolicy::BuildTerm(const RoutingPolicyTerm &c matches.push_back(community); } + if (!cfg_term.match.protocols_match.empty()) { + MatchProtocol *protocol = + new MatchProtocol(cfg_term.match.protocols_match); + matches.push_back(protocol); + } + if (!cfg_term.match.prefixes_to_match.empty()) { PrefixMatchConfigList inet_prefix_list; PrefixMatchConfigList inet6_prefix_list; @@ -529,10 +535,10 @@ void RoutingPolicy::RetryDelete() { } RoutingPolicy::PolicyResult RoutingPolicy::operator()(const BgpRoute *route, - BgpAttr *attr) const { + const BgpPath *path, BgpAttr *attr) const { BOOST_FOREACH(PolicyTermPtr term, terms()) { bool terminal = term->terminal(); - bool matched = term->ApplyTerm(route, attr); + bool matched = term->ApplyTerm(route, path, attr); if (matched && terminal) { return std::make_pair(terminal, (*term->actions().begin())->accept()); @@ -555,10 +561,11 @@ bool PolicyTerm::terminal() const { return false; } -bool PolicyTerm::ApplyTerm(const BgpRoute *route, BgpAttr *attr) const { +bool PolicyTerm::ApplyTerm(const BgpRoute *route, const BgpPath *path, + BgpAttr *attr) const { bool matched = true; BOOST_FOREACH(RoutingPolicyMatch *match, matches()) { - if (!(*match)(route, attr)) { + if (!(*match)(route, path, attr)) { matched = false; break; } diff --git a/src/bgp/routing-policy/routing_policy.h b/src/bgp/routing-policy/routing_policy.h index c2afdf4bbad..2ff3671dd95 100644 --- a/src/bgp/routing-policy/routing_policy.h +++ b/src/bgp/routing-policy/routing_policy.h @@ -20,6 +20,7 @@ #include class BgpAttr; +class BgpPath; class BgpRoute; class BgpServer; class BgpTable; @@ -200,7 +201,8 @@ class PolicyTerm { PolicyTerm(); ~PolicyTerm(); bool terminal() const; - bool ApplyTerm(const BgpRoute *route, BgpAttr *attr) const; + bool ApplyTerm(const BgpRoute *route, + const BgpPath *path, BgpAttr *attr) const; void set_actions(const ActionList &actions) { actions_ = actions; } @@ -253,7 +255,8 @@ class RoutingPolicy { terms_.push_back(term); } - PolicyResult operator()(const BgpRoute *route, BgpAttr *attr) const; + PolicyResult operator()(const BgpRoute *route, + const BgpPath *path, BgpAttr *attr) const; uint32_t generation() const { return generation_; } uint32_t refcount() const { return refcount_; } @@ -373,7 +376,7 @@ class RoutingPolicyMgr { LifetimeActor *deleter(); RoutingPolicy::PolicyResult ExecuteRoutingPolicy(const RoutingPolicy *policy, - const BgpRoute *route, BgpAttr *attr) const; + const BgpRoute *route, const BgpPath *path, BgpAttr *attr) const; // Update the routing policy list on attach point diff --git a/src/bgp/routing-policy/routing_policy_match.cc b/src/bgp/routing-policy/routing_policy_match.cc index 4bab81f3dd8..2c5975376ce 100644 --- a/src/bgp/routing-policy/routing_policy_match.cc +++ b/src/bgp/routing-policy/routing_policy_match.cc @@ -5,18 +5,24 @@ #include "bgp/routing-policy/routing_policy_match.h" #include +#include #include +#include #include +#include #include +#include #include using std::ostringstream; using std::string; using std::make_pair; +using std::vector; +using std::map; -MatchCommunity::MatchCommunity(const std::vector &communities) { +MatchCommunity::MatchCommunity(const vector &communities) { BOOST_FOREACH(const string &community, communities) { uint32_t value = CommunityType::CommunityFromString(community); // Invalid community from config is ignored @@ -26,7 +32,7 @@ MatchCommunity::MatchCommunity(const std::vector &communities) { } std::sort(to_match_.begin(), to_match_.end()); - std::vector::iterator it = + vector::iterator it = std::unique(to_match_.begin(), to_match_.end()); to_match_.erase(it, to_match_.end()); } @@ -34,11 +40,11 @@ MatchCommunity::MatchCommunity(const std::vector &communities) { MatchCommunity::~MatchCommunity() { } -bool MatchCommunity::Match(const BgpRoute *route, - const BgpAttr *attr) const { +bool MatchCommunity::Match(const BgpRoute *route, const BgpPath *path, + const BgpAttr *attr) const { const Community *comm = attr->community(); if (comm) { - std::vector list = comm->communities(); + vector list = comm->communities(); if (list.size() < to_match_.size()) return false; std::sort(list.begin(), list.end()); if (std::includes(list.begin(), list.end(), @@ -88,8 +94,8 @@ MatchPrefix::~MatchPrefix() { } template -bool MatchPrefix::Match(const BgpRoute *route, - const BgpAttr *attr) const { +bool MatchPrefix::Match(const BgpRoute *route, const BgpPath *path, + const BgpAttr *attr) const { const RouteT *in_route = dynamic_cast(route); if (in_route == NULL) return false; const PrefixT &prefix = in_route->GetPrefix(); @@ -132,3 +138,105 @@ string MatchPrefix::ToString() const { template class MatchPrefix; template class MatchPrefix; + +static const map fromString + = boost::assign::map_list_of + ("bgp", MatchProtocol::BGP) + ("xmpp", MatchProtocol::XMPP) + ("static", MatchProtocol::StaticRoute) + ("service-chain", MatchProtocol::ServiceChainRoute) + ("aggregate", MatchProtocol::AggregateRoute); + +static const map toString + = boost::assign::map_list_of + (MatchProtocol::BGP, "bgp") + (MatchProtocol::XMPP, "xmpp") + (MatchProtocol::StaticRoute, "static") + (MatchProtocol::ServiceChainRoute, "service-chain") + (MatchProtocol::AggregateRoute, "aggregate"); + +static const map + pathSourceMap = boost::assign::map_list_of + (MatchProtocol::BGP, BgpPath::BGP_XMPP) + (MatchProtocol::XMPP, BgpPath::BGP_XMPP) + (MatchProtocol::StaticRoute, BgpPath::StaticRoute) + (MatchProtocol::ServiceChainRoute, BgpPath::ServiceChain) + (MatchProtocol::AggregateRoute, BgpPath::Aggregate); + +static const string MatchProtocolToString( + MatchProtocol::MatchProtocolType protocol) { + map::const_iterator it = + toString.find(protocol); + if (it != toString.end()) { + return it->second; + } + return "unspecified"; +} + +static MatchProtocol::MatchProtocolType MatchProtocolFromString( + const string &protocol) { + map::const_iterator it = + fromString.find(protocol); + if (it != fromString.end()) { + return it->second; + } + return MatchProtocol::Unspecified; +} + +static BgpPath::PathSource PathSourceFromMatchProtocol( + MatchProtocol::MatchProtocolType src) { + map::const_iterator + it = pathSourceMap.find(src); + if (it != pathSourceMap.end()) { + return it->second; + } + return BgpPath::None; +} + +MatchProtocol::MatchProtocol(const vector &protocols) { + BOOST_FOREACH(const string &protocol, protocols) { + MatchProtocolType value = MatchProtocolFromString(protocol); + // Invalid community from config is ignored + if (value != Unspecified) { + to_match_.push_back(value); + } + } +} + +MatchProtocol::~MatchProtocol() { +} + +bool MatchProtocol::Match(const BgpRoute *route, const BgpPath *path, + const BgpAttr *attr) const { + BgpPath::PathSource path_src = path->GetSource(); + bool is_xmpp = path->GetPeer() ? path->GetPeer()->IsXmppPeer() : false; + BOOST_FOREACH(MatchProtocolType protocol, protocols()) { + BgpPath::PathSource mapped_src = PathSourceFromMatchProtocol(protocol); + if (mapped_src != BgpPath::None) { + if (mapped_src == path_src) { + if (protocol == XMPP && !is_xmpp) continue; + if (protocol == BGP && is_xmpp) continue; + return true; + } + } + } + return false; +} + +string MatchProtocol::ToString() const { + ostringstream oss; + oss << "protocol [ "; + BOOST_FOREACH(MatchProtocolType protocol, protocols()) { + string name = MatchProtocolToString(protocol); + oss << name << ","; + } + oss.seekp(-1, oss.cur); + oss << " ]"; + return oss.str(); +} + +bool MatchProtocol::IsEqual(const RoutingPolicyMatch &protocol) const { + const MatchProtocol in_protocol = + static_cast(protocol); + return (protocols() == in_protocol.protocols()); +} diff --git a/src/bgp/routing-policy/routing_policy_match.h b/src/bgp/routing-policy/routing_policy_match.h index 71a3de6babe..77fa2d8ea70 100644 --- a/src/bgp/routing-policy/routing_policy_match.h +++ b/src/bgp/routing-policy/routing_policy_match.h @@ -16,6 +16,7 @@ #include "bgp/inet6/inet6_route.h" class BgpAttr; +class BgpPath; class BgpRoute; class Community; @@ -24,10 +25,12 @@ class RoutingPolicyMatch { virtual std::string ToString() const = 0; virtual ~RoutingPolicyMatch() { } - bool operator()(const BgpRoute *route, const BgpAttr *attr) const { - return Match(route, attr); + bool operator()(const BgpRoute *route, + const BgpPath *path, const BgpAttr *attr) const { + return Match(route, path, attr); } - virtual bool Match(const BgpRoute *route, const BgpAttr *attr) const = 0; + virtual bool Match(const BgpRoute *route, + const BgpPath *path, const BgpAttr *attr) const = 0; virtual bool operator==(const RoutingPolicyMatch &match) const { if (typeid(match) == typeid(*this)) return(IsEqual(match)); @@ -41,7 +44,8 @@ class MatchCommunity: public RoutingPolicyMatch { typedef std::vector CommunityList; explicit MatchCommunity(const std::vector &communities); virtual ~MatchCommunity(); - virtual bool Match(const BgpRoute *route, const BgpAttr *attr) const; + virtual bool Match(const BgpRoute *route, + const BgpPath *path, const BgpAttr *attr) const; virtual std::string ToString() const; virtual bool IsEqual(const RoutingPolicyMatch &community) const; const CommunityList &communities() const { @@ -51,6 +55,30 @@ class MatchCommunity: public RoutingPolicyMatch { CommunityList to_match_; }; +class MatchProtocol: public RoutingPolicyMatch { +public: + enum MatchProtocolType { + Unspecified = 0, + BGP, + XMPP, + StaticRoute, + ServiceChainRoute, + AggregateRoute, + }; + typedef std::vector PathSourceList; + explicit MatchProtocol(const std::vector &protocols); + virtual ~MatchProtocol(); + virtual bool Match(const BgpRoute *route, + const BgpPath *path, const BgpAttr *attr) const; + virtual std::string ToString() const; + virtual bool IsEqual(const RoutingPolicyMatch &community) const; + const PathSourceList &protocols() const { + return to_match_; + } +private: + PathSourceList to_match_; +}; + template struct PrefixMatchBase { typedef T1 RouteT; @@ -77,7 +105,8 @@ class MatchPrefix : public RoutingPolicyMatch { typedef std::vector PrefixMatchList; explicit MatchPrefix(const PrefixMatchConfigList &list); virtual ~MatchPrefix(); - virtual bool Match(const BgpRoute *route, const BgpAttr *attr) const; + virtual bool Match(const BgpRoute *route, + const BgpPath *path, const BgpAttr *attr) const; virtual std::string ToString() const; virtual bool IsEqual(const RoutingPolicyMatch &prefix) const; private: diff --git a/src/bgp/test/routing_policy_test.cc b/src/bgp/test/routing_policy_test.cc index a75680f2d85..b2819124f75 100644 --- a/src/bgp/test/routing_policy_test.cc +++ b/src/bgp/test/routing_policy_test.cc @@ -389,6 +389,34 @@ TEST_F(RoutingPolicyTest, PolicyMultiplePrefixMatchUpdateLocalPref) { DeleteRoute(peers_[0], "test.inet.0", "30.1.1.1/32"); } +TEST_F(RoutingPolicyTest, PolicyProtocolMatchUpdateLocalPref) { + string content = + FileRead("controller/src/bgp/testdata/routing_policy_0e.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + boost::system::error_code ec; + peers_.push_back( + new BgpPeerMock(Ip4Address::from_string("192.168.0.1", ec))); + + AddRoute(peers_[0], "test.inet.0", + "10.0.1.1/32", 100); + task_util::WaitForIdle(); + + VERIFY_EQ(1, RouteCount("test.inet.0")); + BgpRoute *rt = + RouteLookup("test.inet.0", "10.0.1.1/32"); + ASSERT_TRUE(rt != NULL); + VERIFY_EQ(peers_[0], rt->BestPath()->GetPeer()); + const BgpAttr *attr = rt->BestPath()->GetAttr(); + const BgpAttr *orig_attr = rt->BestPath()->GetOriginalAttr(); + uint32_t original_local_pref = orig_attr->local_pref(); + uint32_t policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 102); + ASSERT_TRUE(original_local_pref == 100); + + DeleteRoute(peers_[0], "test.inet.0", "10.0.1.1/32"); +} TEST_F(RoutingPolicyTest, PolicyCommunityMatchReject) { string content = @@ -2029,6 +2057,138 @@ TEST_F(RoutingPolicyTest, MultiplePolicies_UpdateOrder_1) { "2001:db8:85a3::8a2e:370:7334/128"); } +TEST_F(RoutingPolicyTest, ProtocolMatchServiceChain) { + string content = + FileRead("controller/src/bgp/testdata/routing_policy_0f.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + boost::system::error_code ec; + peers_.push_back( + new BgpPeerMock(Ip4Address::from_string("192.168.0.1", ec))); + + AddRoute(peers_[0], "red.inet.0", + "1.1.2.3/32", 100); + AddRoute(peers_[0], "blue.inet.0", + "192.168.1.1/32", 100); + task_util::WaitForIdle(); + + VERIFY_EQ(2, RouteCount("red.inet.0")); + VERIFY_EQ(1, RouteCount("blue.inet.0")); + + // Policy applied on Service Chain routes + BgpRoute *rt = + RouteLookup("red.inet.0", "192.168.1.1/32"); + ASSERT_TRUE(rt != NULL); + const BgpAttr *attr = rt->BestPath()->GetAttr(); + const BgpAttr *orig_attr = rt->BestPath()->GetOriginalAttr(); + uint32_t original_local_pref = orig_attr->local_pref(); + uint32_t policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 102); + ASSERT_TRUE(original_local_pref == 100); + // Bgp routes are not altered + rt = RouteLookup("red.inet.0", "1.1.2.3/32"); + ASSERT_TRUE(rt != NULL); + attr = rt->BestPath()->GetAttr(); + orig_attr = rt->BestPath()->GetOriginalAttr(); + original_local_pref = orig_attr->local_pref(); + policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 100); + ASSERT_TRUE(original_local_pref == 100); + + DeleteRoute(peers_[0], "blue.inet.0", "192.168.1.1/32"); + DeleteRoute(peers_[0], "red.inet.0", "1.1.2.3/32"); +} + +TEST_F(RoutingPolicyTest, ProtocolMatchServiceChain_PolicyUpdate) { + string content = + FileRead("controller/src/bgp/testdata/routing_policy_0f.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + boost::system::error_code ec; + peers_.push_back( + new BgpPeerMock(Ip4Address::from_string("192.168.0.1", ec))); + + AddRoute(peers_[0], "red.inet.0", + "1.1.2.3/32", 100); + AddRoute(peers_[0], "blue.inet.0", + "192.168.1.1/32", 100); + task_util::WaitForIdle(); + + VERIFY_EQ(2, RouteCount("red.inet.0")); + VERIFY_EQ(1, RouteCount("blue.inet.0")); + + content = FileRead("controller/src/bgp/testdata/routing_policy_0g.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + // Policy applied on both Service Chain routes and bgp routes + BgpRoute *rt = + RouteLookup("red.inet.0", "192.168.1.1/32"); + ASSERT_TRUE(rt != NULL); + const BgpAttr *attr = rt->BestPath()->GetAttr(); + const BgpAttr *orig_attr = rt->BestPath()->GetOriginalAttr(); + uint32_t original_local_pref = orig_attr->local_pref(); + uint32_t policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 999); + ASSERT_TRUE(original_local_pref == 100); + rt = RouteLookup("red.inet.0", "1.1.2.3/32"); + ASSERT_TRUE(rt != NULL); + attr = rt->BestPath()->GetAttr(); + orig_attr = rt->BestPath()->GetOriginalAttr(); + original_local_pref = orig_attr->local_pref(); + policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 999); + ASSERT_TRUE(original_local_pref == 100); + + DeleteRoute(peers_[0], "blue.inet.0", "192.168.1.1/32"); + DeleteRoute(peers_[0], "red.inet.0", "1.1.2.3/32"); +} + +TEST_F(RoutingPolicyTest, ProtocolMatchStaticRoute) { + string content = + FileRead("controller/src/bgp/testdata/routing_policy_0h.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + boost::system::error_code ec; + peers_.push_back( + new BgpPeerMock(Ip4Address::from_string("192.168.0.1", ec))); + + AddRoute(peers_[0], "nat.inet.0", + "192.168.1.254/32", 100); + AddRoute(peers_[0], "nat.inet.0", + "192.168.1.1/32", 100); + task_util::WaitForIdle(); + + VERIFY_EQ(3, RouteCount("nat.inet.0")); + VERIFY_EQ(1, RouteCount("blue.inet.0")); + + // Policy applied on Static routes + BgpRoute *rt = + RouteLookup("nat.inet.0", "192.168.1.0/24"); + ASSERT_TRUE(rt != NULL); + const BgpAttr *attr = rt->BestPath()->GetAttr(); + const BgpAttr *orig_attr = rt->BestPath()->GetOriginalAttr(); + uint32_t original_local_pref = orig_attr->local_pref(); + uint32_t policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 102); + ASSERT_TRUE(original_local_pref == 100); + // Bgp routes are not altered + rt = RouteLookup("nat.inet.0", "192.168.1.1/32"); + ASSERT_TRUE(rt != NULL); + attr = rt->BestPath()->GetAttr(); + orig_attr = rt->BestPath()->GetOriginalAttr(); + original_local_pref = orig_attr->local_pref(); + policy_local_pref = attr->local_pref(); + ASSERT_TRUE(policy_local_pref == 100); + ASSERT_TRUE(original_local_pref == 100); + + DeleteRoute(peers_[0], "nat.inet.0", "192.168.1.1/32"); + DeleteRoute(peers_[0], "nat.inet.0", "192.168.1.254/32"); +} + static void ValidateShowRoutingPolicyResponse( Sandesh *sandesh, bool *done, const vector &policy_list) { diff --git a/src/bgp/testdata/routing_policy_0e.xml b/src/bgp/testdata/routing_policy_0e.xml new file mode 100644 index 00000000000..2314a8e6d03 --- /dev/null +++ b/src/bgp/testdata/routing_policy_0e.xml @@ -0,0 +1,23 @@ + + + + + + bgp + xmpp + + + + 102 + + accept + + + + + + 1.0 + + target:1:103 + + diff --git a/src/bgp/testdata/routing_policy_0f.xml b/src/bgp/testdata/routing_policy_0f.xml new file mode 100644 index 00000000000..42b7a265250 --- /dev/null +++ b/src/bgp/testdata/routing_policy_0f.xml @@ -0,0 +1,43 @@ + + + + 2000 + + + 1000 + + + + + service-chain + + + + 102 + + accept + + + + + red-vn + + blue + red + 192.168.1.0/24 + 192.168.2.0/24 + 1.1.2.3 + + + 1.0 + + target:1:103 + + + blue-vn + + 1.0 + + target:1:104 + + diff --git a/src/bgp/testdata/routing_policy_0g.xml b/src/bgp/testdata/routing_policy_0g.xml new file mode 100644 index 00000000000..774f744deec --- /dev/null +++ b/src/bgp/testdata/routing_policy_0g.xml @@ -0,0 +1,18 @@ + + + + + + service-chain + bgp + xmpp + + + + 999 + + accept + + + + diff --git a/src/bgp/testdata/routing_policy_0h.xml b/src/bgp/testdata/routing_policy_0h.xml new file mode 100644 index 00000000000..c9874751aa7 --- /dev/null +++ b/src/bgp/testdata/routing_policy_0h.xml @@ -0,0 +1,32 @@ + + + + + + static + + + + 102 + + accept + + + + + + + 192.168.1.0/24 + 192.168.1.254 + target:1:104 + + + + 1.0 + + target:1:103 + + + target:1:104 + +