use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class AclServiceUtils method buildMatchesForLPortTagAndRemoteAclTag.
public static List<MatchInfoBase> buildMatchesForLPortTagAndRemoteAclTag(Integer lportTag, Integer remoteAclTag, Class<? extends ServiceModeBase> serviceMode) {
List<MatchInfoBase> matches = new ArrayList<>();
if (serviceMode != null && serviceMode.isAssignableFrom(ServiceModeEgress.class)) {
matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
matches.add(AclServiceUtils.buildRemoteAclTagMetadataMatch(remoteAclTag));
} else {
// In case of ingress service mode, only metadata is used for
// matching both lportTag and aclTag. Hence performing "or"
// operation on both lportTag and aclTag metadata.
BigInteger metaData = MetaDataUtil.getLportTagMetaData(lportTag).or(getRemoteAclTagMetadata(BigInteger.valueOf(remoteAclTag)));
BigInteger metaDataMask = MetaDataUtil.METADATA_MASK_LPORT_TAG.or(MetaDataUtil.METADATA_MASK_REMOTE_ACL_TAG);
matches.add(new MatchMetadata(metaData, metaDataMask));
}
return matches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class AclInterfaceStateListener method add.
@Override
protected void add(InstanceIdentifier<Interface> key, Interface added) {
if (!L2vlan.class.equals(added.getType())) {
return;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface;
iface = interfaceManager.getInterfaceInfoFromConfigDataStore(added.getName());
if (iface == null) {
LOG.error("No interface with name {} available in interfaceConfig, servicing interfaceState ADD" + "for ACL failed", added.getName());
return;
}
InterfaceAcl aclInPort = iface.getAugmentation(InterfaceAcl.class);
if (aclInPort == null) {
LOG.trace("Interface {} is not an ACL Interface, ignoring ADD interfaceState event", added.getName());
return;
}
AclInterface aclInterface = aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
builder.dpId(AclServiceUtils.getDpIdFromIterfaceState(added)).lPortTag(added.getIfIndex()).isMarkedForDelete(false);
if (AclServiceUtils.isOfInterest(prevAclInterface)) {
if (prevAclInterface.getSubnetIpPrefixes() == null) {
// For upgrades
List<IpPrefixOrAddress> subnetIpPrefixes = AclServiceUtils.getSubnetIpPrefixes(dataBroker, added.getName());
builder.subnetIpPrefixes(subnetIpPrefixes);
}
SortedSet<Integer> ingressRemoteAclTags = aclServiceUtils.getRemoteAclTags(aclInPort.getSecurityGroups(), DirectionIngress.class);
SortedSet<Integer> egressRemoteAclTags = aclServiceUtils.getRemoteAclTags(aclInPort.getSecurityGroups(), DirectionEgress.class);
builder.ingressRemoteAclTags(ingressRemoteAclTags).egressRemoteAclTags(egressRemoteAclTags);
}
});
if (AclServiceUtils.isOfInterest(aclInterface)) {
List<Uuid> aclList = aclInterface.getSecurityGroups();
if (aclList != null) {
aclDataUtil.addAclInterfaceMap(aclList, aclInterface);
}
if (aclInterface.getElanId() == null) {
LOG.debug("On Add event, skip ADD since ElanId is not updated");
return;
}
if (aclClusterUtil.isEntityOwner()) {
LOG.debug("On add event, notify ACL service manager to add ACL for interface: {}", aclInterface);
aclServiceManger.notify(aclInterface, null, Action.BIND);
if (aclList != null) {
aclServiceUtils.addAclPortsLookup(aclInterface, aclList, aclInterface.getAllowedAddressPairs());
}
aclServiceManger.notify(aclInterface, null, Action.ADD);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class AclLiveStatisticsHelper method getAclPortStats.
/**
* Gets the acl port stats.
*
* @param direction the direction
* @param interfaceNames the interface names
* @param odlDirectStatsService the odl direct stats service
* @param dataBroker the data broker
* @return the acl port stats
*/
public static List<AclPortStats> getAclPortStats(Direction direction, List<String> interfaceNames, OpendaylightDirectStatisticsService odlDirectStatsService, DataBroker dataBroker) {
LOG.trace("Get ACL port stats for direction {} and interfaces {}", direction, interfaceNames);
List<AclPortStats> lstAclPortStats = new ArrayList<>();
Short tableId = getTableId(direction);
FlowCookie aclDropFlowCookie = new FlowCookie(AclConstants.COOKIE_ACL_DROP_FLOW);
FlowCookie aclDropFlowCookieMask = new FlowCookie(COOKIE_ACL_DROP_FLOW_MASK);
for (String interfaceName : interfaceNames) {
AclPortStatsBuilder aclStatsBuilder = new AclPortStatsBuilder().setInterfaceName(interfaceName);
Interface interfaceState = AclServiceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
if (interfaceState == null) {
String errMsg = "Interface not found in datastore.";
addError(lstAclPortStats, aclStatsBuilder, errMsg);
continue;
}
BigInteger dpId = AclServiceUtils.getDpIdFromIterfaceState(interfaceState);
if (dpId == null) {
String errMsg = "Failed to find device for the interface.";
addError(lstAclPortStats, aclStatsBuilder, errMsg);
continue;
}
NodeRef nodeRef = buildNodeRef(dpId);
Integer lportTag = interfaceState.getIfIndex();
Match metadataMatch = buildMetadataMatch(lportTag);
GetFlowStatisticsInputBuilder input = new GetFlowStatisticsInputBuilder().setNode(nodeRef).setCookie(aclDropFlowCookie).setCookieMask(aclDropFlowCookieMask).setMatch(metadataMatch).setStoreStats(false);
if (direction != Direction.Both) {
input.setTableId(tableId);
}
Future<RpcResult<GetFlowStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getFlowStatistics(input.build());
RpcResult<GetFlowStatisticsOutput> rpcResult = null;
try {
rpcResult = rpcResultFuture.get();
} catch (InterruptedException | ExecutionException e) {
String errMsg = "Unable to retrieve drop counts due to error: " + e.getMessage();
addError(lstAclPortStats, aclStatsBuilder, errMsg);
LOG.error("Exception occurred during get flow statistics for interface {}", interfaceName, e);
}
if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
GetFlowStatisticsOutput flowStatsOutput = rpcResult.getResult();
getAclDropStats(direction, aclStatsBuilder, flowStatsOutput);
lstAclPortStats.add(aclStatsBuilder.build());
} else {
handleRpcErrors(lstAclPortStats, aclStatsBuilder, rpcResult);
}
}
return lstAclPortStats;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class EvpnSnatFlowProgrammer method removeTunnelTableEntry.
public void removeTunnelTableEntry(BigInteger dpnId, long l3Vni, WriteTransaction removeFlowInvTx) {
LOG.debug("removeTunnelTableEntry : Remove terminating service table {} --> table {} flow on NAPT DpnId {} " + "with l3Vni {} as matching parameter", NwConstants.INTERNAL_TUNNEL_TABLE, NwConstants.INBOUND_NAPT_TABLE, dpnId, l3Vni);
List<MatchInfo> mkMatches = new ArrayList<>();
// Matching metadata
mkMatches.add(new MatchTunnelId(BigInteger.valueOf(l3Vni)));
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, NatEvpnUtil.getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, l3Vni, NatConstants.SNAT_FLOW_NAME), 5, String.format("%s:%d", "TST Flow Entry ", l3Vni), 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(l3Vni)), mkMatches, null);
mdsalManager.removeFlowToTx(dpnId, flowEntity, removeFlowInvTx);
LOG.debug("removeTunnelTableEntry : Successfully removed terminating service table flow {} on DpnId {}", flowEntity, dpnId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class NaptManager method removeNaptPortPool.
void removeNaptPortPool(String poolName) {
DeleteIdPoolInput deleteIdPoolInput = new DeleteIdPoolInputBuilder().setPoolName(poolName).build();
LOG.debug("removeNaptPortPool : Remove Napt port pool requested for : {}", poolName);
try {
Future<RpcResult<Void>> result = idManager.deleteIdPool(deleteIdPoolInput);
if (result != null && result.get().isSuccessful()) {
LOG.debug("removeNaptPortPool : Deleted PortPool {}", poolName);
} else {
LOG.error("removeNaptPortPool : Unable to delete PortPool {}", poolName);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("removeNaptPortPool : Failed to delete PortPool {} for NAPT Service", poolName, e);
}
}
Aggregations