From 086bf44986ce82e9afbf1504c0a0c76bfbb0fd5a Mon Sep 17 00:00:00 2001
From: Srini Seetharaman <srini.seetharaman@gmail.com>
Date: Wed, 25 Jun 2014 21:35:13 -0700
Subject: [PATCH] Updating packet_in handler in simple_switch and
 simple_switch_13 to ignore the LLDP packets. This resolves potential problems
 with running switch and topology discovery together.

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
---
 ryu/app/simple_switch.py    | 3 +++
 ryu/app/simple_switch_13.py | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py
index ffa8009..0300a78 100644
--- a/ryu/app/simple_switch.py
+++ b/ryu/app/simple_switch.py
@@ -29,6 +29,7 @@ from ryu.ofproto import ofproto_v1_0
 from ryu.lib.mac import haddr_to_bin
 from ryu.lib.packet import packet
 from ryu.lib.packet import ethernet
+from ryu.ofproto import ether
 
 
 class SimpleSwitch(app_manager.RyuApp):
@@ -62,6 +63,8 @@ class SimpleSwitch(app_manager.RyuApp):
 
         dst = eth.dst
         src = eth.src
+        if eth.ethertype == ether.ETH_TYPE_LLDP:
+            return
 
         dpid = datapath.id
         self.mac_to_port.setdefault(dpid, {})
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 47cf0a7..6ea0d41 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -20,6 +20,7 @@ from ryu.controller.handler import set_ev_cls
 from ryu.ofproto import ofproto_v1_3
 from ryu.lib.packet import packet
 from ryu.lib.packet import ethernet
+from ryu.ofproto import ether
 
 
 class SimpleSwitch13(app_manager.RyuApp):
@@ -71,6 +72,8 @@ class SimpleSwitch13(app_manager.RyuApp):
 
         dst = eth.dst
         src = eth.src
+        if eth.ethertype == ether.ETH_TYPE_LLDP:
+            return
 
         dpid = datapath.id
         self.mac_to_port.setdefault(dpid, {})
-- 
1.9.1

