EndpointGroup epgDhcp = new EndpointGroupBuilder().setId(MappingUtils.EPG_DHCP_ID)
.setName(new Name("DHCP_group"))
.setDescription(new Description("Group where are all DHCP endpoints."))
+ .setIntraGroupPolicy(IntraGroupPolicy.RequireContract)
.build();
rwTx.put(LogicalDatastoreType.CONFIGURATION, epgDhcpIid, epgDhcp);
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadArpSpaAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadRegAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadTunIPv4Action;
+import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadTunIdAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxMoveArpShaToArpThaAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxMoveArpSpaToArpTpaAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxMoveEthSrcToEthDstAction;
-import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxMoveRegTunIdAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.outputAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.setDlDstAction;
import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.setDlSrcAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.NetworkDomainId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.CheckedFuture;
/**
* Manage the table that maps the destination address to the next hop for the
* path as well as applies any relevant routing transformations.
- *
*/
public class DestinationMapper extends FlowTable {
- protected static final Logger LOG =
- LoggerFactory.getLogger(DestinationMapper.class);
+
+ protected static final Logger LOG = LoggerFactory.getLogger(DestinationMapper.class);
// TODO Li alagalah: Improve UT coverage for this class.
/**
* This is the MAC address of the magical router in the sky
*/
- public static final MacAddress ROUTER_MAC =
- new MacAddress("88:f0:31:b5:12:b5");
- public static final MacAddress MULTICAST_MAC =
- new MacAddress("01:00:00:00:00:00");
+ public static final MacAddress ROUTER_MAC = new MacAddress("88:f0:31:b5:12:b5");
+ public static final MacAddress MULTICAST_MAC = new MacAddress("01:00:00:00:00:00");
public DestinationMapper(OfContext ctx) {
super(ctx);
}
@Override
- public void sync(NodeId nodeId, PolicyInfo policyInfo, FlowMap flowMap)
- throws Exception {
+ public void sync(NodeId nodeId, PolicyInfo policyInfo, FlowMap flowMap) throws Exception {
TenantId currentTenant;
flowMap.writeFlow(nodeId, TABLE_ID, dropFlow(Integer.valueOf(1), null));
- Set<EpKey> visitedEps = new HashSet<>();
- Set<Integer> fdIds = new HashSet<>();
-
- for (EgKey epg : ctx.getEndpointManager().getGroupsForNode(nodeId)) {
- Set<EgKey> peers = Sets.union(Collections.singleton(epg),
- policyInfo.getPeers(epg));
- for (EgKey peer : peers) {
- for (Endpoint epPeer : ctx.getEndpointManager().getEndpointsForGroup(peer)) {
- currentTenant = epPeer.getTenant();
- subnetsByTenant.put(currentTenant, getSubnets(currentTenant));
- syncEP(flowMap, nodeId, policyInfo, epPeer, visitedEps);
- // Process subnets and flood-domains for epPeer
- EndpointFwdCtxOrdinals epOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, epPeer);
- fdIds.add(epOrds.getFdId());
+ SetMultimap<EpKey, EpKey> visitedEps = HashMultimap.create();
+ Set<EndpointFwdCtxOrdinals> epOrdSet = new HashSet<>();
+
+ for (Endpoint srcEp : ctx.getEndpointManager().getEndpointsForNode(nodeId)) {
+ Set<EndpointGroupId> srcEpgIds = new HashSet<>();
+ if (srcEp.getEndpointGroup() != null)
+ srcEpgIds.add(srcEp.getEndpointGroup());
+ if (srcEp.getEndpointGroups() != null)
+ srcEpgIds.addAll(srcEp.getEndpointGroups());
+
+ for (EndpointGroupId epgId : srcEpgIds) {
+ EgKey epg = new EgKey(srcEp.getTenant(), epgId);
+ Set<EgKey> peers = Sets.union(Collections.singleton(epg), policyInfo.getPeers(epg));
+ for (EgKey peer : peers) {
+ for (Endpoint peerEp : ctx.getEndpointManager().getEndpointsForGroup(peer)) {
+ currentTenant = peerEp.getTenant();
+ subnetsByTenant.put(currentTenant, getSubnets(currentTenant));
+ EpKey srcEpKey = new EpKey(srcEp.getL2Context(), srcEp.getMacAddress());
+ EpKey peerEpKey = new EpKey(peerEp.getL2Context(), peerEp.getMacAddress());
+
+ if (visitedEps.get(srcEpKey) != null && visitedEps.get(srcEpKey).contains(peerEpKey)) {
+ continue;
+ }
+ syncEP(flowMap, nodeId, policyInfo, srcEp, peerEp);
+ visitedEps.put(srcEpKey, peerEpKey);
+
+ // Process subnets and flood-domains for epPeer
+ EndpointFwdCtxOrdinals epOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo,
+ peerEp);
+ epOrdSet.add(epOrds);
+ }
}
}
}
for (Entry<TenantId, HashSet<Subnet>> subnetEntry : subnetsByTenant.entrySet()) {
- if(subnetEntry.getValue() == null ) {
- LOG.trace("Tenant: {} has empty subnet entry.",subnetEntry.getKey());
+ if (subnetEntry.getValue() == null) {
+ LOG.trace("Tenant: {} has empty subnet entry.", subnetEntry.getKey());
continue;
}
- currentTenant=subnetEntry.getKey();
+ currentTenant = subnetEntry.getKey();
for (Subnet sn : subnetEntry.getValue()) {
- L3Context l3c = getL3ContextForSubnet(currentTenant,sn);
+ L3Context l3c = getL3ContextForSubnet(currentTenant, sn);
Flow arpFlow = createRouterArpFlow(currentTenant, nodeId, sn,
OrdinalFactory.getContextOrdinal(currentTenant, l3c.getId()));
if (arpFlow != null) {
flowMap.writeFlow(nodeId, TABLE_ID, arpFlow);
} else {
- LOG.debug("Gateway ARP flow is not created, because virtual router IP has not been set for subnet {} .",
+ LOG.debug(
+ "Gateway ARP flow is not created, because virtual router IP has not been set for subnet {} .",
sn.getIpPrefix().getValue());
}
}
}
// Write broadcast flows per flood domain.
- for (Integer fdId : fdIds) {
- if (groupExists(nodeId, fdId)) {
- flowMap.writeFlow(nodeId, TABLE_ID, createBroadcastFlow(fdId));
+ for (EndpointFwdCtxOrdinals epOrd : epOrdSet) {
+ if (groupExists(nodeId, epOrd.getFdId())) {
+ flowMap.writeFlow(nodeId, TABLE_ID, createBroadcastFlow(epOrd));
}
}
}
// set up next-hop destinations for all the endpoints in the endpoint
// group on the node
- private Flow createBroadcastFlow(int fdId) {
- FlowId flowId = new FlowId(new StringBuilder()
- .append("broadcast|")
- .append(fdId).toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(new EthernetMatchBuilder()
- .setEthernetDestination(new EthernetDestinationBuilder()
- .setAddress(MULTICAST_MAC)
- .setMask(MULTICAST_MAC)
- .build())
- .build());
- addNxRegMatch(mb, RegMatch.of(NxmNxReg5.class, Long.valueOf(fdId)));
-
- FlowBuilder flowb = base()
- .setPriority(Integer.valueOf(140))
- .setId(flowId)
- .setMatch(mb.build())
- .setInstructions(instructions(applyActionIns(nxMoveRegTunIdAction(NxmNxReg0.class, false),
- groupAction(Long.valueOf(fdId)))));
+ private Flow createBroadcastFlow(EndpointFwdCtxOrdinals epOrd) {
+ FlowId flowId = new FlowId(new StringBuilder().append("broadcast|").append(epOrd.getFdId()).toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(new EthernetMatchBuilder().setEthernetDestination(
+ new EthernetDestinationBuilder().setAddress(MULTICAST_MAC).setMask(MULTICAST_MAC).build()).build());
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg5.class, Long.valueOf(epOrd.getFdId())));
+
+ FlowBuilder flowb = base().setPriority(Integer.valueOf(140))
+ .setId(flowId)
+ .setMatch(mb.build())
+ .setInstructions(
+ instructions(applyActionIns(nxLoadTunIdAction(BigInteger.valueOf(epOrd.getFdId()), false),
+ groupAction(Long.valueOf(epOrd.getFdId())))));
return flowb.build();
}
ReadOnlyTransaction t = ctx.getDataBroker().newReadOnlyTransaction();
InstanceIdentifier<Node> niid = createNodePath(nodeId);
- Optional<Node> r =
- t.read(LogicalDatastoreType.CONFIGURATION, niid).get();
+ Optional<Node> r = t.read(LogicalDatastoreType.CONFIGURATION, niid).get();
if (!r.isPresent())
return false;
FlowCapableNode fcn = r.get().getAugmentation(FlowCapableNode.class);
MacAddress defaultMacAddress = ROUTER_MAC;
EndpointL3Key l3Key = new EndpointL3Key(ipAddress, l3c.getId());
- InstanceIdentifier<EndpointL3> endpointsIid =
- InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3.class, l3Key).build();
+ InstanceIdentifier<EndpointL3> endpointsIid = InstanceIdentifier.builder(Endpoints.class)
+ .child(EndpointL3.class, l3Key)
+ .build();
ReadOnlyTransaction t = ctx.getDataBroker().newReadOnlyTransaction();
Optional<EndpointL3> r;
BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue()));
- FlowId flowId = new FlowId(new StringBuffer()
- .append("routerarp|")
- .append(sn.getId().getValue())
- .append("|")
- .append(ikey)
- .append("|")
- .append(l3Id)
- .toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(ethernetMatch(null, null, ARP))
- .setLayer3Match(new ArpMatchBuilder()
- .setArpOp(Integer.valueOf(1))
- .setArpTargetTransportAddress(new Ipv4Prefix(ikey + "/32"))
- .build());
- addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class,
- Long.valueOf(l3Id)));
-
- FlowBuilder flowb = base()
- .setPriority(150)
- .setId(flowId)
- .setMatch(mb.build())
- .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(),
- setDlSrcAction(routerMac),
- nxLoadArpOpAction(BigInteger.valueOf(2L)),
- nxMoveArpShaToArpThaAction(),
- nxLoadArpShaAction(intRouterMac),
- nxMoveArpSpaToArpTpaAction(),
- nxLoadArpSpaAction(ikey),
- outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT")))));
+ FlowId flowId = new FlowId(new StringBuffer().append("routerarp|")
+ .append(sn.getId().getValue())
+ .append("|")
+ .append(ikey)
+ .append("|")
+ .append(l3Id)
+ .toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, null, ARP)).setLayer3Match(
+ new ArpMatchBuilder().setArpOp(Integer.valueOf(1))
+ .setArpTargetTransportAddress(new Ipv4Prefix(ikey + "/32"))
+ .build());
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class, Long.valueOf(l3Id)));
+
+ FlowBuilder flowb = base().setPriority(150)
+ .setId(flowId)
+ .setMatch(mb.build())
+ .setInstructions(
+ instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac),
+ nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(),
+ nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(),
+ nxLoadArpSpaAction(ikey), outputAction(new NodeConnectorId(nodeId.getValue()
+ + ":INPORT")))));
return flowb.build();
} else {
- LOG.warn("IPv6 virtual router {} for subnet {} not supported",
- sn.getVirtualRouterIp(), sn.getId().getValue());
+ LOG.warn("IPv6 virtual router {} for subnet {} not supported", sn.getVirtualRouterIp(), sn.getId()
+ .getValue());
return null;
}
int order = 0;
- Action setdEPG = nxLoadRegAction(NxmNxReg2.class,
- BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
- Action setdCG = nxLoadRegAction(NxmNxReg3.class,
- BigInteger.valueOf(epFwdCtxOrds.getCgId()));
+ Action setdEPG = nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
+ Action setdCG = nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(epFwdCtxOrds.getCgId()));
Action setNextHop;
String nextHop;
try {
portNum = getOfPortNum(ofc.getNodeConnectorId());
} catch (NumberFormatException ex) {
- LOG.warn("Could not parse port number {}",
- ofc.getNodeConnectorId(), ex);
+ LOG.warn("Could not parse port number {}", ofc.getNodeConnectorId(), ex);
return null;
}
- setNextHop = nxLoadRegAction(NxmNxReg7.class,
- BigInteger.valueOf(portNum));
+ setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
// END L2 LOCAL
applyActions.add(setdEPG);
applyActions.add(setdCG);
applyActions.add(setNextHop);
- Instruction applyActionsIns = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
- .build();
+ Instruction applyActionsIns = new InstructionBuilder().setOrder(order++)
+ .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
+ .build();
instructions.add(applyActionsIns);
- Instruction gotoTable = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(gotoTableIns((short) (getTableId() + 1)))
- .build();
+ Instruction gotoTable = new InstructionBuilder().setOrder(order++)
+ .setInstruction(gotoTableIns((short) (getTableId() + 1)))
+ .build();
instructions.add(gotoTable);
- FlowId flowid = new FlowId(new StringBuilder()
- .append(epFwdCtxOrds.getBdId())
- .append("|l2|")
- .append(ep.getMacAddress().getValue())
- .append("|")
- .append(nextHop)
- .toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(ethernetMatch(null,
- ep.getMacAddress(),
- null));
+ FlowId flowid = new FlowId(new StringBuilder().append(epFwdCtxOrds.getBdId())
+ .append("|l2|")
+ .append(ep.getMacAddress().getValue())
+ .append("|")
+ .append(nextHop)
+ .toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, ep.getMacAddress(), null));
addNxRegMatch(mb, RegMatch.of(NxmNxReg4.class, Long.valueOf(epFwdCtxOrds.getBdId())));
- FlowBuilder flowb = base()
- .setId(flowid)
- .setPriority(Integer.valueOf(50))
- .setMatch(mb.build())
- .setInstructions(new InstructionsBuilder()
- .setInstruction(instructions)
- .build());
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(50))
+ .setMatch(mb.build())
+ .setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
return flowb.build();
}
- private void syncEP(FlowMap flowMap,
- NodeId nodeId, PolicyInfo policyInfo,
- Endpoint epPeer, Set<EpKey> visitedEps)
+ private void syncEP(FlowMap flowMap, NodeId nodeId, PolicyInfo policyInfo, Endpoint srcEp, Endpoint destEp)
throws Exception {
- EpKey epPeerKey = new EpKey(epPeer.getL2Context(), epPeer.getMacAddress());
-
- if (visitedEps.contains(epPeerKey)) {
- return;
- }
- visitedEps.add(epPeerKey);
-
// TODO: Conditions messed up, but for now, send policyInfo until this
// is fixed.
- EndpointFwdCtxOrdinals epFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, epPeer);
+ EndpointFwdCtxOrdinals destEpFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, destEp);
+ EndpointFwdCtxOrdinals srcEpFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, srcEp);
- if (epPeer.getTenant() == null || (epPeer.getEndpointGroup() == null && epPeer.getEndpointGroups() == null)) {
- LOG.trace("Didn't process endpoint due to either tenant, or EPG(s) being null", epPeer.getKey());
+ if (destEp.getTenant() == null || (destEp.getEndpointGroup() == null && destEp.getEndpointGroups() == null)) {
+ LOG.trace("Didn't process endpoint due to either tenant, or EPG(s) being null", destEp.getKey());
return;
}
- OfOverlayContext ofc = epPeer.getAugmentation(OfOverlayContext.class);
+ OfOverlayContext ofc = destEp.getAugmentation(OfOverlayContext.class);
// ////////////////////////////////////////////////////////////////////////////////////////
/*
- * NOT HANDLING EXTERNALS
+ * NOT HANDLING EXTERNALS TODO: alagalah Li: External Gateway
+ * functionality needed here.
*/
if (LocationType.External.equals(ofc.getLocationType())) {
// XXX - TODO - perform NAT and send to the external network
// this is a local endpoint; send to the approppriate local
// port
- flowMap.writeFlow(nodeId, TABLE_ID, createLocalL2Flow(epPeer, epFwdCtxOrds, ofc));
-
+ if (srcEpFwdCtxOrds.getBdId() == destEpFwdCtxOrds.getBdId()) {
+ flowMap.writeFlow(nodeId, TABLE_ID, createLocalL2Flow(destEp, destEpFwdCtxOrds, ofc));
+ }
// TODO Li alagalah: Need to move to EndpointL3 for L3 processing.
// The Endpoint conflation must end!
- if (epPeer.getL3Address() == null) {
- LOG.trace("Endpoint {} didn't have L3 Address so was not processed for L3 flows.", epPeer.getKey());
+ if (destEp.getL3Address() == null) {
+ LOG.trace("Endpoint {} didn't have L3 Address so was not processed for L3 flows.", destEp.getKey());
return;
}
- for (L3Address l3a : epPeer.getL3Address()) {
+ for (L3Address l3a : destEp.getL3Address()) {
if (l3a.getIpAddress() == null || l3a.getL3Context() == null) {
LOG.error("Endpoint with L3Address but either IPAddress or L3Context is null. {}",
- epPeer.getL3Address());
+ destEp.getL3Address());
continue;
} else {
for (Subnet localSubnet : localSubnets) {
- Flow flow = createLocalL3RoutedFlow(epPeer, l3a, epFwdCtxOrds, ofc, localSubnet);
+ Flow flow = createLocalL3RoutedFlow(destEp, l3a, destEpFwdCtxOrds, ofc, localSubnet);
if (flow != null) {
flowMap.writeFlow(nodeId, TABLE_ID, flow);
} else {
} else {
// this endpoint is on a different switch; send to the
// appropriate tunnel
-
- Flow remoteL2Flow = createRemoteL2Flow(epPeer, nodeId, epFwdCtxOrds, ofc);
- if (remoteL2Flow != null) {
- flowMap.writeFlow(nodeId, TABLE_ID, remoteL2Flow);
+ if (srcEpFwdCtxOrds.getBdId() == destEpFwdCtxOrds.getBdId()) {
+ Flow remoteL2Flow = createRemoteL2Flow(destEp, nodeId, srcEpFwdCtxOrds, destEpFwdCtxOrds, ofc);
+ if (remoteL2Flow != null) {
+ flowMap.writeFlow(nodeId, TABLE_ID, remoteL2Flow);
+ }
+ } else {
+ LOG.trace("DestinationMapper: RemoteL2Flow: not created, in different BDs src: {} dst: {}",
+ srcEpFwdCtxOrds.getBdId(), destEpFwdCtxOrds.getBdId());
}
// TODO Li alagalah: Need to move to EndpointL3 for L3 processing.
// The Endpoint conflation must end!
- if (epPeer.getL3Address() == null) {
- LOG.trace("Endpoint {} didn't have L3 Address so was not processed for L3 flows.", epPeer.getKey());
+ if (destEp.getL3Address() == null) {
+ LOG.trace("Endpoint {} didn't have L3 Address so was not processed for L3 flows.", destEp.getKey());
return;
}
- for (L3Address l3a : epPeer.getL3Address()) {
+ for (L3Address l3a : destEp.getL3Address()) {
if (l3a.getIpAddress() == null || l3a.getL3Context() == null) {
LOG.error("Endpoint with L3Address but either IPAddress or L3Context is null. {}",
- epPeer.getL3Address());
+ destEp.getL3Address());
continue;
} else {
for (Subnet localSubnet : localSubnets) {
- Flow remoteL3Flow = createRemoteL3RoutedFlow(epPeer, l3a, nodeId, epFwdCtxOrds, ofc, localSubnet);
+ Flow remoteL3Flow = createRemoteL3RoutedFlow(destEp, l3a, nodeId, srcEpFwdCtxOrds,
+ destEpFwdCtxOrds, ofc, localSubnet);
if (remoteL3Flow != null) {
flowMap.writeFlow(nodeId, TABLE_ID, remoteL3Flow);
} else {
LOG.trace("No subnets in tenant {}", destL3Address.getIpAddress());
return null;
}
- NetworkDomainId epNetworkContainment= getEPNetworkContainment(destEp);
+ NetworkDomainId epNetworkContainment = getEPNetworkContainment(destEp);
for (Subnet subnet : subnets) {
// TODO Li alagalah add IPv6 support
if (subnet.getId().getValue().equals(epNetworkContainment.getValue())) {
if (!(srcL3c.getId().getValue().equals(destL3c.getId().getValue()))) {
LOG.trace("Trying to route between two L3Contexts {} and {}. Not currently supported.", srcL3c.getId()
- .getValue(), destL3c.getId().getValue());
+ .getValue(), destL3c.getId().getValue());
return null;
}
- MacAddress matcherMac = routerPortMac(destL3c,srcSubnet.getVirtualRouterIp());
+ MacAddress matcherMac = routerPortMac(destL3c, srcSubnet.getVirtualRouterIp());
MacAddress epDestMac = destEp.getMacAddress();
MacAddress destSubnetGatewayMac = routerPortMac(destL3c, destSubnet.getVirtualRouterIp());
- if (srcSubnet.getId().getValue().equals(destSubnet.getId().getValue())){
+ if (srcSubnet.getId().getValue().equals(destSubnet.getId().getValue())) {
// This is our final destination, so match on actual EP mac.
- matcherMac=epDestMac;
+ matcherMac = epDestMac;
}
ArrayList<Instruction> l3instructions = new ArrayList<>();
int order = 0;
- Action setdEPG = nxLoadRegAction(NxmNxReg2.class,
- BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
- Action setdCG = nxLoadRegAction(NxmNxReg3.class,
- BigInteger.valueOf(epFwdCtxOrds.getCgId()));
+ Action setdEPG = nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
+ Action setdCG = nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(epFwdCtxOrds.getCgId()));
Action setNextHop;
String nextHop;
try {
portNum = getOfPortNum(ofc.getNodeConnectorId());
} catch (NumberFormatException ex) {
- LOG.warn("Could not parse port number {}",
- ofc.getNodeConnectorId(), ex);
+ LOG.warn("Could not parse port number {}", ofc.getNodeConnectorId(), ex);
return null;
}
- setNextHop = nxLoadRegAction(NxmNxReg7.class,
- BigInteger.valueOf(portNum));
+ setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
// END L3 LOCAL
- Action setDlSrc = setDlSrcAction(destSubnetGatewayMac);
- l3ApplyActions.add(setDlSrc);
+ // Lets not re-write the srcMac if its local.
+ if (!(matcherMac.getValue().equals(epDestMac.getValue()))) {
+ Action setDlSrc = setDlSrcAction(destSubnetGatewayMac);
+ l3ApplyActions.add(setDlSrc);
+ }
Action setDlDst = setDlDstAction(epDestMac);
l3ApplyActions.add(setDlDst);
applyActions.add(setNextHop);
applyActions.addAll(l3ApplyActions);
- Instruction applyActionsIns = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
- .build();
+ Instruction applyActionsIns = new InstructionBuilder().setOrder(order++)
+ .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
+ .build();
l3instructions.add(applyActionsIns);
- Instruction gotoTable = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(gotoTableIns((short) (getTableId() + 1)))
- .build();
+ Instruction gotoTable = new InstructionBuilder().setOrder(order++)
+ .setInstruction(gotoTableIns((short) (getTableId() + 1)))
+ .build();
l3instructions.add(gotoTable);
Layer3Match m = null;
Long etherType = null;
if (destL3Address.getIpAddress().getIpv4Address() != null) {
ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32";
etherType = IPv4;
- m = new Ipv4MatchBuilder()
- .setIpv4Destination(new Ipv4Prefix(ikey))
- .build();
+ m = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build();
} else if (destL3Address.getIpAddress().getIpv6Address() != null) {
ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128";
etherType = IPv6;
- m = new Ipv6MatchBuilder()
- .setIpv6Destination(new Ipv6Prefix(ikey))
- .build();
+ m = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build();
} else {
LOG.error("Endpoint has IPAddress that is not recognised as either IPv4 or IPv6.", destL3Address.toString());
return null;
}
- FlowId flowid = new FlowId(new StringBuilder()
- .append(Integer.toString(epFwdCtxOrds.getL3Id()))
- .append("|l3|")
- .append(ikey)
- .append("|")
- .append(Integer.toString(epFwdCtxOrds.getEpgId()))
- .append("|")
- .append(Integer.toString(epFwdCtxOrds.getCgId()))
- .append("|")
- .append(matcherMac)
- .append("|")
- .append(destSubnetGatewayMac)
- .append("|")
- .append(nextHop)
- .toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(ethernetMatch(null,
- matcherMac,
- etherType))
- .setLayer3Match(m);
- addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class,
- Long.valueOf(epFwdCtxOrds.getL3Id())));
- FlowBuilder flowb = base()
- .setId(flowid)
- .setPriority(Integer.valueOf(132))
- .setMatch(mb.build())
- .setInstructions(new InstructionsBuilder()
- .setInstruction(l3instructions)
- .build());
+ FlowId flowid = new FlowId(new StringBuilder().append(Integer.toString(epFwdCtxOrds.getL3Id()))
+ .append("|l3|")
+ .append(ikey)
+ .append("|")
+ .append(Integer.toString(epFwdCtxOrds.getEpgId()))
+ .append("|")
+ .append(Integer.toString(epFwdCtxOrds.getCgId()))
+ .append("|")
+ .append(matcherMac)
+ .append("|")
+ .append(destSubnetGatewayMac)
+ .append("|")
+ .append(nextHop)
+ .toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType))
+ .setLayer3Match(m);
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class, Long.valueOf(epFwdCtxOrds.getL3Id())));
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(132))
+ .setMatch(mb.build())
+ .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build());
return flowb.build();
}
- private Flow createRemoteL2Flow(Endpoint ep, NodeId nodeId, EndpointFwdCtxOrdinals epFwdCtxOrds,
- OfOverlayContext ofc) {
+ private Flow createRemoteL2Flow(Endpoint ep, NodeId nodeId, EndpointFwdCtxOrdinals srcEpFwdCtxOrds,
+ EndpointFwdCtxOrdinals destEpFwdCtxOrds, OfOverlayContext ofc) {
// TODO Li alagalah - refactor common code but keep simple method
int order = 0;
- Action setdEPG = nxLoadRegAction(NxmNxReg2.class,
- BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
- Action setdCG = nxLoadRegAction(NxmNxReg3.class,
- BigInteger.valueOf(epFwdCtxOrds.getCgId()));
+ Action setdEPG = nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(destEpFwdCtxOrds.getEpgId()));
+ Action setdCG = nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(destEpFwdCtxOrds.getCgId()));
Action setNextHop;
String nextHop;
// BEGIN TUNNEL HANDLING
- IpAddress tunDst =
- ctx.getSwitchManager().getTunnelIP(ofc.getNodeId());
- NodeConnectorId tunPort =
- ctx.getSwitchManager().getTunnelPort(nodeId);
+ IpAddress tunDst = ctx.getSwitchManager().getTunnelIP(ofc.getNodeId());
+ NodeConnectorId tunPort = ctx.getSwitchManager().getTunnelPort(nodeId);
if (tunDst == null) {
LOG.warn("Failed to get Tunnel IP for NodeId {} with EP {}", nodeId, ep);
return null;
tundstAction = nxLoadTunIPv4Action(nextHop, false);
} else if (tunDst.getIpv6Address() != null) {
// nextHop = tunDst.getIpv6Address().getValue();
- LOG.error("IPv6 tunnel destination {} for {} not supported",
- tunDst.getIpv6Address().getValue(),
+ LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(),
ofc.getNodeId());
return null;
} else {
try {
portNum = getOfPortNum(tunPort);
} catch (NumberFormatException ex) {
- LOG.warn("Could not parse port number {}",
- ofc.getNodeConnectorId(), ex);
+ LOG.warn("Could not parse port number {}", ofc.getNodeConnectorId(), ex);
return null;
}
- setNextHop = nxLoadRegAction(NxmNxReg7.class,
- BigInteger.valueOf(portNum));
- Action tunIdAction =
- nxMoveRegTunIdAction(NxmNxReg0.class, false);
+ setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
+ Action tunIdAction = nxLoadTunIdAction(BigInteger.valueOf(srcEpFwdCtxOrds.getTunnelId()), false);
applyActions.add(tunIdAction);
applyActions.add(tundstAction);
applyActions.add(setdEPG);
applyActions.add(setdCG);
applyActions.add(setNextHop);
- Instruction applyActionsIns = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
- .build();
+ Instruction applyActionsIns = new InstructionBuilder().setOrder(order++)
+ .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
+ .build();
instructions.add(applyActionsIns);
- applyActionsIns = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
- .build();
+ applyActionsIns = new InstructionBuilder().setOrder(order++)
+ .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
+ .build();
- Instruction gotoTable = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(gotoTableIns((short) (getTableId() + 1)))
- .build();
+ Instruction gotoTable = new InstructionBuilder().setOrder(order++)
+ .setInstruction(gotoTableIns((short) (getTableId() + 1)))
+ .build();
instructions.add(gotoTable);
- FlowId flowid = new FlowId(new StringBuilder()
- .append(epFwdCtxOrds.getBdId())
- .append("|l2|")
- .append(ep.getMacAddress().getValue())
- .append("|")
- .append(nextHop)
- .toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(ethernetMatch(null,
- ep.getMacAddress(),
- null));
- addNxRegMatch(mb, RegMatch.of(NxmNxReg4.class, Long.valueOf(epFwdCtxOrds.getBdId())));
- FlowBuilder flowb = base()
- .setId(flowid)
- .setPriority(Integer.valueOf(50))
- .setMatch(mb.build())
- .setInstructions(new InstructionsBuilder()
- .setInstruction(instructions)
- .build());
+ FlowId flowid = new FlowId(new StringBuilder().append(destEpFwdCtxOrds.getBdId())
+ .append("|l2|")
+ .append(ep.getMacAddress().getValue())
+ .append("|")
+ .append(srcEpFwdCtxOrds.getTunnelId())
+ .append("|")
+ .append(nextHop)
+ .toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, ep.getMacAddress(), null));
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg4.class, Long.valueOf(destEpFwdCtxOrds.getBdId())));
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(50))
+ .setMatch(mb.build())
+ .setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
return flowb.build();
}
private Flow createRemoteL3RoutedFlow(Endpoint destEp, L3Address destL3Address, NodeId nodeId,
- EndpointFwdCtxOrdinals epFwdCtxOrds, OfOverlayContext ofc, Subnet srcSubnet) {
+ EndpointFwdCtxOrdinals srcEpFwdCtxOrds, EndpointFwdCtxOrdinals destEpFwdCtxOrds, OfOverlayContext ofc,
+ Subnet srcSubnet) {
// TODO Li alagalah - refactor common code but keep simple method
LOG.trace("No subnets in tenant {}", destL3Address.getIpAddress());
return null;
}
- NetworkDomainId epNetworkContainment= getEPNetworkContainment(destEp);
+ NetworkDomainId epNetworkContainment = getEPNetworkContainment(destEp);
for (Subnet subnet : subnets) {
// TODO Li alagalah add IPv6 support
if (subnet.getId().getValue().equals(epNetworkContainment.getValue())) {
LOG.trace("Local subnet {} has no gateway IP", srcSubnet.getIpPrefix());
return null;
}
- L3Context destL3c = getL3ContextForSubnet(destEp.getTenant(),destSubnet);
+ L3Context destL3c = getL3ContextForSubnet(destEp.getTenant(), destSubnet);
if (destL3c == null || destL3c.getId() == null) {
LOG.error("No L3 Context found associated with subnet {}", destSubnet.getId());
return null;
}
- L3Context srcL3c = getL3ContextForSubnet(destEp.getTenant(),srcSubnet);
+ L3Context srcL3c = getL3ContextForSubnet(destEp.getTenant(), srcSubnet);
if (srcL3c == null || srcL3c.getId() == null) {
LOG.error("No L3 Context found associated with subnet {}", srcSubnet.getId());
return null;
if (!(srcL3c.getId().getValue().equals(destL3c.getId().getValue()))) {
LOG.trace("Trying to route between two L3Contexts {} and {}. Not currently supported.", srcL3c.getId()
- .getValue(), destL3c.getId().getValue());
+ .getValue(), destL3c.getId().getValue());
return null;
}
- MacAddress matcherMac = routerPortMac(destL3c,srcSubnet.getVirtualRouterIp());
+ MacAddress matcherMac = routerPortMac(destL3c, srcSubnet.getVirtualRouterIp());
MacAddress epDestMac = destEp.getMacAddress();
MacAddress destSubnetGatewayMac = routerPortMac(destL3c, destSubnet.getVirtualRouterIp());
int order = 0;
- Action setdEPG = nxLoadRegAction(NxmNxReg2.class,
- BigInteger.valueOf(epFwdCtxOrds.getEpgId()));
- Action setdCG = nxLoadRegAction(NxmNxReg3.class,
- BigInteger.valueOf(epFwdCtxOrds.getCgId()));
+ Action setdEPG = nxLoadRegAction(NxmNxReg2.class, BigInteger.valueOf(destEpFwdCtxOrds.getEpgId()));
+ Action setdCG = nxLoadRegAction(NxmNxReg3.class, BigInteger.valueOf(destEpFwdCtxOrds.getCgId()));
Action setNextHop;
String nextHop;
// BEGIN TUNNEL HANDLING
- IpAddress tunDst =
- ctx.getSwitchManager().getTunnelIP(ofc.getNodeId());
- NodeConnectorId tunPort =
- ctx.getSwitchManager().getTunnelPort(nodeId);
+ IpAddress tunDst = ctx.getSwitchManager().getTunnelIP(ofc.getNodeId());
+ NodeConnectorId tunPort = ctx.getSwitchManager().getTunnelPort(nodeId);
if (tunDst == null) {
LOG.warn("Failed to get Tunnel IP for NodeId {} with L3Address {}", nodeId, destL3Address);
return null;
tundstAction = nxLoadTunIPv4Action(nextHop, false);
} else if (tunDst.getIpv6Address() != null) {
// nextHop = tunDst.getIpv6Address().getValue();
- LOG.error("IPv6 tunnel destination {} for {} not supported",
- tunDst.getIpv6Address().getValue(),
+ LOG.error("IPv6 tunnel destination {} for {} not supported", tunDst.getIpv6Address().getValue(),
ofc.getNodeId());
return null;
} else {
try {
portNum = getOfPortNum(tunPort);
} catch (NumberFormatException ex) {
- LOG.warn("Could not parse port number {}",
- ofc.getNodeConnectorId(), ex);
+ LOG.warn("Could not parse port number {}", ofc.getNodeConnectorId(), ex);
return null;
}
- setNextHop = nxLoadRegAction(NxmNxReg7.class,
- BigInteger.valueOf(portNum));
- Action tunIdAction =
- nxMoveRegTunIdAction(NxmNxReg0.class, false);
+ setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
+ Action tunIdAction = nxLoadTunIdAction(BigInteger.valueOf(srcEpFwdCtxOrds.getTunnelId()), false);
applyActions.add(tunIdAction);
applyActions.add(tundstAction);
// END TUNNEL
-
order += 1;
applyActions.add(setdEPG);
applyActions.add(setdCG);
l3ApplyActions.add(decTtl);
applyActions.addAll(l3ApplyActions);
- Instruction applyActionsIns = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
- .build();
+ Instruction applyActionsIns = new InstructionBuilder().setOrder(order++)
+ .setInstruction(applyActionIns(applyActions.toArray(new Action[applyActions.size()])))
+ .build();
l3instructions.add(applyActionsIns);
- Instruction gotoTable = new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(gotoTableIns((short) (getTableId() + 1)))
- .build();
+ Instruction gotoTable = new InstructionBuilder().setOrder(order++)
+ .setInstruction(gotoTableIns((short) (getTableId() + 1)))
+ .build();
l3instructions.add(gotoTable);
Layer3Match m = null;
Long etherType = null;
if (destL3Address.getIpAddress().getIpv4Address() != null) {
ikey = destL3Address.getIpAddress().getIpv4Address().getValue() + "/32";
etherType = IPv4;
- m = new Ipv4MatchBuilder()
- .setIpv4Destination(new Ipv4Prefix(ikey))
- .build();
+ m = new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix(ikey)).build();
} else if (destL3Address.getIpAddress().getIpv6Address() != null) {
ikey = destL3Address.getIpAddress().getIpv6Address().getValue() + "/128";
etherType = IPv6;
- m = new Ipv6MatchBuilder()
- .setIpv6Destination(new Ipv6Prefix(ikey))
- .build();
+ m = new Ipv6MatchBuilder().setIpv6Destination(new Ipv6Prefix(ikey)).build();
} else {
LOG.error("Endpoint has IPAddress that is not recognised as either IPv4 or IPv6.", destL3Address.toString());
return null;
}
- FlowId flowid = new FlowId(new StringBuilder()
- .append(Integer.toString(epFwdCtxOrds.getL3Id()))
- .append("|l3|")
- .append(ikey)
- .append("|")
- .append(Integer.toString(epFwdCtxOrds.getEpgId()))
- .append("|")
- .append(Integer.toString(epFwdCtxOrds.getCgId()))
- .append("|")
- .append(matcherMac)
- .append("|")
- .append(destSubnetGatewayMac)
- .append("|")
- .append(nextHop)
- .toString());
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(ethernetMatch(null,
- matcherMac,
- etherType))
- .setLayer3Match(m);
- addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class,
- Long.valueOf(epFwdCtxOrds.getL3Id())));
- FlowBuilder flowb = base()
- .setId(flowid)
- .setPriority(Integer.valueOf(132))
- .setMatch(mb.build())
- .setInstructions(new InstructionsBuilder()
- .setInstruction(l3instructions)
- .build());
+ FlowId flowid = new FlowId(new StringBuilder().append(Integer.toString(destEpFwdCtxOrds.getL3Id()))
+ .append("|l3|")
+ .append(ikey)
+ .append("|")
+ .append(destEpFwdCtxOrds.getEpgId())
+ .append("|")
+ .append(destEpFwdCtxOrds.getCgId())
+ .append("|")
+ .append(matcherMac)
+ .append("|")
+ .append(destSubnetGatewayMac)
+ .append("|")
+ .append(srcEpFwdCtxOrds.getEpgId())
+ .append("|")
+ .append(srcEpFwdCtxOrds.getFdId())
+ .append("|")
+ .append(nextHop)
+ .toString());
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType))
+ .setLayer3Match(m);
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg0.class, Long.valueOf(srcEpFwdCtxOrds.getEpgId())),
+ RegMatch.of(NxmNxReg5.class, Long.valueOf(srcEpFwdCtxOrds.getFdId())),
+ RegMatch.of(NxmNxReg6.class, Long.valueOf(destEpFwdCtxOrds.getL3Id())));
+
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(132))
+ .setMatch(mb.build())
+ .setInstructions(new InstructionsBuilder().setInstruction(l3instructions).build());
return flowb.build();
}
* which we can't do because of the backwards way endpoints were
* "architected".
*/
- return ctx.getPolicyResolver().getTenant(endpoint.getTenant())
- .getEndpointGroup(endpoint.getEndpointGroup()).getNetworkDomain();
+ return ctx.getPolicyResolver()
+ .getTenant(endpoint.getTenant())
+ .getEndpointGroup(endpoint.getEndpointGroup())
+ .getNetworkDomain();
}
}
LOG.error("No local subnets.");
return null;
}
- NetworkDomainId epNetworkContainment= getEPNetworkContainment(endpoint);
+ NetworkDomainId epNetworkContainment = getEPNetworkContainment(endpoint);
for (Subnet subnet : subnets) {
if (epNetworkContainment.getValue().equals(subnet.getId().getValue())) {
localSubnets.add(subnet);
* Reads data from datastore as synchronous call.
*
* @return {@link Optional#isPresent()} is {@code true} if reading was
- * successful and data exists in datastore;
- * {@link Optional#isPresent()} is {@code false} otherwise
+ * successful and data exists in datastore; {@link Optional#isPresent()} is
+ * {@code false} otherwise
*/
public static <T extends DataObject> Optional<T> readFromDs(LogicalDatastoreType store, InstanceIdentifier<T> path,
ReadTransaction rTx) {
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputReg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputRegBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsi;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsiBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNspBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsiBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNspBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg0Key;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg1Key;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg2Key;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg6Key;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg7Key;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxRegBuilder;
* Utilities for constructing OpenFlow flows
*/
public final class FlowUtils {
+
/**
* ARP ethertype
*/
* IPv6 ethertype
*/
public static final Long IPv6 = Long.valueOf(0x86DD);
-
+
/**
* Creates an Instance Identifier (path) for node with specified id
*
* @param nodeId
* @return
*/
- public static final InstanceIdentifier<Node>
- createNodePath(final NodeId nodeId) {
- return InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, new NodeKey(nodeId))
- .build();
+ public static final InstanceIdentifier<Node> createNodePath(final NodeId nodeId) {
+ return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(nodeId)).build();
}
/**
* @param tableId the ID of the table
* @return the {@link InstanceIdentifier<Table>}
*/
- public static final InstanceIdentifier<Table>
- createTablePath(final NodeId nodeId,
- final short tableId) {
+ public static final InstanceIdentifier<Table> createTablePath(final NodeId nodeId, final short tableId) {
return createNodePath(nodeId).builder()
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(tableId))
- .build();
+ .augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(tableId))
+ .build();
}
-
+
/**
* Creates a group path from a node ID and group ID
*
* @param groupId the ID of the group table
* @return the {@link InstanceIdentifier<Group>}
*/
- public static final InstanceIdentifier<Group>
- createGroupPath(final NodeId nodeId,
- final GroupId groupId) {
+ public static final InstanceIdentifier<Group> createGroupPath(final NodeId nodeId, final GroupId groupId) {
return createNodePath(nodeId).builder()
- .augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(groupId))
- .build();
+ .augmentation(FlowCapableNode.class)
+ .child(Group.class, new GroupKey(groupId))
+ .build();
}
+
/**
* Creates a group path from a node ID and group ID
*
* @param bucketId the ID of the bucket in the group table
* @return the {@link InstanceIdentifier<Bucket>}
*/
- public static final InstanceIdentifier<Bucket>
- createBucketPath(final NodeId nodeId,
- final GroupId groupId,
- final BucketId bucketId) {
+ public static final InstanceIdentifier<Bucket> createBucketPath(final NodeId nodeId, final GroupId groupId,
+ final BucketId bucketId) {
return createNodePath(nodeId).builder()
- .augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(groupId))
- .child(Buckets.class)
- .child(Bucket.class, new BucketKey(bucketId))
- .build();
+ .augmentation(FlowCapableNode.class)
+ .child(Group.class, new GroupKey(groupId))
+ .child(Buckets.class)
+ .child(Bucket.class, new BucketKey(bucketId))
+ .build();
}
-
+
/**
* Creates a path for particular flow, by appending flow-specific information
* to table path.
* @param flowKey
* @return
*/
- public static InstanceIdentifier<Flow>
- createFlowPath(final InstanceIdentifier<Table> table,
- final FlowKey flowKey) {
+ public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table, final FlowKey flowKey) {
return table.child(Flow.class, flowKey);
}
-
+
/**
* Creates a path for particular flow, by appending flow-specific information
* to table path.
* @param flowId
* @return
*/
- public static InstanceIdentifier<Flow>
- createFlowPath(final InstanceIdentifier<Table> table,
- final FlowId flowId) {
+ public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table, final FlowId flowId) {
return createFlowPath(table, new FlowKey(flowId));
}
public static Instructions gotoTableInstructions(short tableId) {
- return new InstructionsBuilder()
- .setInstruction(ImmutableList.of(new InstructionBuilder()
- .setOrder(Integer.valueOf(0))
- .setInstruction(gotoTableIns(tableId))
- .build()))
- .build();
- }
-
+ return new InstructionsBuilder().setInstruction(
+ ImmutableList.of(new InstructionBuilder().setOrder(Integer.valueOf(0))
+ .setInstruction(gotoTableIns(tableId))
+ .build())).build();
+ }
+
public static Instruction gotoTableIns(short tableId) {
- return new GoToTableCaseBuilder()
- .setGoToTable(new GoToTableBuilder()
- .setTableId(tableId)
- .build())
- .build();
+ return new GoToTableCaseBuilder().setGoToTable(new GoToTableBuilder().setTableId(tableId).build()).build();
}
- public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(Action... actions) {
- ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist
- = new ArrayList<>();
+ public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(
+ Action... actions) {
+ ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist = new ArrayList<>();
int count = 0;
for (Action action : actions) {
- alist.add(new ActionBuilder()
- .setOrder(Integer.valueOf(count++))
- .setAction(action)
- .build());
+ alist.add(new ActionBuilder().setOrder(Integer.valueOf(count++)).setAction(action).build());
}
return alist;
}
- public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(List<ActionBuilder> actions) {
- ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist
- = new ArrayList<>();
+
+ public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(
+ List<ActionBuilder> actions) {
+ ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist = new ArrayList<>();
int count = 0;
for (ActionBuilder action : actions) {
- alist.add(action
- .setOrder(Integer.valueOf(count++))
- .build());
+ alist.add(action.setOrder(Integer.valueOf(count++)).build());
}
return alist;
}
+
public static Instruction applyActionIns(Action... actions) {
- return new ApplyActionsCaseBuilder()
- .setApplyActions(new ApplyActionsBuilder()
- .setAction(actionList(actions))
- .build())
- .build();
+ return new ApplyActionsCaseBuilder().setApplyActions(
+ new ApplyActionsBuilder().setAction(actionList(actions)).build()).build();
}
+
public static Instruction applyActionIns(List<ActionBuilder> actions) {
- return new ApplyActionsCaseBuilder()
- .setApplyActions(new ApplyActionsBuilder()
- .setAction(actionList(actions))
- .build())
- .build();
+ return new ApplyActionsCaseBuilder().setApplyActions(
+ new ApplyActionsBuilder().setAction(actionList(actions)).build()).build();
}
+
public static Instructions instructions(Instruction... instructions) {
- ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins
- = new ArrayList<>();
+ ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins = new ArrayList<>();
int order = 0;
for (Instruction i : instructions) {
- ins.add(new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(i)
- .build());
+ ins.add(new InstructionBuilder().setOrder(order++).setInstruction(i).build());
}
return new InstructionsBuilder().setInstruction(ins).build();
}
public static Instructions dropInstructions() {
return instructions(applyActionIns(dropAction()));
}
-
+
public static Action dropAction() {
- return new DropActionCaseBuilder()
- .setDropAction(new DropActionBuilder()
- .build())
- .build();
+ return new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
}
-
+
public static Action outputAction(NodeConnectorId id) {
- return new OutputActionCaseBuilder()
- .setOutputAction(new OutputActionBuilder()
- .setOutputNodeConnector(new Uri(id.getValue()))
- .build())
- .build();
+ return new OutputActionCaseBuilder().setOutputAction(
+ new OutputActionBuilder().setOutputNodeConnector(new Uri(id.getValue())).build()).build();
}
public static Action groupAction(Long id) {
- return new GroupActionCaseBuilder()
- .setGroupAction(new GroupActionBuilder()
- .setGroupId(id)
- .build())
- .build();
+ return new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().setGroupId(id).build()).build();
}
-
+
public static Action setDlSrcAction(MacAddress mac) {
- return new SetDlSrcActionCaseBuilder()
- .setSetDlSrcAction(new SetDlSrcActionBuilder()
- .setAddress(mac)
- .build())
+ return new SetDlSrcActionCaseBuilder().setSetDlSrcAction(new SetDlSrcActionBuilder().setAddress(mac).build())
.build();
}
public static Action setDlDstAction(MacAddress mac) {
- return new SetDlDstActionCaseBuilder()
- .setSetDlDstAction(new SetDlDstActionBuilder()
- .setAddress(mac)
- .build())
+ return new SetDlDstActionCaseBuilder().setSetDlDstAction(new SetDlDstActionBuilder().setAddress(mac).build())
.build();
}
public static Action decNwTtlAction() {
- return new DecNwTtlCaseBuilder()
- .setDecNwTtl(new DecNwTtlBuilder()
- .build())
- .build();
+ return new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build();
}
- public static Action nxLoadRegAction(DstChoice dstChoice,
- BigInteger value,
- int endOffset,
- boolean groupBucket) {
- NxRegLoad r = new NxRegLoadBuilder()
- .setDst(new DstBuilder()
- .setDstChoice(dstChoice)
- .setStart(Integer.valueOf(0))
- .setEnd(Integer.valueOf(endOffset))
- .build())
+ public static Action nxLoadRegAction(DstChoice dstChoice, BigInteger value, int endOffset, boolean groupBucket) {
+ NxRegLoad r = new NxRegLoadBuilder().setDst(
+ new DstBuilder().setDstChoice(dstChoice)
+ .setStart(Integer.valueOf(0))
+ .setEnd(Integer.valueOf(endOffset))
+ .build())
.setValue(value)
.build();
if (groupBucket) {
- return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder()
- .setNxRegLoad(r).build();
+ return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegLoad(r).build();
} else {
- return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
- .setNxRegLoad(r).build();
+ return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(r).build();
}
}
public static Action nxSetNsiAction(Short nsi) {
- NxSetNsi newNsi = new NxSetNsiBuilder()
- .setNsi(nsi)
- .build();
- return new NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder()
- .setNxSetNsi(newNsi)
- .build();
+ NxSetNsi newNsi = new NxSetNsiBuilder().setNsi(nsi).build();
+ return new NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsi(newNsi).build();
}
public static Action nxSetNspAction(Long nsp) {
- NxSetNsp newNsp = new NxSetNspBuilder()
- .setNsp(nsp)
- .build();
- return new NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder()
- .setNxSetNsp(newNsp)
- .build();
+ NxSetNsp newNsp = new NxSetNspBuilder().setNsp(nsp).build();
+ return new NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsp(newNsp).build();
}
- public static Action nxLoadRegAction(DstChoice dstChoice,
- BigInteger value) {
+ public static Action nxLoadRegAction(DstChoice dstChoice, BigInteger value) {
return nxLoadRegAction(dstChoice, value, 31, false);
}
- public static Action nxLoadRegAction(Class<? extends NxmNxReg> reg,
- BigInteger value) {
- return nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(reg).build(),
- value);
+ public static Action nxLoadRegAction(Class<? extends NxmNxReg> reg, BigInteger value) {
+ return nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(reg).build(), value);
}
- public static Action nxLoadTunIPv4Action(String ipAddress,
- boolean groupBucket) {
+
+ public static Action nxLoadTunIPv4Action(String ipAddress, boolean groupBucket) {
int ip = InetAddresses.coerceToInteger(InetAddresses.forString(ipAddress));
long ipl = ip & 0xffffffffL;
- return nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder()
- .setNxTunIpv4Dst(Boolean.TRUE).build(),
- BigInteger.valueOf(ipl),
- 31,
- groupBucket);
+ return nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
+ BigInteger.valueOf(ipl), 31, groupBucket);
}
public static Action nxLoadArpOpAction(BigInteger value) {
- return nxLoadRegAction(new DstOfArpOpCaseBuilder()
- .setOfArpOp(Boolean.TRUE).build(), value, 15, false);
+ return nxLoadRegAction(new DstOfArpOpCaseBuilder().setOfArpOp(Boolean.TRUE).build(), value, 15, false);
}
public static Action nxLoadArpShaAction(BigInteger value) {
- return nxLoadRegAction(new DstNxArpShaCaseBuilder()
- .setNxArpSha(Boolean.TRUE).build(), value, 47, false);
+ return nxLoadRegAction(new DstNxArpShaCaseBuilder().setNxArpSha(Boolean.TRUE).build(), value, 47, false);
}
public static Action nxLoadArpSpaAction(BigInteger value) {
- return nxLoadRegAction(new DstOfArpSpaCaseBuilder()
- .setOfArpSpa(Boolean.TRUE).build(), value);
+ return nxLoadRegAction(new DstOfArpSpaCaseBuilder().setOfArpSpa(Boolean.TRUE).build(), value);
}
public static Action nxLoadArpSpaAction(String ipAddress) {
return nxLoadArpSpaAction(BigInteger.valueOf(ipl));
}
- public static Action nxMoveRegAction(SrcChoice srcChoice,
- DstChoice dstChoice,
- int endOffset,
- boolean groupBucket) {
- NxRegMove r = new NxRegMoveBuilder()
- .setSrc(new SrcBuilder()
- .setSrcChoice(srcChoice)
- .setStart(Integer.valueOf(0))
- .setEnd(Integer.valueOf(endOffset))
- .build())
- .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
- .setDstChoice(dstChoice)
+ public static Action nxMoveRegAction(SrcChoice srcChoice, DstChoice dstChoice, int endOffset, boolean groupBucket) {
+ NxRegMove r = new NxRegMoveBuilder().setSrc(
+ new SrcBuilder().setSrcChoice(srcChoice)
+ .setStart(Integer.valueOf(0))
+ .setEnd(Integer.valueOf(endOffset))
+ .build())
+ .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder().setDstChoice(
+ dstChoice)
.setStart(Integer.valueOf(0))
.setEnd(Integer.valueOf(endOffset))
.build())
.build();
if (groupBucket) {
- return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder()
- .setNxRegMove(r).build();
+ return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegMove(r).build();
} else {
- return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder()
- .setNxRegMove(r).build();
+ return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(r).build();
}
}
-
- public static Action nxMoveRegAction(SrcChoice srcChoice,
- DstChoice dstChoice) {
+
+ public static Action nxMoveRegAction(SrcChoice srcChoice, DstChoice dstChoice) {
return nxMoveRegAction(srcChoice, dstChoice, 31, false);
}
- public static Action nxMoveRegTunIdAction(Class<? extends NxmNxReg> src,
- boolean groupBucket) {
- return nxMoveRegAction(new SrcNxRegCaseBuilder()
- .setNxReg(src).build(),
- new DstNxTunIdCaseBuilder()
- .setNxTunId(Boolean.TRUE).build(),
- 31,
- groupBucket);
+ public static Action nxMoveRegTunIdAction(Class<? extends NxmNxReg> src, boolean groupBucket) {
+ return nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(src).build(),
+ new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(), 31, groupBucket);
+ }
+
+ public static Action nxLoadTunIdAction(BigInteger tunnelId, boolean groupBucket) {
+ return nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(), tunnelId, 31, groupBucket);
}
public static Action nxMoveArpShaToArpThaAction() {
- return nxMoveRegAction(new SrcNxArpShaCaseBuilder()
- .setNxArpSha(Boolean.TRUE).build(),
- new DstNxArpThaCaseBuilder()
- .setNxArpTha(Boolean.TRUE).build(),
- 47, false);
+ return nxMoveRegAction(new SrcNxArpShaCaseBuilder().setNxArpSha(Boolean.TRUE).build(),
+ new DstNxArpThaCaseBuilder().setNxArpTha(Boolean.TRUE).build(), 47, false);
}
public static Action nxMoveEthSrcToEthDstAction() {
- return nxMoveRegAction(new SrcOfEthSrcCaseBuilder()
- .setOfEthSrc(Boolean.TRUE).build(),
- new DstOfEthDstCaseBuilder()
- .setOfEthDst(Boolean.TRUE).build(),
- 47, false);
+ return nxMoveRegAction(new SrcOfEthSrcCaseBuilder().setOfEthSrc(Boolean.TRUE).build(),
+ new DstOfEthDstCaseBuilder().setOfEthDst(Boolean.TRUE).build(), 47, false);
}
public static Action nxMoveArpSpaToArpTpaAction() {
- return nxMoveRegAction(new SrcOfArpSpaCaseBuilder()
- .setOfArpSpa(Boolean.TRUE).build(),
- new DstOfArpTpaCaseBuilder()
- .setOfArpTpa(Boolean.TRUE).build());
+ return nxMoveRegAction(new SrcOfArpSpaCaseBuilder().setOfArpSpa(Boolean.TRUE).build(),
+ new DstOfArpTpaCaseBuilder().setOfArpTpa(Boolean.TRUE).build());
}
public static Action nxOutputRegAction(SrcChoice srcChoice) {
- NxOutputReg r = new NxOutputRegBuilder()
- .setSrc(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.SrcBuilder()
- .setSrcChoice(srcChoice)
- .setOfsNbits(Integer.valueOf(31))
- .build())
+ NxOutputReg r = new NxOutputRegBuilder().setSrc(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.SrcBuilder().setSrcChoice(
+ srcChoice)
+ .setOfsNbits(Integer.valueOf(31))
+ .build())
.setMaxLen(Integer.valueOf(0xffff))
.build();
- return new NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder()
- .setNxOutputReg(r).build();
+ return new NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder().setNxOutputReg(r).build();
}
public static Action nxOutputRegAction(Class<? extends NxmNxReg> reg) {
}
public static class RegMatch {
+
final Class<? extends NxmNxReg> reg;
final Long value;
+
public RegMatch(Class<? extends NxmNxReg> reg, Long value) {
super();
this.reg = reg;
this.value = value;
}
+
public static RegMatch of(Class<? extends NxmNxReg> reg, Long value) {
return new RegMatch(reg, value);
}
}
-
- public static void addNxRegMatch(MatchBuilder match,
- RegMatch... matches) {
+
+ public static void addNxRegMatch(MatchBuilder match, RegMatch... matches) {
ArrayList<ExtensionList> extensions = new ArrayList<>();
for (RegMatch rm : matches) {
Class<? extends ExtensionKey> key;
} else {
key = NxmNxReg7Key.class;
}
- NxAugMatchNodesNodeTableFlow am =
- new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxReg(new NxmNxRegBuilder()
- .setReg(rm.reg)
- .setValue(rm.value)
- .build())
- .build();
- extensions.add(new ExtensionListBuilder()
- .setExtensionKey(key)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxReg(
+ new NxmNxRegBuilder().setReg(rm.reg).setValue(rm.value).build()).build();
+ extensions.add(new ExtensionListBuilder().setExtensionKey(key)
+ .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
.build());
}
- GeneralAugMatchNodesNodeTableFlow m =
- new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(extensions)
- .build();
+ GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(
+ extensions).build();
match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
}
- public static void addNxTunIdMatch(MatchBuilder match,
- int tunId) {
- NxAugMatchNodesNodeTableFlow am =
- new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxTunId(new NxmNxTunIdBuilder()
- .setValue(BigInteger.valueOf(tunId))
- .build())
- .build();
- GeneralAugMatchNodesNodeTableFlow m =
- new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(ImmutableList.of(new ExtensionListBuilder()
- .setExtensionKey(NxmNxTunIdKey.class)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build()))
- .build();
+ public static void addNxTunIdMatch(MatchBuilder match, int tunId) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxTunId(
+ new NxmNxTunIdBuilder().setValue(BigInteger.valueOf(tunId)).build()).build();
+ GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(
+ ImmutableList.of(new ExtensionListBuilder().setExtensionKey(NxmNxTunIdKey.class)
+ .setExtension(
+ new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
+ .build())).build();
match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
}
- public static void addNxNsiMatch(MatchBuilder match,
- short nsi) {
- NxAugMatchNodesNodeTableFlow am =
- new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxNsi(new NxmNxNsiBuilder()
- .setNsi(nsi)
- .build())
- .build();
- GeneralAugMatchNodesNodeTableFlow m =
- new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(ImmutableList.of(new ExtensionListBuilder()
- .setExtensionKey(NxmNxNsiKey.class)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build()))
- .build();
+ public static void addNxNsiMatch(MatchBuilder match, short nsi) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxNsi(
+ new NxmNxNsiBuilder().setNsi(nsi).build()).build();
+ GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(
+ ImmutableList.of(new ExtensionListBuilder().setExtensionKey(NxmNxNsiKey.class)
+ .setExtension(
+ new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
+ .build())).build();
match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
}
- public static void addNxNspMatch(MatchBuilder match,
- Long nsp) {
- NxAugMatchNodesNodeTableFlow am =
- new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxNsp(new NxmNxNspBuilder()
- .setValue(nsp)
- .build())
- .build();
- GeneralAugMatchNodesNodeTableFlow m =
- new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(ImmutableList.of(new ExtensionListBuilder()
- .setExtensionKey(NxmNxNspKey.class)
- .setExtension(new ExtensionBuilder()
- .addAugmentation(NxAugMatchNodesNodeTableFlow.class, am)
- .build())
- .build()))
- .build();
+ public static void addNxNspMatch(MatchBuilder match, Long nsp) {
+ NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxNsp(
+ new NxmNxNspBuilder().setValue(nsp).build()).build();
+ GeneralAugMatchNodesNodeTableFlow m = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(
+ ImmutableList.of(new ExtensionListBuilder().setExtensionKey(NxmNxNspKey.class)
+ .setExtension(
+ new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
+ .build())).build();
match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
}
- public static EthernetMatch ethernetMatch(MacAddress srcMac,
- MacAddress dstMac,
- Long etherType) {
- EthernetMatchBuilder emb = new EthernetMatchBuilder();
+ public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) {
+ EthernetMatchBuilder emb = new EthernetMatchBuilder();
if (srcMac != null)
- emb.setEthernetSource(new EthernetSourceBuilder()
- .setAddress(srcMac)
- .build());
+ emb.setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build());
if (dstMac != null)
- emb.setEthernetDestination(new EthernetDestinationBuilder()
- .setAddress(dstMac)
- .build());
+ emb.setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build());
if (etherType != null)
- emb.setEthernetType(new EthernetTypeBuilder()
- .setType(new EtherType(etherType))
- .build());
+ emb.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(etherType)).build());
return emb.build();
}
/**
* Parse an OF port number from a node connector ID
+ *
* @param id the ID
* @return the port number
*/
public static long getOfPortNum(NodeConnectorId id) {
String cnid = id.getValue();
int ci = cnid.lastIndexOf(':');
- if (ci < 0 || (ci+1 >= cnid.length()))
+ if (ci < 0 || (ci + 1 >= cnid.length()))
throw new NumberFormatException("Invalid node connector ID " + cnid);
- return Long.parseLong(cnid.substring(ci+1));
+ return Long.parseLong(cnid.substring(ci + 1));
}
}
-
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
private final static AtomicInteger policyOrdinal = new AtomicInteger(1);
- private final static ConcurrentMap<String, Integer> ordinals =
- new ConcurrentHashMap<>();
+ private final static ConcurrentMap<String, Integer> ordinals = new ConcurrentHashMap<>();
+
// XXX - need to garbage collect
- private final static ConcurrentMap<ConditionGroup, Integer> cgOrdinals =
- new ConcurrentHashMap<>();
+ private final static ConcurrentMap<ConditionGroup, Integer> cgOrdinals = new ConcurrentHashMap<>();
- public static int getContextOrdinal(final TenantId tenantId,
- final UniqueId id) throws Exception {
+ public static int getContextOrdinal(final TenantId tenantId, final UniqueId id) throws Exception {
if (tenantId == null || id == null)
return 0;
return getContextOrdinalFromString(tenantId.getValue() + "|" + id.getValue());
* the data plane. This is unique only for this node, and not globally.
*
* @param cg
- * the {@link ConditionGroup}
+ * the {@link ConditionGroup}
* @return the unique ID
*/
public static int getCondGroupOrdinal(final ConditionGroup cg) {
* the given policy item.
*
* @param tenantId
- * the tenant ID of the element
+ * the tenant ID of the element
* @param id
- * the unique ID for the element
+ * the unique ID for the element
* @return the 32-bit ordinal value
* @throws Exception
*/
}
public static int getContextOrdinal(Endpoint ep, NetworkDomainId networkContainment) throws Exception {
- // TODO: Define private static final Comparator<EndpointGroupId>
- // COMPARATOR = new Comparator<EndpointGroupId>() { ... }
- // pass to constructor: new TreeSet<>(COMPARATOR);
Set<String> epgs = new TreeSet<>();
key.append(epg);
}
- key.append("|")
- .append(networkContainment);
+ key.append("|").append(networkContainment);
+
+ return getContextOrdinalFromString(key.toString());
+
+ }
+
+ public static int getContextOrdinal(Endpoint ep) throws Exception {
+
+ Set<String> epgs = new TreeSet<>();
+
+ // Get EPGs and add to ordered Set
+ if (ep.getEndpointGroup() != null) {
+ epgs.add(ep.getEndpointGroup().getValue());
+ }
+ if (ep.getEndpointGroups() != null) {
+ for (EndpointGroupId epgId : ep.getEndpointGroups()) {
+ epgs.add(epgId.getValue());
+ }
+ }
+
+ StringBuilder key = new StringBuilder(ep.getTenant().getValue());
+
+ for (String epg : epgs) {
+ key.append('|');
+ key.append(epg);
+ }
return getContextOrdinalFromString(key.toString());
* the given policy item.
*
* @param id
- * the unique ID for the element
+ * the unique ID for the element
* @return the 32-bit ordinal value
*/
private static int getContextOrdinalFromString(final String id) throws Exception {
private NetworkDomainId networkContainment;
private EpKey ep;
- private int epgId = 0, bdId = 0, fdId = 0, l3Id = 0, cgId = 0;
+ private int epgId = 0, bdId = 0, fdId = 0, l3Id = 0, cgId = 0, tunnelId = 0;
private EndpointFwdCtxOrdinals(Endpoint ep, PolicyInfo policyInfo, OfContext ctx) throws Exception {
this.ep = new EpKey(ep.getL2Context(), ep.getMacAddress());
if (epg.getNetworkDomain() != null) {
this.networkContainment = epg.getNetworkDomain();
} else {
- LOG.info(
- "endPoint ordinals for {} not processed in SourceMapper. Must be able to resolve network containment either directly, or from primary EPG",
- ep.getKey());
+ LOG.info("endPoint ordinals for {} not processed in SourceMapper. Must be able to resolve "
+ + "network containment either directly, or from primary EPG", ep.getKey());
return;
}
}
// conditions, but
// out of scope until broader bugs with conditions are fixed.
List<ConditionName> conds = ctx.getEndpointManager().getCondsForEndpoint(ep);
- ConditionGroup cg =
- policyInfo.getEgCondGroup(new EgKey(ep.getTenant(), ep.getEndpointGroup()), conds);
+ ConditionGroup cg = policyInfo.getEgCondGroup(new EgKey(ep.getTenant(), ep.getEndpointGroup()), conds);
this.cgId = getCondGroupOrdinal(cg);
// Based on network containment, determine components of
// Set ordinal id's for use in flows for each forwarding context
// component
- this.epgId = getContextOrdinal(ep, networkContainment);
+ this.epgId = getContextOrdinal(ep);
+
+ // TODO: alagalah Li/Be: This idea can be extended to include conditions.
+ this.tunnelId = getContextOrdinal(ep, networkContainment);
if (bd != null)
- this.bdId = getContextOrdinal(ep.getTenant(),
- bd.getId());
+ this.bdId = getContextOrdinal(ep.getTenant(), bd.getId());
if (fd != null)
- this.fdId = getContextOrdinal(ep.getTenant(),
- fd.getId());
+ this.fdId = getContextOrdinal(ep.getTenant(), fd.getId());
if (l3c != null)
- this.l3Id = getContextOrdinal(ep.getTenant(),
- l3c.getId());
+ this.l3Id = getContextOrdinal(ep.getTenant(), l3c.getId());
+
+ }
+ public int getTunnelId() {
+ return tunnelId;
}
public int getEpgId() {
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* unless specifically allowed by policy
*/
public class PolicyEnforcer extends FlowTable {
- protected static final Logger LOG =
- LoggerFactory.getLogger(PolicyEnforcer.class);
+
+ protected static final Logger LOG = LoggerFactory.getLogger(PolicyEnforcer.class);
public static final short TABLE_ID = 3;
for (EgKey dstEpgKey : peers) {
for (Endpoint dstEp : ctx.getEndpointManager().getEndpointsForGroup(dstEpgKey)) {
// mEPG ordinals
- EndpointFwdCtxOrdinals srcEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, srcEp);
- EndpointFwdCtxOrdinals dstEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, dstEp);
+ EndpointFwdCtxOrdinals srcEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx,
+ policyInfo, srcEp);
+ EndpointFwdCtxOrdinals dstEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx,
+ policyInfo, dstEp);
int dcgId = dstEpFwdCxtOrds.getCgId();
int depgId = dstEpFwdCxtOrds.getEpgId();
int scgId = srcEpFwdCxtOrds.getCgId();
if (visitedPairs.contains(p))
continue;
visitedPairs.add(p);
- syncPolicy(flowMap, nodeId, policyInfo,
- p, dstEpgKey, srcEpgKey, dcg, scg);
+ syncPolicy(flowMap, nodeId, policyInfo, p, dstEpgKey, srcEpgKey, dcg, scg);
- //Reverse
+ // Reverse
p = new CgPair(sepgId, depgId, scgId, dcgId);
if (visitedPairs.contains(p))
continue;
visitedPairs.add(p);
- syncPolicy(flowMap, nodeId, policyInfo,
- p, srcEpgKey, dstEpgKey, scg, dcg);
+ syncPolicy(flowMap, nodeId, policyInfo, p, srcEpgKey, dstEpgKey, scg, dcg);
}
}
}
}
// Allow same EPG
-// Set<Endpoint> visitedEps = new HashSet<>();
+ // Set<Endpoint> visitedEps = new HashSet<>();
for (Endpoint srcEp : ctx.getEndpointManager().getEndpointsForNode(nodeId)) {
-// visitedEps.add(srcEp);
+ // visitedEps.add(srcEp);
for (EgKey srcEpgKey : ctx.getEndpointManager().getEgKeysForEndpoint(srcEp)) {
IndexedTenant tenant = ctx.getPolicyResolver().getTenant(srcEpgKey.getTenantId());
if (igp == null || igp.equals(IntraGroupPolicy.Allow)) {
for (Endpoint dstEp : ctx.getEndpointManager().getEndpointsForGroup(srcEpgKey)) {
// mEPG ordinals
-// if(visitedEps.contains(dstEp)) {
-// continue;
-// }
-// visitedEps.add(dstEp);
- EndpointFwdCtxOrdinals srcEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, srcEp);
- EndpointFwdCtxOrdinals dstEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, dstEp);
+ // if(visitedEps.contains(dstEp)) {
+ // continue;
+ // }
+ // visitedEps.add(dstEp);
+ EndpointFwdCtxOrdinals srcEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx,
+ policyInfo, srcEp);
+ EndpointFwdCtxOrdinals dstEpFwdCxtOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx,
+ policyInfo, dstEp);
int depgId = dstEpFwdCxtOrds.getEpgId();
int sepgId = srcEpFwdCxtOrds.getEpgId();
flowMap.writeFlow(nodeId, TABLE_ID, allowSameEpg(sepgId, depgId));
}
private Flow createArpFlow(Integer fdId) {
-
+
Long etherType = FlowUtils.ARP;
- //L2 Classifier so 20,000 for now
+ // L2 Classifier so 20,000 for now
Integer priority = 20000;
- FlowId flowid = new FlowId(new StringBuilder()
- .append("arp")
- .append("|")
- .append(etherType)
- .append("|")
- .append(fdId)
- .toString());
-
- MatchBuilder mb = new MatchBuilder()
- .setEthernetMatch(FlowUtils.ethernetMatch(null,null,etherType));
-
+ FlowId flowid = new FlowId(new StringBuilder().append("arp")
+ .append("|")
+ .append(etherType)
+ .append("|")
+ .append(fdId)
+ .toString());
+
+ MatchBuilder mb = new MatchBuilder().setEthernetMatch(FlowUtils.ethernetMatch(null, null, etherType));
+
addNxRegMatch(mb, RegMatch.of(NxmNxReg5.class, Long.valueOf(fdId)));
-
- Flow flow = base()
- .setPriority(priority)
- .setId(flowid)
- .setMatch(mb.build())
- .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))))
- .build();
+
+ Flow flow = base().setPriority(priority)
+ .setId(flowid)
+ .setMatch(mb.build())
+ .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))))
+ .build();
return flow;
}
private Flow allowSameEpg(int sepgId, int depgId) {
-
- FlowId flowId = new FlowId(new StringBuilder()
- .append("intraallow|")
- .append(sepgId).toString());
- MatchBuilder mb = new MatchBuilder();
- addNxRegMatch(mb,
- RegMatch.of(NxmNxReg0.class, Long.valueOf(sepgId)),
- RegMatch.of(NxmNxReg2.class, Long.valueOf(depgId)));
- FlowBuilder flow = base()
- .setId(flowId)
- .setMatch(mb.build())
- .setPriority(65000)
- .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))));
- return flow.build();
+
+ FlowId flowId = new FlowId(new StringBuilder().append("intraallow|").append(sepgId).toString());
+ MatchBuilder mb = new MatchBuilder();
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg0.class, Long.valueOf(sepgId)),
+ RegMatch.of(NxmNxReg2.class, Long.valueOf(depgId)));
+ FlowBuilder flow = base().setId(flowId)
+ .setMatch(mb.build())
+ .setPriority(65000)
+ .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))));
+ return flow.build();
}
private Flow allowFromTunnel(NodeConnectorId tunPort) {
-
FlowId flowId = new FlowId("tunnelallow");
- MatchBuilder mb = new MatchBuilder()
- .setInPort(tunPort);
- addNxRegMatch(mb,
- RegMatch.of(NxmNxReg1.class, Long.valueOf(0xffffff)));
- FlowBuilder flow = base()
- .setId(flowId)
- .setMatch(mb.build())
- .setPriority(65000)
- .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))));
+ MatchBuilder mb = new MatchBuilder().setInPort(tunPort);
+ addNxRegMatch(mb, RegMatch.of(NxmNxReg1.class, Long.valueOf(0xffffff)));
+ FlowBuilder flow = base().setId(flowId)
+ .setMatch(mb.build())
+ .setPriority(65000)
+ .setInstructions(instructions(applyActionIns(nxOutputRegAction(NxmNxReg7.class))));
return flow.build();
}
- private void syncPolicy(FlowMap flowMap, NodeId nodeId,
- PolicyInfo policyInfo,
- CgPair p, EgKey sepg, EgKey depg,
- ConditionGroup scg, ConditionGroup dcg)
- throws Exception {
+ private void syncPolicy(FlowMap flowMap, NodeId nodeId, PolicyInfo policyInfo, CgPair p, EgKey sepg, EgKey depg,
+ ConditionGroup scg, ConditionGroup dcg) throws Exception {
// XXX - TODO raise an exception for rules between the same
// endpoint group that are asymmetric
Policy policy = policyInfo.getPolicy(sepg, depg);
TenantId tenantId = rg.getContractTenant().getId();
IndexedTenant tenant = ctx.getPolicyResolver().getTenant(tenantId);
for (Rule r : rg.getRules()) {
- syncDirection(flowMap, nodeId, tenant,
- p, r, Direction.In, priority);
- syncDirection(flowMap, nodeId, tenant,
- p, r, Direction.Out, priority);
+ syncDirection(flowMap, nodeId, tenant, p, r, Direction.In, priority);
+ syncDirection(flowMap, nodeId, tenant, p, r, Direction.Out, priority);
priority -= 1;
}
* determined first by the value of the order parameter, with the lower
* order actions being applied first; for Actions with either the same order
* or no order, ordering is lexicographical by name.
- *
*/
private static class ActionRefComparator implements Comparator<ActionRef> {
+
public static final ActionRefComparator INSTANCE = new ActionRefComparator();
@Override
public int compare(ActionRef arg0, ActionRef arg1) {
return ComparisonChain.start()
- .compare(arg0.getOrder(), arg1.getOrder(),
- Ordering.natural().nullsLast())
- .compare(arg0.getName().getValue(), arg1.getName().getValue(),
- Ordering.natural().nullsLast())
- .result();
+ .compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast())
+ .compare(arg0.getName().getValue(), arg1.getName().getValue(), Ordering.natural().nullsLast())
+ .result();
}
}
- private void syncDirection(FlowMap flowMap, NodeId nodeId, IndexedTenant contractTenant,
- CgPair cgPair, Rule rule, Direction direction, int priority) {
+ private void syncDirection(FlowMap flowMap, NodeId nodeId, IndexedTenant contractTenant, CgPair cgPair, Rule rule,
+ Direction direction, int priority) {
/*
* Create the ordered action list. The implicit action is "allow", and
* is therefore always in the list
* incorporating operational policy for actions
*/
- //TODO: can pass Comparator ActionRefComparator to List constructor, rather than referencing in sort
+ // TODO: can pass Comparator ActionRefComparator to List constructor, rather than
+ // referencing in sort
List<ActionBuilder> abl = new ArrayList<ActionBuilder>();
if (rule.getActionRef() != null) {
/*
ActionInstance ai = contractTenant.getAction(ar.getName());
if (ai == null) {
// XXX TODO fail the match and raise an exception
- LOG.warn("Action instance {} not found",
- ar.getName().getValue());
+ LOG.warn("Action instance {} not found", ar.getName().getValue());
return;
}
Action act = SubjectFeatures.getAction(ai.getActionDefinitionId());
if (act == null) {
// XXX TODO fail the match and raise an exception
- LOG.warn("Action definition {} not found",
- ai.getActionDefinitionId().getValue());
+ LOG.warn("Action definition {} not found", ai.getActionDefinitionId().getValue());
return;
}
*/
abl = act.updateAction(abl, params, ar.getOrder());
}
- }
- else {
+ } else {
Action act = SubjectFeatures.getAction(AllowAction.DEFINITION.getId());
abl = act.updateAction(abl, new HashMap<String, Object>(), 0);
}
Map<String, ParameterValue> paramsFromClassifier = new HashMap<>();
Set<ClassifierDefinitionId> classifiers = new HashSet<>();
for (ClassifierRef cr : rule.getClassifierRef()) {
- if (cr.getDirection() != null &&
- !cr.getDirection().equals(Direction.Bidirectional) &&
- !cr.getDirection().equals(direction)) {
+ if (cr.getDirection() != null && !cr.getDirection().equals(Direction.Bidirectional)
+ && !cr.getDirection().equals(direction)) {
continue;
}
ClassifierInstance ci = contractTenant.getClassifier(cr.getName());
if (ci == null) {
// XXX TODO fail the match and raise an exception
- LOG.warn("Classifier instance {} not found",
- cr.getName().getValue());
+ LOG.warn("Classifier instance {} not found", cr.getName().getValue());
return;
}
- Classifier cfier = SubjectFeatures
- .getClassifier(ci.getClassifierDefinitionId());
+ Classifier cfier = SubjectFeatures.getClassifier(ci.getClassifierDefinitionId());
if (cfier == null) {
// XXX TODO fail the match and raise an exception
- LOG.warn("Classifier definition {} not found",
- ci.getClassifierDefinitionId().getValue());
+ LOG.warn("Classifier definition {} not found", ci.getClassifierDefinitionId().getValue());
return;
}
classifiers.add(new ClassifierDefinitionId(ci.getClassifierDefinitionId()));
MatchBuilder baseMatch = new MatchBuilder();
if (direction.equals(Direction.In)) {
idb.append(cgPair.sepg)
- .append("|")
- .append(cgPair.scgId)
- .append("|")
- .append(cgPair.depg)
- .append("|")
- .append(cgPair.dcgId)
- .append("|")
- .append(priority);
- addNxRegMatch(baseMatch,
- RegMatch.of(NxmNxReg0.class, Long.valueOf(cgPair.sepg)),
+ .append("|")
+ .append(cgPair.scgId)
+ .append("|")
+ .append(cgPair.depg)
+ .append("|")
+ .append(cgPair.dcgId)
+ .append("|")
+ .append(priority);
+ addNxRegMatch(baseMatch, RegMatch.of(NxmNxReg0.class, Long.valueOf(cgPair.sepg)),
RegMatch.of(NxmNxReg1.class, Long.valueOf(cgPair.scgId)),
RegMatch.of(NxmNxReg2.class, Long.valueOf(cgPair.depg)),
RegMatch.of(NxmNxReg3.class, Long.valueOf(cgPair.dcgId)));
} else {
idb.append(cgPair.depg)
- .append("|")
- .append(cgPair.dcgId)
- .append("|")
- .append(cgPair.sepg)
- .append("|")
- .append(cgPair.scgId)
- .append("|")
- .append(priority);
- addNxRegMatch(baseMatch,
- RegMatch.of(NxmNxReg0.class, Long.valueOf(cgPair.depg)),
+ .append("|")
+ .append(cgPair.dcgId)
+ .append("|")
+ .append(cgPair.sepg)
+ .append("|")
+ .append(cgPair.scgId)
+ .append("|")
+ .append(priority);
+ addNxRegMatch(baseMatch, RegMatch.of(NxmNxReg0.class, Long.valueOf(cgPair.depg)),
RegMatch.of(NxmNxReg1.class, Long.valueOf(cgPair.dcgId)),
RegMatch.of(NxmNxReg2.class, Long.valueOf(cgPair.sepg)),
RegMatch.of(NxmNxReg3.class, Long.valueOf(cgPair.scgId)));
for (MatchBuilder match : result.getMatchBuilders()) {
Match m = match.build();
FlowId flowId = new FlowId(baseId + "|" + m.toString());
- flow.setMatch(m)
+ flow.setMatch(m)
.setId(flowId)
.setPriority(Integer.valueOf(priority))
.setInstructions(instructions(applyActionIns(abl)));
- flowMap.writeFlow(nodeId, TABLE_ID, flow.build());
+ flowMap.writeFlow(nodeId, TABLE_ID, flow.build());
}
}
}
@Immutable
private static class CgPair {
+
private final int sepg;
private final int depg;
private final int scgId;
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.math.BigInteger;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfContext;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.PolicyManager.FlowMap;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.OrdinalFactory.EndpointFwdCtxOrdinals;
-import org.opendaylight.groupbasedpolicy.resolver.ConditionGroup;
import org.opendaylight.groupbasedpolicy.resolver.EgKey;
import org.opendaylight.groupbasedpolicy.resolver.IndexedTenant;
import org.opendaylight.groupbasedpolicy.resolver.PolicyInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.EndpointLocation.LocationType;
* router domain to registers to be used by other tables.
*/
public class SourceMapper extends FlowTable {
- protected static final Logger LOG =
- LoggerFactory.getLogger(SourceMapper.class);
- //TODO Li alagalah Improve UT coverage for this class.
+ protected static final Logger LOG = LoggerFactory.getLogger(SourceMapper.class);
+
+ // TODO Li alagalah Improve UT coverage for this class.
public static final short TABLE_ID = 1;
public SourceMapper(OfContext ctx) {
}
@Override
- public void sync(NodeId nodeId,
- PolicyInfo policyInfo, FlowMap flowMap) throws Exception {
-
- flowMap.writeFlow(nodeId,TABLE_ID,dropFlow(Integer.valueOf(1), null));
-
- /*
- * 1. Retrieve all endpoints connected to node 2. For each endpoint: -
- * calculate and update index for multi-EPG ordinal for flow sEPG - set
- * bdId, fdId, L3c based from following order: : 1. EP specific
- * NetworkContextId : 2. Primary EPG : 3. "First" EPG in endpoint-groups
- * - capture information for adding appropriate tunnel (sEPG ordinal,
- * ep.bd, ep.fd, ep.l3c) - write flow 3. For each EPG captured above: -
- * write tunnel flow
- */
+ public void sync(NodeId nodeId, PolicyInfo policyInfo, FlowMap flowMap) throws Exception {
- for (Endpoint ep : ctx.getEndpointManager().getEndpointsForNode(nodeId)) {
+ flowMap.writeFlow(nodeId, TABLE_ID, dropFlow(Integer.valueOf(1), null));
+ for (Endpoint ep : ctx.getEndpointManager().getEndpointsForNode(nodeId)) {
OfOverlayContext ofc = ep.getAugmentation(OfOverlayContext.class);
- if (ofc != null && ofc.getNodeConnectorId() != null &&
- (ofc.getLocationType() == null ||
- LocationType.Internal.equals(ofc.getLocationType())) &&
- ep.getTenant() != null && (ep.getEndpointGroup() != null || ep.getEndpointGroups() != null)) {
+ if (ofc != null && ofc.getNodeConnectorId() != null
+ && (ofc.getLocationType() == null || LocationType.Internal.equals(ofc.getLocationType()))
+ && ep.getTenant() != null && (ep.getEndpointGroup() != null || ep.getEndpointGroups() != null)) {
- IndexedTenant tenant =
- ctx.getPolicyResolver().getTenant(ep.getTenant());
+ IndexedTenant tenant = ctx.getPolicyResolver().getTenant(ep.getTenant());
if (tenant == null)
continue;
- // TODO: MOVE TO NEW CLASS BEGIN____>>>>>>>>>
- /*
- * sepg currently set for conditions.
- * TODO: conditions are broken beyond repair. This will do for now.
- * Bug raised already to be fixed in Li
- *
- */
+ EndpointFwdCtxOrdinals epFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, ep);
EgKey sepg = new EgKey(ep.getTenant(), ep.getEndpointGroup());
- createRemoteTunnels(flowMap,nodeId,ep,policyInfo);
+ createRemoteTunnels(flowMap, nodeId, ep, policyInfo, epFwdCtxOrds);
/**
* Sync the local EP information.
*/
- syncEP(flowMap, policyInfo, nodeId, ep, ofc, sepg);
+ syncEP(flowMap, policyInfo, nodeId, ep, ofc, sepg, epFwdCtxOrds);
}
}
}
- private void createRemoteTunnels(FlowMap flowMap,NodeId nodeId, Endpoint ep,
- PolicyInfo policyInfo) throws Exception {
+ private void createRemoteTunnels(FlowMap flowMap, NodeId nodeId, Endpoint ep, PolicyInfo policyInfo,
+ EndpointFwdCtxOrdinals epFwdCtxOrds) throws Exception {
Set<EgKey> epgs = new HashSet<>();
- EndpointFwdCtxOrdinals epFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, ep);
-
// Get EPGs and add to Set to remove duplicates
- //TODO alagalah Li: test EndpointManager.getEgKeys
+ // TODO alagalah Li: test EndpointManager.getEgKeys
if (ep.getEndpointGroup() != null) {
epgs.add(new EgKey(ep.getTenant(), ep.getEndpointGroup()));
}
// Create tunnels on remote Nodes that may talk to us.
for (EgKey epg : epgs) {
- Set<EgKey> peers = Sets.union(Collections.singleton(epg),
- policyInfo.getPeers(epg));
+ Set<EgKey> peers = Sets.union(Collections.singleton(epg), policyInfo.getPeers(epg));
for (EgKey peer : peers) {
for (NodeId remoteNodeId : ctx.getEndpointManager().getNodesForGroup(peer)) {
// Only put tunnels on destination nodes
- if(remoteNodeId == nodeId) continue;
- NodeConnectorId tunPort =
- ctx.getSwitchManager().getTunnelPort(remoteNodeId);
- if(tunPort == null) {
+ if (remoteNodeId.getValue().equals(nodeId.getValue())) {
continue;
}
- flowMap.writeFlow(remoteNodeId, TABLE_ID, createTunnelFlow(tunPort,epFwdCtxOrds));
-
+ NodeConnectorId tunPort = ctx.getSwitchManager().getTunnelPort(remoteNodeId);
+ if (tunPort == null) {
+ LOG.trace("No tunnel port for tunnel in SourceMapper between local:{} and remote:{}",
+ nodeId.getValue(), remoteNodeId.getValue());
+ continue;
+ }
+ flowMap.writeFlow(remoteNodeId, TABLE_ID, createTunnelFlow(tunPort, epFwdCtxOrds));
+ flowMap.writeFlow(remoteNodeId, TABLE_ID, createBroadcastFlow(tunPort, epFwdCtxOrds));
}
}
}
}
+ private Flow createBroadcastFlow(NodeConnectorId tunPort, EndpointFwdCtxOrdinals epFwdCtxOrds) {
+
+ int fdId = epFwdCtxOrds.getFdId();
+
+ FlowId flowid = new FlowId(new StringBuilder().append(tunPort.getValue())
+ .append("|tunnel|")
+ .append("|")
+ .append(fdId)
+ .toString());
+
+ MatchBuilder mb = new MatchBuilder().setInPort(tunPort);
+ addNxTunIdMatch(mb, fdId);
+
+ // set condition group register to all ones to
+ // bypass
+ // policy enforcement
+ /*
+ * TODO: This breaks distributed policy enforcement
+ * especially wrt multi-action. BAD. Must be addressed
+ * (this is why we can't have nice things).
+ * This can be fixed with new tunnelId ordinal in
+ * Ordinal Factory.
+ */
+
+ Action fdReg = nxLoadRegAction(NxmNxReg5.class, BigInteger.valueOf(fdId));
+
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(150))
+ .setMatch(mb.build())
+ .setInstructions(instructions(applyActionIns(fdReg), gotoTableIns((short) (TABLE_ID + 1))));
+ return flowb.build();
+ }
+
private Flow createTunnelFlow(NodeConnectorId tunPort, EndpointFwdCtxOrdinals epFwdCtxOrds) {
// ... this is a remote node.
- int egId=epFwdCtxOrds.getEpgId();
- int bdId=epFwdCtxOrds.getBdId();
- int fdId=epFwdCtxOrds.getFdId();
- int l3Id=epFwdCtxOrds.getL3Id();
-
- FlowId flowid = new FlowId(new StringBuilder()
- .append(tunPort.getValue())
- .append("|tunnel|")
- .append(egId)
- .append("|")
- .append(bdId)
- .append("|")
- .append(fdId)
- .append("|")
- .append(l3Id)
- .toString());
-
- MatchBuilder mb = new MatchBuilder()
- .setInPort(tunPort);
- addNxTunIdMatch(mb, egId);
- Action segReg = nxLoadRegAction(NxmNxReg0.class,
- BigInteger.valueOf(egId));
- // set condition group register to all ones to
- // bypass
- // policy enforcement
- /*
- * TODO: This breaks distributed policy enforcement
- * especially wrt multi-action. BAD. Must be addressed
- * (this is why we can't have nice things)
- */
- Action scgReg = nxLoadRegAction(NxmNxReg1.class,
- BigInteger.valueOf(0xffffff));
- Action bdReg = nxLoadRegAction(NxmNxReg4.class,
- BigInteger.valueOf(bdId));
- Action fdReg = nxLoadRegAction(NxmNxReg5.class,
- BigInteger.valueOf(fdId));
- Action vrfReg = nxLoadRegAction(NxmNxReg6.class,
- BigInteger.valueOf(l3Id));
- FlowBuilder flowb = base()
- .setId(flowid)
- .setPriority(Integer.valueOf(150))
- .setMatch(mb.build())
- .setInstructions(instructions(applyActionIns(segReg,
- scgReg,
- bdReg,
- fdReg,
- vrfReg),
+ int egId = epFwdCtxOrds.getEpgId();
+ int bdId = epFwdCtxOrds.getBdId();
+ int fdId = epFwdCtxOrds.getFdId();
+ int l3Id = epFwdCtxOrds.getL3Id();
+ int tunnelId = epFwdCtxOrds.getTunnelId();
+
+ FlowId flowid = new FlowId(new StringBuilder().append(tunPort.getValue())
+ .append("|tunnel|")
+ .append(egId)
+ .append("|")
+ .append(bdId)
+ .append("|")
+ .append(fdId)
+ .append("|")
+ .append(l3Id)
+ .append("|")
+ .append(tunnelId)
+ .toString());
+
+ MatchBuilder mb = new MatchBuilder().setInPort(tunPort);
+ addNxTunIdMatch(mb, tunnelId);
+ Action segReg = nxLoadRegAction(NxmNxReg0.class, BigInteger.valueOf(egId));
+ // set condition group register to all ones to
+ // bypass
+ // policy enforcement
+ /*
+ * TODO: This breaks distributed policy enforcement
+ * especially wrt multi-action. BAD. Must be addressed
+ * (this is why we can't have nice things).
+ * This can be fixed with new tunnelId ordinal in
+ * Ordinal Factory.
+ */
+ Action scgReg = nxLoadRegAction(NxmNxReg1.class, BigInteger.valueOf(0xffffff));
+ Action bdReg = nxLoadRegAction(NxmNxReg4.class, BigInteger.valueOf(bdId));
+ Action fdReg = nxLoadRegAction(NxmNxReg5.class, BigInteger.valueOf(fdId));
+ Action vrfReg = nxLoadRegAction(NxmNxReg6.class, BigInteger.valueOf(l3Id));
+ FlowBuilder flowb = base().setId(flowid)
+ .setPriority(Integer.valueOf(150))
+ .setMatch(mb.build())
+ .setInstructions(
+ instructions(applyActionIns(segReg, scgReg, bdReg, fdReg, vrfReg),
gotoTableIns((short) (TABLE_ID + 1))));
- return flowb.build();
+ return flowb.build();
}
- private void syncEP(FlowMap flowMap,
- PolicyInfo policyInfo,
- NodeId nodeId, Endpoint ep, OfOverlayContext ofc,
- EgKey egKey)
- throws Exception {
-
+ private void syncEP(FlowMap flowMap, PolicyInfo policyInfo, NodeId nodeId, Endpoint ep, OfOverlayContext ofc,
+ EgKey egKey, EndpointFwdCtxOrdinals epFwdCtxOrds) throws Exception {
- //TODO alagalah Li/Be: We should also match on EndpointL3 with the appropriate
+ // TODO alagalah Li/Be: We should also match on EndpointL3 with the appropriate
// network containment. This would solve a lot of problems and prepare for EndpointL3 RPC.
- EndpointFwdCtxOrdinals epFwdCtxOrds = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, policyInfo, ep);
-
- int egId=epFwdCtxOrds.getEpgId();
- int bdId=epFwdCtxOrds.getBdId();
- int fdId=epFwdCtxOrds.getFdId();
- int l3Id=epFwdCtxOrds.getL3Id();
-
- // Set sEPG, flood domain, bridge domain, and layer 3 context
- // for internal endpoints by directly matching each endpoint
-
- List<ConditionName> conds = ctx.getEndpointManager().getCondsForEndpoint(ep);
- ConditionGroup cg =
- policyInfo.getEgCondGroup(new EgKey(ep.getTenant(),
- egKey.getEgId()),
- conds);
-
- int cgId = OrdinalFactory.getCondGroupOrdinal(cg);
-
- FlowId flowid = new FlowId(new StringBuilder()
- .append(ofc.getNodeConnectorId().getValue())
- .append("|")
- .append(ep.getMacAddress().getValue())
- .append("|")
- .append(egId)
- .append("|")
- .append(bdId)
- .append("|")
- .append(fdId)
- .append("|")
- .append(l3Id)
- .append("|")
- .append(cgId)
- .toString());
- Action segReg = nxLoadRegAction(NxmNxReg0.class,
- BigInteger.valueOf(egId));
- Action scgReg = nxLoadRegAction(NxmNxReg1.class,
- BigInteger.valueOf(cgId));
- Action bdReg = nxLoadRegAction(NxmNxReg4.class,
- BigInteger.valueOf(bdId));
- Action fdReg = nxLoadRegAction(NxmNxReg5.class,
- BigInteger.valueOf(fdId));
- Action vrfReg = nxLoadRegAction(NxmNxReg6.class,
- BigInteger.valueOf(l3Id));
- FlowBuilder flowb = base()
- .setPriority(Integer.valueOf(100))
- .setId(flowid)
- .setMatch(new MatchBuilder()
- .setEthernetMatch(ethernetMatch(ep.getMacAddress(),
- null, null))
+ int egId = epFwdCtxOrds.getEpgId();
+ int bdId = epFwdCtxOrds.getBdId();
+ int fdId = epFwdCtxOrds.getFdId();
+ int l3Id = epFwdCtxOrds.getL3Id();
+ int cgId = epFwdCtxOrds.getCgId();
+
+ FlowId flowid = new FlowId(new StringBuilder().append(ofc.getNodeConnectorId().getValue())
+ .append("|")
+ .append(ep.getMacAddress().getValue())
+ .append("|")
+ .append(egId)
+ .append("|")
+ .append(bdId)
+ .append("|")
+ .append(fdId)
+ .append("|")
+ .append(l3Id)
+ .append("|")
+ .append(cgId)
+ .toString());
+ Action segReg = nxLoadRegAction(NxmNxReg0.class, BigInteger.valueOf(egId));
+ Action scgReg = nxLoadRegAction(NxmNxReg1.class, BigInteger.valueOf(cgId));
+ Action bdReg = nxLoadRegAction(NxmNxReg4.class, BigInteger.valueOf(bdId));
+ Action fdReg = nxLoadRegAction(NxmNxReg5.class, BigInteger.valueOf(fdId));
+ Action vrfReg = nxLoadRegAction(NxmNxReg6.class, BigInteger.valueOf(l3Id));
+ FlowBuilder flowb = base().setPriority(Integer.valueOf(100))
+ .setId(flowid)
+ .setMatch(
+ new MatchBuilder().setEthernetMatch(ethernetMatch(ep.getMacAddress(), null, null))
.setInPort(ofc.getNodeConnectorId())
.build())
- .setInstructions(instructions(applyActionIns(segReg,
- scgReg,
- bdReg,
- fdReg,
- vrfReg),
- gotoTableIns((short) (TABLE_ID + 1))));
+ .setInstructions(
+ instructions(applyActionIns(segReg, scgReg, bdReg, fdReg, vrfReg),
+ gotoTableIns((short) (TABLE_ID + 1))));
flowMap.writeFlow(nodeId, TABLE_ID, flowb.build());
}
-
}
/*\r
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.\r
- * \r
+ *\r
* This program and the accompanying materials are made available under the\r
* terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
\r
protected static final Logger LOG = LoggerFactory.getLogger(SourceMapperTest.class);\r
\r
+ @Override\r
@Before\r
public void setup() throws Exception {\r
initCtx();\r
Instruction ins = f.getInstructions().getInstruction().get(0);\r
assertTrue(ins.getInstruction() instanceof ApplyActionsCase);\r
List<Action> actions = ((ApplyActionsCase) ins.getInstruction()).getApplyActions().getAction();\r
- NetworkDomainId networkContainement = policyResolver.getTenant(tid)\r
- .getEndpointGroup(eg)\r
- .getNetworkDomain();\r
- int v = OrdinalFactory.getContextOrdinal(ep, networkContainement);\r
+ int v = OrdinalFactory.getContextOrdinal(ep);\r
assertEquals(FlowUtils.nxLoadRegAction(NxmNxReg0.class, BigInteger.valueOf(v)), actions.get(0)\r
.getAction());\r
v = OrdinalFactory.getCondGroupOrdinal(cg);\r