Search in sources :

Example 21 with Type

use of org.onosproject.openstacknetworking.api.OpenstackNetwork.Type in project onos by opennetworkinglab.

the class OpenstackSwitchingIcmpHandler method processRouterIntfEvent.

private void processRouterIntfEvent(Router osRouter, RouterInterface routerIface, boolean install) {
    if (!getStatefulSnatFlag()) {
        return;
    }
    Subnet osSubnet = osNetworkService.subnet(routerIface.getSubnetId());
    Type netType = osNetworkService.networkType(osSubnet.getNetworkId());
    String segId = osNetworkService.segmentId(osSubnet.getNetworkId());
    IpAddress gatewayIp = IpAddress.valueOf(osSubnet.getGateway());
    Set<Subnet> routableSubnets = routableSubnets(osRouter, osSubnet.getId());
    osNodeService.completeNodes(COMPUTE).stream().filter(cNode -> cNode.dataIp() != null).forEach(cNode -> {
        setRoutableSubnetsIcmpRules(cNode, segId, osSubnet, routableSubnets, gatewayIp, netType, install);
    });
}
Also used : OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) OpenstackNetworkingUtil.externalGatewayIp(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalGatewayIp) NXM_OF_ICMP_TYPE(org.onosproject.openstacknetworking.util.RulePopulatorUtil.NXM_OF_ICMP_TYPE) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) TYPE_ECHO_REPLY(org.onlab.packet.ICMP.TYPE_ECHO_REPLY) RulePopulatorUtil.buildMoveEthSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveEthSrcToDstExtension) MastershipService(org.onosproject.mastership.MastershipService) NodeId(org.onosproject.cluster.NodeId) PRIORITY_ICMP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_RULE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) NXM_NX_IP_TTL(org.onosproject.openstacknetworking.util.RulePopulatorUtil.NXM_NX_IP_TTL) Device(org.onosproject.net.Device) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) ClusterService(org.onosproject.cluster.ClusterService) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) TYPE_ECHO_REQUEST(org.onlab.packet.ICMP.TYPE_ECHO_REQUEST) RouterInterface(org.openstack4j.model.network.RouterInterface) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CODE_ECHO_REQEUST(org.onlab.packet.ICMP.CODE_ECHO_REQEUST) Router(org.openstack4j.model.network.Router) Activate(org.osgi.service.component.annotations.Activate) DEFAULT_GATEWAY_MAC(org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC) RulePopulatorUtil.buildMoveIpSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveIpSrcToDstExtension) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Subnet(org.openstack4j.model.network.Subnet) RulePopulatorUtil.buildLoadExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildLoadExtension) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) ConfigProperty(org.onosproject.cfg.ConfigProperty) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) IpAddress(org.onlab.packet.IpAddress) Subnet(org.openstack4j.model.network.Subnet)

Example 22 with Type

use of org.onosproject.openstacknetworking.api.OpenstackNetwork.Type in project onos by opennetworkinglab.

the class OpenstackNetworkingUtil method traceRequestString.

/**
 * Creates flow trace request string.
 *
 * @param srcIp src ip address
 * @param dstIp dst ip address
 * @param srcInstancePort src instance port
 * @param osNetService openstack networking service
 * @param uplink true if this request is for uplink
 * @return flow trace request string
 */
public static String traceRequestString(String srcIp, String dstIp, InstancePort srcInstancePort, OpenstackNetworkService osNetService, boolean uplink) {
    StringBuilder requestStringBuilder = new StringBuilder(DEFAULT_REQUEST_STRING);
    if (uplink) {
        requestStringBuilder.append(COMMA).append(IN_PORT).append(srcInstancePort.portNumber().toString()).append(COMMA).append(NW_SRC).append(srcIp).append(COMMA);
        String modifiedDstIp = dstIp;
        Type netType = osNetService.networkType(srcInstancePort.networkId());
        if (netType == Type.VXLAN || netType == Type.GRE || netType == Type.VLAN || netType == Type.GENEVE) {
            if (srcIp.equals(dstIp)) {
                modifiedDstIp = osNetService.gatewayIp(srcInstancePort.portId());
                requestStringBuilder.append(DL_DST).append(DEFAULT_GATEWAY_MAC_STR).append(COMMA);
            } else if (!osNetService.ipPrefix(srcInstancePort.portId()).contains(IpAddress.valueOf(dstIp))) {
                requestStringBuilder.append(DL_DST).append(DEFAULT_GATEWAY_MAC_STR).append(COMMA);
            }
        } else {
            if (srcIp.equals(dstIp)) {
                modifiedDstIp = osNetService.gatewayIp(srcInstancePort.portId());
            }
        }
        requestStringBuilder.append(NW_DST).append(modifiedDstIp).append("\n");
    } else {
        requestStringBuilder.append(COMMA).append(NW_SRC).append(dstIp).append(COMMA);
        Type netType = osNetService.networkType(srcInstancePort.networkId());
        if (netType == Type.VXLAN || netType == Type.GRE || netType == Type.VLAN || netType == Type.GENEVE) {
            requestStringBuilder.append(TUN_ID).append(osNetService.segmentId(srcInstancePort.networkId())).append(COMMA);
        }
        requestStringBuilder.append(NW_DST).append(srcIp).append("\n");
    }
    return requestStringBuilder.toString();
}
Also used : Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) VnicType(org.onosproject.openstacknetworking.api.Constants.VnicType)

Aggregations

Type (org.onosproject.openstacknetworking.api.OpenstackNetwork.Type)22 Network (org.openstack4j.model.network.Network)13 OpenstackNetworkingUtil.tunnelPortNumByNetType (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType)12 Subnet (org.openstack4j.model.network.Subnet)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)9 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)9 IpAddress (org.onlab.packet.IpAddress)8 PortNumber (org.onosproject.net.PortNumber)7 Set (java.util.Set)6 ExecutorService (java.util.concurrent.ExecutorService)6 Collectors (java.util.stream.Collectors)6 VlanId (org.onlab.packet.VlanId)6 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)6 CoreService (org.onosproject.core.CoreService)6 DeviceService (org.onosproject.net.device.DeviceService)6 OPENSTACK_NETWORKING_APP_ID (org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID)6 Objects (java.util.Objects)5