use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class FibInstaller method updateFilteringObjective.
/**
* Installs or removes unicast filtering objectives relating to an interface.
*
* @param routerIntf interface to update objectives for
* @param install true to install the objectives, false to remove them
*/
private void updateFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
Interface intf = routerIntf.intf();
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan();
FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
// first add filter for the interface
fob.withKey(Criteria.matchInPort(intf.connectPoint().port())).addCondition(Criteria.matchEthDst(intf.mac())).addCondition(Criteria.matchVlanId(intf.vlan()));
fob.withPriority(PRIORITY_OFFSET);
if (intf.vlan() == VlanId.NONE) {
TrafficTreatment tt = DefaultTrafficTreatment.builder().pushVlan().setVlanId(assignedVlan).build();
fob.withMeta(tt);
}
fob.permit().fromApp(fibAppId);
sendFilteringObjective(install, fob, intf);
// then add the same mac/vlan filters for control-plane connect point
fob.withKey(Criteria.matchInPort(routerIntf.controlPlaneConnectPoint().port()));
sendFilteringObjective(install, fob, intf);
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class FibInstallerTest method setUpInterfaceService.
/**
* Sets up InterfaceService.
*/
private void setUpInterfaceService() {
interfaceService.addListener(anyObject(InterfaceListener.class));
expectLastCall().andDelegateTo(new TestInterfaceService());
// Interface with no VLAN
Interface sw1Eth1 = new Interface("intf1", SW1_ETH1, Collections.singletonList(INTF1), MAC1, VlanId.NONE);
expect(interfaceService.getMatchingInterface(NEXT_HOP1)).andReturn(sw1Eth1);
interfaces.add(sw1Eth1);
// Interface with a VLAN
Interface sw2Eth1 = new Interface("intf2", SW1_ETH2, Collections.singletonList(INTF2), MAC2, VLAN1);
expect(interfaceService.getMatchingInterface(NEXT_HOP2)).andReturn(sw2Eth1);
interfaces.add(sw2Eth1);
expect(interfaceService.getInterfaces()).andReturn(interfaces);
replay(interfaceService);
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class DirectHostManager method handle.
private boolean handle(Ethernet eth) {
checkNotNull(eth);
// skip them.
if (!enabled || (eth.getEtherType() != Ethernet.TYPE_IPV6 && eth.getEtherType() != Ethernet.TYPE_IPV4)) {
return false;
}
// According to the type we set the destIp.
IpAddress dstIp;
if (eth.getEtherType() == Ethernet.TYPE_IPV4) {
IPv4 ip = (IPv4) eth.getPayload();
dstIp = IpAddress.valueOf(ip.getDestinationAddress());
} else {
IPv6 ip = (IPv6) eth.getPayload();
dstIp = IpAddress.valueOf(INET6, ip.getDestinationAddress());
}
// Looking for a candidate output port.
Interface egressInterface = interfaceService.getMatchingInterface(dstIp);
if (egressInterface == null) {
log.info("No egress interface found for {}", dstIp);
return false;
}
// Looking for the destination mac.
Optional<Host> host = hostService.getHostsByIp(dstIp).stream().filter(h -> h.location().equals(egressInterface.connectPoint())).filter(h -> h.vlan().equals(egressInterface.vlan())).findAny();
// and we queue the packets waiting for a destination.
if (host.isPresent()) {
transformAndSend((IP) eth.getPayload(), eth.getEtherType(), egressInterface, host.get().mac());
} else {
hostService.startMonitoringIp(dstIp);
ipPacketCache.asMap().compute(dstIp, (ip, queue) -> {
if (queue == null) {
queue = new ConcurrentLinkedQueue<>();
}
queue.add((IP) eth.getPayload());
return queue;
});
}
return true;
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class PimInterfaceManager method updateInterface.
private void updateInterface(PimInterfaceConfig config) {
ConnectPoint cp = config.subject();
if (!config.isEnabled()) {
removeInterface(cp);
return;
}
String intfName = config.getInterfaceName();
Interface intf = interfaceService.getInterfaceByName(cp, intfName);
if (intf == null) {
log.debug("Interface configuration missing: {}", config.getInterfaceName());
return;
}
log.debug("Updating Interface for " + intf.connectPoint().toString());
pimInterfaces.computeIfAbsent(cp, k -> buildPimInterface(config, intf));
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class PimInterfaceManager method getSourceInterface.
private PimInterface getSourceInterface(McastRoute route) {
Route unicastRoute = unicastRouteService.longestPrefixMatch(route.source());
if (unicastRoute == null) {
log.warn("No route to source {}", route.source());
return null;
}
Interface intf = interfaceService.getMatchingInterface(unicastRoute.nextHop());
if (intf == null) {
log.warn("No interface with route to next hop {}", unicastRoute.nextHop());
return null;
}
PimInterface pimInterface = pimInterfaces.get(intf.connectPoint());
if (pimInterface == null) {
log.warn("PIM is not enabled on interface {}", intf);
return null;
}
Set<Host> hosts = hostService.getHostsByIp(unicastRoute.nextHop());
Host host = null;
for (Host h : hosts) {
if (h.vlan().equals(intf.vlan())) {
host = h;
}
}
if (host == null) {
log.warn("Next hop host entry not found: {}", unicastRoute.nextHop());
return null;
}
pimInterface.addRoute(route, unicastRoute.nextHop(), host.mac());
return pimInterface;
}
Aggregations