@@ -143,15 +143,12 @@ const Ip6Address& MetadataProxy::Ipv6ServiceAddress() const {
143
143
144
144
void MetadataProxy::InitializeHttp6Server (const VmInterface *vhost0) {
145
145
if (vhost0 == NULL ||
146
- vhost0->mdata_ip6_addr ().is_unspecified () ||
147
- !vhost0->mdata_ip6_addr ().is_link_local () ||
148
146
!ipv6_service_address_.is_unspecified ()) {
149
147
return ;
150
148
}
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"
155
152
" MetadataProxy::InitializeHttp6Server" );
156
153
return ;
157
154
}
@@ -162,6 +159,41 @@ void MetadataProxy::InitializeHttp6Server(const VmInterface *vhost0) {
162
159
http_server6_->Initialize (
163
160
services_->agent ()->metadata_server_port (),
164
161
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 );
165
197
}
166
198
167
199
void MetadataProxy::OnAVrfChange (DBTablePartBase *, DBEntryBase * entry) {
@@ -183,7 +215,6 @@ void MetadataProxy::OnAVrfChange(DBTablePartBase *, DBEntryBase * entry) {
183
215
}
184
216
}
185
217
}
186
- // this->AdvertiseVhostRoute(vrf_entry);
187
218
}
188
219
}
189
220
@@ -213,15 +244,6 @@ void MetadataProxy::OnAFabricRouteChange
213
244
if (interface == NULL ) {
214
245
return ;
215
246
}
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
- }
225
247
}
226
248
227
249
void MetadataProxy::OnAnInterfaceChange (DBTablePartBase *, DBEntryBase *entry) {
@@ -238,10 +260,8 @@ void MetadataProxy::OnAnInterfaceChange(DBTablePartBase *, DBEntryBase *entry) {
238
260
InitializeHttp6Server (vmi);
239
261
}
240
262
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 ();
245
265
}
246
266
}
247
267
0 commit comments