* @return
*/
private void checkPerSourceMacRate(OFPacketIn pin) {
byte[] data = pin.getPacketData();
byte[] mac = Arrays.copyOfRange(data, 6, 12);
MACAddress srcMac = MACAddress.valueOf(mac);
short ethType = (short) (((data[12] & 0xff) << 8) + (data[13] & 0xff));
if (ethType != Ethernet.TYPE_LLDP && ethType != Ethernet.TYPE_BSN &&
macCache.update(srcMac.toLong())) {
// Check if we already pushed a flow in the last 5 seconds
if (macBlockedCache.update(srcMac.toLong())) {
return;
}
// write out drop flow per srcMac
int port = pin.getInPort();
SwitchPort swPort = new SwitchPort(getId(), port);
ForwardingBase.blockHost(floodlightProvider,
swPort, srcMac.toLong(), (short) 5,
AppCookie.makeCookie(OFSWITCH_APP_ID, 0));
floodlightProvider.addSwitchEvent(this.datapathId,
"SWITCH_PORT_BLOCKED_TEMPORARILY " +
"OFPort " + port + " mac " + srcMac, false);
log.info("Excessive packet in from {} on {}, block host for 5 sec",
srcMac.toString(), swPort);
}
}