public static List<ListenableFuture<Void>> bindService(InstanceIdentifier<BoundServices> instanceIdentifier,
BoundServices boundServiceNew, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
- WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
String interfaceName =
InstanceIdentifier.keyOf(instanceIdentifier.firstIdentifierOf(ServicesInfo.class)).getInterfaceName();
int vlanId = 0;
List<MatchInfo> matches = null;
if (iface.getType().isAssignableFrom(L2vlan.class)) {
- IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
- if( l2vlan != null){
- vlanId = l2vlan.getVlanId().getValue();
- }
- matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, vlanId);
+ matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
} else if (iface.getType().isAssignableFrom(Tunnel.class)){
matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
}
if (matches != null) {
- FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, boundServiceNew,
- dataBroker, t, matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew,
+ transaction, matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
}
- if (t != null) {
- futures.add(t.submit());
+ if (transaction != null) {
+ futures.add(transaction.submit());
}
return futures;
}
highestPriority = boundService.getServicePriority();
}
}
- LOG.error("Reached unexpected part 1 of the code when handling bind service for interface: {}, when binding" +
- "service: {}", iface, boundServiceNew);
}
if (!isCurrentServiceHighestPriority) {
- FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundServiceNew, iface, t,
+ FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, boundServiceNew, iface, transaction,
ifState.getIfIndex());
} else {
BoundServices serviceToReplace = tmpServicesMap.get(highestPriority);
- FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, serviceToReplace, iface, t,
+ FlowBasedServicesUtils.installLPortDispatcherFlow(dpId, serviceToReplace, iface, transaction,
ifState.getIfIndex());
- int vlanId = 0;
List<MatchInfo> matches = null;
if (iface.getType().isAssignableFrom(L2vlan.class)) {
- vlanId = iface.getAugmentation(IfL2vlan.class).getVlanId().getValue();
- matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, vlanId);
+ matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
} else if (iface.getType().isAssignableFrom(Tunnel.class)){
matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
}
if (matches != null) {
- FlowBasedServicesUtils.removeIngressFlow(iface, serviceToReplace, dpId, t);
- FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, boundServiceNew, dataBroker, t,
+
+ WriteTransaction removeFlowTransaction = dataBroker.newWriteOnlyTransaction();
+ FlowBasedServicesUtils.removeIngressFlow(iface, serviceToReplace, dpId, removeFlowTransaction);
+ futures.add(removeFlowTransaction.submit());
+
+ WriteTransaction installFlowTransaction = dataBroker.newWriteOnlyTransaction();
+ FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew, installFlowTransaction,
matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ futures.add(installFlowTransaction.submit());
}
}
- if (t != null) {
- futures.add(t.submit());
+ if (transaction != null) {
+ futures.add(transaction.submit());
}
return futures;
}
long portNo = Long.parseLong(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- int vlanId = 0;
- if (iface.getType().isAssignableFrom(L2vlan.class)) {
- IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
- if(l2vlan != null) {
- vlanId = iface.getAugmentation(IfL2vlan.class).getVlanId().getValue();
- }
- }
List<BoundServices> boundServices = servicesInfo.getBoundServices();
if (boundServices.isEmpty()) {
// Remove entry from Ingress Table.
List<MatchInfo> matches = null;
if (iface.getType().isAssignableFrom(L2vlan.class)) {
- matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, vlanId);
+ matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
} else if (iface.getType().isAssignableFrom(Tunnel.class)){
matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
}
BoundServices toBeMoved = tmpServicesMap.get(highestPriority);
FlowBasedServicesUtils.removeIngressFlow(iface, boundServiceOld, dpId, t);
- FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, toBeMoved, dataBroker, t,
+ FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, toBeMoved, t,
matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, toBeMoved, t);
NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
long portNo = Long.parseLong(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- int vlanId = 0;
List<MatchInfo> matches = null;
if (iface.getType().isAssignableFrom(L2vlan.class)) {
- IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
- if(l2vlan != null) {
- vlanId = l2vlan.getVlanId().getValue();
- }
- matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, vlanId);
+ matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
} else if (iface.getType().isAssignableFrom(Tunnel.class)){
matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
}
if (matches != null) {
- FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface.getName(), vlanId, highestPriorityBoundService,
- dataBroker, t, matches, ifaceState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, highestPriorityBoundService,
+ t, matches, ifaceState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
}
for (BoundServices boundService : allServices) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfoKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.services.info.BoundServices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return null;
}
- public static List<MatchInfo> getMatchInfoForVlanPortAtIngressTable(BigInteger dpId, long portNo, long vlanId) {
+ public static List<MatchInfo> getMatchInfoForVlanPortAtIngressTable(BigInteger dpId, long portNo, Interface iface) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchInfo(MatchFieldType.in_port, new BigInteger[] {dpId, BigInteger.valueOf(portNo)}));
+ int vlanId = 0;
+ IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
+ if(l2vlan != null){
+ vlanId = l2vlan.getVlanId().getValue();
+ }
if (vlanId > 0) {
LOG.error("VlanId matching support is not fully available in Be.");
matches.add(new MatchInfo(MatchFieldType.vlan_vid, new long[]{vlanId}));
return 0L;
}
- public static void installInterfaceIngressFlow(BigInteger dpId, String interfaceName, int vlanId,
+ public static void installInterfaceIngressFlow(BigInteger dpId, Interface iface,
BoundServices boundServiceNew,
- DataBroker dataBroker, WriteTransaction t,
+ WriteTransaction t,
List<MatchInfo> matches, int lportTag, short tableId) {
List<Instruction> instructions = boundServiceNew.getAugmentation(StypeOpenflow.class).getInstruction();
int serviceInstructionsSize = instructions.size();
List<Instruction> instructionSet = new ArrayList<Instruction>();
+ int vlanId = 0;
+ IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
+ if(l2vlan != null){
+ vlanId = l2vlan.getVlanId().getValue();
+ }
if (vlanId != 0) {
// incrementing instructionSize and using it as actionKey. Because it won't clash with any other instructions
int actionKey = ++serviceInstructionsSize;
}
String serviceRef = boundServiceNew.getServiceName();
- String flowRef = getFlowRef(dpId, interfaceName, boundServiceNew);
+ String flowRef = getFlowRef(dpId, iface.getName(), boundServiceNew);
StypeOpenflow stypeOpenflow = boundServiceNew.getAugmentation(StypeOpenflow.class);
Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
stypeOpenflow.getFlowPriority(), serviceRef, 0, 0,