Hello,

In testing this I found a bug with the way I was unpacking the packet
from the parser. I will submit a follow up patch.

Thanks,

/Evan

On Thu, May 19, 2016 at 5:16 PM,  <[email protected]> wrote:
> From: Evan Gray <[email protected]>
>
> 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 <[email protected]>
> ---
>  ryu/topology/switches.py | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py
> index 333407a..b463c56 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
> @@ -832,11 +832,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
> @@ -867,19 +866,19 @@ 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]
> -            self.hosts.update_ip(host, ip_v4=arp_pkt.src_ip)
> +            pkt = pkt_type.parser(pkt_data)
> +            self.hosts.update_ip(host, ip_v4=pkt.src_ip)
>
>          # ipv4 packet, update ipv4 address
>          elif eth.ethertype == ether_types.ETH_TYPE_IP:
> -            ipv4_pkt = pkt.get_protocols(ipv4.ipv4)[0]
> -            self.hosts.update_ip(host, ip_v4=ipv4_pkt.src)
> +            pkt = pkt_type.parser(pkt_data)
> +            self.hosts.update_ip(host, ip_v4=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]
> -            self.hosts.update_ip(host, ip_v6=ipv6_pkt.src)
> +            pkt = pkt_type.parser(pkt_data)
> +            self.hosts.update_ip(host, ip_v6=pkt.src)
>
>      def send_lldp_packet(self, port):
>          try:
> --
> 2.5.5

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to