Search in sources :

Example 71 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class FibInstaller method addNextHop.

private synchronized void addNextHop(ResolvedRoute route) {
    prefixToNextHop.put(route.prefix(), route.nextHop());
    if (nextHopsCount.count(route.nextHop()) == 0) {
        // There was no next hop in the multiset
        Interface egressIntf = interfaceService.getMatchingInterface(route.nextHop());
        if (egressIntf == null) {
            log.warn("no egress interface found for {}", route);
            return;
        }
        NextHopGroupKey groupKey = new NextHopGroupKey(route.nextHop());
        NextHop nextHop = new NextHop(route.nextHop(), route.nextHopMac(), groupKey);
        TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setEthSrc(egressIntf.mac()).setEthDst(nextHop.mac());
        TrafficSelector.Builder metabuilder = null;
        if (!egressIntf.vlan().equals(VlanId.NONE)) {
            treatment.pushVlan().setVlanId(egressIntf.vlan()).setVlanPcp((byte) 0);
        } else {
            // untagged outgoing port may require internal vlan in some pipelines
            metabuilder = DefaultTrafficSelector.builder();
            metabuilder.matchVlanId(VlanId.vlanId(ASSIGNED_VLAN));
        }
        treatment.setOutput(egressIntf.connectPoint().port());
        int nextId = flowObjectiveService.allocateNextId();
        NextObjective.Builder nextBuilder = DefaultNextObjective.builder().withId(nextId).addTreatment(treatment.build()).withType(NextObjective.Type.SIMPLE).fromApp(fibAppId);
        if (metabuilder != null) {
            nextBuilder.withMeta(metabuilder.build());
        }
        // TODO add callbacks
        NextObjective nextObjective = nextBuilder.add();
        flowObjectiveService.next(deviceId, nextObjective);
        nextHops.put(nextHop.ip(), nextId);
        if (routeToNextHop) {
            // Install route to next hop
            ForwardingObjective fob = generateRibForwardingObj(IpPrefix.valueOf(route.nextHop(), 32), nextId).add();
            flowObjectiveService.forward(deviceId, fob);
        }
    }
    nextHopsCount.add(route.nextHop());
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) NextHop(org.onosproject.routing.NextHop) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) NextHopGroupKey(org.onosproject.routing.NextHopGroupKey)

Example 72 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class FibInstallerTest method testRouteAddWithVlan.

/**
 * Tests adding a route with to a next hop in a VLAN.
 *
 * We verify that the flowObjectiveService records the correct state and that the
 * correct flowObjectiveService is submitted to the flowObjectiveService.
 */
@Test
public void testRouteAddWithVlan() {
    ResolvedRoute route = createRoute(PREFIX1, NEXT_HOP2, MAC2);
    // Create the next objective
    NextObjective nextObjective = createNextObjective(MAC2, MAC2, SW1_ETH2.port(), VLAN1, true);
    flowObjectiveService.next(DEVICE_ID, nextObjective);
    // Create the flow objective
    ForwardingObjective fwd = createForwardingObjective(PREFIX1, true);
    flowObjectiveService.forward(DEVICE_ID, fwd);
    EasyMock.expectLastCall().once();
    setUpFlowObjectiveService();
    // Send in the add event
    routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
    verify(flowObjectiveService);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) RouteEvent(org.onosproject.routeservice.RouteEvent) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) Test(org.junit.Test)

Example 73 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class FibInstallerTest method testRouteAdd.

/**
 * Tests adding a route.
 *
 * We verify that the flowObjectiveService records the correct state and that the
 * correct flow is submitted to the flowObjectiveService.
 */
@Test
public void testRouteAdd() {
    ResolvedRoute resolvedRoute = createRoute(PREFIX1, NEXT_HOP1, MAC1);
    // Create the next objective
    NextObjective nextObjective = createNextObjective(MAC1, MAC1, SW1_ETH1.port(), VlanId.NONE, true);
    flowObjectiveService.next(DEVICE_ID, nextObjective);
    // Create the flow objective
    ForwardingObjective fwd = createForwardingObjective(PREFIX1, true);
    flowObjectiveService.forward(DEVICE_ID, fwd);
    EasyMock.expectLastCall().once();
    setUpFlowObjectiveService();
    // Send in the add event
    RouteEvent routeEvent = new RouteEvent(RouteEvent.Type.ROUTE_ADDED, resolvedRoute);
    routeListener.event(routeEvent);
    verify(flowObjectiveService);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) RouteEvent(org.onosproject.routeservice.RouteEvent) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) Test(org.junit.Test)

Example 74 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class FibInstallerTest method testRouteDelete.

/**
 * Tests deleting a route.
 *
 * We verify that the flowObjectiveService records the correct state and that the
 * correct flow is withdrawn from the flowObjectiveService.
 */
@Test
public void testRouteDelete() {
    // Firstly add a route
    testRouteAdd();
    // Construct the existing route
    ResolvedRoute route = createRoute(PREFIX1, NEXT_HOP1, MAC1);
    // Create the flow objective
    reset(flowObjectiveService);
    ForwardingObjective fwd = createForwardingObjective(PREFIX1, false);
    flowObjectiveService.forward(DEVICE_ID, fwd);
    replay(flowObjectiveService);
    // Send in the delete event
    routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_REMOVED, route));
    verify(flowObjectiveService);
}
Also used : RouteEvent(org.onosproject.routeservice.RouteEvent) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) Test(org.junit.Test)

Example 75 with ForwardingObjective

use of org.onosproject.net.flowobjective.ForwardingObjective in project onos by opennetworkinglab.

the class TunnellingConnectivityManager method notifySwitchAvailable.

/**
 * Pushes the flow rules for forwarding BGP TCP packets to controller.
 * It is called when switches are connected and available.
 */
public void notifySwitchAvailable() {
    // control plane OVS is available, push default flows
    TrafficSelector selectorDst = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchTcpDst(TpPort.tpPort(BGP_PORT)).build();
    TrafficSelector selectorSrc = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchTcpSrc(TpPort.tpPort(BGP_PORT)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
    ForwardingObjective puntSrc = DefaultForwardingObjective.builder().fromApp(appId).makePermanent().withSelector(selectorSrc).withTreatment(treatment).withFlag(ForwardingObjective.Flag.VERSATILE).add();
    flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), puntSrc);
    ForwardingObjective puntDst = DefaultForwardingObjective.builder().fromApp(appId).makePermanent().withSelector(selectorDst).withTreatment(treatment).withFlag(ForwardingObjective.Flag.VERSATILE).add();
    flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), puntDst);
    log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId());
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)88 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)57 TrafficSelector (org.onosproject.net.flow.TrafficSelector)50 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)48 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)38 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)37 Test (org.junit.Test)33 NextObjective (org.onosproject.net.flowobjective.NextObjective)32 Objective (org.onosproject.net.flowobjective.Objective)32 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)28 List (java.util.List)24 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)20 FlowRule (org.onosproject.net.flow.FlowRule)20 DeviceId (org.onosproject.net.DeviceId)18 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)18 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)16 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)15 GroupDescription (org.onosproject.net.group.GroupDescription)15 PiAction (org.onosproject.net.pi.runtime.PiAction)14 ArrayList (java.util.ArrayList)13