use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class FlowBasedServicesUtils method installLportIngressFlow.
public static void installLportIngressFlow(BigInteger dpId, long portNo, Interface iface, List<ListenableFuture<Void>> futures, ManagedNewTransactionRunner txRunner, int lportTag) {
int vlanId = 0;
boolean isVlanTransparent = false;
IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
if (l2vlan != null) {
vlanId = l2vlan.getVlanId() == null ? 0 : l2vlan.getVlanId().getValue();
isVlanTransparent = l2vlan.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
}
int instructionKey = 0;
List<Instruction> instructions = new ArrayList<>();
final SplitHorizon splitHorizon = iface.getAugmentation(SplitHorizon.class);
boolean overrideSplitHorizonProtection = splitHorizon != null && splitHorizon.isOverrideSplitHorizonProtection();
int actionKey = -1;
List<Action> actions = new ArrayList<>();
if (vlanId != 0 && !isVlanTransparent) {
actions.add(MDSALUtil.createPopVlanAction(++actionKey));
}
if (overrideSplitHorizonProtection) {
actions.add(MDSALUtil.createNxOfInPortAction(++actionKey, 0));
}
if (!actions.isEmpty()) {
instructions.add(MDSALUtil.buildApplyActionsInstruction(actions, instructionKey++));
}
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, (short) 0, BigInteger.ZERO, isExternal(iface));
BigInteger metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG);
instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, instructionKey++));
instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.LPORT_DISPATCHER_TABLE, instructionKey++));
int priority = isVlanTransparent ? 1 : vlanId == 0 ? IfmConstants.FLOW_PRIORITY_FOR_UNTAGGED_VLAN : IfmConstants.FLOW_HIGH_PRIORITY;
String flowRef = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, iface.getName());
List<MatchInfo> matches = getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
Flow ingressFlow = MDSALUtil.buildFlowNew(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.VLAN_TABLE_COOKIE, matches, instructions);
LOG.debug("Installing ingress flow {} for {}", flowRef, iface.getName());
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> installFlow(dpId, ingressFlow, tx)));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class FlowBasedServicesUtils method installInterfaceIngressFlow.
public static void installInterfaceIngressFlow(BigInteger dpId, Interface iface, BoundServices boundServiceNew, WriteTransaction writeTransaction, List<MatchInfo> matches, int lportTag, short tableId) {
List<Instruction> instructions = boundServiceNew.getAugmentation(StypeOpenflow.class).getInstruction();
int serviceInstructionsSize = instructions != null ? instructions.size() : 0;
List<Instruction> instructionSet = new ArrayList<>();
int vlanId = 0;
IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
if (l2vlan != null && l2vlan.getVlanId() != 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;
instructionSet.add(MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, ++serviceInstructionsSize));
}
if (lportTag != 0L) {
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(instructions);
short index = boundServiceNew.getServicePriority();
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ++index, metadataValues[0], isExternal(iface));
BigInteger metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_SERVICE_INDEX, MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG, metadataValues[1]);
instructionSet.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++serviceInstructionsSize));
}
if (instructions != null && !instructions.isEmpty()) {
for (Instruction info : instructions) {
// Skip meta data write as that is handled already
if (info.getInstruction() instanceof WriteMetadataCase) {
continue;
} else if (info.getInstruction() instanceof WriteActionsCase) {
info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
} else if (info.getInstruction() instanceof ApplyActionsCase) {
info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
}
instructionSet.add(info);
}
}
String serviceRef = boundServiceNew.getServiceName();
String flowRef = getFlowRef(dpId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, iface.getName(), boundServiceNew.getServicePriority());
StypeOpenflow stypeOpenflow = boundServiceNew.getAugmentation(StypeOpenflow.class);
Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, flowRef, stypeOpenflow.getFlowPriority(), serviceRef, 0, 0, stypeOpenflow.getFlowCookie(), matches, instructionSet);
installFlow(dpId, ingressFlow, writeTransaction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class OvsVlanMemberConfigUpdateHelper method updateConfiguration.
public List<ListenableFuture<Void>> updateConfiguration(ParentRefs parentRefsNew, Interface interfaceOld, IfL2vlan ifL2vlanNew, Interface interfaceNew) {
LOG.info("updating interface configuration for vlan memeber {} with parent-interface {}", interfaceNew.getName(), parentRefsNew.getParentInterface());
List<ListenableFuture<Void>> futures = new ArrayList<>();
ParentRefs parentRefsOld = interfaceOld.getAugmentation(ParentRefs.class);
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefsOld.getParentInterface());
InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
InterfaceChildEntry interfaceChildEntry = interfaceMetaUtils.getInterfaceChildEntryFromConfigDS(interfaceParentEntryKey, interfaceChildEntryKey);
if (interfaceChildEntry == null) {
futures.addAll(ovsVlanMemberConfigAddHelper.addConfiguration(interfaceNew.getAugmentation(ParentRefs.class), interfaceNew));
return futures;
}
IfL2vlan ifL2vlanOld = interfaceOld.getAugmentation(IfL2vlan.class);
if (ifL2vlanOld == null || ifL2vlanNew.getL2vlanMode() != ifL2vlanOld.getL2vlanMode()) {
LOG.error("Configuration Error. Vlan Mode Change of Vlan Trunk Member {} as new trunk member: {} is " + "not allowed.", interfaceOld, interfaceNew);
return futures;
}
if (vlanIdModified(ifL2vlanOld.getVlanId(), ifL2vlanNew.getVlanId()) || !parentRefsOld.getParentInterface().equals(parentRefsNew.getParentInterface())) {
LOG.info("vlan-id modified for interface {}", interfaceNew.getName());
futures.addAll(ovsVlanMemberConfigRemoveHelper.removeConfiguration(parentRefsOld, interfaceOld));
futures.addAll(ovsVlanMemberConfigAddHelper.addConfiguration(parentRefsNew, interfaceNew));
return futures;
}
if (Objects.equals(interfaceNew.isEnabled(), interfaceOld.isEnabled())) {
return futures;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface pifState = interfaceManagerCommonUtils.getInterfaceState(parentRefsNew.getParentInterface());
if (pifState != null) {
OperStatus operStatus = interfaceNew.isEnabled() ? pifState.getOperStatus() : OperStatus.Down;
LOG.info("admin-state modified for interface {}", interfaceNew.getName());
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceNew.getName());
InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
ifaceBuilder.setOperStatus(operStatus);
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
tx.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
}));
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class SouthboundUtils method addTunnelPortToBridge.
private void addTunnelPortToBridge(IfTunnel ifTunnel, InstanceIdentifier<?> bridgeIid, Interface iface, String portName) {
LOG.debug("adding tunnel port {} to bridge {}", portName, bridgeIid);
Class<? extends InterfaceTypeBase> type = TUNNEL_TYPE_MAP.get(ifTunnel.getTunnelInterfaceType());
if (type == null) {
LOG.warn("Unknown Tunnel Type obtained while creating interface: {}", iface);
return;
}
int vlanId = 0;
IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
vlanId = ifL2vlan.getVlanId().getValue();
}
Map<String, String> options = Maps.newHashMap();
// Options common to any kind of tunnel
if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow())) {
options.put(TUNNEL_OPTIONS_LOCAL_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress localIp = ifTunnel.getTunnelSource();
options.put(TUNNEL_OPTIONS_LOCAL_IP, String.valueOf(localIp.getValue()));
}
if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow())) {
options.put(TUNNEL_OPTIONS_REMOTE_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress remoteIp = ifTunnel.getTunnelDestination();
options.put(TUNNEL_OPTIONS_REMOTE_IP, String.valueOf(remoteIp.getValue()));
}
// Specific options for each type of tunnel
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeMplsOverGre.class)) {
options.put(TUNNEL_OPTIONS_PKT_TYPE, TUNNEL_OPTIONS_VALUE_LEGACY_L3);
} else {
options.put(TUNNEL_OPTIONS_KEY, TUNNEL_OPTIONS_VALUE_FLOW);
}
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlanGpe.class)) {
options.put(TUNNEL_OPTIONS_EXTS, TUNNEL_OPTIONS_VALUE_GPE);
options.put(TUNNEL_OPTIONS_NSI, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSP, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC1, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC2, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC3, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC4, TUNNEL_OPTIONS_VALUE_FLOW);
// VxLAN-GPE interfaces will not use the default UDP port to avoid
// problems with other meshes
options.put(TUNNEL_OPTIONS_DESTINATION_PORT, TUNNEL_OPTIONS_VALUE_GPE_DESTINATION_PORT);
}
if (ifTunnel.getTunnelOptions() != null) {
for (TunnelOptions tunOpt : ifTunnel.getTunnelOptions()) {
options.putIfAbsent(tunOpt.getTunnelOption(), tunOpt.getValue());
}
}
addTerminationPoint(bridgeIid, portName, vlanId, type, options, ifTunnel);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class OvsInterfaceConfigAddHelper method addVlanConfiguration.
private void addVlanConfiguration(Interface interfaceNew, ParentRefs parentRefs, WriteTransaction defaultConfigShardTransaction, WriteTransaction defaultOperShardTransaction, List<ListenableFuture<Void>> futures) {
IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
return;
}
if (!interfaceManagerCommonUtils.createInterfaceChildEntryIfNotPresent(defaultConfigShardTransaction, parentRefs.getParentInterface(), interfaceNew.getName(), ifL2vlan.getL2vlanMode())) {
return;
}
LOG.info("adding vlan configuration for interface {}", interfaceNew.getName());
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
interfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), defaultOperShardTransaction, futures, ifState);
VlanMemberStateAddWorker vlanMemberStateAddWorker = new VlanMemberStateAddWorker(txRunner, interfaceManagerCommonUtils, interfaceMetaUtils, interfaceNew.getName(), ifState);
coordinator.enqueueJob(interfaceNew.getName(), vlanMemberStateAddWorker, IfmConstants.JOB_MAX_RETRIES);
}
Aggregations