use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class ConntrackBasedSnatService method installSnatMissEntryForPrimrySwch.
protected void installSnatMissEntryForPrimrySwch(BigInteger dpnId, Long routerId, int elanId, int addOrRemove) {
LOG.info("installSnatSpecificEntriesForNaptSwitch : called for the primary NAPT switch dpnId {}", dpnId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
List<NxCtAction> ctActionsList = new ArrayList<>();
NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
ctActionsList.add(nxCtAction);
ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.OUTBOUND_NAPT_TABLE, ctActionsList);
actionsInfos.add(actionNxConntrack);
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.PSNAT_TABLE, routerId);
syncFlow(dpnId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class EvpnDnatFlowProgrammer method makeTunnelTableEntry.
private void makeTunnelTableEntry(BigInteger dpnId, long l3Vni, List<Instruction> customInstructions, WriteTransaction writeFlowInvTx) {
LOG.debug("makeTunnelTableEntry : Create terminating service table {} --> table {} flow on DpnId {} " + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.PDNAT_TABLE, dpnId, l3Vni);
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchTunnelId(BigInteger.valueOf(l3Vni)));
Flow terminatingServiceTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.DNAT_FLOW_NAME), 6, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, customInstructions);
mdsalManager.addFlowToTx(dpnId, terminatingServiceTableFlowEntity, writeFlowInvTx);
LOG.debug("makeTunnelTableEntry : Successfully installed terminating service table flow {} on DpnId {}", terminatingServiceTableFlowEntity, dpnId);
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class ExternalNetworksChangeListenerTest method testSnatFlowEntity.
@Test
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void testSnatFlowEntity() {
FlowEntity flowMock = mock(FlowEntity.class);
final short snatTable = 40;
final int defaultSnatFlowPriority = 0;
final String flowidSeparator = ".";
String routerName = "200";
List<BucketInfo> bucketInfo = new ArrayList<>();
List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
listActionInfoPrimary.add(new ActionOutput(new Uri("3")));
BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
List<ActionInfo> listActionInfoSecondary = new ArrayList<>();
listActionInfoSecondary.add(new ActionOutput(new Uri("4")));
BucketInfo bucketSecondary = new BucketInfo(listActionInfoPrimary);
bucketInfo.add(0, bucketPrimary);
bucketInfo.add(1, bucketSecondary);
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
long groupId = 300;
actionsInfos.add(new ActionGroup(groupId));
instructions.add(new InstructionApplyActions(actionsInfos));
BigInteger dpnId = new BigInteger("100");
long routerId = 200;
String snatFlowidPrefix = "SNAT.";
String flowRef = snatFlowidPrefix + dpnId + flowidSeparator + snatTable + flowidSeparator + routerId;
BigInteger cookieSnat = NatUtil.getCookieSnatFlow(routerId);
try {
PowerMockito.when(MDSALUtil.class, "buildFlowEntity", dpnId, snatTable, flowRef, defaultSnatFlowPriority, flowRef, 0, 0, cookieSnat, matches, instructions).thenReturn(flowMock);
} catch (Exception e) {
// Test failed anyways
assertEquals("true", "false");
}
/* TODO : Fix this to mock it properly when it reads DS
extNetworks.buildSnatFlowEntity(dpnId, routerName, groupId);
PowerMockito.verifyStatic(); */
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class Ipv6ServiceUtils method installIcmpv6RsPuntFlow.
public void installIcmpv6RsPuntFlow(short tableId, BigInteger dpId, Long elanTag, int addOrRemove) {
if (dpId == null || dpId.equals(Ipv6Constants.INVALID_DPID)) {
return;
}
List<MatchInfo> routerSolicitationMatch = getIcmpv6RSMatch(elanTag);
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
// Punt to controller
actionsInfos.add(new ActionPuntToController());
instructions.add(new InstructionApplyActions(actionsInfos));
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, getIPv6FlowRef(dpId, elanTag, "IPv6RS"), Ipv6Constants.DEFAULT_FLOW_PRIORITY, "IPv6RS", 0, 0, NwConstants.COOKIE_IPV6_TABLE, routerSolicitationMatch, instructions);
if (addOrRemove == Ipv6Constants.DEL_FLOW) {
LOG.trace("Removing IPv6 Router Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
mdsalUtil.removeFlow(rsFlowEntity);
} else {
LOG.trace("Installing IPv6 Router Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
mdsalUtil.installFlow(rsFlowEntity);
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfo in project netvirt by opendaylight.
the class IPv6Handler method installPing6ResponderFlowEntry.
public void installPing6ResponderFlowEntry(BigInteger dpnId, long vpnId, String routerInternalIp, MacAddress routerMac, long label, int addOrRemove) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchIpProtocol.ICMPV6);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(new MatchIcmpv6((short) 128, (short) 0));
matches.add(MatchEthernetType.IPV6);
matches.add(new MatchIpv6Destination(routerInternalIp));
List<ActionInfo> actionsInfos = new ArrayList<>();
// Set Eth Src and Eth Dst
actionsInfos.add(new ActionMoveSourceDestinationEth());
actionsInfos.add(new ActionSetFieldEthernetSource(routerMac));
// Move Ipv6 Src to Ipv6 Dst
actionsInfos.add(new ActionMoveSourceDestinationIpv6());
actionsInfos.add(new ActionSetSourceIpv6(new Ipv6Prefix(routerInternalIp)));
// Set the ICMPv6 type to 129 (echo reply)
actionsInfos.add(new ActionSetIcmpv6Type((short) 129));
actionsInfos.add(new ActionNxLoadInPort(BigInteger.ZERO));
actionsInfos.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
int priority = FibConstants.DEFAULT_FIB_FLOW_PRIORITY + FibConstants.DEFAULT_IPV6_PREFIX_LENGTH;
String flowRef = FibUtil.getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, label, priority);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, instructions);
if (addOrRemove == NwConstants.ADD_FLOW) {
mdsalManager.syncInstallFlow(flowEntity);
} else {
mdsalManager.syncRemoveFlow(flowEntity);
}
}
Aggregations