alshabib

pkt glitch FIXED... ovs was not sending a bufferid

Change-Id: Id6fedf7c6ed8fbcfefb7308b0ee442e614e5e3af
package org.onlab.onos.fwd;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Set;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -27,10 +31,6 @@ import org.onlab.onos.net.topology.TopologyService;
import org.onlab.packet.Ethernet;
import org.slf4j.Logger;
import java.util.Set;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Sample reactive forwarding application.
*/
......@@ -115,7 +115,7 @@ public class ReactiveForwarding {
if (path == null) {
log.warn("Doh... don't know where to go... {} -> {} received on {}",
ethPkt.getSourceMAC(), ethPkt.getDestinationMAC(),
pkt.receivedFrom().port());
pkt.receivedFrom());
flood(context);
return;
}
......
......@@ -25,9 +25,12 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
private final OFPacketIn pktin;
private OFPacketOut pktout = null;
private final boolean isBuffered;
private DefaultOpenFlowPacketContext(OpenFlowSwitch s, OFPacketIn pkt) {
this.sw = s;
this.pktin = pkt;
this.isBuffered = pktin.getBufferId() != OFBufferId.NO_BUFFER;
}
@Override
......@@ -117,4 +120,9 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
return !free.get();
}
@Override
public boolean isBuffered() {
return isBuffered;
}
}
......
......@@ -67,4 +67,10 @@ public interface OpenFlowPacketContext {
* @return the port
*/
public Integer inPort();
/**
* Indicates that this packet is buffered at the switch.
* @return buffer indication
*/
boolean isBuffered();
}
......
......@@ -225,5 +225,10 @@ public class OpenFlowHostProviderTest {
return false;
}
@Override
public boolean isBuffered() {
return false;
}
}
}
......
......@@ -32,18 +32,19 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
public void send() {
if (!this.block()) {
if (outPacket() == null) {
sendBufferedPacket();
sendPacket(null);
} else {
Ethernet eth = new Ethernet();
eth.deserialize(outPacket().data().array(), 0,
outPacket().data().array().length);
ofPktCtx.build(eth, OFPort.FLOOD);
sendPacket(eth);
}
}
}
private void sendBufferedPacket() {
private void sendPacket(Ethernet eth) {
List<Instruction> ins = treatmentBuilder().build().instructions();
OFPort p = null;
//TODO: support arbitrary list of treatments must be supported in ofPacketContext
......@@ -53,10 +54,13 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
break; //for now...
}
}
if (eth == null) {
ofPktCtx.build(p);
} else {
ofPktCtx.build(eth, p);
}
ofPktCtx.send();
}
private OFPort buildPort(PortNumber port) {
return OFPort.of((int) port.toLong());
}
......
package org.onlab.onos.provider.of.packet.impl;
import static org.onlab.onos.openflow.controller.RoleState.SLAVE;
import static org.slf4j.LoggerFactory.getLogger;
import java.nio.ByteBuffer;
......@@ -16,6 +17,7 @@ import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.Instruction;
import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction;
import org.onlab.onos.net.packet.DefaultInboundPacket;
import org.onlab.onos.net.packet.DefaultOutboundPacket;
import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.net.packet.PacketProvider;
import org.onlab.onos.net.packet.PacketProviderRegistry;
......@@ -36,8 +38,6 @@ import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
import static org.onlab.onos.openflow.controller.RoleState.*;
/**
* Provider which uses an OpenFlow controller to detect network
......@@ -152,9 +152,15 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())),
pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()));
DefaultOutboundPacket outPkt = null;
if (!pktCtx.isBuffered()) {
outPkt = new DefaultOutboundPacket(id, null,
ByteBuffer.wrap(pktCtx.unparsed()));
}
OpenFlowCorePacketContext corePktCtx =
new OpenFlowCorePacketContext(System.currentTimeMillis(),
inPkt, null, pktCtx.isHandled(), pktCtx);
inPkt, outPkt, pktCtx.isHandled(), pktCtx);
providerService.processPacket(corePktCtx);
}
......