Pavlin Radoslavov

Fixes related to SDN-IP intents:

 * Use intent priority when installing multipoint-to-singlepoint intents:
   the loinger the routing prefix match, the higher the intent priority.
   This is needed to perform correctly the equivalent of longest prefix
   match in the switch.
 * Use intent priority for the point-to-point intents: the priority for
   this BGP-related control traffic is higher than the
   multipoint-to-singlepoint intents.

 * Use the appropriate Key when installing multipoint-to-singlepoint intents.
   The key is the network (destination routing) prefix address represented
   as a string.

Change-Id: Ic489a1e5f31adceb4c9d1dcea52293a2b3db0b79
......@@ -32,6 +32,7 @@ import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.routing.FibListener;
......@@ -43,6 +44,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -62,6 +64,9 @@ import static com.google.common.base.Preconditions.checkArgument;
* IntentService.
*/
public class IntentSynchronizer implements FibListener {
private static final int PRIORITY_OFFSET = 100;
private static final int PRIORITY_MULTIPLIER = 5;
private static final Logger log =
LoggerFactory.getLogger(IntentSynchronizer.class);
......@@ -332,9 +337,14 @@ public class IntentSynchronizer implements FibListener {
selector.matchVlanId(VlanId.ANY);
}
return new MultiPointToSinglePointIntent(appId, selector.build(),
int priority =
prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
Key key = Key.of(prefix.toString(), appId);
return new MultiPointToSinglePointIntent(appId, key, selector.build(),
treatment.build(),
ingressPorts, egressPort);
ingressPorts, egressPort,
Collections.emptyList(),
priority);
}
@Override
......
......@@ -37,12 +37,14 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Manages the connectivity requirements between peers.
*/
public class PeerConnectivityManager {
private static final int PRIORITY_OFFSET = 1000;
private static final Logger log = LoggerFactory.getLogger(
PeerConnectivityManager.class);
......@@ -188,8 +190,13 @@ public class PeerConnectivityManager {
null,
BGP_PORT);
int priority = PRIORITY_OFFSET;
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdConnectPoint, bgpdPeerConnectPoint));
bgpdConnectPoint,
bgpdPeerConnectPoint,
Collections.emptyList(),
priority));
// Path from BGP speaker to BGP peer matching source TCP port 179
selector = buildSelector(tcpProtocol,
......@@ -199,7 +206,10 @@ public class PeerConnectivityManager {
null);
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdConnectPoint, bgpdPeerConnectPoint));
bgpdConnectPoint,
bgpdPeerConnectPoint,
Collections.emptyList(),
priority));
// Path from BGP peer to BGP speaker matching destination TCP port 179
selector = buildSelector(tcpProtocol,
......@@ -209,7 +219,10 @@ public class PeerConnectivityManager {
BGP_PORT);
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdPeerConnectPoint, bgpdConnectPoint));
bgpdPeerConnectPoint,
bgpdConnectPoint,
Collections.emptyList(),
priority));
// Path from BGP peer to BGP speaker matching source TCP port 179
selector = buildSelector(tcpProtocol,
......@@ -219,7 +232,10 @@ public class PeerConnectivityManager {
null);
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdPeerConnectPoint, bgpdConnectPoint));
bgpdPeerConnectPoint,
bgpdConnectPoint,
Collections.emptyList(),
priority));
// ICMP path from BGP speaker to BGP peer
selector = buildSelector(icmpProtocol,
......@@ -229,7 +245,10 @@ public class PeerConnectivityManager {
null);
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdConnectPoint, bgpdPeerConnectPoint));
bgpdConnectPoint,
bgpdPeerConnectPoint,
Collections.emptyList(),
priority));
// ICMP path from BGP peer to BGP speaker
selector = buildSelector(icmpProtocol,
......@@ -239,7 +258,10 @@ public class PeerConnectivityManager {
null);
intents.add(new PointToPointIntent(appId, selector, treatment,
bgpdPeerConnectPoint, bgpdConnectPoint));
bgpdPeerConnectPoint,
bgpdConnectPoint,
Collections.emptyList(),
priority));
return intents;
}
......