Search in sources :

Example 1 with FlowRule

use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.

the class K8sFlowRuleManager method setAnyRoutingRule.

private void setAnyRoutingRule(IpPrefix srcIpPrefix, MacAddress mac, K8sNetwork k8sNetwork) {
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(srcIpPrefix).matchIPDst(IpPrefix.valueOf(k8sNetwork.cidr()));
    for (K8sNode node : k8sNodeService.completeNodes()) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.valueOf(k8sNetwork.segmentId()));
        if (node.hostname().equals(k8sNetwork.name())) {
            if (mac != null) {
                tBuilder.setEthSrc(mac);
            }
            tBuilder.transition(STAT_EGRESS_TABLE);
        } else {
            K8sNode localNode = k8sNodeService.node(k8sNetwork.name());
            tBuilder.setOutput(node.intgToTunPortNum());
            // install flows into tunnel bridge
            PortNumber portNum = tunnelPortNumByNetId(k8sNetwork.networkId(), k8sNetworkService, node);
            TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, node.tunBridge(), localNode.dataIp().getIp4Address()), node.tunBridge()).setTunnelId(Long.valueOf(k8sNetwork.segmentId())).setOutput(portNum).build();
            FlowRule remoteFlowRule = DefaultFlowRule.builder().forDevice(node.tunBridge()).withSelector(sBuilder.build()).withTreatment(treatmentToRemote).withPriority(PRIORITY_CIDR_RULE).fromApp(appId).makePermanent().forTable(TUN_ENTRY_TABLE).build();
            applyRule(remoteFlowRule, true);
        }
        FlowRule flowRule = DefaultFlowRule.builder().forDevice(node.intgBridge()).withSelector(sBuilder.build()).withTreatment(tBuilder.build()).withPriority(PRIORITY_CIDR_RULE).fromApp(appId).makePermanent().forTable(ROUTING_TABLE).build();
        applyRule(flowRule, true);
    }
}
Also used : K8sNode(org.onosproject.k8snode.api.K8sNode) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PortNumber(org.onosproject.net.PortNumber)

Example 2 with FlowRule

use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.

the class K8sFlowRuleManager method setupJumpTable.

private void setupJumpTable(K8sNode k8sNode) {
    DeviceId deviceId = k8sNode.intgBridge();
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    selector.matchEthDst(DEFAULT_GATEWAY_MAC);
    treatment.transition(ROUTING_TABLE);
    FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(HIGH_PRIORITY).fromApp(appId).makePermanent().forTable(GROUPING_TABLE).build();
    applyRule(flowRule, true);
    selector = DefaultTrafficSelector.builder();
    treatment = DefaultTrafficTreatment.builder();
    treatment.transition(STAT_EGRESS_TABLE);
    flowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(DROP_PRIORITY).fromApp(appId).makePermanent().forTable(GROUPING_TABLE).build();
    applyRule(flowRule, true);
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 3 with FlowRule

use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.

the class K8sFlowRuleManager method setUpTableMissEntry.

@Override
public void setUpTableMissEntry(DeviceId deviceId, int table) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.drop();
    FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(DROP_PRIORITY).fromApp(appId).makePermanent().forTable(table).build();
    applyRule(flowRule, true);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 4 with FlowRule

use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.

the class SimpleFabricRouting method dump.

// Dump Cli Handler
private void dump(String subject, PrintStream out) {
    if ("intents".equals(subject)) {
        out.println("Routing Route Intents:\n");
        for (Intent entry : intentService.getIntents()) {
            if (appId.equals(entry.appId())) {
                MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
                out.println("    " + intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
            }
        }
        out.println("");
        out.println("Routing Intercept Flow Rules:\n");
        List<FlowRule> rules = new ArrayList(interceptFlowRules);
        Collections.sort(rules, new Comparator<FlowRule>() {

            @Override
            public int compare(FlowRule a, FlowRule b) {
                int r = a.deviceId().toString().compareTo(b.deviceId().toString());
                // descending on priority
                return (r != 0) ? r : Integer.compare(b.priority(), a.priority());
            }
        });
        for (FlowRule rule : rules) {
            out.println("    device=" + rule.deviceId().toString() + " priority=" + rule.priority() + " selector=" + rule.selector().criteria().toString());
        }
        out.println("");
        out.println("Routing Intents to Be Purged:\n");
        for (Key key : toBePurgedIntentKeys) {
            out.println("    " + key.toString());
        }
        out.println("");
    } else if ("reactive-intents".equals(subject)) {
        for (Intent entry : intentService.getIntents()) {
            if (appId.equals(entry.appId())) {
                MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
                out.println(intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key)

Example 5 with FlowRule

use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.

the class SimpleFabricRouting method generateInterceptFlowRule.

private FlowRule generateInterceptFlowRule(boolean isDstLocalSubnet, DeviceId deviceId, IpPrefix prefix) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    if (prefix.isIp4()) {
        selector.matchEthType(Ethernet.TYPE_IPV4);
        if (prefix.prefixLength() > 0) {
            selector.matchIPDst(prefix);
        }
    } else {
        selector.matchEthType(Ethernet.TYPE_IPV6);
        if (prefix.prefixLength() > 0) {
            selector.matchIPv6Dst(prefix);
        }
    }
    FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId).withPriority(reactivePriority(false, isDstLocalSubnet, prefix.prefixLength())).withSelector(selector.build()).withTreatment(DefaultTrafficTreatment.builder().punt().build()).fromApp(appId).makePermanent().forTable(0).build();
    return rule;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule)

Aggregations

FlowRule (org.onosproject.net.flow.FlowRule)351 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)226 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)207 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)207 TrafficSelector (org.onosproject.net.flow.TrafficSelector)174 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)174 Test (org.junit.Test)133 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)90 Intent (org.onosproject.net.intent.Intent)88 DeviceId (org.onosproject.net.DeviceId)87 List (java.util.List)86 Collection (java.util.Collection)68 Collectors (java.util.stream.Collectors)68 CoreService (org.onosproject.core.CoreService)66 VlanId (org.onlab.packet.VlanId)65 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)61 Collections (java.util.Collections)60 FlowEntry (org.onosproject.net.flow.FlowEntry)59 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)56 ArrayList (java.util.ArrayList)54