ignore lldp packet to avoid wrong links

Signed-off-by: Takeshi <a86487817@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Takeshi 2015-07-10 10:14:22 +08:00 committed by FUJITA Tomonori
parent 7d37e33b5b
commit b5c4b9ae51
4 changed files with 16 additions and 36 deletions

View File

@ -17,11 +17,8 @@
An OpenFlow 1.0 L2 learning switch implementation.
"""
import logging
import struct
from ryu.base import app_manager
from ryu.controller import mac_to_port
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
@ -29,7 +26,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.topology.switches import LLDPPacket
from ryu.lib.packet import ether_types
class SimpleSwitch(app_manager.RyuApp):
@ -55,19 +52,15 @@ class SimpleSwitch(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
try:
# ignore lldp packet
LLDPPacket.lldp_parse(msg.data)
return
except LLDPPacket.LLDPUnknownFormat:
pass
datapath = msg.datapath
ofproto = datapath.ofproto
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src

View File

@ -13,9 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import struct
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
@ -23,7 +20,7 @@ from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_2
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.topology.switches import LLDPPacket
from ryu.lib.packet import ether_types
class SimpleSwitch12(app_manager.RyuApp):
@ -53,12 +50,6 @@ class SimpleSwitch12(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
try:
# ignore lldp packet
LLDPPacket.lldp_parse(msg.data)
return
except LLDPPacket.LLDPUnknownFormat:
pass
datapath = msg.datapath
ofproto = datapath.ofproto
in_port = msg.match['in_port']
@ -66,6 +57,9 @@ class SimpleSwitch12(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src

View File

@ -20,7 +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.topology.switches import LLDPPacket
from ryu.lib.packet import ether_types
class SimpleSwitch13(app_manager.RyuApp):
@ -71,13 +71,6 @@ class SimpleSwitch13(app_manager.RyuApp):
self.logger.debug("packet truncated: only %s of %s bytes",
ev.msg.msg_len, ev.msg.total_len)
msg = ev.msg
try:
# ignore lldp packet
LLDPPacket.lldp_parse(msg.data)
return
except LLDPPacket.LLDPUnknownFormat:
pass
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
@ -86,6 +79,9 @@ class SimpleSwitch13(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src

View File

@ -20,7 +20,7 @@ from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_4
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.topology.switches import LLDPPacket
from ryu.lib.packet import ether_types
class SimpleSwitch14(app_manager.RyuApp):
@ -62,12 +62,6 @@ class SimpleSwitch14(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
try:
# ignore lldp packet
LLDPPacket.lldp_parse(msg.data)
return
except LLDPPacket.LLDPUnknownFormat:
pass
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
@ -76,6 +70,9 @@ class SimpleSwitch14(app_manager.RyuApp):
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src