faucetsdn / ryu

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

How to add a CT action in the switch's flow table? #163

Closed TheMasterOfMagic closed 2 years ago

TheMasterOfMagic commented 2 years ago

I'm a new beginner learning ovs and ryu and I encountered a problem, which I still cannot solve after searching the official documents.

As far as I know, for example, to tell the switch to hand in any incoming ARP flows to the controller, I can do the below thing in python:

match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_ARP)
actions = [
    parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)
]
self.add_flow(datapath, 1, match, actions)

which are equivalent to the followings ovs-ofctl command.

ovs-ofctl add-flow <bridge> "priority=1,arp,actions=CONTROLLER:65535"

And my question is, how to tell the switch to do the specified CT action? or what are equivalent to the command below?

ovs-ofctl add-flow <bridge> "ip,nw_dst=10.0.0.1,actions=ct(commit,table=1,nat(dst=10.0.0.2))"

PS:

If there is any info that may help but not posted here, please feel free to let me know!