On Wed, 15 Oct 2014 16:17:49 -0700 Shu Shen <[email protected]> wrote:
> Signed-off-by: Shu Shen <[email protected]> > --- > ryu/app/simple_switch_14.py | 101 > ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 101 insertions(+) > create mode 100644 ryu/app/simple_switch_14.py Applied, thanks! > + @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 table-miss flow entry > + # > + # We specify NO BUFFER to max_len of the output action due to > + # OVS bug. At this moment, if we specify a lesser number, e.g., > + # 128, OVS will send Packet-In with invalid buffer_id and > + # truncated packet data. In that case, we cannot output packets > + # correctly. OVS gurus, the above comment is still the case? > + match = parser.OFPMatch() > + actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, > + ofproto.OFPCML_NO_BUFFER)] > + self.add_flow(datapath, 0, match, actions) > + > + def add_flow(self, datapath, priority, match, actions): > + ofproto = datapath.ofproto > + parser = datapath.ofproto_parser > + > + inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, > + actions)] > + > + mod = parser.OFPFlowMod(datapath=datapath, priority=priority, > + match=match, instructions=inst) > + datapath.send_msg(mod) > + > + @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) > + def _packet_in_handler(self, ev): > + msg = ev.msg > + datapath = msg.datapath > + ofproto = datapath.ofproto > + parser = datapath.ofproto_parser > + in_port = msg.match['in_port'] > + > + pkt = packet.Packet(msg.data) > + eth = pkt.get_protocols(ethernet.ethernet)[0] > + > + dst = eth.dst > + src = eth.src > + > + dpid = datapath.id > + self.mac_to_port.setdefault(dpid, {}) > + > + self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port) > + > + # learn a mac address to avoid FLOOD next time. > + self.mac_to_port[dpid][src] = in_port > + > + if dst in self.mac_to_port[dpid]: > + out_port = self.mac_to_port[dpid][dst] > + else: > + out_port = ofproto.OFPP_FLOOD > + > + actions = [parser.OFPActionOutput(out_port)] > + > + # install a flow to avoid packet_in next time > + if out_port != ofproto.OFPP_FLOOD: > + match = parser.OFPMatch(in_port=in_port, eth_dst=dst) > + self.add_flow(datapath, 1, match, actions) > + > + data = None > + if msg.buffer_id == ofproto.OFP_NO_BUFFER: > + data = msg.data > + > + out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, > + in_port=in_port, actions=actions, > data=data) > + datapath.send_msg(out) > -- > 1.9.3 > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Ryu-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ryu-devel ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
