RYU 如何扔掉一个符合要求的数据包

又遇到一个问题,使用OFPMatch匹配的某个数据包,但是怎么Drop掉?又不会了,翻到了下面的代码

参考网址:http://stackoverflow.com/questions/41023354/ryu-controller-drop-packet

def dropEthType(self,
                match_eth_type = 0x0800):
    parser = self.parser
    proto = self.proto
    match = parser.OFPMatch(eth_type = match_eth_type)
    instruction = [
        parser.OFPInstructionActions(proto.OFPIT_CLEAR_ACTIONS, [])
        ]
    msg = parser.OFPFlowMod(self.datapath,
                            table_id = OFDPA_FLOW_TABLE_ID_ACL_POLICY,
                            priority = 1,
                            command = proto.OFPFC_ADD,
                            match = match,
                            instructions = instruction
                            )
    self._log("dropEthType : %s" % str(msg))
    reply = api.send_msg(self.ryuapp, msg)
    if reply:
        raise Exception

 

posted @ 2017-05-20 20:07  WenYao.Huang  阅读(1034)  评论(0编辑  收藏  举报