Search in sources :

Example 1 with NextHopGroupKey

use of org.onosproject.routing.NextHopGroupKey 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)

Aggregations

DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)1 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)1 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)1 NextObjective (org.onosproject.net.flowobjective.NextObjective)1 Interface (org.onosproject.net.intf.Interface)1 NextHop (org.onosproject.routing.NextHop)1 NextHopGroupKey (org.onosproject.routing.NextHopGroupKey)1