use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project genius by opendaylight.
the class FlowBasedServicesUtils method installLPortDispatcherFlow.
public static void installLPortDispatcherFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, short nextServiceIndex) {
String serviceRef = boundService.getServiceName();
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForDispatcherTable(interfaceTag, currentServiceIndex);
// Get the metadata and mask from the service's write metadata
// instruction
StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
List<Instruction> serviceInstructions = stypeOpenFlow.getInstruction();
int instructionSize = serviceInstructions != null ? serviceInstructions.size() : 0;
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions);
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(interfaceTag, nextServiceIndex, metadataValues[0]);
BigInteger metadataMask = MetaDataUtil.getWriteMetaDataMaskForDispatcherTable();
// build the final instruction for LPort Dispatcher table flow entry
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize));
if (serviceInstructions != null && !serviceInstructions.isEmpty()) {
for (Instruction info : serviceInstructions) {
// 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()));
}
instructions.add(info);
}
}
// build the flow and install it
String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex);
Flow ingressFlow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions);
LOG.debug("Installing LPort Dispatcher Flow on DPN {}, for interface {}, with flowRef {}", dpId, interfaceName, flowRef);
installFlow(dpId, ingressFlow, writeTransaction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project genius by opendaylight.
the class IfmUtil method mergeOpenflowMetadataWriteInstructions.
public static BigInteger[] mergeOpenflowMetadataWriteInstructions(List<Instruction> instructions) {
BigInteger metadata = new BigInteger("0", 16);
BigInteger metadataMask = new BigInteger("0", 16);
if (instructions != null && !instructions.isEmpty()) {
// check if metadata write instruction is present
for (Instruction instruction : instructions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction actualInstruction = instruction.getInstruction();
if (actualInstruction instanceof WriteMetadataCase) {
WriteMetadataCase writeMetaDataInstruction = (WriteMetadataCase) actualInstruction;
WriteMetadata availableMetaData = writeMetaDataInstruction.getWriteMetadata();
metadata = metadata.or(availableMetaData.getMetadata());
metadataMask = metadataMask.or(availableMetaData.getMetadataMask());
}
}
}
return new BigInteger[] { metadata, metadataMask };
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project genius by opendaylight.
the class ArpUtilImpl method fireArpReqRecvdNotification.
private void fireArpReqRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMac, InetAddress dstInetAddr, int tableId, BigInteger metadata) throws InterruptedException {
arpReqRecvd.mark();
String macAddress = NWUtil.toStringMacAddress(srcMac);
ArpRequestReceivedBuilder builder = new ArpRequestReceivedBuilder();
builder.setInterface(interfaceName);
builder.setOfTableId((long) tableId);
builder.setSrcIpaddress(new IpAddress(srcInetAddr.getHostAddress().toCharArray()));
builder.setDstIpaddress(new IpAddress(dstInetAddr.getHostAddress().toCharArray()));
builder.setSrcMac(new PhysAddress(macAddress));
builder.setMetadata(metadata);
ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
arpReqRecvdNotificationRejected.mark();
} else {
arpReqRecvdNotification.mark();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project genius by opendaylight.
the class ArpUtilImpl method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived packetReceived) {
Class<? extends PacketInReason> pktInReason = packetReceived.getPacketInReason();
LOG.trace("Packet Received {}", packetReceived);
if (pktInReason == SendToController.class) {
try {
int tableId = packetReceived.getTableId().getValue();
byte[] data = packetReceived.getPayload();
Ethernet ethernet = new Ethernet();
ethernet.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
if (ethernet.getEtherType() != ArpConstants.ETH_TYPE_ARP) {
return;
}
Packet pkt = ethernet.getPayload();
ARP arp = (ARP) pkt;
InetAddress srcInetAddr = InetAddress.getByAddress(arp.getSenderProtocolAddress());
InetAddress dstInetAddr = InetAddress.getByAddress(arp.getTargetProtocolAddress());
byte[] srcMac = ethernet.getSourceMACAddress();
byte[] dstMac = ethernet.getDestinationMACAddress();
Metadata metadata = packetReceived.getMatch().getMetadata();
String interfaceName = getInterfaceName(metadata);
checkAndFireMacChangedNotification(interfaceName, srcInetAddr, srcMac);
macsDB.put(interfaceName + "-" + srcInetAddr.getHostAddress(), NWUtil.toStringMacAddress(srcMac));
if (arp.getOpCode() == ArpConstants.ARP_REQUEST_OP) {
fireArpReqRecvdNotification(interfaceName, srcInetAddr, srcMac, dstInetAddr, tableId, metadata.getMetadata());
} else {
fireArpRespRecvdNotification(interfaceName, srcInetAddr, srcMac, tableId, metadata.getMetadata(), dstInetAddr, dstMac);
}
if (macAddrs.get(srcInetAddr.getHostAddress()) != null) {
threadPool.execute(new MacResponderTask(arp));
}
} catch (PacketException | UnknownHostException | InterruptedException | ExecutionException e) {
LOG.trace("Failed to decode packet", e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method stateSynchronizationAchieved.
/**
* Indicate that the peer has completed state synchronization.
*
* @param ctx Message context
*/
protected final synchronized void stateSynchronizationAchieved(final MessageContext ctx) {
if (this.synced.getAndSet(true)) {
LOG.debug("State synchronization achieved while synchronizing, not updating state");
return;
}
if (this.triggeredResyncInProcess) {
this.triggeredResyncInProcess = false;
}
updatePccNode(ctx, new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).build());
// The node has completed synchronization, cleanup metadata no longer reported back
this.nodeState.cleanupExcept(this.lsps.values());
LOG.debug("Session {} achieved synchronized state", this.session);
}
Aggregations