use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class PeerConnectivityManager method buildSpeakerIntents.
private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker, EncapsulationType encap) {
List<PointToPointIntent> intents = new ArrayList<>();
// Get the BGP Speaker VLAN Id
VlanId bgpSpeakerVlanId = speaker.vlan();
for (IpAddress peerAddress : speaker.peers()) {
Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress);
if (peeringInterface == null) {
log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker);
continue;
}
IpAddress bgpSpeakerAddress = null;
for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
if (address.subnetAddress().contains(peerAddress)) {
bgpSpeakerAddress = address.ipAddress();
break;
}
}
checkNotNull(bgpSpeakerAddress);
VlanId peerVlanId = peeringInterface.vlan();
intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress, encap));
}
return intents;
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SdnIpFib method generateRouteIntent.
/**
* Generates a route intent for a prefix, the next hop IP address, and
* the next hop MAC address.
* <p/>
* This method will find the egress interface for the intent.
* Intent will match dst IP prefix and rewrite dst MAC address at all other
* border switches, then forward packets according to dst MAC address.
*
* @param prefix the IP prefix of the route to add
* @param nextHopIpAddress the IP address of the next hop
* @param nextHopMacAddress the MAC address of the next hop
* @param encap the encapsulation type in use
* @return the generated intent, or null if no intent should be submitted
*/
private MultiPointToSinglePointIntent generateRouteIntent(IpPrefix prefix, IpAddress nextHopIpAddress, MacAddress nextHopMacAddress, EncapsulationType encap) {
// Find the attachment point (egress interface) of the next hop
Interface egressInterface = interfaceService.getMatchingInterface(nextHopIpAddress);
if (egressInterface == null) {
log.warn("No outgoing interface found for {}", nextHopIpAddress);
return null;
}
ConnectPoint egressPort = egressInterface.connectPoint();
log.debug("Generating intent for prefix {}, next hop mac {}", prefix, nextHopMacAddress);
Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
// TODO this should be only peering interfaces
interfaceService.getInterfaces().forEach(intf -> {
// Get ony ingress interfaces with IPs configured
if (validIngressIntf(intf, egressInterface)) {
TrafficSelector.Builder selector = buildIngressTrafficSelector(intf, prefix);
FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(intf.connectPoint(), selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
}
});
// Build treatment: rewrite the destination MAC address
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setEthDst(nextHopMacAddress);
// Build the egress selector for VLAN Id
TrafficSelector.Builder selector = buildTrafficSelector(egressInterface);
FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(egressPort, selector.build());
// Set priority
int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
// Set key
Key key = Key.of(prefix.toString(), appId);
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatment.build()).priority(priority).constraints(CONSTRAINTS);
setEncap(intentBuilder, CONSTRAINTS, encap);
return intentBuilder.build();
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SdnIpFibTest method testAddInterface.
/**
* Tests adding a new interface.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is withdrawn from the IntentService.
*/
@Test
public void testAddInterface() {
// Add a route first
testRouteAddToNoVlan();
// Create the new expected intent
MultiPointToSinglePointIntent addedIntent = createIntentToThreeSrcOneTwoFour(PREFIX1);
reset(intentSynchronizer);
intentSynchronizer.submit(eqExceptId(addedIntent));
expectLastCall().once();
replay(intentSynchronizer);
// Create the new interface and add notify it
Interface intf = new Interface("sw4-eth1", SW4_ETH1, Collections.singletonList(IIP4), MAC4, NO_VLAN);
InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, intf);
interfaceListener.event(intfEvent);
verify(intentSynchronizer);
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SdnIpFibTest method testRemoveEgressInterface.
/**
* Tests removing an existing egress interface.
*
* We first push an intent with destination sw3 and source sw1 and sw2. We
* then remove the egress interface on sw3.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is withdrawn from the IntentService.
*/
@Test
public void testRemoveEgressInterface() {
// Add a route first
testRouteAddToNoVlan();
// Create existing intent
MultiPointToSinglePointIntent removedIntent = createIntentToThreeSrcOneTwo(PREFIX1);
// Set up expectation
reset(intentSynchronizer);
// Setup the expected intents
intentSynchronizer.withdraw(eqExceptId(removedIntent));
replay(intentSynchronizer);
// Define the existing egress interface and remove it
Interface intf = new Interface("sw3-eth1", SW3_ETH1, Collections.singletonList(IIP3), MAC3, VlanId.NONE);
InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
interfaceListener.event(intfEvent);
verify(intentSynchronizer);
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class DefaultFabricNetworkTest method createInterface.
private static Interface createInterface(int index) {
String name = "INTF_NAME_" + index;
ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index);
InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32");
InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32");
List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2);
MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00");
VlanId vlanId = VlanId.NONE;
return new Interface(name, cp, intfIps, mac, vlanId);
}
Aggregations