public static final String ODL = "org.opendaylight.controller";
public static final String YANG = "org.opendaylight.yangtools";
- private static final int MULTI_SITE_SLEEP_TIME = 1;
+ private static final int MULTI_SITE_SLEEP_TIME = 2;
private static final int MAX_NOTIFICATION_RETRYS = 20;
private static final MappingAuthkey NULL_AUTH_KEY = new MappingAuthkeyBuilder().setKeyType(0).build();
multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
//TEST CASE 2
- //following action should trigger generatting of SMR messages:
+ //following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.1/32
multiSiteScenario.storeNorthMappingSrcDst(SITE_A, SITE_C);
multiSiteScenario.assertPingFails(SITE_D4, 5, SITE_C, 4);
//TEST CASE 3
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.1/32
// 3) 192.0.1.5/32
multiSiteScenario.assertPingWorks(SITE_D4, 5, SITE_C, 4);
//TEST CASE 4
- // following action should trigger generatting of SMR messages:
- // 1) 192.0.4.5/32
+ // following action should trigger generating of SMR messages:
+ // 1) 192.0.2.5/32
+ // 2) 192.0.1.1/32
+ // 3) 192.0.1.5/32
+ // 4) 192.0.4.5/32
multiSiteScenario.storeNorthMappingSrcDst(SITE_B, SITE_C_RLOC_10);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D4.getHost(5));
+ multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B.getHost(5), SITE_A.getHost(1),
+ SITE_A.getHost(5), SITE_D4.getHost(5));
//way of testing ping - get RLOC for mapping src-dst and compare it with awaited value doesn't test
//that ping won't be successfull
multiSiteScenario.assertPingFails(SITE_B, 5, SITE_C, 4);
//TEST CASE 5
- // following action should trigger generatting of SMR messages:
- // 1) 192.0.4.5/32
- // 2) 192.0.2.5/32
+ // following action should trigger generating of SMR messages:
+ // 1) 192.0.2.5/32
+ // 2) 192.0.1.1/32
+ // 3) 192.0.1.5/32
+ // 4) 192.0.4.5/32
multiSiteScenario.storeNorthMappingNegative(SITE_C, Action.Drop);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D4.getHost(5), SITE_B.getHost(5));
+ multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B.getHost(5), SITE_A.getHost(1),
+ SITE_A.getHost(5), SITE_D4.getHost(5));
multiSiteScenario.assertPingFails(SITE_D4, 5, SITE_C, 4);
//TEST CASE 6
multiSiteScenario.assertPingFails(SITE_D5, 5, SITE_C, 3);
//TEST CASE 7
- multiSiteScenario.deleteNorthMapingSrcDst(SITE_A, SITE_C);
- sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.4.5/32
// 2) 192.0.2.5/32
// 3) 192.0.5.5/32
+ // 4) 192.0.1.5/32
+ // 5) 192.0.1.1/32
+ multiSiteScenario.deleteNorthMapingSrcDst(SITE_A, SITE_C);
+ sleepForSeconds(MULTI_SITE_SLEEP_TIME);
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
- SITE_B.getHost(5));
+ SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.4.5/32
// 2) 192.0.2.5/32
// 3) 192.0.5.5/32
+ // 4) 192.0.1.5/32
+ // 5) 192.0.1.1/32
multiSiteScenario.storeNorthMappingSrcDst(SITE_B, SITE_C);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
- SITE_B.getHost(5));
+ SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
multiSiteScenario.assertPingWorks(SITE_B, 5, SITE_C, 4);
multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
//TEST CASE 8
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.4.5/32
// 2) 192.0.2.5/32
// 3) 192.0.5.5/32
- // 4) 192.0.1.1/32
+ // 4) 192.0.1.5/32
+ // 5) 192.0.1.1/32
multiSiteScenario.deleteNorthMapingSrcDst(SITE_B, SITE_C);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
- SITE_B.getHost(5),
- SITE_A.getHost(1));
+ SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
multiSiteScenario.assertPingFails(SITE_B, 5, SITE_C, 4);
multiSiteScenario.assertPingFails(SITE_A, 1, SITE_C, 4);
//TEST CASE 9
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.4.5/32
// 2) 192.0.2.5/32
// 3) 192.0.5.5/32
- // 4) 192.0.1.1/32
+ // 4) 192.0.1.5/32
+ // 5) 192.0.1.1/32
multiSiteScenario.deleteNorthMappingNegative(SITE_C);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_D5.getHost(5), SITE_D4.getHost(5),
- SITE_B.getHost(5),
- SITE_A.getHost(1));
+ SITE_B.getHost(5), SITE_A.getHost(1), SITE_A.getHost(5));
multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_B, 4);
multiSiteScenario.assertPingWorks(SITE_B, 5, SITE_C, 4);
multiSiteScenario.assertPingWorks(SITE_A, 5, SITE_C, 4);
multiSiteScenario.assertPingWorks(SITE_B_SB, 5, SITE_C_WP_50_2_SB, 4, SITE_D_WP_50_2_SB);
//TEST CASE 2
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.storeNorthMappingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB, SITE_D_WP_50_2_SB);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.storeNorthMappingNegative(SITE_C_SB, Action.Drop);
//TEST CASE 3
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.storeNorthMappingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB);
//TEST CASE 4
multiSiteScenario.storeNorthMappingSrcDst(SITE_B_SB, SITE_C_WP_50_2_SB, SITE_D_WP_50_2_SB);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
//TEST CASE 5
multiSiteScenario.deleteSouthboundMappings(SITE_D_DELETE_SB);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
//TEST CASE 6
multiSiteScenario.deleteNorthMapingSrcDst(SITE_A_SB, SITE_C_WP_50_2_SB);
sleepForSeconds(MULTI_SITE_SLEEP_TIME);
- // following action should trigger generatting of SMR messages:
+ // following action should trigger generating of SMR messages:
// 1) 192.0.2.5/32
// 2) 192.0.1.5/32
multiSiteScenario.checkSMR(socketReader, SITE_C.getEidPrefix(), SITE_B_SB.getHost(5), SITE_A_SB.getHost(5));
import org.opendaylight.lispflowmapping.lisp.type.MappingData;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
+import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
return lms.handleMapRequest(mapRequestBuilder.build());
}
+ /**
+ * This method expects a SMR Map-Request as input, which it will turn into a SMR-invoked Map-Request and use the
+ * LISP mapping service to send it
+ *
+ * @param mapRequest the SMR Map-Request
+ */
+ private void emitSMRInvokedMapRequestMessage(MapRequest mapRequest) {
+ if (mapRequest.getEidItem().isEmpty()) {
+ fail("Empty SMR received!");
+ }
+
+ Eid srcEid = addMaximumPrefixIfNecessary(mapRequest.getSourceEid().getEid());
+ final EidItemBuilder eidItemBuilder = new EidItemBuilder();
+ eidItemBuilder.setEid(srcEid);
+ eidItemBuilder.setEidItemId(LispAddressStringifier.getString(srcEid));
+ final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
+
+ final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder(mapRequest);
+ mapRequestBuilder.setSmr(false);
+ mapRequestBuilder.setSmrInvoked(true);
+ mapRequestBuilder.setItrRloc(prepareDummyItrRloc());
+ mapRequestBuilder.setEidItem(eidItem);
+ for (EidItem ei : mapRequest.getEidItem()) {
+ mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(ei.getEid()).build());
+ LOG.debug("Sending SMR-invoked Map-Reqeust for EID {}, Source EID {}",
+ LispAddressStringifier.getString(srcEid),
+ LispAddressStringifier.getString(ei.getEid()));
+ lms.handleMapRequest(mapRequestBuilder.build());
+ }
+ }
+
+ /*
+ * Since the Source EID field from a Map-Request packet does not have a prefix length field, IPv4 and IPv6 addresses
+ * are serialized into Ipv4Binary and Ipv6Binary objects. However, when we want to use the addresses in a
+ * SMR-invoked Map-Request, we need to use an Ipv4PrefixBinary or Ipv6PrefixBinary object respectively, since that's
+ * what the EID item field would be deserialized into.
+ */
+ private static Eid addMaximumPrefixIfNecessary(Eid eid) {
+ Address address = eid.getAddress();
+ if (address instanceof Ipv4Binary) {
+ return LispAddressUtil.asIpv4PrefixBinaryEid(
+ eid, ((Ipv4Binary) address).getIpv4Binary().getValue(), MaskUtil.IPV4_MAX_MASK);
+ } else if (address instanceof Ipv6Binary) {
+ return LispAddressUtil.asIpv6PrefixBinaryEid(
+ eid, ((Ipv6Binary) address).getIpv6Binary().getValue(), MaskUtil.IPV6_MAX_MASK);
+ }
+ return eid;
+ }
+
private List<ItrRloc> prepareDummyItrRloc() {
List<ItrRloc> itrRlocs = new ArrayList<>();
final ItrRlocBuilder itrRlocBuilder = new ItrRlocBuilder();
final List<EidItem> currentEidItems = mapRequest.getEidItem();
assertNotNull(currentEidItems);
assertTrue(SMRContainsExpectedEid(eids, currentEidItems));
+ emitSMRInvokedMapRequestMessage(mapRequest);
}
//all expected eids should be after looping via mapRequests matched.
assertTrue("Expected eids wasn't/weren't found " + eids, eids.isEmpty());
void smrReceived(SmrEvent event) {
final List<Subscriber> subscriberList = event.getSubscriberList();
for (Subscriber subscriber : subscriberList) {
- LOG.trace("SMR-invoked event, EID {}, subscriber {}", LispAddressStringifier.getString(event.getEid()),
- subscriber.getString());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("SMR-invoked event, EID {}, subscriber {}",
+ LispAddressStringifier.getString(event.getEid()),
+ subscriber.getString());
+ LOG.trace("eidFutureMap: {}", eidFutureMap);
+ }
final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(event.getEid());
if (subscriberFutureMap != null) {
final ScheduledFuture<?> future = subscriberFutureMap.get(subscriber);
if (future != null && !future.isCancelled()) {
future.cancel(true);
- LOG.debug("SMR-invoked MapRequest received, scheduled task for subscriber {}, EID {} with"
- + " nonce {} has been cancelled", subscriber.getString(),
- LispAddressStringifier.getString(event.getEid()), event.getNonce());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SMR-invoked MapRequest received, scheduled task for subscriber {}, EID {} with"
+ + " nonce {} has been cancelled", subscriber.getString(),
+ LispAddressStringifier.getString(event.getEid()), event.getNonce());
+ }
subscriberFutureMap.remove(subscriber);
+ } else {
+ if (future == null) {
+ LOG.trace("No outstanding SMR tasks for EID {}, subscriber {}",
+ LispAddressStringifier.getString(event.getEid()), subscriber.getString());
+ } else {
+ LOG.trace("Future {} is cancelled", future);
+ }
}
if (subscriberFutureMap.isEmpty()) {
eidFutureMap.remove(event.getEid());
}
+ } else {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("No outstanding SMR tasks for EID {}",
+ LispAddressStringifier.getString(event.getEid()));
+ }
}
}
}