import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ofsfc.provider.utils.SfcInstanceIdentifierUtils;
import org.opendaylight.ofsfc.provider.utils.SfcOfL2APIUtil;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.SfcAction;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.access.list.entries.Actions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.Actions1;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.SfcAction;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.sfc.action.AclServiceFunctionPath;
}
private void configureAclFlows(AccessListEntries createdAccessListEntries, boolean isAddFlow) {
+ Matches matches;
+ AceIp aceIp;
+ AceIpv4 aceIpv4;
+ Short srcPort = 0;
+ Short dstPort = 0;
+ String srcIpAddress = null;
+ String dstIpAddress = null;
+ byte protocol = (byte) 0;
- AclServiceFunctionPath sfcAction = (AclServiceFunctionPath) (SfcAction) createdAccessListEntries.getActions();
+ OpenflowSfcFlowProgrammer flowProgrammer = OpenflowSfcFlowProgrammer.getInstance();
+ SfcAction sfcAction = createdAccessListEntries.getActions().getAugmentation(Actions1.class).getSfcAction();
+ String aclServicePathName = ((AclServiceFunctionPath) sfcAction).getServiceFunctionPath();
- String sfpName = sfcAction.getServiceFunctionPath();
- ServiceFunctionPath servicefunctionPath = SfcOfL2APIUtil.readServiceFunctionPath(getDataBroker(), sfpName);
+ ServiceFunctionPath servicefunctionPath = SfcOfL2APIUtil.readServiceFunctionPath(getDataBroker(),
+ aclServicePathName);
Long pathId = servicefunctionPath.getPathId();
- Matches matches;
- AceIp aceIp;
- AceIpv4 aceIpv4;
-
matches = createdAccessListEntries.getMatches();
aceIp = (AceIp) matches.getAceType();
aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
- String srcIpAddress = aceIpv4.getSourceIpv4Address().getValue();
- String dstIpAddress = aceIpv4.getDestinationIpv4Address().getValue();
-
- Short srcPort = aceIp.getSourcePortRange().getLowerPort().getValue().shortValue();
- Short dstPort = aceIp.getDestinationPortRange().getLowerPort().getValue().shortValue();
-
- byte protocol = aceIp.getIpProtocol().byteValue();
+ if (aceIpv4.getSourceIpv4Address() != null) {
+ srcIpAddress = aceIpv4.getSourceIpv4Address().getValue();
+ }
+ if (aceIpv4.getDestinationIpv4Address() != null) {
+ dstIpAddress = aceIpv4.getDestinationIpv4Address().getValue();
+ }
+ if (aceIp != null) {
+ if (aceIp.getSourcePortRange() != null) {
+ srcPort = aceIp.getSourcePortRange().getLowerPort().getValue().shortValue();
+ }
+ if (aceIp.getDestinationPortRange() != null) {
+ dstPort = aceIp.getDestinationPortRange().getLowerPort().getValue().shortValue();
+ }
+ if (aceIp.getIpProtocol() != null) {
+ protocol = aceIp.getIpProtocol().byteValue();
+ }
+ }
List<ServicePathHop> servicePathHopList = servicefunctionPath.getServicePathHop();
for (ServicePathHop servicePathHop : servicePathHopList) {
- OpenflowSfcFlowProgrammer.getInstance().setNodeInfo(servicePathHop.getServiceFunctionForwarder());
- OpenflowSfcFlowProgrammer.getInstance().configureClassificationFlow(srcIpAddress, (short) 32, dstIpAddress,
- (short) 32, srcPort, dstPort, protocol, pathId, isAddFlow);
+
+ flowProgrammer.setNodeInfo(servicePathHop.getServiceFunctionForwarder());
+ flowProgrammer.configureClassificationFlow(srcIpAddress, (short) 32, dstIpAddress, (short) 32, srcPort,
+ dstPort, protocol, pathId, isAddFlow);
}
}
private String sffNodeName;
private static final int SCHEDULED_THREAD_POOL_SIZE = 1;
- private static final int QUEUE_SIZE = 16;
+ private static final int QUEUE_SIZE = 50;
private static final int ASYNC_THREAD_POOL_CORE_SIZE = 1;
private static final int ASYNC_THREAD_POOL_MAX_SIZE = 1;
private static final int ASYNC_THREAD_POOL_KEEP_ALIVE_TIME_SECS = 300;
LOG.trace("+++++++++++++++++ SfcProviderSffFlowWriter.writeSffAcl() SFPid {}", sfpId);
+ boolean isIpMatch = false;
+ boolean isPortMatch = false;
//
// Create the 5-tuple matching criteria
ethTypeBuilder.setType(new EtherType(0x0800L));
EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
+ MatchBuilder match = new MatchBuilder();
+ match.setEthernetMatch(ethMatchBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
- ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(longToIp(srcIp, srcMask)));
- ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(longToIp(dstIp, dstMask)));
+ if (srcIp != null) {
+ ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(longToIp(srcIp, srcMask)));
+ isIpMatch = true;
+ }
+ if (dstIp != null) {
+ ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(longToIp(dstIp, dstMask)));
+ isIpMatch = true;
+ }
+ if (isIpMatch == true) {
+ match.setLayer3Match(ipv4MatchBuilder.build());
+ }
IpMatchBuilder ipmatch = new IpMatchBuilder();
- ipmatch.setIpProtocol((short) protocol);
-
- MatchBuilder match = new MatchBuilder();
- match.setEthernetMatch(ethMatchBuilder.build());
- match.setLayer3Match(ipv4MatchBuilder.build());
- match.setIpMatch(ipmatch.build());
-
- if (protocol == 6) {
- TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
- // There must be a bug in
- // setTcpSource/DestinationPort(), because its
- // looking at the upper 2 bytes of the port and thinks
- // its out of range
- tcpMatch.setTcpSourcePort(new PortNumber(new Integer(0x0000FFFF & srcPort)));
- tcpMatch.setTcpDestinationPort(new PortNumber(new Integer(0x0000FFFF & dstPort)));
- match.setLayer4Match(tcpMatch.build());
- } else {
- UdpMatchBuilder udpMatch = new UdpMatchBuilder();
- udpMatch.setUdpSourcePort(new PortNumber(new Integer(0x0000FFFF & srcPort)));
- udpMatch.setUdpDestinationPort(new PortNumber(new Integer(0x0000FFFF & dstPort)));
- match.setLayer4Match(udpMatch.build());
+ if (protocol != 0) {
+ ipmatch.setIpProtocol((short) protocol);
+ match.setIpMatch(ipmatch.build());
+
+ if (protocol == 6) {
+ TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
+ // There must be a bug in
+ // setTcpSource/DestinationPort(), because its
+ // looking at the upper 2 bytes of the port and thinks
+ // its out of range
+ if (srcPort != 0) {
+ tcpMatch.setTcpSourcePort(new PortNumber(new Integer(0x0000FFFF & srcPort)));
+ isPortMatch = true;
+ }
+ if (dstPort != 0) {
+ tcpMatch.setTcpDestinationPort(new PortNumber(new Integer(0x0000FFFF & dstPort)));
+ isPortMatch = true;
+ }
+ if (isPortMatch == true) {
+ match.setLayer4Match(tcpMatch.build());
+ }
+ } else {
+ UdpMatchBuilder udpMatch = new UdpMatchBuilder();
+ if (srcPort != 0) {
+ udpMatch.setUdpSourcePort(new PortNumber(new Integer(0x0000FFFF & srcPort)));
+ isPortMatch = true;
+ }
+ if (dstPort != 0) {
+ udpMatch.setUdpDestinationPort(new PortNumber(new Integer(0x0000FFFF & dstPort)));
+ isPortMatch = true;
+ }
+ if (isPortMatch == true) {
+ match.setLayer4Match(udpMatch.build());
+ }
+ }
}
//
EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
ethSourceBuilder.setAddress(new MacAddress(srcMac));
- ethernetMatch.setEthernetType(ethtype.setType(type).build());
+ // ethernetMatch.setEthernetType(ethtype.setType(type).build());
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
match.setEthernetMatch(ethernetMatch.build());
EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
EtherType type = new EtherType(0x0800L);
- ethmatch.setEthernetType(ethtype.setType(type).build());
+ // ethmatch.setEthernetType(ethtype.setType(type).build());
match.setEthernetMatch(ethmatch.build());
// Create the Actions
EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
ethDestinationBuilder.setAddress(new MacAddress(dstMac));
-
- //ethernetMatch.setEthernetType(ethtype.setType(type).build());
+ // ethernetMatch.setEthernetType(ethtype.setType(type).build());
ethernetMatch.setEthernetDestination(ethDestinationBuilder.build());
matchBuilder.setEthernetMatch(ethernetMatch.build());