Search in sources :

Example 1 with SegmentRoutingAppConfig

use of org.onosproject.segmentrouting.config.SegmentRoutingAppConfig in project trellis-control by opennetworkinglab.

the class AppConfigHandler method init.

/**
 * Populates initial vRouter and blackhole rules.
 *
 * @param deviceId device ID
 */
public void init(DeviceId deviceId) {
    SegmentRoutingAppConfig config = srManager.cfgService.getConfig(srManager.appId, SegmentRoutingAppConfig.class);
    populateVRouter(deviceId, getMacAddresses(config));
    if (config != null) {
        config.blackholeIPs().forEach(ipPrefix -> {
            srManager.routingRulePopulator.populateDefaultRouteBlackhole(deviceId, ipPrefix);
        });
    }
}
Also used : SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)

Example 2 with SegmentRoutingAppConfig

use of org.onosproject.segmentrouting.config.SegmentRoutingAppConfig in project trellis-control by opennetworkinglab.

the class AppConfigHandler method processAppConfigRemoved.

/**
 * Processes Segment Routing App Config removed event.
 *
 * @param event network config removed event
 */
protected void processAppConfigRemoved(NetworkConfigEvent event) {
    log.info("Processing AppConfig CONFIG_REMOVED");
    SegmentRoutingAppConfig prevConfig = (SegmentRoutingAppConfig) event.prevConfig().get();
    deviceService.getAvailableDevices().forEach(device -> {
        revokeVRouter(device.id(), getMacAddresses(prevConfig));
        prevConfig.blackholeIPs().forEach(ipPrefix -> {
            srManager.routingRulePopulator.removeDefaultRouteBlackhole(device.id(), ipPrefix);
        });
    });
}
Also used : SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)

Example 3 with SegmentRoutingAppConfig

use of org.onosproject.segmentrouting.config.SegmentRoutingAppConfig in project trellis-control by opennetworkinglab.

the class AppConfigHandler method processAppConfigAdded.

/**
 * Processes Segment Routing App Config added event.
 *
 * @param event network config added event
 */
protected void processAppConfigAdded(NetworkConfigEvent event) {
    log.info("Processing AppConfig CONFIG_ADDED");
    SegmentRoutingAppConfig config = (SegmentRoutingAppConfig) event.config().get();
    deviceService.getAvailableDevices().forEach(device -> {
        populateVRouter(device.id(), getMacAddresses(config));
        config.blackholeIPs().forEach(ipPrefix -> {
            srManager.routingRulePopulator.populateDefaultRouteBlackhole(device.id(), ipPrefix);
        });
    });
}
Also used : SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)

Example 4 with SegmentRoutingAppConfig

use of org.onosproject.segmentrouting.config.SegmentRoutingAppConfig in project trellis-control by opennetworkinglab.

the class ArpHandler method processPacketIn.

/**
 * Processes incoming ARP packets.
 *
 * If it is an ARP request to router itself or known hosts,
 * then it sends ARP response.
 * If it is an ARP request to unknown hosts in its own subnet,
 * then it flood the ARP request to the ports.
 * If it is an ARP response, then set a flow rule for the host
 * and forward any IP packets to the host in the packet buffer to the host.
 * <p>
 * Note: We handles all ARP packet in, even for those ARP packets between
 * hosts in the same subnet.
 * For an ARP packet with broadcast destination MAC,
 * some switches pipelines will send it to the controller due to table miss,
 * other switches will flood the packets directly in the data plane without
 * packet in.
 * We can deal with both cases.
 *
 * @param pkt incoming ARP packet and context information
 * @param hostService the host service
 */
public void processPacketIn(NeighbourMessageContext pkt, HostService hostService) {
    SegmentRoutingAppConfig appConfig = srManager.cfgService.getConfig(srManager.appId, SegmentRoutingAppConfig.class);
    if (appConfig != null && appConfig.suppressSubnet().contains(pkt.inPort())) {
        // Ignore ARP packets come from suppressed ports
        pkt.drop();
        return;
    }
    if (!validateArpSpa(pkt)) {
        log.debug("Ignore ARP packet discovered on {} with unexpected src protocol address {}.", pkt.inPort(), pkt.sender().getIp4Address());
        pkt.drop();
        return;
    }
    if (pkt.type() == REQUEST) {
        handleArpRequest(pkt, hostService);
    } else {
        handleArpReply(pkt, hostService);
    }
}
Also used : SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)

Example 5 with SegmentRoutingAppConfig

use of org.onosproject.segmentrouting.config.SegmentRoutingAppConfig in project trellis-control by opennetworkinglab.

the class McastUtils method getRouterMac.

/**
 * Get router mac using application config and the connect point.
 *
 * @param deviceId the device id
 * @param port the port number
 * @return the router mac if the port is configured, otherwise null
 */
private MacAddress getRouterMac(DeviceId deviceId, PortNumber port) {
    // Do nothing if the port is configured as suppressed
    ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
    SegmentRoutingAppConfig appConfig = srManager.cfgService.getConfig(srManager.appId(), SegmentRoutingAppConfig.class);
    if (appConfig != null && appConfig.suppressSubnet().contains(connectPoint)) {
        log.info("Ignore suppressed port {}", connectPoint);
        return MacAddress.NONE;
    }
    // Get the router mac using the device configuration
    MacAddress routerMac;
    try {
        routerMac = srManager.deviceConfiguration().getDeviceMac(deviceId);
    } catch (DeviceConfigNotFoundException dcnfe) {
        log.warn("Failed to get device MAC since the device {} is not configured", deviceId);
        return null;
    }
    return routerMac;
}
Also used : SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Aggregations

SegmentRoutingAppConfig (org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IpPrefix (org.onlab.packet.IpPrefix)2 MacAddress (org.onlab.packet.MacAddress)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 EasyMock (org.easymock.EasyMock)1 Is.is (org.hamcrest.core.Is.is)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Ethernet (org.onlab.packet.Ethernet)1 ICMP (org.onlab.packet.ICMP)1 ICMP6 (org.onlab.packet.ICMP6)1 ECHO_REPLY (org.onlab.packet.ICMP6.ECHO_REPLY)1 IPv4 (org.onlab.packet.IPv4)1 IPv6 (org.onlab.packet.IPv6)1