use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.
the class AclInterfaceListener method add.
@Override
public void add(InstanceIdentifier<Interface> key, Interface port) {
LOG.trace("Received AclInterface add event, port={}", port);
InterfaceAcl aclInPort = port.getAugmentation(InterfaceAcl.class);
if (aclInPort != null && aclInPort.isPortSecurityEnabled()) {
String interfaceId = port.getName();
AclInterface aclInterface = addOrUpdateAclInterfaceCache(interfaceId, aclInPort);
// if interface state event comes first followed by interface config event.
if (aclInterface.getDpId() != null && aclInterface.getElanId() != null && aclClusterUtil.isEntityOwner()) {
LOG.debug("On add event, notify ACL bind/add for interface: {}", interfaceId);
aclServiceManager.notify(aclInterface, null, Action.BIND);
aclServiceManager.notify(aclInterface, null, Action.ADD);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.
the class AclInterfaceStateListener method remove.
@Override
protected void remove(InstanceIdentifier<Interface> key, Interface deleted) {
if (!L2vlan.class.equals(deleted.getType())) {
return;
}
String interfaceId = deleted.getName();
AclInterface aclInterface = aclInterfaceCache.remove(interfaceId);
if (AclServiceUtils.isOfInterest(aclInterface)) {
List<Uuid> aclList = aclInterface.getSecurityGroups();
if (aclClusterUtil.isEntityOwner()) {
LOG.debug("On remove event, notify ACL service manager to remove ACL from interface: {}", aclInterface);
aclServiceManger.notify(aclInterface, null, Action.UNBIND);
aclServiceManger.notify(aclInterface, null, Action.REMOVE);
if (aclList != null) {
aclServiceUtils.deleteAclPortsLookup(aclInterface, aclList, aclInterface.getAllowedAddressPairs());
}
}
if (aclList != null) {
aclDataUtil.removeAclInterfaceMap(aclList, aclInterface);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.
the class AclNodeListener method add.
@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode dataObjectModification) {
NodeKey nodeKey = key.firstKeyOf(Node.class);
BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
LOG.info("Received ACL node [{}] add event", dpId);
if (securityGroupMode != null && securityGroupMode != SecurityGroupMode.Stateful) {
LOG.error("Invalid security group mode ({}) obtained from AclserviceConfig. dpId={}", securityGroupMode, dpId);
return;
}
jobCoordinator.enqueueJob(String.valueOf(dpId), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
new AclNodeDefaultFlowsTxBuilder(dpId, mdsalManager, config, tx).build();
LOG.info("Adding default ACL flows for dpId={}", dpId);
})), AclConstants.JOB_MAX_RETRIES);
LOG.trace("FlowCapableNode (dpid: {}) add event is processed.", dpId);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.
the class AclInstanceRecoveryHandler method recoverService.
@Override
public void recoverService(String entityId) {
LOG.info("Recover ACL instance {}", entityId);
Uuid aclId = new Uuid(entityId);
Collection<AclInterface> aclInterfaces = aclDataUtil.getInterfaceList(aclId);
for (AclInterface aclInterface : aclInterfaces) {
String aclInterfaceId = aclInterface.getInterfaceId();
Optional<Interface> interfaceOptional = AclServiceUtils.getInterface(dataBroker, aclInterfaceId);
if (interfaceOptional.isPresent()) {
Interface interfaceBefore = interfaceOptional.get();
LOG.debug("Starting Recovery of acl Instance {} for interface {}", entityId, interfaceBefore.getName());
InterfaceAcl interfaceAclBefore = interfaceBefore.getAugmentation(InterfaceAcl.class);
List<Uuid> sgList = new ArrayList<>(interfaceAclBefore.getSecurityGroups());
sgList.remove(aclId);
InterfaceAcl interfaceAclAfter = new InterfaceAclBuilder(interfaceAclBefore).setSecurityGroups(sgList).build();
Interface interfaceAfter = new InterfaceBuilder(interfaceBefore).addAugmentation(InterfaceAcl.class, interfaceAclAfter).build();
aclInterfaceListener.update(null, interfaceBefore, interfaceAfter);
aclInterfaceListener.update(null, interfaceAfter, interfaceBefore);
} else {
LOG.error("Interfaces not present for aclInterface {} ", aclInterfaceId);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.
the class AbstractAclServiceImpl method programAclForExistingTrafficTable.
private void programAclForExistingTrafficTable(AclInterface port, Ace ace, int addOrRemove, String flowName, List<MatchInfoBase> matches, Integer priority) {
AceIp acl = (AceIp) ace.getMatches().getAceType();
final String newFlowName = flowName + this.directionString + "_" + port.getDpId() + "_" + port.getLPortTag() + "_" + ((acl.getAceIpVersion() instanceof AceIpv4) ? "_IPv4" : "_IPv6") + "_FlowAfterRuleDeleted";
final List<MatchInfoBase> newMatches = matches.stream().filter(obj -> !(obj instanceof NxMatchCtState || obj instanceof MatchMetadata)).collect(Collectors.toList());
newMatches.add(AclServiceUtils.buildLPortTagMatch(port.getLPortTag(), serviceMode));
newMatches.add(new NxMatchCtState(AclConstants.TRACKED_RPL_CT_STATE, AclConstants.TRACKED_RPL_CT_STATE_MASK));
List<InstructionInfo> instructions = AclServiceUtils.createCtMarkInstructionForNewState(getAclFilterCumDispatcherTable(), port.getElanId());
// Reversing the flow add/delete operation for this table.
int operation = (addOrRemove == NwConstants.ADD_FLOW) ? NwConstants.DEL_FLOW : NwConstants.ADD_FLOW;
syncFlow(port.getDpId(), getAclForExistingTrafficTable(), newFlowName, priority, "ACL", 0, AclServiceUtils.getHardTimoutForApplyStatefulChangeOnExistingTraffic(ace, aclServiceUtils), AclConstants.COOKIE_ACL_BASE, newMatches, instructions, operation);
}
Aggregations