2017-07-10 95 views
0

我试图实现一种方法,阻止特定的流量,从而丢弃数据包。我传递给它数据路径,源IP和目标IP。应用程序检测流程,但流程继续工作,源发送数据,并且dest主机接收数据。我究竟做错了什么?块流/丢包ryu控制器

def drop_flow(self, datapath, ip_src, ip_dst): 
    ofproto = datapath.ofproto 
    parser = datapath.ofproto_parser 

    match = parser.OFPMatch(ipv4_src=ip_src, 
          ipv4_dst=ip_dst) 

    inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, [])] 
    mod = parser.OFPFlowMod(datapath=datapath, 
          command=ofproto.OFPFC_DELETE, 
          out_port=ofproto.OFPP_ANY, 
          out_group=ofproto.OFPG_ANY, 
          match=match, instructions=inst) 

    print "deleting flow entries in the table " 
    datapath.send_msg(mod) 

谢谢!

回答

0

也许你应该这样做:

mod = parser.OFPFlowMod(datapath=datapath, 
         out_port=ofproto.OFPP_ANY, 
         out_group=ofproto.OFPG_ANY, 
         match=match, instructions=inst) 

你给的命令是删除流程,并希望将其添加到交换机上,不是吗?

希望它有帮助!