Skip to content

Commit

Permalink
* Use dns server IP as source address while sending ARP
Browse files Browse the repository at this point in the history
  query for allowed address pair address
Closes-bug:#1551105

Change-Id: I78f2ddeea2509dea3d8e98b5b71f1404d0cfc50f
  • Loading branch information
naveen-n committed Mar 12, 2016
1 parent 8ae0136 commit dcf0e64
Show file tree
Hide file tree
Showing 30 changed files with 234 additions and 236 deletions.
6 changes: 3 additions & 3 deletions src/vnsw/agent/oper/agent_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AgentPath::AgentPath(const Peer *peer, AgentRoute *rt):
tunnel_type_(TunnelType::ComputeType(TunnelType::AllType())),
vrf_name_(""), gw_ip_(0), unresolved_(true), is_stale_(false),
is_subnet_discard_(false), dependant_rt_(rt), path_preference_(),
local_ecmp_mpls_label_(rt), composite_nh_key_(NULL), subnet_gw_ip_(),
local_ecmp_mpls_label_(rt), composite_nh_key_(NULL), subnet_service_ip_(),
arp_mac_(), arp_interface_(NULL), arp_valid_(false),
ecmp_suppressed_(false) {
}
Expand Down Expand Up @@ -694,8 +694,8 @@ bool LocalVmRoute::AddChangePath(Agent *agent, AgentPath *path,
sync_route_ = true;
}

if (path->subnet_gw_ip() != subnet_gw_ip_) {
path->set_subnet_gw_ip(subnet_gw_ip_);
if (path->subnet_service_ip() != subnet_service_ip_) {
path->set_subnet_service_ip(subnet_service_ip_);
ret = true;
}

Expand Down
14 changes: 7 additions & 7 deletions src/vnsw/agent/oper/agent_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class AgentPath : public Path {
const bool unresolved() const {return unresolved_;}
const Ip4Address& tunnel_dest() const {return tunnel_dest_;}
bool is_subnet_discard() const {return is_subnet_discard_;}
const IpAddress subnet_gw_ip() const { return subnet_gw_ip_;}
const IpAddress subnet_service_ip() const { return subnet_service_ip_;}

TunnelType::Type GetTunnelType() const {
return TunnelType::ComputeType(tunnel_bmap_);
Expand All @@ -164,8 +164,8 @@ class AgentPath : public Path {
void set_is_subnet_discard(bool discard) {
is_subnet_discard_= discard;
}
void set_subnet_gw_ip(const IpAddress &ip) {
subnet_gw_ip_ = ip;
void set_subnet_service_ip(const IpAddress &ip) {
subnet_service_ip_ = ip;
}
void set_local_ecmp_mpls_label(MplsLabel *mpls);
const MplsLabel* local_ecmp_mpls_label() const;
Expand Down Expand Up @@ -268,7 +268,7 @@ class AgentPath : public Path {
//This IP address gets used in sending arp query to the VM
//helping in deciding the priority during live migration and
//allowed address pair
IpAddress subnet_gw_ip_;
IpAddress subnet_service_ip_;
//Mac address of ARP NH, used to notify change
//to routes dependent on mac change, or ageout of ARP
MacAddress arp_mac_;
Expand Down Expand Up @@ -382,12 +382,12 @@ class LocalVmRoute : public AgentRouteData {
uint32_t vxlan_id, bool force_policy, const string &vn_name,
uint8_t flags, const SecurityGroupList &sg_list,
const PathPreference &path_preference,
const IpAddress &subnet_gw_ip) :
const IpAddress &subnet_service_ip) :
AgentRouteData(false), intf_(intf), mpls_label_(mpls_label),
vxlan_id_(vxlan_id), force_policy_(force_policy),
dest_vn_name_(vn_name), proxy_arp_(false), sync_route_(false),
flags_(flags), sg_list_(sg_list), tunnel_bmap_(TunnelType::MplsType()),
path_preference_(path_preference), subnet_gw_ip_(subnet_gw_ip) {
path_preference_(path_preference), subnet_service_ip_(subnet_service_ip) {
}
virtual ~LocalVmRoute() { }
void DisableProxyArp() {proxy_arp_ = false;}
Expand Down Expand Up @@ -416,7 +416,7 @@ class LocalVmRoute : public AgentRouteData {
SecurityGroupList sg_list_;
TunnelType::TypeBmap tunnel_bmap_;
PathPreference path_preference_;
IpAddress subnet_gw_ip_;
IpAddress subnet_service_ip_;
DISALLOW_COPY_AND_ASSIGN(LocalVmRoute);
};

Expand Down
8 changes: 4 additions & 4 deletions src/vnsw/agent/oper/inet_unicast_route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1095,12 +1095,12 @@ InetUnicastAgentRouteTable::AddLocalVmRouteReq(const Peer *peer,
bool force_policy,
const PathPreference
&path_preference,
const IpAddress &subnet_gw_ip) {
const IpAddress &subnet_service_ip) {
VmInterfaceKey intf_key(AgentKey::ADD_DEL_CHANGE, intf_uuid, "");
LocalVmRoute *data = new LocalVmRoute(intf_key, label,
VxLanTable::kInvalidvxlan_id, force_policy,
vn_name, InterfaceNHFlags::INET4, sg_list,
path_preference, subnet_gw_ip);
path_preference, subnet_service_ip);

AddLocalVmRouteReq(peer, vm_vrf, addr, plen, data);
}
Expand Down Expand Up @@ -1131,15 +1131,15 @@ InetUnicastAgentRouteTable::AddLocalVmRoute(const Peer *peer,
bool force_policy,
const PathPreference
&path_preference,
const IpAddress &subnet_gw_ip) {
const IpAddress &subnet_service_ip) {
DBRequest req(DBRequest::DB_ENTRY_ADD_CHANGE);
req.key.reset(new InetUnicastRouteKey(peer, vm_vrf, addr, plen));

VmInterfaceKey intf_key(AgentKey::ADD_DEL_CHANGE, intf_uuid, "");
req.data.reset(new LocalVmRoute(intf_key, label, VxLanTable::kInvalidvxlan_id,
force_policy, vn_name,
InterfaceNHFlags::INET4, sg_list,
path_preference, subnet_gw_ip));
path_preference, subnet_service_ip));
InetUnicastTableProcess(Agent::GetInstance(), vm_vrf, req);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vnsw/agent/oper/inet_unicast_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ class InetUnicastAgentRouteTable : public AgentRouteTable {
const SecurityGroupList &sg_list,
bool force_policy,
const PathPreference &path_preference,
const IpAddress &subnet_gw_ip);
const IpAddress &subnet_service_ip);
static void AddLocalVmRoute(const Peer *peer, const string &vm_vrf,
const IpAddress &addr, uint8_t plen,
const uuid &intf_uuid, const string &vn_name,
uint32_t label,
const SecurityGroupList &sg_list,
bool force_policy,
const PathPreference &path_preference,
const IpAddress &subnet_gw_ip);
const IpAddress &subnet_service_ip);
static void AddRemoteVmRouteReq(const Peer *peer, const string &vm_vrf,
const IpAddress &vm_addr,uint8_t plen,
AgentRouteData *data);
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/oper/test/test_aap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ TEST_F(TestAap, SubnetGw) {
EXPECT_TRUE(RouteFind("vrf1", ip1, 32));

IpamInfo ipam_info[] = {
{"10.10.10.0", 24, "10.10.10.200", true},
{"10.10.10.0", 24, "10.10.10.200", true, "10.10.10.201"}
};
AddIPAM("vn1", ipam_info, 1, NULL, "vdns1");
client->WaitForIdle();

Ip4Address subnet_gw_ip = Ip4Address::from_string("10.10.10.200");
Ip4Address subnet_service_ip = Ip4Address::from_string("10.10.10.201");
InetUnicastRouteEntry *rt = RouteGet("vrf1", ip1, 32);
EXPECT_TRUE(rt->GetActivePath()->subnet_gw_ip() == subnet_gw_ip);
EXPECT_TRUE(rt->GetActivePath()->subnet_service_ip() == subnet_service_ip);

DelIPAM("vn1", "vdns1");
client->WaitForIdle();
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/oper/test/test_ipv6.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ TEST_F(Ipv6Test, v6_subnet_gw_route) {
};

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"fd11::", 120, "fd11::1", true},
{"fd12::", 96, "fd12::1", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
{"fd11::", 120, "fd11::1", true, "fd11::1"},
{"fd12::", 96, "fd12::1", true, "fd12::1"},
};
client->Reset();
CreateVmportEnv(input, 1, 0);
Expand Down
12 changes: 6 additions & 6 deletions src/vnsw/agent/oper/test/test_linklocal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ TEST_F(LinkLocalTest, LinkLocalReqTest) {
client->Reset();

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"1.2.3.128", 27, "1.2.3.129", true},
{"7.8.9.0", 24, "7.8.9.12", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
{"1.2.3.128", 27, "1.2.3.129", true, "1.2.3.129"},
{"7.8.9.0", 24, "7.8.9.12", true, "7.8.9.12"},
};
AddIPAM("ipam1", ipam_info, 3);
client->WaitForIdle();
Expand Down Expand Up @@ -237,9 +237,9 @@ TEST_F(LinkLocalTest, GlobalVrouterDeleteTest) {
client->Reset();

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"1.2.3.128", 27, "1.2.3.129", true},
{"7.8.9.0", 24, "7.8.9.12", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
{"1.2.3.128", 27, "1.2.3.129", true, "1.2.3.129"},
{"7.8.9.0", 24, "7.8.9.12", true, "7.8.9.12"},
};
AddIPAM("ipam1", ipam_info, 3);
client->WaitForIdle();
Expand Down
11 changes: 4 additions & 7 deletions src/vnsw/agent/oper/vm_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,8 @@ Ip4Address VmInterface::GetGateway(const IpAddress &vm_ip) const {
ipam = vn_->GetIpam(subnet_);
}

if (ipam && ipam->default_gw.is_v4()) {
ip = ipam->default_gw.to_v4();
if (ipam && ipam->dns_server.is_v4()) {
ip = ipam->dns_server.to_v4();
}
return ip;
}
Expand Down Expand Up @@ -2553,7 +2553,7 @@ void VmInterface::UpdateIpv6InterfaceRoute(bool old_ipv6_active, bool force_upda

PathPreference path_preference;
SetPathPreference(&path_preference, false);
//TODO: change subnet_gw_ip to Ip6Address
//TODO: change subnet_service_ip to Ip6Address
InetUnicastAgentRouteTable::AddLocalVmRoute
(peer_.get(), vrf_->GetName(), primary_ip6_addr_, 128, GetUuid(),
vn_->GetName(), label_, sg_id_list, false, path_preference,
Expand Down Expand Up @@ -3758,11 +3758,8 @@ void VmInterface::AllowedAddressPair::L2DeActivate(VmInterface *interface) const
void VmInterface::AllowedAddressPair::Activate(VmInterface *interface,
bool force_update,
bool policy_change) const {
const VnIpam *ipam = interface->vn_->GetIpam(addr_);
Ip4Address ip(0);
if (ipam) {
ip = ipam->default_gw.to_v4();
}
ip = interface->GetGateway(addr_);

if (installed_ && force_update == false && policy_change == false &&
gw_ip_ == ip) {
Expand Down
4 changes: 2 additions & 2 deletions src/vnsw/agent/pkt/test/test_pkt_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ TEST_F(FlowTest, Flow_return_error) {
//Test for subnet broadcast flow
TEST_F(FlowTest, Subnet_broadcast_Flow) {
IpamInfo ipam_info[] = {
{"11.1.1.0", 24, "11.1.1.200", true},
{"11.1.1.0", 24, "11.1.1.200", true, "11.1.1.200"},
};
AddIPAM("vn5", ipam_info, 1);
client->WaitForIdle();
Expand Down Expand Up @@ -3795,7 +3795,7 @@ TEST_F(FlowTest, FlowPolicyUuid_15) {
*/
TEST_F(FlowTest, FlowPolicyUuid_16) {
IpamInfo ipam_info[] = {
{"11.1.1.0", 24, "11.1.1.200", true},
{"11.1.1.0", 24, "11.1.1.200", true, "11.1.1.200"},
};
AddIPAM("vn5", ipam_info, 1);
client->WaitForIdle();
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/test/test_rpf_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ TEST_F(FlowRpfTest, Flow_rpf_failure_subnet_discard_route) {
EXPECT_EQ(0U, agent()->pkt()->flow_table()->Size());

IpamInfo ipam_info[] = {
{"11.1.1.0", 24, "11.1.1.200", true},
{"11.1.1.0", 24, "11.1.1.200", true, "11.1.1.200"},
};
AddIPAM("vn5", ipam_info, 1);
client->WaitForIdle();
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/test/test_xml_packet_ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST_F(TestPkt, flow_tsn_mode_1) {
Agent *agent = Agent::GetInstance();
//agent->set_tsn_enabled(true);
IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.254", true}
{"1.1.1.0", 24, "1.1.1.254", true, "1.1.1.254"}
};
AddVn("vn1", 1);
AddVrf("vrf1", 1);
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/services/arp_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void ArpDBState::SendArpRequestForAllIntf(const InetUnicastRouteEntry *route) {
const AgentPath *path = static_cast<const AgentPath *>(it.operator->());
if (path->peer() &&
path->peer()->GetType() == Peer::LOCAL_VM_PORT_PEER) {
if (path->subnet_gw_ip() == Ip4Address(0)) {
if (path->subnet_service_ip() == Ip4Address(0)) {
return;
}
const NextHop *nh = path->ComputeNextHop(vrf_state_->agent);
Expand All @@ -166,10 +166,10 @@ void ArpDBState::SendArpRequestForAllIntf(const InetUnicastRouteEntry *route) {
//Ignore non vm interface nexthop
continue;
}
if (path->subnet_gw_ip().is_v4() == false) {
if (path->subnet_service_ip().is_v4() == false) {
continue;
}
gw_ip_ = path->subnet_gw_ip();
gw_ip_ = path->subnet_service_ip();
uint32_t intf_id = intf->id();
bool wait_for_traffic = path->path_preference().wait_for_traffic();
//Build new list of interfaces in active state
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/services/test/arp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ TEST_F(ArpTest, ArpReqOnVmInterface) {
EXPECT_TRUE(agent->GetArpProto()->GetStats().vm_arp_req == 0);

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
};
AddIPAM("vn1", ipam_info, 1, NULL, "vdns1");
client->WaitForIdle();
Expand Down Expand Up @@ -577,7 +577,7 @@ TEST_F(ArpTest, ArpReqOnVmInterface_1) {
EXPECT_TRUE(agent->GetArpProto()->GetStats().vm_arp_req == 0);

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
};
AddIPAM("vn1", ipam_info, 1, NULL, "vdns1");
client->WaitForIdle();
Expand Down Expand Up @@ -617,7 +617,7 @@ TEST_F(ArpTest, ArpReqOnVmInterface_2) {
EXPECT_TRUE(agent->GetArpProto()->GetStats().vm_arp_req == 0);

IpamInfo ipam_info[] = {
{"1.1.1.0", 24, "1.1.1.200", true},
{"1.1.1.0", 24, "1.1.1.200", true, "1.1.1.200"},
};
AddIPAM("vn1", ipam_info, 1, NULL, "vdns1");
client->WaitForIdle();
Expand Down

0 comments on commit dcf0e64

Please sign in to comment.