Search in sources :

Example 96 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class OfdpaExtensionSelectorInterpreter method mapSelector.

@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    } else if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_ACTSET_OUTPUT.type())) {
        PortNumber port = ((OfdpaMatchActsetOutput) extensionSelector).port();
        return factory.oxms().ofdpaActsetOutput(U32.of(port.toLong()));
    } else if (type.equals(ExtensionSelectorTypes.OFDPA_MATCH_ALLOW_VLAN_TRANSLATION.type())) {
        Short allowVlanTranslation = ((OfdpaMatchAllowVlanTranslation) extensionSelector).allowVlanTranslation();
        return factory.oxms().ofdpaAllowVlanTranslation(U8.of(allowVlanTranslation));
    }
    throw new UnsupportedOperationException("Unexpected ExtensionSelector: " + extensionSelector.toString());
}
Also used : OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) ExtensionSelectorType(org.onosproject.net.flow.criteria.ExtensionSelectorType) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Example 97 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class OvsOfdpaExtensionSelectorInterpreter method mapOxm.

@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
    if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
        U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
        PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
        return new OfdpaMatchActsetOutput(portNumber);
    }
    throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
Also used : OFOxmOfdpaActsetOutput(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaActsetOutput) U32(org.projectfloodlight.openflow.types.U32) PortNumber(org.onosproject.net.PortNumber)

Example 98 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class KubevirtFloatingIpHandler method setFloatingIpDownstreamRulesToGatewayTunBridge.

private void setFloatingIpDownstreamRulesToGatewayTunBridge(KubevirtFloatingIp floatingIp, KubevirtNode electedGw, KubevirtNetwork network, KubevirtPort port, boolean install) {
    KubevirtNode workerNode = kubevirtNodeService.node(port.deviceId());
    if (workerNode == null) {
        log.warn("Failed to install floating Ip rules for floating ip {} " + "because fail to fine the worker node that the associated port is running on", floatingIp.floatingIp());
        return;
    }
    PortNumber tunnelPortNumber = tunnelPort(electedGw, network);
    if (tunnelPortNumber == null) {
        return;
    }
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).matchEthDst(port.macAddress());
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.parseLong(network.segmentId())).extension(buildExtension(deviceService, electedGw.tunBridge(), workerNode.dataIp().getIp4Address()), electedGw.tunBridge()).setOutput(tunnelPortNumber);
    flowService.setRule(appId, electedGw.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_FLOATING_GATEWAY_TUN_BRIDGE_RULE, TUNNEL_DEFAULT_TABLE, install);
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 99 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class KubevirtLbHandler method setLbDownStreamRulesForTunBridge.

private void setLbDownStreamRulesForTunBridge(KubevirtLoadBalancer loadBalancer, KubevirtNode gateway, boolean install) {
    Set<KubevirtPort> ports = portService.ports(loadBalancer.networkId());
    KubevirtNetwork network = networkService.network(loadBalancer.networkId());
    PortNumber tunnelPortNumber = tunnelPort(gateway, network);
    if (tunnelPortNumber == null) {
        return;
    }
    loadBalancer.members().forEach(ip -> {
        ports.stream().filter(port -> port.ipAddress().equals(ip) && port.macAddress() != null).findAny().ifPresent(port -> {
            KubevirtNode workerNode = nodeService.node(port.deviceId());
            TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).matchEthDst(port.macAddress());
            TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.parseLong(network.segmentId())).extension(buildExtension(deviceService, gateway.tunBridge(), workerNode.dataIp().getIp4Address()), gateway.tunBridge()).setOutput(tunnelPortNumber);
            flowRuleService.setRule(appId, gateway.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_LB_GATEWAY_TUN_BRIDGE_RULE, TUNNEL_DEFAULT_TABLE, install);
        });
    });
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) KubevirtNetwork(org.onosproject.kubevirtnetworking.api.KubevirtNetwork) KubevirtNetworkingUtil.getRouterForKubevirtNetwork(org.onosproject.kubevirtnetworking.util.KubevirtNetworkingUtil.getRouterForKubevirtNetwork) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) KubevirtPort(org.onosproject.kubevirtnetworking.api.KubevirtPort) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 100 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class KubevirtNetworkHandler method setDefaultEgressRuleToGatewayNode.

private void setDefaultEgressRuleToGatewayNode(KubevirtRouter router, KubevirtNetwork network, DeviceId gwDeviceId, boolean install) {
    MacAddress routerMacAddress = getRouterMacAddress(router);
    if (routerMacAddress == null) {
        log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no br-int port for device {}", gwDeviceId);
        return;
    }
    KubevirtNode gwNode = kubevirtNodeService.node(gwDeviceId);
    if (gwNode == null) {
        log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no gateway node for device {}", gwDeviceId);
        return;
    }
    PortNumber tunToIntPortNum = portNumber(deviceService, gwNode.tunBridge(), TUNNEL_TO_INTEGRATION);
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchTunnelId(Long.parseLong(network.segmentId()));
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setOutput(tunToIntPortNum);
    flowService.setRule(appId, gwNode.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_TUNNEL_RULE, TUNNEL_DEFAULT_TABLE, install);
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) KubevirtNetworkingUtil.getRouterMacAddress(org.onosproject.kubevirtnetworking.util.KubevirtNetworkingUtil.getRouterMacAddress) MacAddress(org.onlab.packet.MacAddress) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

PortNumber (org.onosproject.net.PortNumber)336 DeviceId (org.onosproject.net.DeviceId)136 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)109 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)103 ConnectPoint (org.onosproject.net.ConnectPoint)82 TrafficSelector (org.onosproject.net.flow.TrafficSelector)80 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)74 Port (org.onosproject.net.Port)67 ArrayList (java.util.ArrayList)64 Set (java.util.Set)64 List (java.util.List)59 Logger (org.slf4j.Logger)58 Collectors (java.util.stream.Collectors)51 DeviceService (org.onosproject.net.device.DeviceService)49 VlanId (org.onlab.packet.VlanId)42 MacAddress (org.onlab.packet.MacAddress)41 Device (org.onosproject.net.Device)40 FlowRule (org.onosproject.net.flow.FlowRule)40 Optional (java.util.Optional)39 Sets (com.google.common.collect.Sets)35