use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildUniIntents.
// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
});
return uniIntents;
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SimpleFabricNeighbour method handleRequest.
/**
* Handles request messages.
*
* @param context the message context
*/
protected void handleRequest(NeighbourMessageContext context) {
MacAddress mac = simpleFabric.vMacForIp(context.target());
if (mac != null) {
log.trace("simple fabric neightbour request on virtualGatewayAddress {}; response to {} {} mac={}", context.target(), context.inPort(), context.vlan(), mac);
context.reply(mac);
return;
}
// else forward to corresponding host
FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
if (fabricNetwork != null) {
int numForwards = 0;
if (!context.dstMac().isBroadcast() && !context.dstMac().isMulticast()) {
for (Host host : hostService.getHostsByMac(context.dstMac())) {
log.trace("simple fabric neightbour request forward unicast to {}", host.location());
// ASSUME: vlan is same
context.forward(host.location());
// TODO: may need to check host.location().time()
numForwards++;
}
if (numForwards > 0) {
return;
}
}
// else do broadcast to all host in the same l2 network
log.trace("simple fabric neightbour request forward broadcast: {} {}", context.inPort(), context.vlan());
for (Interface iface : fabricNetwork.interfaces()) {
if (!context.inPort().equals(iface.connectPoint())) {
log.trace("simple fabric forward neighbour request broadcast to {}", iface);
context.forward(iface);
}
}
} else {
log.warn("simple fabric neightbour request drop: {} {}", context.inPort(), context.vlan());
context.drop();
}
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class PeerConnectivityManagerTest method setUpInterfaces.
/**
* Sets up logical interfaces, which emulate the configured interfaces
* in the SDN-IP application.
*
* @return configured interfaces as a map from interface name to Interface
*/
private Map<String, Interface> setUpInterfaces() {
Map<String, Interface> configuredInterfaces = new HashMap<>();
String interfaceSw1Eth1 = "s1-eth1";
InterfaceIpAddress ia1 = new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"), IpPrefix.valueOf("192.168.10.0/24"));
Interface intfsw1eth1 = new Interface(interfaceSw1Eth1, s1Eth1, Collections.singletonList(ia1), MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE);
configuredInterfaces.put(interfaceSw1Eth1, intfsw1eth1);
String interfaceSw2Eth1 = "s2-eth1";
InterfaceIpAddress ia2 = new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), IpPrefix.valueOf("192.168.20.0/24"));
Interface intfsw2eth1 = new Interface(interfaceSw2Eth1, s2Eth1, Collections.singletonList(ia2), MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE);
configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1);
String interfaceSw2Eth1intf2 = "s2-eth1_2";
InterfaceIpAddress ia3 = new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), IpPrefix.valueOf("192.168.30.0/24"));
Interface intfsw2eth1intf2 = new Interface(interfaceSw2Eth1intf2, s2Eth1, Collections.singletonList(ia3), MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE);
configuredInterfaces.put(interfaceSw2Eth1intf2, intfsw2eth1intf2);
String interfaceSw3Eth1 = "s3-eth1";
InterfaceIpAddress ia4 = new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24"));
Interface intfsw3eth1 = new Interface(Interface.NO_INTERFACE_NAME, s3Eth1, ImmutableList.of(ia4), MacAddress.valueOf("00:00:00:00:00:04"), VLAN10);
configuredInterfaces.put(interfaceSw3Eth1, intfsw3eth1);
String interfaceSw3Eth1intf2 = "s3-eth1_2";
InterfaceIpAddress ia5 = new InterfaceIpAddress(IpAddress.valueOf("192.168.50.101"), IpPrefix.valueOf("192.168.50.0/24"));
Interface intfsw3eth1intf2 = new Interface(Interface.NO_INTERFACE_NAME, s3Eth1, ImmutableList.of(ia5), MacAddress.valueOf("00:00:00:00:00:05"), VLAN20);
configuredInterfaces.put(interfaceSw3Eth1intf2, intfsw3eth1intf2);
expect(interfaceService.getInterfacesByPort(s1Eth1)).andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101"))).andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1"))).andReturn(intfsw1eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(s2Eth1)).andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101"))).andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1"))).andReturn(intfsw2eth1).anyTimes();
expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101"))).andReturn(Collections.singleton(intfsw2eth1intf2)).anyTimes();
expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1"))).andReturn(intfsw2eth1intf2).anyTimes();
expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.40.101"))).andReturn(Collections.singleton(intfsw3eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.40.1"))).andReturn(intfsw3eth1).anyTimes();
expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.50.101"))).andReturn(Collections.singleton(intfsw3eth1intf2)).anyTimes();
expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.50.1"))).andReturn(intfsw3eth1intf2).anyTimes();
// Non-existent interface used during one of the tests
expect(interfaceService.getInterfacesByPort(new ConnectPoint(DeviceId.deviceId("of:0000000000000100"), PortNumber.portNumber(1)))).andReturn(null).anyTimes();
expect(interfaceService.getInterfaces()).andReturn(Sets.newHashSet(configuredInterfaces.values())).anyTimes();
return configuredInterfaces;
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SdnIpFibTest method setUpInterfaceService.
/**
* Sets up the interface service.
*/
private void setUpInterfaceService() {
List<InterfaceIpAddress> iIps1 = Lists.newArrayList();
iIps1.add(IIP1);
Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1, iIps1, MAC1, VLAN10);
interfaces.add(sw1Eth1);
List<InterfaceIpAddress> iIps2 = Lists.newArrayList();
iIps2.add(IIP2);
Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1, iIps2, MAC2, VLAN20);
interfaces.add(sw2Eth1);
List<InterfaceIpAddress> iIps3 = Lists.newArrayList();
iIps3.add(IIP3);
Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1, iIps3, MAC3, NO_VLAN);
interfaces.add(sw3Eth1);
expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(Collections.singleton(sw1Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IP1)).andReturn(sw1Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(Collections.singleton(sw2Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IP2)).andReturn(sw2Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(Collections.singleton(sw3Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(IP3)).andReturn(sw3Eth1).anyTimes();
expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class SdnIpFibTest method testRemoveIngressInterface.
/**
* Tests removing an existing interface.
*
* We first push an intent with destination sw3 and source sw1 and sw2. We
* then remove the ingress interface on sw1.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is withdrawn from the IntentService.
*/
@Test
public void testRemoveIngressInterface() {
// Add a route first
testRouteAddToNoVlan();
// Create the new expected intent
MultiPointToSinglePointIntent remainingIntent = createIntentToThreeSrcTwo(PREFIX1);
reset(intentSynchronizer);
intentSynchronizer.submit(eqExceptId(remainingIntent));
expectLastCall().once();
replay(intentSynchronizer);
// Define the existing ingress interface and remove it
Interface intf = new Interface("sw1-eth1", SW1_ETH1, Collections.singletonList(IIP1), MAC1, VLAN10);
InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
interfaceListener.event(intfEvent);
verify(intentSynchronizer);
}
Aggregations