import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceTypeFlowBased;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow;
NwConstants.SFC_SERVICE_INDEX,
NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE,
+ true,
interfaceName);
}
NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX,
NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE,
OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_COOKIE,
+ false,
interfaceName);
}
public void unbindPortOnIngressClassifier(String interfaceName) {
- unbindService(interfaceName, NwConstants.SFC_CLASSIFIER_INDEX);
+ unbindService(interfaceName, NwConstants.SFC_CLASSIFIER_INDEX, true);
}
public void unbindPortOnEgressClassifier(String interfaceName) {
- unbindService(interfaceName, NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX);
+ unbindService(interfaceName, NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX, false);
}
public Optional<NodeId> getNodeIdFromLogicalInterface(String logicalInterface) {
public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(dpnId);
if (tpList == null) {
+ // Most likely the bridge doesnt exist for this dpnId
+ LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]",
+ dpnId);
return Optional.empty();
}
}
}
- LOG.warn("getEgressVxlanPortForNode nothing available for dpnId [{}]", dpnId);
+ LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
return Optional.empty();
}
+ public List<String> getInterfacesFromNode(NodeId nodeId) {
+ // getPortsOnBridge() only returns Tunnel ports, so instead using getDpnInterfaceList.
+ GetDpnInterfaceListInputBuilder inputBuilder = new GetDpnInterfaceListInputBuilder();
+ inputBuilder.setDpid(BigInteger.valueOf(Long.valueOf(nodeId.getValue().split(":")[1])));
+ GetDpnInterfaceListInput input = inputBuilder.build();
+
+ try {
+ LOG.debug("getInterfacesFromNode: invoking rpc");
+ RpcResult<GetDpnInterfaceListOutput> output =
+ interfaceManagerRpcService.getDpnInterfaceList(input).get();
+ if (!output.isSuccessful()) {
+ LOG.error("getInterfacesFromNode({}) failed: {}", input, output);
+ return Collections.emptyList();
+ }
+ LOG.debug("getInterfacesFromNode({}) succeeded: {}", input, output);
+ return output.getResult().getInterfacesList();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("getInterfacesFromNode failed to retrieve target interface name: ", e);
+ }
+
+ return Collections.emptyList();
+ }
+
private void bindService(short serviceId, String serviceName, int servicePriority,
- short serviceDestTable, BigInteger serviceTableCookie, String interfaceName) {
+ short serviceDestTable, BigInteger serviceTableCookie,
+ boolean isIngress, String interfaceName) {
+ ServicesInfoKey servicesInfoKey = isIngress
+ ? new ServicesInfoKey(interfaceName, ServiceModeIngress.class) :
+ new ServicesInfoKey(interfaceName, ServiceModeEgress.class);
InstanceIdentifier<BoundServices> id = InstanceIdentifier.builder(ServiceBindings.class)
- .child(ServicesInfo.class, new ServicesInfoKey(interfaceName, ServiceModeIngress.class))
+ .child(ServicesInfo.class, servicesInfoKey)
.child(BoundServices.class, new BoundServicesKey(serviceId)).build();
StypeOpenflow stypeOpenflow = new StypeOpenflowBuilder().setFlowCookie(serviceTableCookie)
BoundServices boundServices = new BoundServicesBuilder().setServiceName(serviceName)
.setServicePriority(serviceId).setServiceType(ServiceTypeFlowBased.class)
.addAugmentation(StypeOpenflow.class, stypeOpenflow).build();
-
LOG.info("Binding Service ID [{}] name [{}] priority [{}] table [{}] cookie [{}] interface [{}]",
serviceId, serviceName, servicePriority, serviceDestTable, serviceTableCookie, interfaceName);
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, id, boundServices);
}
- private void unbindService(String interfaceName, short serviceId) {
+ private void unbindService(String interfaceName, short serviceId, boolean isIngress) {
+ ServicesInfoKey servicesInfoKey = isIngress
+ ? new ServicesInfoKey(interfaceName, ServiceModeIngress.class) :
+ new ServicesInfoKey(interfaceName, ServiceModeEgress.class);
+
InstanceIdentifier<BoundServices> id = InstanceIdentifier.builder(ServiceBindings.class)
- .child(ServicesInfo.class, new ServicesInfoKey(interfaceName, ServiceModeIngress.class))
+ .child(ServicesInfo.class, servicesInfoKey)
.child(BoundServices.class, new BoundServicesKey(serviceId)).build();
LOG.info("Unbinding Service ID [{}] interface [{}]", serviceId, interfaceName);
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@Singleton
public class OpenFlow13Provider {
public static final short NSH_MDTYPE_ONE = 0x01;
public static final long DEFAULT_NSH_CONTEXT_VALUE = 0L;
private static final int DEFAULT_NETMASK = 32;
- private static final Logger LOG = LoggerFactory.getLogger(OpenFlow13Provider.class);
- private static AtomicLong flowIdInc = new AtomicLong();
public MatchBuilder getMatchBuilderFromAceMatches(Matches matches) {
if (matches == null) {
actionList.size()));
InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- LOG.info("createIngressClassifierAclFlow match.toString() [{}]", match.build().toString());
// The flowIdStr needs to be unique, so the best way to make it unique is to use the match
String flowIdStr = INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue() + match.build().toString();
OpenFlow13Utils.addMatchTunIpv4Dst(match, localIpStr, DEFAULT_NETMASK);
List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE,
+ actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.SFC_TRANSPORT_INGRESS_TABLE,
actionList.size()));
InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);