0
votes

i'm trying to implement a method that blocks a specific flow and consequently drops packets. I pass to it the datapath, the source ip and the destination ip. The app detects the flow, but the flow continues to work, the source sends data, and the dest host receives it. What am I doing wrong?

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)

Thanks!

1

1 Answers

0
votes

Maybe you should do this:

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

The command you gave is to delete the flow, and you want to add it to the switch, isn't it?

Hope it helps!