use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFib method encapUpdate.
/*
* Triggered when the network configuration configuration is modified.
* It checks if the encapsulation type has changed from last time, and in
* case modifies all intents.
*/
private void encapUpdate() {
synchronized (this) {
// Get the encapsulation type just set from the configuration
EncapsulationType encap = encap();
for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
// Get each intent currently registered by SDN-IP
MultiPointToSinglePointIntent intent = entry.getValue();
// Make sure the same constraint is not already part of the
// intent constraints
List<Constraint> constraints = intent.constraints();
if (!constraints.stream().filter(c -> c instanceof EncapsulationConstraint && new EncapsulationConstraint(encap).equals(c)).findAny().isPresent()) {
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder(intent);
// Set the new encapsulation constraint
setEncap(intentBuilder, constraints, encap);
// Build and submit the new intent
MultiPointToSinglePointIntent newIntent = intentBuilder.build();
routeIntents.put(entry.getKey(), newIntent);
intentSynchronizer.submit(newIntent);
}
}
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFib method update.
private void update(ResolvedRoute route) {
synchronized (this) {
IpPrefix prefix = route.prefix();
EncapsulationType encap = encap();
MultiPointToSinglePointIntent intent = generateRouteIntent(prefix, route.nextHop(), route.nextHopMac(), encap);
if (intent == null) {
log.debug("No interface found for route {}", route);
return;
}
routeIntents.put(prefix, intent);
intentSynchronizer.submit(intent);
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFib method removeInterface.
/*
* Handles the case in which an existing interface gets removed.
*/
private void removeInterface(Interface intf) {
synchronized (this) {
for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
// Retrieve the IP prefix and intent possibly affected
IpPrefix prefix = entry.getKey();
MultiPointToSinglePointIntent intent = entry.getValue();
// The interface removed might be an ingress interface, so the
// selector needs to match on the interface tagging params and
// on the prefix
TrafficSelector.Builder ingressSelector = buildIngressTrafficSelector(intf, prefix);
FilteredConnectPoint removedIngressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), ingressSelector.build());
// The interface removed might be an egress interface, so the
// selector needs to match only on the interface tagging params
TrafficSelector.Builder selector = buildTrafficSelector(intf);
FilteredConnectPoint removedEgressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), selector.build());
if (intent.filteredEgressPoint().equals(removedEgressFilteredCP)) {
// The interface is an egress interface for the intent.
// This intent just lost its head. Remove it and let higher
// layer routing reroute
intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
} else {
if (intent.filteredIngressPoints().contains(removedIngressFilteredCP)) {
// The FilteredConnectPoint is an ingress
// FilteredConnectPoint for the intent
Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet(intent.filteredIngressPoints());
// Remove FilteredConnectPoint from the existing set
ingressFilteredCPs.remove(removedIngressFilteredCP);
if (!ingressFilteredCPs.isEmpty()) {
// There are still ingress points. Create a new
// intent and resubmit
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder(intent).filteredIngressPoints(ingressFilteredCPs).build();
routeIntents.put(entry.getKey(), newIntent);
intentSynchronizer.submit(newIntent);
} else {
// No more ingress FilteredConnectPoint. Withdraw
// the intent
intentSynchronizer.withdraw(routeIntents.remove(entry.getKey()));
}
}
}
}
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testRouteAddToNoVlan.
/**
* Tests adding a route. The egress interface has no VLAN configured.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is submitted to the IntentService.
*/
@Test
public void testRouteAddToNoVlan() {
// Build the expected route
ResolvedRoute route = createRoute(PREFIX1, IP3, MAC3);
MultiPointToSinglePointIntent intent = createIntentToThreeSrcOneTwo(PREFIX1);
// Setup the expected intents
intentSynchronizer.submit(eqExceptId(intent));
replay(intentSynchronizer);
// Send in the added event
routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
verify(intentSynchronizer);
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testRouteAddToVlan.
/**
* Tests adding a route. The egress interface has a VLAN configured.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is submitted to the IntentService.
*/
@Test
public void testRouteAddToVlan() {
// Build the expected route
ResolvedRoute route = createRoute(PREFIX2, IP1, MAC1);
MultiPointToSinglePointIntent intent = createIntentToOne(PREFIX2);
// Setup the expected intents
intentSynchronizer.submit(eqExceptId(intent));
replay(intentSynchronizer);
// Send in the added event
routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
verify(intentSynchronizer);
}
Aggregations