1
votes

I am looking to create a match rule for the OpenFlow switch, with Python-RYU controller. The rule should match any non-tcp packet (ip protocol 6).

As I know, the match rule for tcp connection is:

match = parser.OFPMatch(in_port=in_port, eth_dst=dst, ip_proto=6) self.add_flow(datapath, 1, match, actions)

I need to complement rule. Thanks

1

1 Answers

2
votes

You could a create rule with higher priority for TCP packets and another one with lower priority for all packets. That way all* TCP packets will match the first rule and all* non-TCP packets will match the second one.

(*) All that match in_port and eth_dst, as well

The only drawback is that you need to know what to do with TCP packets. An idea is to send them to controller (ofproto.OFPP_CONTROLLER).

tcp_match = parser.OFPMatch(in_port=in_port, eth_dst=dst, ip_proto=6)
self.add_flow(datapath, 2, tcp_match, tcp_actions)
nontcp_match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
self.add_flow(datapath, 1, nontcp_match, nontcp_actions)

EDIT:
It seems that you need to add eth_type=0x0800 to the match as well for it to work.