BUG-3576 Resubmit - Flows should be installed only for unicast 62/23762/2
authorAnton Ivanov <aivanov@brocade.com>
Mon, 6 Jul 2015 07:32:29 +0000 (08:32 +0100)
committerAnton Ivanov <aivanov@brocade.com>
Mon, 7 Sep 2015 15:08:14 +0000 (15:08 +0000)
Macs should be checked for non-unicast not just for broadcast when
considered for flow creation (or learning).

Change-Id: I25a8ac5be86b41b73a9fa157b8b6158b71be3dd7
Signed-off-by: Anton Ivanov <aivanov@brocade.com>
l2switch-main/implementation/src/main/java/org/opendaylight/l2switch/flow/ReactiveFlowWriter.java

index a72bb085126071d52380c830a98cb8266add5fd0..e118009bdaac12582cfd8ea699a24dc97c24fe9a 100644 (file)
@@ -25,13 +25,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.ethernet.rev140528.e
 public class ReactiveFlowWriter implements ArpPacketListener {
   private InventoryReader inventoryReader;
   private FlowWriterService flowWriterService;
-  private final MacAddress MAC_TO_IGNORE = new MacAddress("ff:ff:ff:ff:ff:ff");
 
   public ReactiveFlowWriter(InventoryReader inventoryReader, FlowWriterService flowWriterService) {
     this.inventoryReader = inventoryReader;
     this.flowWriterService = flowWriterService;
   }
 
+  /**
+   * Checks if a MAC should be considered for flow creation
+   *
+   * @param macToCheck MacAddress to consider
+   * @return true if a MacAddess is broadcast or multicast, false if
+   * the MacAddress is unicast (and thus legible for flow creation).
+   */
+
+  private boolean ignoreThisMac(MacAddress macToCheck) {
+    if (macToCheck == null) return true;
+    String [] octets = macToCheck.getValue().split(":");
+    short first_byte = Short.parseShort(octets[0]);
+    return ((first_byte & 1) == 1);
+  }
+
   @Override
   public void onArpPacketReceived(ArpPacketReceived packetReceived) {
     if(packetReceived == null || packetReceived.getPacketChain() == null) {
@@ -54,7 +68,7 @@ public class ReactiveFlowWriter implements ArpPacketListener {
       return;
     }
     MacAddress destMac = ethernetPacket.getDestinationMac();
-    if(!MAC_TO_IGNORE.equals(destMac)) {
+    if(!ignoreThisMac(destMac)) {
       writeFlows(rawPacket.getIngress(),
           ethernetPacket.getSourceMac(),
           ethernetPacket.getDestinationMac());