@Test public void createChainTunnelFlows_directionOut() throws Exception { TenantBuilder tenantBuilder = buildTenant(); Tenant tenant = tenantBuilder.build(); EndpointBuilder sourceEndpointBuilder = buildEndpoint(IPV4_0, MAC_0, CONNECTOR_0); Endpoint sourceEndpoint = sourceEndpointBuilder.build(); EgKey sourceEgKey = new EgKey(tenant.getId(), ENDPOINT_GROUP_0); EndpointBuilder destinationEndpointBuilder = buildEndpoint(IPV4_1, MAC_1, CONNECTOR_1); Endpoint destinationEndpoint = destinationEndpointBuilder.build(); EgKey destinationEgKey = new EgKey(tenant.getId(), ENDPOINT_GROUP_1); SfcNshHeaderBuilder nshHeaderBuilder = new SfcNshHeaderBuilder(); nshHeaderBuilder.setNshMetaC1(Long.valueOf(0L)); nshHeaderBuilder.setNshNsiToChain((short) 255); nshHeaderBuilder.setNshNspToChain(27L); nshHeaderBuilder.setNshTunIpDst(IPV4_2); SfcNshHeader nshHeader = nshHeaderBuilder.build(); when(ctx.getTenant(any(TenantId.class))).thenReturn(getTestIndexedTenant()); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(ctx.getSwitchManager()).thenReturn(switchManager); when(ctx.getPolicyManager()).thenReturn(policyManager); when(ctx.getCurrentPolicy()).thenReturn(policyInfo); when(switchManager.getTunnelPort(NODE_ID, TunnelTypeVxlanGpe.class)).thenReturn(CONNECTOR_2); when(switchManager.getTunnelIP(NODE_ID, TunnelTypeVxlanGpe.class)).thenReturn(new IpAddress(IPV4_2)); when(policyManager.getTABLEID_EXTERNAL_MAPPER()).thenReturn((short) 6); NetworkElements netElements = new NetworkElements(sourceEndpoint, destinationEndpoint, sourceEgKey, destinationEgKey, NODE_ID, ctx); assertNotNull(netElements); ChainActionFlows.createChainTunnelFlows(nshHeader, netElements, ofWriter, ctx, HasDirection.Direction.Out); verify(ofWriter, times(1)).writeFlow(NODE_ID, (short) 6, createExternalTestFlow(netElements)); }
public static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter, OfContext ctx, Direction direction) { NodeId localNodeId = netElements.getLocalNodeId(); EndpointFwdCtxOrdinals epOrdinals = netElements.getSrcEpOrdinals(); NodeConnectorId localNodeTunPort = ctx.getSwitchManager().getTunnelPort(localNodeId, TunnelTypeVxlanGpe.class); Ipv4Address tunDestAddress = ctx.getSwitchManager() .getTunnelIP(netElements.getDstNodeId(), TunnelTypeVxlanGpe.class) .getIpv4Address(); if (localNodeTunPort == null) { LOG.error("createChainTunnelFlows: No valid VXLAN GPE tunnel for Node {} ", localNodeId); return; } if (direction.equals(Direction.In)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), allowFromChainPort( sfcNshHeader, localNodeTunPort, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), ctx)); for (Flow flow : createChainTunnelFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), flow); } ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER(), allowFromChainTunnel(localNodeTunPort, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER())); ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), createChainBroadcastFlow(sfcNshHeader, localNodeTunPort, epOrdinals, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)); } else { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_EXTERNAL_MAPPER(), createExternalFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager(), ctx.getSwitchManager(), tunDestAddress)); } }
ChainActionFlows { public static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter, OfContext ctx, Direction direction) { NodeId localNodeId = netElements.getLocalNodeId(); EndpointFwdCtxOrdinals epOrdinals = netElements.getSrcEpOrdinals(); NodeConnectorId localNodeTunPort = ctx.getSwitchManager().getTunnelPort(localNodeId, TunnelTypeVxlanGpe.class); Ipv4Address tunDestAddress = ctx.getSwitchManager() .getTunnelIP(netElements.getDstNodeId(), TunnelTypeVxlanGpe.class) .getIpv4Address(); if (localNodeTunPort == null) { LOG.error("createChainTunnelFlows: No valid VXLAN GPE tunnel for Node {} ", localNodeId); return; } if (direction.equals(Direction.In)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), allowFromChainPort( sfcNshHeader, localNodeTunPort, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), ctx)); for (Flow flow : createChainTunnelFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), flow); } ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER(), allowFromChainTunnel(localNodeTunPort, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER())); ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), createChainBroadcastFlow(sfcNshHeader, localNodeTunPort, epOrdinals, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)); } else { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_EXTERNAL_MAPPER(), createExternalFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager(), ctx.getSwitchManager(), tunDestAddress)); } } }
ChainActionFlows { public static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter, OfContext ctx, Direction direction) { NodeId localNodeId = netElements.getLocalNodeId(); EndpointFwdCtxOrdinals epOrdinals = netElements.getSrcEpOrdinals(); NodeConnectorId localNodeTunPort = ctx.getSwitchManager().getTunnelPort(localNodeId, TunnelTypeVxlanGpe.class); Ipv4Address tunDestAddress = ctx.getSwitchManager() .getTunnelIP(netElements.getDstNodeId(), TunnelTypeVxlanGpe.class) .getIpv4Address(); if (localNodeTunPort == null) { LOG.error("createChainTunnelFlows: No valid VXLAN GPE tunnel for Node {} ", localNodeId); return; } if (direction.equals(Direction.In)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), allowFromChainPort( sfcNshHeader, localNodeTunPort, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), ctx)); for (Flow flow : createChainTunnelFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), flow); } ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER(), allowFromChainTunnel(localNodeTunPort, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER())); ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), createChainBroadcastFlow(sfcNshHeader, localNodeTunPort, epOrdinals, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)); } else { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_EXTERNAL_MAPPER(), createExternalFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager(), ctx.getSwitchManager(), tunDestAddress)); } } ChainActionFlows(); }
ChainActionFlows { public static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter, OfContext ctx, Direction direction) { NodeId localNodeId = netElements.getLocalNodeId(); EndpointFwdCtxOrdinals epOrdinals = netElements.getSrcEpOrdinals(); NodeConnectorId localNodeTunPort = ctx.getSwitchManager().getTunnelPort(localNodeId, TunnelTypeVxlanGpe.class); Ipv4Address tunDestAddress = ctx.getSwitchManager() .getTunnelIP(netElements.getDstNodeId(), TunnelTypeVxlanGpe.class) .getIpv4Address(); if (localNodeTunPort == null) { LOG.error("createChainTunnelFlows: No valid VXLAN GPE tunnel for Node {} ", localNodeId); return; } if (direction.equals(Direction.In)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), allowFromChainPort( sfcNshHeader, localNodeTunPort, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), ctx)); for (Flow flow : createChainTunnelFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), flow); } ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER(), allowFromChainTunnel(localNodeTunPort, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER())); ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), createChainBroadcastFlow(sfcNshHeader, localNodeTunPort, epOrdinals, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)); } else { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_EXTERNAL_MAPPER(), createExternalFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager(), ctx.getSwitchManager(), tunDestAddress)); } } ChainActionFlows(); static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter,
            OfContext ctx, Direction direction); }
ChainActionFlows { public static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter, OfContext ctx, Direction direction) { NodeId localNodeId = netElements.getLocalNodeId(); EndpointFwdCtxOrdinals epOrdinals = netElements.getSrcEpOrdinals(); NodeConnectorId localNodeTunPort = ctx.getSwitchManager().getTunnelPort(localNodeId, TunnelTypeVxlanGpe.class); Ipv4Address tunDestAddress = ctx.getSwitchManager() .getTunnelIP(netElements.getDstNodeId(), TunnelTypeVxlanGpe.class) .getIpv4Address(); if (localNodeTunPort == null) { LOG.error("createChainTunnelFlows: No valid VXLAN GPE tunnel for Node {} ", localNodeId); return; } if (direction.equals(Direction.In)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), allowFromChainPort( sfcNshHeader, localNodeTunPort, ctx.getPolicyManager().getTABLEID_PORTSECURITY(), ctx)); for (Flow flow : createChainTunnelFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)) { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), flow); } ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER(), allowFromChainTunnel(localNodeTunPort, ctx.getPolicyManager().getTABLEID_POLICY_ENFORCER())); ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), createChainBroadcastFlow(sfcNshHeader, localNodeTunPort, epOrdinals, ctx.getPolicyManager().getTABLEID_SOURCE_MAPPER(), ctx)); } else { ofWriter.writeFlow(localNodeId, ctx.getPolicyManager().getTABLEID_EXTERNAL_MAPPER(), createExternalFlow(sfcNshHeader, localNodeTunPort, netElements, ctx.getPolicyManager(), ctx.getSwitchManager(), tunDestAddress)); } } ChainActionFlows(); static void createChainTunnelFlows(SfcNshHeader sfcNshHeader, NetworkElements netElements, OfWriter ofWriter,
            OfContext ctx, Direction direction);  }