use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetType in project netvirt by opendaylight.
the class ElanNodeListener method createLldpFlow.
private void createLldpFlow(BigInteger dpId, String dstMac, String flowName) {
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchEthernetType(ElanConstants.LLDP_ETH_TYPE));
mkMatches.add(new MatchEthernetDestination(new MacAddress(dstMac)));
List<ActionInfo> listActionInfo = new ArrayList<>();
listActionInfo.add(new ActionPuntToController());
List<InstructionInfo> mkInstructions = new ArrayList<>();
mkInstructions.add(new InstructionApplyActions(listActionInfo));
String flowId = dpId.toString() + NwConstants.ELAN_DMAC_TABLE + "lldp" + ElanConstants.LLDP_ETH_TYPE + dstMac;
FlowEntity lldpFlow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_DMAC_TABLE, flowId, 16, flowName, 0, 0, ElanConstants.COOKIE_ELAN_KNOWN_DMAC, mkMatches, mkInstructions);
mdsalManager.installFlow(lldpFlow);
}
use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetType in project netvirt by opendaylight.
the class VxlanGreConntrackBasedSnatService method installSnatMissEntry.
protected void installSnatMissEntry(BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId, int addOrRemove) {
LOG.debug("installSnatMissEntry : Installing SNAT miss entry in switch {}", dpnId);
List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
String ifNamePrimary = getTunnelInterfaceName(dpnId, primarySwitchId);
List<BucketInfo> listBucketInfo = new ArrayList<>();
if (ifNamePrimary != null) {
LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
}
BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
listBucketInfo.add(0, bucketPrimary);
LOG.debug("installSnatMissEntry : installSnatMissEntry called for dpnId {} with primaryBucket {} ", dpnId, listBucketInfo.get(0));
// Install the select group
long groupId = createGroupId(getGroupIdKey(routerName));
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
LOG.debug("installSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
mdsalManager.installGroup(groupEntity);
// Install miss entry pointing to group
LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}", dpnId, routerName, groupId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchEthernetType(0x0800L));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfo = new ArrayList<>();
BigInteger tunnelId = BigInteger.valueOf(routerId);
if (elanManager.isOpenStackVniSemanticsEnforced()) {
tunnelId = NatOverVxlanUtil.getRouterVni(idManager, routerName, routerId);
}
actionsInfo.add(new ActionSetFieldTunnelId(tunnelId));
LOG.debug("AbstractSnatService : Setting the tunnel to the list of action infos {}", actionsInfo);
actionsInfo.add(new ActionGroup(groupId));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
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.matches.MatchEthernetType in project netvirt by opendaylight.
the class AbstractSnatService method installSnatMissEntry.
protected void installSnatMissEntry(BigInteger dpnId, Long routerId, String routerName, BigInteger primarySwitchId, String externalIp, long extSubnetId, int addOrRemove) {
LOG.debug("installSnatMissEntry : Installing SNAT miss entry in switch {}", dpnId);
List<ActionInfo> listActionInfoPrimary = new ArrayList<>();
String ifNamePrimary = getTunnelInterfaceName(dpnId, primarySwitchId);
List<BucketInfo> listBucketInfo = new ArrayList<>();
if (ifNamePrimary != null) {
LOG.debug("installSnatMissEntry : On Non- Napt switch , Primary Tunnel interface is {}", ifNamePrimary);
listActionInfoPrimary = NatUtil.getEgressActionsForInterface(interfaceManager, ifNamePrimary, routerId);
}
BucketInfo bucketPrimary = new BucketInfo(listActionInfoPrimary);
listBucketInfo.add(0, bucketPrimary);
LOG.debug("installSnatMissEntry : installSnatMissEntry called for dpnId {} with primaryBucket {} ", dpnId, listBucketInfo.get(0));
// Install the select group
long groupId = createGroupId(getGroupIdKey(routerName));
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
LOG.debug("installSnatMissEntry : installing the SNAT to NAPT GroupEntity:{}", groupEntity);
mdsalManager.installGroup(groupEntity);
// Install miss entry pointing to group
LOG.debug("installSnatMissEntry : buildSnatFlowEntity is called for dpId {}, routerName {} and groupId {}", dpnId, routerName, groupId);
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchEthernetType(0x0800L));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfo = new ArrayList<>();
actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(routerId)));
LOG.debug("installSnatMissEntry : Setting the tunnel to the list of action infos {}", actionsInfo);
actionsInfo.add(new ActionGroup(groupId));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
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);
// Install the FIB entry for traffic destined to SNAT IP in Non-NAPT switch.
matches = new ArrayList<>();
actionsInfo = new ArrayList<>();
matches.add(new MatchEthernetType(0x0800L));
if (addOrRemove == NwConstants.ADD_FLOW) {
if (extSubnetId == NatConstants.INVALID_ID) {
LOG.error("installSnatMissEntry : external subnet id is invalid.");
return;
}
actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(extSubnetId)));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(extSubnetId), MetaDataUtil.METADATA_MASK_VRFID));
}
matches.add(new MatchIpv4Destination(externalIp, "32"));
LOG.debug("installSnatMissEntry : Setting the tunnel to the list of action infos {}", actionsInfo);
actionsInfo.add(new ActionGroup(groupId));
instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfo));
flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, routerId);
flowRef = flowRef + "inboundmiss" + externalIp;
syncFlow(dpnId, NwConstants.L3_FIB_TABLE, flowRef, NatConstants.SNAT_FIB_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions, addOrRemove);
}
use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetType in project netvirt by opendaylight.
the class AclServiceUtils method buildIpAndSrcServiceMatch.
public static List<? extends MatchInfoBase> buildIpAndSrcServiceMatch(Integer aclTag, AllowedAddressPairs aap) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.add(buildRemoteAclTagMetadataMatch(aclTag));
if (aap.getIpAddress().getIpAddress() != null) {
if (aap.getIpAddress().getIpAddress().getIpv4Address() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Source srcMatch = new MatchIpv4Source(new Ipv4Prefix(aap.getIpAddress().getIpAddress().getIpv4Address().getValue() + "/32"));
flowMatches.add(srcMatch);
} else if (aap.getIpAddress().getIpAddress().getIpv6Address() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Source srcMatch = new MatchIpv6Source(new Ipv6Prefix(aap.getIpAddress().getIpAddress().getIpv6Address().getValue() + "/128"));
flowMatches.add(srcMatch);
}
} else if (aap.getIpAddress().getIpPrefix() != null) {
if (aap.getIpAddress().getIpPrefix().getIpv4Prefix() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Source srcMatch = new MatchIpv4Source(aap.getIpAddress().getIpPrefix().getIpv4Prefix());
flowMatches.add(srcMatch);
} else if (aap.getIpAddress().getIpPrefix().getIpv6Prefix() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Source srcMatch = new MatchIpv6Source(aap.getIpAddress().getIpPrefix().getIpv6Prefix());
flowMatches.add(srcMatch);
}
}
return flowMatches;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetType in project netvirt by opendaylight.
the class AclServiceUtils method buildIpAndDstServiceMatch.
public static List<? extends MatchInfoBase> buildIpAndDstServiceMatch(Integer aclTag, AllowedAddressPairs aap) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.add(buildRemoteAclTagMetadataMatch(aclTag));
if (aap.getIpAddress().getIpAddress() != null) {
if (aap.getIpAddress().getIpAddress().getIpv4Address() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Destination dstMatch = new MatchIpv4Destination(new Ipv4Prefix(aap.getIpAddress().getIpAddress().getIpv4Address().getValue() + "/32"));
flowMatches.add(dstMatch);
} else if (aap.getIpAddress().getIpAddress().getIpv6Address() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Destination dstMatch = new MatchIpv6Destination(new Ipv6Prefix(aap.getIpAddress().getIpAddress().getIpv6Address().getValue() + "/128"));
flowMatches.add(dstMatch);
}
} else if (aap.getIpAddress().getIpPrefix() != null) {
if (aap.getIpAddress().getIpPrefix().getIpv4Prefix() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Destination dstMatch = new MatchIpv4Destination(aap.getIpAddress().getIpPrefix().getIpv4Prefix());
flowMatches.add(dstMatch);
} else if (aap.getIpAddress().getIpPrefix().getIpv6Prefix() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Destination dstMatch = new MatchIpv6Destination(aap.getIpAddress().getIpPrefix().getIpv6Prefix());
flowMatches.add(dstMatch);
}
}
return flowMatches;
}
Aggregations