Skip to content

Commit 9305eb0

Browse files
committed
Merge "Metadata6 with vhost fabric VRF routes to the IPv6 LL address of vhost0 interface"
2 parents c8aa9c3 + f572cc7 commit 9305eb0

File tree

9 files changed

+179
-485
lines changed

9 files changed

+179
-485
lines changed

src/vnsw/agent/kstate/test/test_kstate.cc

-7
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
#include "xmpp/test/xmpp_test_util.h"
1212
#include "ksync/ksync_sock_user.h"
1313

14-
// This is required to deactivate metadata proxy part, which installs it's
15-
// own routes
16-
#include "services/metadata_proxy.h"
17-
#include "services/metadata_server.h"
18-
#include "services/services_init.h"
19-
2014
#define vm1_ip "1.1.1.1"
2115
#define vm2_ip "2.1.1.1"
2216
#define vm3_ip "3.1.1.1"
@@ -66,7 +60,6 @@ class KStateTest : public ::testing::Test {
6660
public:
6761

6862
KStateTest() {
69-
Agent::GetInstance()->services()->metadataproxy()->Shutdown();
7063
}
7164

7265
~KStateTest() {}

src/vnsw/agent/oper/metadata_ip.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ void MetaDataIpAllocator::ReleaseIndex(MetaDataIp *ip) {
188188
}
189189

190190
bool MetaDataIpAllocator::CanAddRoute(MetaDataIp* ip) {
191-
if (ip->intf_->vn() == NULL || ip->intf_->vrf() == NULL) {
191+
if (ip->intf_->vmi_type() == VmInterface::VHOST ||
192+
ip->intf_->vn() == NULL || ip->intf_->vrf() == NULL) {
192193
return false;
193194
}
194195

src/vnsw/agent/oper/test/test_tsn_elector.cc

-7
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
#include <oper/interface_common.h>
2323
#include <oper/tunnel_nh.h>
2424

25-
// This is required to deactivate metadata proxy part, which installs it's
26-
// own routes
27-
#include "services/metadata_proxy.h"
28-
#include "services/metadata_server.h"
29-
#include "services/services_init.h"
30-
3125
#include "testing/gunit.h"
3226
#include "test_cmn_util.h"
3327
#include "vr_types.h"
@@ -53,7 +47,6 @@ static void ValidateSandeshResponse(Sandesh *sandesh, vector<int> &result) {
5347
class TsnElectorTest : public ::testing::Test {
5448
public:
5549
TsnElectorTest() : agent_(Agent::GetInstance()) {
56-
Agent::GetInstance()->services()->metadataproxy()->Shutdown();
5750
}
5851

5952
~TsnElectorTest() {

src/vnsw/agent/pkt/test/test_tsn_flow.cc

-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
#include <base/task.h>
1313
#include <base/test/task_test_util.h>
1414

15-
// This is required to deactivate metadata proxy part, which installs it's
16-
// own routes
17-
#include "services/metadata_proxy.h"
18-
#include "services/metadata_server.h"
19-
#include "services/services_init.h"
20-
2115
#define vm1_ip "11.1.1.1"
2216
#define vm2_ip "11.1.1.2"
2317

@@ -32,7 +26,6 @@ VmInterface *flow1;
3226
class TestTsnFlow : public ::testing::Test {
3327
public:
3428
TestTsnFlow() : agent_(NULL), flow_proto_(NULL), util_() {
35-
Agent::GetInstance()->services()->metadataproxy()->Shutdown();
3629
}
3730

3831
~TestTsnFlow(){};

src/vnsw/agent/services/metadata_proxy.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,7 @@ class MetadataProxy {
6868
/// @param vhost_ll_ip is a new IP address for vhost0 interface
6969
/// @return true if address has been successfully bound to the
7070
/// interface and false otherwise
71-
bool NetlinkAddVhostIp(const IpAddress& vhost_ll_ip);
72-
73-
/// @brief Deletes an IP address specified in vhost_ll_ip from vhost0
74-
//// interface inet6 addresses
75-
/// @param vhost_ll_ip is an IPv6 address to the vhost0 interface
76-
void NetlinkDelVhostIp(const IpAddress& vhost_ll_ip);
77-
78-
/// @brief Adds a new neighbour (an arp entry) with given IP and MAC
79-
/// addresses
80-
/// @param nb_ip - the IP address of a neighbour
81-
/// @param via_mac - the MAC address of a neighbour
82-
void NetlinkAddVhostNb(const IpAddress& nb_ip, const MacAddress& via_mac);
71+
bool NetlinkGetVhostIp(Ip6Address& vhost_ll_ip);
8372

8473
/// @brief Advertises routes to a given vm-interface via a given IPv6
8574
/// address. Routes are announced in the fabric VRF entry and in a given
@@ -104,6 +93,15 @@ class MetadataProxy {
10493
/// @brief Initializes an HTTP server for IPv6 requests
10594
void InitializeHttp6Server(const VmInterface *vhost0);
10695

96+
/// @brief Advertises the LL route to vhost0 interface in the fabric VRF
97+
/// instance
98+
void AdvertiseVhostRoute();
99+
100+
101+
/// @brief Deletes the LL route to vhost0 interface in the fabric VRF
102+
/// instance
103+
void DeleteVhostRoute();
104+
107105
/// @brief A callback that is invoked each time when a VRF entry is
108106
/// modified: added, changed or deleted
109107
/// @param part is a pointer to a table partititon containing corresponding

src/vnsw/agent/services/metadata_proxy_ip6.cc

+40-20
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,12 @@ const Ip6Address& MetadataProxy::Ipv6ServiceAddress() const {
143143

144144
void MetadataProxy::InitializeHttp6Server(const VmInterface *vhost0) {
145145
if (vhost0 == NULL ||
146-
vhost0->mdata_ip6_addr().is_unspecified() ||
147-
!vhost0->mdata_ip6_addr().is_link_local() ||
148146
!ipv6_service_address_.is_unspecified()) {
149147
return;
150148
}
151-
ipv6_service_address_ = vhost0->mdata_ip6_addr();
152-
if (!NetlinkAddVhostIp(ipv6_service_address_)) {
153-
LOG(ERROR, "An error has occured during binding IPv6 ll"
154-
" address to vhost0 in"
149+
if (!NetlinkGetVhostIp(ipv6_service_address_)) {
150+
LOG(ERROR, "An error has occured during retrieving IPv6 ll"
151+
" address from vhost0 in"
155152
" MetadataProxy::InitializeHttp6Server");
156153
return;
157154
}
@@ -162,6 +159,41 @@ void MetadataProxy::InitializeHttp6Server(const VmInterface *vhost0) {
162159
http_server6_->Initialize(
163160
services_->agent()->metadata_server_port(),
164161
ipv6_service_address_, vhost_idx);
162+
AdvertiseVhostRoute();
163+
}
164+
165+
void MetadataProxy::AdvertiseVhostRoute() {
166+
PathPreference path_preference;
167+
EcmpLoadBalance ecmp_load_balance;
168+
169+
Agent *agent = services_->agent();
170+
171+
const VmInterface *vhost_intf =
172+
dynamic_cast<const VmInterface*>(agent->vhost_interface());
173+
174+
VnListType vn_list;
175+
vn_list.insert(agent->fabric_vn_name());
176+
177+
InetUnicastAgentRouteTable *table =
178+
static_cast<InetUnicastAgentRouteTable*>
179+
(agent->vrf_table()->GetInet6UnicastRouteTable(
180+
agent->fabric_vrf_name()));
181+
182+
table->AddLocalVmRouteReq(
183+
agent->link_local_peer(), agent->fabric_vrf_name(),
184+
Ipv6ServiceAddress(), 128, vhost_intf->GetUuid(),
185+
vn_list, vhost_intf->label(), SecurityGroupList(),
186+
TagList(), CommunityList(), true, path_preference,
187+
Ip6Address(), ecmp_load_balance, false, false, false,
188+
vhost_intf->name());
189+
}
190+
191+
void MetadataProxy::DeleteVhostRoute() {
192+
Agent *agent = services_->agent();
193+
194+
InetUnicastAgentRouteTable::Delete(agent->link_local_peer(),
195+
agent->fabric_vrf_name(),
196+
Ipv6ServiceAddress(), 128);
165197
}
166198

167199
void MetadataProxy::OnAVrfChange(DBTablePartBase *, DBEntryBase * entry) {
@@ -183,7 +215,6 @@ void MetadataProxy::OnAVrfChange(DBTablePartBase *, DBEntryBase * entry) {
183215
}
184216
}
185217
}
186-
// this->AdvertiseVhostRoute(vrf_entry);
187218
}
188219
}
189220

@@ -213,15 +244,6 @@ void MetadataProxy::OnAFabricRouteChange
213244
if (interface == NULL) {
214245
return;
215246
}
216-
const Ip6Address mip6 = interface->mdata_ip6_addr();
217-
218-
if (mip6 == route_entry->addr().to_v6()) {
219-
if (entry->IsDeleted()) {
220-
} else {
221-
// Create neighbours records (ip neigh add ...)
222-
this->NetlinkAddVhostNb(mip6, interface->vm_mac());
223-
}
224-
}
225247
}
226248

227249
void MetadataProxy::OnAnInterfaceChange(DBTablePartBase *, DBEntryBase *entry) {
@@ -238,10 +260,8 @@ void MetadataProxy::OnAnInterfaceChange(DBTablePartBase *, DBEntryBase *entry) {
238260
InitializeHttp6Server(vmi);
239261
}
240262

241-
if (vmi->IsDeleted() &&
242-
vmi->name() == services_->agent()->vhost_interface_name()) {
243-
NetlinkDelVhostIp(vmi->mdata_ip6_addr());
244-
return;
263+
if (vmi->IsDeleted() && vmi == services_->agent()->vhost_interface()) {
264+
this->DeleteVhostRoute();
245265
}
246266
}
247267

0 commit comments

Comments
 (0)