Hi everyone,
I'm really new to SDN and Ryu and I have some confusion about what's
happening in my routing. I have my code below As you can see in Line 422,
there is a checker if the packetin handler was called in the core switch.
My core switch is actually also connected to 2 other switches. From Lines
423-427 I forcefully set the out_port so only one of the two out_ports. So
what I expect (and actually want) is that all ipv4 packets are sent to the
first switch. And I'm not expecting (nor wanting) any ipv4 packets sent to
the other switch. But the problem is, both switches are receiving ipv4
packets instead of only one of them. Do you have any suggestions on how to
fix this or at least an explanation of why this is happening?
372 @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
373 def packet_in_handler(self, ev):
374
375 msg = ev.msg
376 dp = msg.datapath
377 ofp = dp.ofproto
378 ofp_parser = dp.ofproto_parser
379 in_port = msg.match['in_port']
380
381 pkt = packet.Packet(msg.data)
382 arp_pkt = pkt.get_protocol(arp.arp)
383 eth_pkt = pkt.get_protocols(ethernet.ethernet)[0]
384
385 out_port = ofp.OFPP_ALL
386
387 match = ofp_parser.OFPMatch(eth_type=0x0806)
388 actions = [ofp_parser.OFPActionOutput(ofp.OFPP_ALL)]
389 inst =
[ofp_parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, actions)]
390 mod = ofp_parser.OFPFlowMod(datapath=dp,
buffer_id=msg.buffer_id, priority=1,
391 match=match, instructions=inst)
392
393 dst = eth_pkt.dst
394 src = eth_pkt.src
395
396 if eth_pkt.ethertype == ether_types.ETH_TYPE_LLDP:
397 return
398
399 if eth_pkt.ethertype == ether_types.ETH_TYPE_IP:
400 ipv4_pkt = pkt.get_protocol(ipv4.ipv4)
401 if ipv4_pkt.dst not in self.mac_ip:
402 self.mac_ip.setdefault(str(ipv4_pkt.dst))
403 self.mac_ip[ipv4_pkt.dst] = [dst, ipv4_pkt.dst]
404 if dp.id not in self.dstBucket:
405 self.dstBucket.setdefault(dp.id, {})
406 self._dst_counter(dp.id, ipv4_pkt)
407
408 if self.dstStats:
409 stats = self.dstStats
410
411 # packet arrives client leaf switches
412 for switchEntry in self.switches_list:
413 if int(switchEntry.dpid[len(switchEntry.dpid)-1]) ==
dp.id:
414 sw = switchEntry
415
416 if sw.type == "client-leaf":
417 out_port = sw.core_port
418 actions = [ofp_parser.OFPActionOutput(out_port)]
419 match = ofp_parser.OFPMatch(in_port=in_port,
eth_type=0x0800)
420 mod = ofp_parser.OFPFlowMod(datapath=dp,
buffer_id=msg.buffer_id, priority=10,
421 match=match,
instructions=inst)
422 elif sw.type == "core":
423 port = sw.server_port[0]
424 port = int(port.split(":")[1])
425 out_port = port
426 print ("Core out port: {}".format(out_port))
427 actions = [ofp_parser.OFPActionOutput(out_port)]
428 match = ofp_parser.OFPMatch(in_port=in_port,
eth_type=0x0800)
429 mod = ofp_parser.OFPFlowMod(datapath=dp,
buffer_id=msg.buffer_id, priority=10,
430 match=match,
instructions=inst)
431 out = ofp_parser.OFPPacketOut(datapath=dp,
buffer_id=msg.buffer_id, in_port=in_port,
432 actions=actions,
data=msg.data)
433 dp.send_msg(mod)
434 return
435
436 dp.send_msg(mod)
Thanks,
Josiah Regencia
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel