Search in sources :

Example 1 with NeighbourMessageContext

use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.

the class ArpHandler method validateArpSpa.

/**
 * Check if the source protocol address of an ARP packet belongs to the same
 * subnet configured on the port it is seen.
 *
 * @param pkt ARP packet and context information
 * @return true if the source protocol address belongs to the configured subnet
 */
private boolean validateArpSpa(NeighbourMessageContext pkt) {
    Ip4Address spa = pkt.sender().getIp4Address();
    Set<IpPrefix> subnet = config.getPortSubnets(pkt.inPort().deviceId(), pkt.inPort().port()).stream().filter(ipPrefix -> ipPrefix.isIp4() && ipPrefix.contains(spa)).collect(Collectors.toSet());
    return !subnet.isEmpty();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) Ip4Address(org.onlab.packet.Ip4Address) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) LoggerFactory(org.slf4j.LoggerFactory) ARP(org.onlab.packet.ARP) Set(java.util.Set) HostService(org.onosproject.net.host.HostService) Collectors(java.util.stream.Collectors) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) REQUEST(org.onosproject.net.neighbour.NeighbourMessageType.REQUEST) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) IpAddress(org.onlab.packet.IpAddress) NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) Ip4Address(org.onlab.packet.Ip4Address)

Example 2 with NeighbourMessageContext

use of org.onosproject.net.neighbour.NeighbourMessageContext in project onos by opennetworkinglab.

the class VplsNeighbourHandler method handleRequest.

/**
 * Handles request messages.
 *
 * @param context the message context
 */
protected void handleRequest(NeighbourMessageContext context) {
    // Find target VPLS first, then broadcast to all interface of this VPLS
    VplsData vplsData = findVpls(context);
    if (vplsData != null) {
        vplsData.interfaces().stream().filter(intf -> !context.inPort().equals(intf.connectPoint())).forEach(context::forward);
    } else {
        log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
        context.drop();
    }
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) VplsStore(org.onosproject.vpls.api.VplsStore) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) InterfaceService(org.onosproject.net.intf.InterfaceService) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Component(org.osgi.service.component.annotations.Component) ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate) NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) Collectors(java.util.stream.Collectors) NeighbourMessageHandler(org.onosproject.net.neighbour.NeighbourMessageHandler) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) VplsData(org.onosproject.vpls.api.VplsData)

Example 3 with NeighbourMessageContext

use of org.onosproject.net.neighbour.NeighbourMessageContext in project onos by opennetworkinglab.

the class NeighbourResolutionManager method handlePacket.

private void handlePacket(PacketContext context) {
    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    NeighbourMessageContext msgContext = DefaultNeighbourMessageContext.createContext(ethPkt, pkt.receivedFrom(), actions);
    if (msgContext == null) {
        return;
    }
    if (handleMessage(msgContext)) {
        context.block();
    }
}
Also used : NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) InboundPacket(org.onosproject.net.packet.InboundPacket) Ethernet(org.onlab.packet.Ethernet)

Example 4 with NeighbourMessageContext

use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.

the class SegmentRoutingNeighbourHandler method flood.

/*
     * Floods only on the port which have been configured with the subnet
     * of the target address. The in port is excluded.
     *
     * @param pkt the ndp/arp packet and context information
     */
protected void flood(NeighbourMessageContext pkt) {
    try {
        srManager.deviceConfiguration.getSubnetPortsMap(pkt.inPort().deviceId()).forEach((subnet, ports) -> {
            if (subnet.contains(pkt.target())) {
                ports.stream().filter(port -> port != pkt.inPort().port()).forEach(port -> {
                    ConnectPoint outPoint = new ConnectPoint(pkt.inPort().deviceId(), port);
                    pkt.forward(outPoint);
                });
            }
        });
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Cannot flood in subnet as device config not available" + " for device: " + pkt.inPort().deviceId());
    }
}
Also used : TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) Logger(org.slf4j.Logger) Host(org.onosproject.net.Host) VlanId(org.onlab.packet.VlanId) LoggerFactory(org.slf4j.LoggerFactory) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) HostService(org.onosproject.net.host.HostService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) HostId(org.onosproject.net.HostId) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) IpAddress(org.onlab.packet.IpAddress) NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) ConnectPoint(org.onosproject.net.ConnectPoint) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 5 with NeighbourMessageContext

use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.

the class IcmpHandler method isNdpForGateway.

/**
 * Utility to verify if the ND are for the gateway.
 *
 * @param pkt the ndp packet
 * @return true if the ndp is for the gateway. False otherwise
 */
private boolean isNdpForGateway(NeighbourMessageContext pkt) {
    DeviceId deviceId = pkt.inPort().deviceId();
    Set<IpAddress> gatewayIpAddresses = null;
    try {
        if (pkt.target().equals(config.getRouterIpv6(deviceId))) {
            return true;
        }
        gatewayIpAddresses = config.getPortIPs(deviceId);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting check for router IP in processing ndp");
        return false;
    }
    return gatewayIpAddresses != null && gatewayIpAddresses.stream().filter(IpAddress::isIp6).anyMatch(gatewayIp -> gatewayIp.equals(pkt.target()) || Arrays.equals(IPv6.getSolicitNodeAddress(gatewayIp.toOctets()), pkt.target().toOctets()));
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) ICMP6(org.onlab.packet.ICMP6) Arrays(java.util.Arrays) Interface(org.onosproject.net.intf.Interface) LoggerFactory(org.slf4j.LoggerFactory) HostService(org.onosproject.net.host.HostService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) NeighborSolicitation(org.onlab.packet.ndp.NeighborSolicitation) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) OutboundPacket(org.onosproject.net.packet.OutboundPacket) NeighbourMessageType(org.onosproject.net.neighbour.NeighbourMessageType) IpAddress(org.onlab.packet.IpAddress) NeighbourMessageContext(org.onosproject.net.neighbour.NeighbourMessageContext) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) ICMP(org.onlab.packet.ICMP) Collectors(java.util.stream.Collectors) IPv6(org.onlab.packet.IPv6) Objects(java.util.Objects) IPv4(org.onlab.packet.IPv4) MPLS(org.onlab.packet.MPLS) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DeviceId(org.onosproject.net.DeviceId) IpAddress(org.onlab.packet.IpAddress) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Aggregations

NeighbourMessageContext (org.onosproject.net.neighbour.NeighbourMessageContext)5 Ethernet (org.onlab.packet.Ethernet)4 MacAddress (org.onlab.packet.MacAddress)4 VlanId (org.onlab.packet.VlanId)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 HostService (org.onosproject.net.host.HostService)4 Logger (org.slf4j.Logger)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 IpAddress (org.onlab.packet.IpAddress)3 DeviceId (org.onosproject.net.DeviceId)3 DeviceConfigNotFoundException (org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)3 LoggerFactory (org.slf4j.LoggerFactory)3 ByteBuffer (java.nio.ByteBuffer)2 Objects (java.util.Objects)2 Ip4Address (org.onlab.packet.Ip4Address)2 Host (org.onosproject.net.Host)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 Interface (org.onosproject.net.intf.Interface)2