Hi All,

I am trying to push a deny flow based on certain conditions when a packet
in event occurs. However I am getting an error message on the controller
when I am pushing the flows onto the switch as the switch is rejecting the
flow. I am not able to decode the error message and wanted to know if there
is any link which suggests how to understand an error message. I have
attached the script which I am trying to run and the error message is as
below:

EVENT ofp_event->SwitchEventApp EventOFPPacketIn
EVENT ofp_event->SwitchEventApp EventOFPErrorMsg
error msg ev version: 0x4 msg_type 0x1 xid 0xb7a5f401
OFPErrorMsg(code=9,data='\x04\x0e\x00h\xb7\xa5\xf4\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\n\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00.\x80\x00\x00\x04\x00\x00\x13\xe9\x80\x00\n\x02\x04\x01\x00L\xb7\xa5\xf4\x02',type=4)
type 0x4 code 0x9 0x4 0xe 0x0 0x68 0xb7 0xa5 0xf4 0x1 0x0 0x0 0x0 0x0 0x0
0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x2 0x0 0x0 0x0 0x0 0x0 0x0 0xa
0xff 0xff 0xff 0xff 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1
0x0 0x2e 0x80 0x0 0x0 0x4 0x0 0x0 0x13 0xe9 0x80 0x0 0xa 0x2 0x4 0x1 0x0
0x4c 0xb7 0xa5 0xf4 0x2
EVENT ofp_event->SwitchEventApp EventOFPErrorMsg

Any help will be deeply appreciated!

Regards,

Vinay Pai B.H.

-- 
Vinay Pai B.H.
Grad Student - Computer Science
Viterbi School of Engineering
University of Southern California
Los Angeles, CA, USA
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER, 
HANDSHAKE_DISPATCHER
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.lib.packet import arp 
from ryu.lib.packet import ipv4
from ryu.lib.packet import udp
from ryu.topology import switches
from ryu.topology.event import EventSwitchEnter, EventSwitchLeave
import time
from ryu import utils
server_ip = '10.10.10.10'
server_proto = 17
server_port =63 
table_id = 2
priority = 10

class SwitchEventApp(app_manager.RyuApp):
  _CONTEXTS = {
    'switches': switches.Switches,
  }

  @set_ev_cls(EventSwitchEnter)
  def _ev_switch_enter_handler(self, ev):
    print('enter: %s' % ev)
  

  @set_ev_cls(EventSwitchLeave)
  def _ev__switch_leave_handler(self, ev):
    print('leave: %s' % ev)

  @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
  def packet_in_handler(self, ev):
    print "Packet In!!"
    msg = ev.msg
    my_datapath = ev.msg.datapath
    ofproto = my_datapath.ofproto
    parser = my_datapath.ofproto_parser
    datapath = msg.datapath
    port = msg.match['in_port']
    print 'inport port {0}'.format(port)
    pkt = packet.Packet(data=msg.data)
    #self.logger.info("packet-in %s" % (pkt,))
    pkt_ethernet = pkt.get_protocol(ethernet.ethernet)
    if not pkt_ethernet:
      print "Packet is not ethernet"
      return
    pkt_arp = pkt.get_protocol(arp.arp)
    if pkt_arp:
      print "Packet is arp"
      self._handle_arp(datapath, port, pkt_ethernet, pkt_arp, parser, 
my_datapath)
      return
    pkt_ipv4 = pkt.get_protocol(ipv4.ipv4)
    pkt_udp = pkt.get_protocol(udp.udp)
    pkt_dst_port = pkt_udp.dst_port
    pkt_dst_ip = pkt_ipv4.dst
    pkt_proto = pkt_ipv4.proto
    if (pkt_udp and pkt_dst_ip == server_ip and pkt_proto == server_proto and 
pkt_dst_port == server_port):
      self._handle_udp(datapath,port,pkt_udp,pkt_ipv4,parser,my_datapath)
      return

  def _handle_udp(self, datapath, port, pkt_udp, pkt_ipv4, parser, my_datapath):
    ofproto = my_datapath.ofproto
    match = parser.OFPMatch(in_port = port, eth_type = 0x800, ipv4_src = 
pkt_ipv4.src, ipv4_dst = server_ip, udp_src = pkt_udp.src_port, udp_dst = 
pkt_udp.dst_port)
    actions = []
    self.add_flow(my_datapath, priority, match, table_id,actions)


  def _handle_arp(self, datapath, port, pkt_ethernet, pkt_arp, parser, 
my_datapath):
    match = parser.OFPMatch(in_port = port, eth_src = self.hw_addr, ipv4_src = 
self.ip_addr)
    actions = [parser.OFPActionOutput(ofp.OFPP_FLOOD,0)]
    self.add_flow(my_datapath, priority, match, table_id,actions)


  def add_flow(self, datapath, priority, match, table_id, actions ):
    ofproto = datapath.ofproto
    parser = datapath.ofproto_parser
    inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
    mod = parser.OFPFlowMod(datapath=datapath, table_id=table_id, 
                         priority=priority, match = match, instructions=inst)
    print 'Flow Sent'
    datapath.send_msg(mod)
    priority +=1

  
@set_ev_cls(ofp_event.EventOFPErrorMsg,[HANDSHAKE_DISPATCHER,CONFIG_DISPATCHER,MAIN_DISPATCHER])
  def error_msg_handler(self, ev):
    msg = ev.msg
    self.logger.debug('OFPErrorMsg received: type=0x%02x code=0x%02x '
                        'message=%s',
                         msg.type, msg.code, utils.hex_array(msg.data))
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to