Skip to content

Commit

Permalink
Granular Routing Policy - failure of multiple policy
Browse files Browse the repository at this point in the history
When interface is configured with static route, agent wrongly exports all the routes as
interface-static type, which causes failure of policy. This fix ensures only static route
is added interface-static type

intf_route_type_ in vm_interface class is removed which is no more required

Change-Id: I1accd2472df07a2ab2388ce6c932bf82b87821ef
Closes-Bug: 1756799
(cherry picked from commit cf79691)
  • Loading branch information
bmadhu77 committed Apr 7, 2018
1 parent 93c10ce commit 5adfd72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/vnsw/agent/oper/test/test_intf.cc
Expand Up @@ -2539,6 +2539,7 @@ TEST_F(IntfTest, IntfStaticRoute) {
struct PortInfo input[] = {
{"vnet1", 1, "1.1.1.10", "00:00:00:01:01:01", 1, 1},
};
InetUnicastRouteEntry *rt;

client->Reset();
CreateVmportEnv(input, 1);
Expand All @@ -2559,6 +2560,11 @@ TEST_F(IntfTest, IntfStaticRoute) {
static_route[0].plen_));
EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_,
static_route[1].plen_));

rt = RouteGet("vrf1", static_route[0].addr_, static_route[0].plen_);

EXPECT_TRUE(rt->intf_route_type().compare(VmInterface::kInterfaceStatic) == 0);

DoInterfaceSandesh("vnet1");
client->WaitForIdle();

Expand Down
22 changes: 8 additions & 14 deletions src/vnsw/agent/oper/vm_interface.cc
Expand Up @@ -87,7 +87,6 @@ VmInterface::VmInterface(const boost::uuids::uuid &uuid,
ipv4_active_ = false;
ipv6_active_ = false;
l2_active_ = false;
intf_route_type_ = kInterface;
}

VmInterface::VmInterface(const boost::uuids::uuid &uuid,
Expand Down Expand Up @@ -138,7 +137,6 @@ VmInterface::VmInterface(const boost::uuids::uuid &uuid,
ipv4_active_ = false;
ipv6_active_ = false;
l2_active_ = false;
intf_route_type_ = kInterface;
}

VmInterface::~VmInterface() {
Expand Down Expand Up @@ -1216,10 +1214,11 @@ bool VmiRouteState::AddL3(const Agent *agent, VmInterface *vmi) const {
if (vrf_ == NULL || vmi->vn() == NULL || ip_.is_unspecified())
return false;

/* expected only for instance IP */
vmi->AddRoute(vrf_->GetName(), ip_, 32, vmi->vn()->GetName(), false,
vmi->ecmp(), false, false, vmi->vm_ip_service_addr(),
Ip4Address(0), CommunityList(), vmi->label(),
vmi->intf_route_type());
VmInterface::kInterface);
return true;
}

Expand Down Expand Up @@ -1443,15 +1442,11 @@ bool VmInterface::InstanceIp::AddL3(const Agent *agent,
vn_name = agent->fabric_vn_name();
}

if (is_service_ip_) {
vmi->intf_route_type_ = kServiceInterface;
}

vmi->AddRoute(vmi->vrf()->GetName(), ip_, plen_, vn_name,
is_force_policy(), ecmp_,is_local_,
is_service_health_check_ip_, vmi->GetServiceIp(ip_),
tracking_ip_, CommunityList(), vmi->label(),
vmi->intf_route_type());
is_service_ip_ ? kServiceInterface : kInterface);
return true;
}

Expand Down Expand Up @@ -1669,7 +1664,7 @@ bool VmInterface::FloatingIp::AddL3(const Agent *agent,
bool ecmp = floating_ip_.is_v4() ? vmi->ecmp() : vmi->ecmp6();
vmi->AddRoute(vrf_.get()->GetName(), floating_ip_, plen, vn_->GetName(),
false, ecmp, false, false, service_ip, fixed_ip_,
CommunityList(), vmi->label(), vmi->intf_route_type());
CommunityList(), vmi->label(), kInterface);

InterfaceTable *table = static_cast<InterfaceTable *>(vmi->get_table());
if (floating_ip_.is_v4() && table->update_floatingip_cb().empty()==false) {
Expand Down Expand Up @@ -1890,7 +1885,7 @@ bool VmInterface::AliasIp::AddL3(const Agent *agent, VmInterface *vmi) const {
service_ip = Ip6Address();
vmi->AddRoute(vrf_->GetName(), alias_ip_, plen, vn_->GetName(), false,
vmi->ecmp(), false, false, service_ip, service_ip,
CommunityList(), vmi->label(), vmi->intf_route_type());
CommunityList(), vmi->label(), kInterface);
return true;
}

Expand Down Expand Up @@ -2042,11 +2037,10 @@ bool VmInterface::StaticRoute::AddL3(const Agent *agent,
dependent_ip = vmi->primary_ip6_addr();
ecmp = vmi->ecmp6();
}
vmi->intf_route_type_ = kInterfaceStatic;
vmi->AddRoute(vrf_->GetName(), addr_, plen_, vn_name,
false, ecmp, false, false, vmi->GetServiceIp(addr_),
dependent_ip, communities_, vmi->label(),
vmi->intf_route_type());
kInterfaceStatic);
}
return true;
}
Expand Down Expand Up @@ -2249,7 +2243,7 @@ bool VmInterface::AllowedAddressPair::AddL3(const Agent *agent,
if (mac_ == MacAddress::kZeroMac || mac_ == vmi->vm_mac_) {
vmi->AddRoute(vrf_->GetName(), addr_, plen_, vmi->vn_->GetName(),
false, ecmp_, false, false, service_ip_, Ip4Address(0),
CommunityList(), vmi->label(), vmi->intf_route_type());
CommunityList(), vmi->label(), kInterface);
return true;
}

Expand Down Expand Up @@ -2285,7 +2279,7 @@ bool VmInterface::AllowedAddressPair::AddL3(const Agent *agent,

vmi->AddRoute(vrf_->GetName(), addr_, plen_, vmi->vn_->GetName(),
false, ecmp_, false, false, service_ip_, Ip6Address(),
CommunityList(), label_, vmi->intf_route_type());
CommunityList(), label_, kInterface);
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions src/vnsw/agent/oper/vm_interface.h
Expand Up @@ -1335,7 +1335,6 @@ class VmInterface : public Interface {
return si_other_end_vmi_;
}
const std::string &service_intf_type() const { return service_intf_type_; }
const std::string &intf_route_type() const { return intf_route_type_; }
VmInterface * PortTuplePairedInterface() const;

// Static methods
Expand Down Expand Up @@ -1560,7 +1559,6 @@ class VmInterface : public Interface {
//In case Vhost interface, uuid_ is stored here
boost::uuids::uuid vmi_cfg_uuid_;
std::string service_intf_type_;
std::string intf_route_type_;
DISALLOW_COPY_AND_ASSIGN(VmInterface);
};

Expand Down

0 comments on commit 5adfd72

Please sign in to comment.