faucetsdn / ryu

Ryu component-based software defined networking framework
https://ryu-sdn.org
Apache License 2.0
1.51k stars 1.16k forks source link

Add a flow entry together with table-miss when starting the Ryu controller! #116

Closed chitsukhin closed 4 years ago

chitsukhin commented 4 years ago

Hello! everyone advise me plz.... I wanna to add flow entry together with table miss entry in every switch in the topology when starting the ryu controller. the flow entry that i want to added is

match = parser.OFPMatch(in_port=in_port, eth_dst=('33:33:00:00:00:fb')) actions = drop

I edit the code to add a flow in simple-switch_13.py

_@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) def switch_features_handler(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser

    # install the table-miss flow entry.
    match = parser.OFPMatch()
    matchmulti = parser.OFPMatch(in_port=in_port, eth_dst=('33:33:00:00:00:fb'))
    actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
                                      ofproto.OFPCML_NO_BUFFER)]
    actionsmulti = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]        
    self.add_flow(datapath, 0, match, actions)
    self.add_flow(datapath, 0, matchmulti, actionsmulti)_

/home/chitsu/Pictures/1.jpg

but It's not okay the code. plz, give me the correct code. I'm poor in coding.

chitsukhin commented 4 years ago

I can solve the error! _install the table-miss flow entry. match = parser.OFPMatch() matchmulti = parser.OFPMatch(eth_type=0x0800, eth_dst=('33:33:00:00:00:fb')) actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)] actionsmulti = ""
self.add_flow(datapath, 0, match, actions) self.addflow(datapath, 1, matchmulti, actionsmulti)