use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class NaptEventHandler method buildAndGetSetActionInstructionInfo.
private static List<InstructionInfo> buildAndGetSetActionInstructionInfo(String ipAddress, int port, long segmentId, long vpnId, short tableId, NAPTEntryEvent.Protocol protocol, String extGwMacAddress) {
ActionInfo ipActionInfo = null;
ActionInfo macActionInfo = null;
ActionInfo portActionInfo = null;
ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
switch(tableId) {
case NwConstants.OUTBOUND_NAPT_TABLE:
ipActionInfo = new ActionSetSourceIp(ipAddress);
// Added External Gateway MAC Address
macActionInfo = new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress));
if (protocol == NAPTEntryEvent.Protocol.TCP) {
portActionInfo = new ActionSetTcpSourcePort(port);
} else if (protocol == NAPTEntryEvent.Protocol.UDP) {
portActionInfo = new ActionSetUdpSourcePort(port);
}
// reset the split-horizon bit to allow traffic from tunnel to be sent back to the provider port
instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID.or(MetaDataUtil.METADATA_MASK_SH_FLAG)));
break;
case NwConstants.INBOUND_NAPT_TABLE:
ipActionInfo = new ActionSetDestinationIp(ipAddress);
if (protocol == NAPTEntryEvent.Protocol.TCP) {
portActionInfo = new ActionSetTcpDestinationPort(port);
} else if (protocol == NAPTEntryEvent.Protocol.UDP) {
portActionInfo = new ActionSetUdpDestinationPort(port);
}
instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
break;
default:
LOG.error("buildAndGetSetActionInstructionInfo : Neither OUTBOUND_NAPT_TABLE nor " + "INBOUND_NAPT_TABLE matches with input table id {}", tableId);
return null;
}
listActionInfo.add(ipActionInfo);
listActionInfo.add(portActionInfo);
if (macActionInfo != null) {
listActionInfo.add(macActionInfo);
LOG.debug("buildAndGetSetActionInstructionInfo : External GW MAC Address {} is found ", macActionInfo);
}
instructionInfo.add(new InstructionApplyActions(listActionInfo));
instructionInfo.add(new InstructionGotoTable(NwConstants.NAPT_PFIB_TABLE));
return instructionInfo;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class ExternalRoutersListener method removeLFibTableEntry.
private void removeLFibTableEntry(BigInteger dpnId, long serviceId, WriteTransaction writeFlowInvTx) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(serviceId));
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
LOG.debug("removeLFibTableEntry : with flow ref {}", flowRef);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, COOKIE_VM_LFIB_TABLE, matches, null);
mdsalManager.removeFlowToTx(dpnId, flowEntity, writeFlowInvTx);
LOG.debug("removeLFibTableEntry : dpID : {} label : {} removed successfully", dpnId, serviceId);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class VpnFloatingIpHandler method removeLFibTableEntry.
private void removeLFibTableEntry(BigInteger dpnId, long serviceId, WriteTransaction removeFlowInvTx) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(serviceId));
String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, serviceId, "");
LOG.debug("removeLFibTableEntry : removing LFib entry with flow ref {}", flowRef);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, null);
mdsalManager.removeFlowToTx(dpnId, flowEntity, removeFlowInvTx);
LOG.debug("removeLFibTableEntry : LFIB Entry for dpID : {} label : {} removed successfully", dpnId, serviceId);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class Ipv6ServiceUtils method getIcmpv6NSMatch.
private List<MatchInfo> getIcmpv6NSMatch(Long elanTag, String ndTarget) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
matches.add(MatchIpProtocol.ICMPV6);
matches.add(new MatchIcmpv6(Ipv6Constants.ICMP_V6_NS_CODE, (short) 0));
matches.add(new MatchIpv6NdTarget(new Ipv6Address(ndTarget)));
matches.add(new MatchMetadata(MetaDataUtil.getElanTagMetadata(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
return matches;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class FibRpcServiceImpl method makeLocalFibEntry.
private void makeLocalFibEntry(long vpnId, BigInteger dpnId, String ipPrefix, List<Instruction> customInstructions) {
String[] values = ipPrefix.split("/");
String ipAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
LOG.debug("Adding route to DPN. ip {} masklen {}", ipAddress, prefixLength);
InetAddress destPrefix = null;
try {
destPrefix = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
LOG.error("UnknowHostException in addRoute. Failed to add Route for ipPrefix {} VpnId {} DPN{}", ipAddress, vpnId, dpnId, e);
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
}
String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vpnId, ipAddress);
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, customInstructions);
mdsalManager.installFlow(dpnId, flowEntity);
LOG.debug("FIB entry for route {} on dpn {} installed successfully - flow {}", ipAddress, dpnId, flowEntity);
}
Aggregations