summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEvan Gray <evanscottgray@gmail.com>2016-05-19 18:33:17 -0500
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-01 12:23:17 +0900
commit7d15368bf9c685e8e61dd6d0c4ceb2387f7220ca (patch)
treed36a24567ea95647f3733c3c0eef41bd7c162d07
parent2a2b2b176217f0e669856bc88b3c909ba782ef58 (diff)
topology: ignore cfm packets on packet in
This commit will allow the host_discovery_packet_in_handler to ignore invalid cfm packets. Ryu will fail to parse cfm packets with an interval of 0 -- We discovered this when one of our systems sent cfm packets with an interval of 0. Signed-off-by: Evan Gray <evanscottgray@gmail.com> Reviewed-by: Iwase Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/topology/switches.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py
index 3b05efe8..644a1fec 100644
--- a/ryu/topology/switches.py
+++ b/ryu/topology/switches.py
@@ -31,8 +31,8 @@ from ryu.lib.dpid import dpid_to_str, str_to_dpid
from ryu.lib.port_no import port_no_to_str
from ryu.lib.packet import packet, ethernet
from ryu.lib.packet import lldp, ether_types
-from ryu.lib.packet import arp, ipv4, ipv6
from ryu.ofproto.ether import ETH_TYPE_LLDP
+from ryu.ofproto.ether import ETH_TYPE_CFM
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import ofproto_v1_2
@@ -836,11 +836,10 @@ class Switches(app_manager.RyuApp):
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def host_discovery_packet_in_handler(self, ev):
msg = ev.msg
- pkt = packet.Packet(msg.data)
- eth = pkt.get_protocols(ethernet.ethernet)[0]
+ eth, pkt_type, pkt_data = ethernet.ethernet.parser(msg.data)
- # ignore lldp packet
- if eth.ethertype == ETH_TYPE_LLDP:
+ # ignore lldp and cfm packets
+ if eth.ethertype in (ETH_TYPE_LLDP, ETH_TYPE_CFM):
return
datapath = msg.datapath
@@ -871,18 +870,18 @@ class Switches(app_manager.RyuApp):
# arp packet, update ip address
if eth.ethertype == ether_types.ETH_TYPE_ARP:
- arp_pkt = pkt.get_protocols(arp.arp)[0]
+ arp_pkt, _, _ = pkt_type.parser(pkt_data)
self.hosts.update_ip(host, ip_v4=arp_pkt.src_ip)
# ipv4 packet, update ipv4 address
elif eth.ethertype == ether_types.ETH_TYPE_IP:
- ipv4_pkt = pkt.get_protocols(ipv4.ipv4)[0]
+ ipv4_pkt, _, _ = pkt_type.parser(pkt_data)
self.hosts.update_ip(host, ip_v4=ipv4_pkt.src)
# ipv6 packet, update ipv6 address
elif eth.ethertype == ether_types.ETH_TYPE_IPV6:
# TODO: need to handle NDP
- ipv6_pkt = pkt.get_protocols(ipv6.ipv6)[0]
+ ipv6_pkt, _, _ = pkt_type.parser(pkt_data)
self.hosts.update_ip(host, ip_v6=ipv6_pkt.src)
def send_lldp_packet(self, port):