Search in sources :

Example 96 with TrafficTreatment

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

the class KubevirtFloatingIpHandler method setFloatingIpArpResponseRules.

private void setFloatingIpArpResponseRules(KubevirtRouter router, KubevirtFloatingIp floatingIp, KubevirtPort port, KubevirtNode electedGw, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(externalPatchPortNum(deviceService, electedGw)).matchEthType(EthType.EtherType.ARP.ethType().toShort()).matchArpOp(ARP.OP_REQUEST).matchArpTpa(floatingIp.floatingIp().getIp4Address()).build();
    Device device = deviceService.getDevice(electedGw.intgBridge());
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().extension(RulePopulatorUtil.buildMoveEthSrcToDstExtension(device), device.id()).extension(RulePopulatorUtil.buildMoveArpShaToThaExtension(device), device.id()).extension(RulePopulatorUtil.buildMoveArpSpaToTpaExtension(device), device.id()).setArpOp(ARP.OP_REPLY).setEthSrc(port.macAddress()).setArpSha(port.macAddress()).setArpSpa(floatingIp.floatingIp().getIp4Address()).setOutput(PortNumber.IN_PORT).build();
    flowService.setRule(appId, electedGw.intgBridge(), selector, treatment, PRIORITY_ARP_GATEWAY_RULE, GW_ENTRY_TABLE, install);
}
Also used : Device(org.onosproject.net.Device) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 97 with TrafficTreatment

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

the class KubevirtFloatingIpHandler method processGarpPacketForFloatingIp.

private void processGarpPacketForFloatingIp(KubevirtFloatingIp floatingIp, KubevirtNode electedGw) {
    if (floatingIp == null) {
        return;
    }
    KubevirtPort kubevirtPort = getKubevirtPortByFloatingIp(floatingIp);
    if (kubevirtPort == null) {
        return;
    }
    Ethernet ethernet = buildGarpPacket(kubevirtPort.macAddress(), floatingIp.floatingIp());
    if (ethernet == null) {
        return;
    }
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(externalPatchPortNum(deviceService, electedGw)).build();
    packetService.emit(new DefaultOutboundPacket(electedGw.intgBridge(), treatment, ByteBuffer.wrap(ethernet.serialize())));
}
Also used : Ethernet(org.onlab.packet.Ethernet) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) KubevirtPort(org.onosproject.kubevirtnetworking.api.KubevirtPort) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 98 with TrafficTreatment

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

the class KubevirtLbHandler method setLbDownstreamRules.

private void setLbDownstreamRules(KubevirtLoadBalancer loadBalancer, KubevirtRouter router, KubevirtNode gateway, boolean install) {
    int groupId = loadBalancer.hashCode();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(router.mac()).group(GroupId.valueOf(groupId)).build();
    loadBalancer.rules().forEach(rule -> {
        TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
        switch(rule.protocol().toUpperCase()) {
            case PROTOCOL_TCP:
                sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchTcpDst(TpPort.tpPort(rule.portRangeMin().intValue()));
                break;
            case PROTOCOL_UDP:
                sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpDst(TpPort.tpPort(rule.portRangeMin().intValue()));
                break;
            case PROTOCOL_ICMP:
                sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_ICMP);
                break;
            default:
                break;
        }
        flowRuleService.setRule(appId, gateway.intgBridge(), sBuilder.build(), treatment, PRIORITY_LB_RULE, GW_DROP_TABLE, install);
    });
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 99 with TrafficTreatment

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

the class KubevirtNetworkHandler method setForwardingRule.

private void setForwardingRule(DeviceId deviceId, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.NORMAL).build();
    flowService.setRule(appId, deviceId, selector, treatment, PRIORITY_FORWARDING_RULE, TENANT_FORWARDING_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 100 with TrafficTreatment

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

the class KubevirtNetworkHandler method setDhcpRuleForTenantNetwork.

private void setDhcpRuleForTenantNetwork(DeviceId deviceId, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpDst(TpPort.tpPort(UDP.DHCP_SERVER_PORT)).matchUdpSrc(TpPort.tpPort(UDP.DHCP_CLIENT_PORT)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
    flowService.setRule(appId, deviceId, selector, treatment, PRIORITY_DHCP_RULE, TENANT_DHCP_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)395 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)369 TrafficSelector (org.onosproject.net.flow.TrafficSelector)257 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)236 FlowRule (org.onosproject.net.flow.FlowRule)93 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)86 PiAction (org.onosproject.net.pi.runtime.PiAction)79 Test (org.junit.Test)78 PortNumber (org.onosproject.net.PortNumber)70 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)56 Instruction (org.onosproject.net.flow.instructions.Instruction)52 DeviceId (org.onosproject.net.DeviceId)46 NextObjective (org.onosproject.net.flowobjective.NextObjective)45 ConnectPoint (org.onosproject.net.ConnectPoint)44 List (java.util.List)43 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)43 Ethernet (org.onlab.packet.Ethernet)40 Criterion (org.onosproject.net.flow.criteria.Criterion)39 GroupBucket (org.onosproject.net.group.GroupBucket)39 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)37