0

我正在尝试实现一种阻止特定流并因此丢弃数据包的方法。我将数据路径、源 ip 和目标 ip 传递给它。应用程序检测到流,但流继续工作,源发送数据,目标主机接收。我究竟做错了什么?

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)

谢谢!

4

1 回答 1

0

也许你应该这样做:

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

你给的命令是删除流,你想把它添加到交换机,不是吗?

希望能帮助到你!

于 2017-11-21T09:16:54.523 回答