Skip to content
Snippets Groups Projects
Commit 002593c6 authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

pushPacket function updated to drop packets if the inport and outport are the same.

parent b06c72c1
No related branches found
No related tags found
No related merge requests found
...@@ -255,12 +255,33 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag ...@@ -255,12 +255,33 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
return match.clone(); return match.clone();
} }
/**
* This function will push a packet-out to a switch. The assumption here is that
* the packet-in was also generated from the same switch. Thus, if the input
* port of the packet-in and the outport are the same, the function will not
* push the packet-out.
* @param sw switch that generated the packet-in, and from which packet-out is sent
* @param match OFmatch
* @param pi packet-in
* @param outport output port
* @param cntx context of the packet
*/
public void pushPacket(IOFSwitch sw, OFMatch match, OFPacketIn pi, short outport, FloodlightContext cntx) { public void pushPacket(IOFSwitch sw, OFMatch match, OFPacketIn pi, short outport, FloodlightContext cntx) {
if (pi == null) { if (pi == null) {
return; return;
} }
// The assumption here is (sw) is the switch that generated the packet-in.
// If the input port is the same as output port, then the packet-out should
// be ignored.
if (pi.getInPort() == outport) {
if (log.isDebugEnabled()) {
log.debug("Attemping to do packet-out to the same interface as packet-in. Dropping packet. SrcSwitch={}, match = {}, pi={}", new Object[]{sw, match, pi});
return;
}
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("PacketOut srcSwitch={} match={} pi={}", new Object[] {sw, match, pi}); log.debug("PacketOut srcSwitch={} match={} pi={}", new Object[] {sw, match, pi});
} }
...@@ -278,7 +299,7 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag ...@@ -278,7 +299,7 @@ public abstract class ForwardingBase implements IOFMessageListener, IDeviceManag
// set buffer_id, in_port // set buffer_id, in_port
po.setBufferId(pi.getBufferId()); po.setBufferId(pi.getBufferId());
po.setInPort(pi.getInPort()); po.setInPort(pi.getInPort());
// set data - only if buffer_id == -1 // set data - only if buffer_id == -1
if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) { if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) {
byte[] packetData = pi.getPacketData(); byte[] packetData = pi.getPacketData();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment