kytos-ng / sdntrace_cp

MIT License
1 stars 6 forks source link

Support instruction type goto_table #108

Closed gretelliz closed 11 months ago

gretelliz commented 1 year ago

Closes #104

Summary

This is to support goto_table in sdntrace_cp.

Local test

Send to s1:

{
    "force": false,
    "flows": [
        {
            "match": {
                "in_port": 1
            },
            "instructions": [
                {
                    "instruction_type": "goto_table",
                    "table_id": 1
                }
            ]
        },
        {
            "table_id": 1,
            "match": {
                "in_port": 1
            },
            "instructions": [
                {
                    "instruction_type": "apply_actions",
                    "actions": [
                        {
                            "action_type": "output",
                            "port": 3
                        }
                    ]
                }
            ]
        }
    ]
}

Send to s2:

{
    "force": false,
    "flows": [
        {
            "match": {
                "in_port": 3
            },
            "instructions": [
                {
                    "instruction_type": "goto_table",
                    "table_id": 2
                }
            ]
        },
        {
            "table_id": 2,
            "match": {
                "in_port": 3
            },
            "instructions": [
                {
                    "instruction_type": "apply_actions",
                    "actions": [
                        {
                            "action_type": "output",
                            "port": 2
                        }
                    ]
                }
            ]
        }
    ]
}

Topology:

h11 h11-eth0:s1-eth1
h12 h12-eth0:s1-eth2
h21 h21-eth0:s2-eth1
h22 h22-eth0:s2-eth2
s1 lo:  s1-eth1:h11-eth0 s1-eth2:h12-eth0 s1-eth3:s2-eth3
s2 lo:  s2-eth1:h21-eth0 s2-eth2:h22-eth0 s2-eth3:s1-eth3

Result:

sudo ovs-ofctl -O OpenFlow13 dump-flows s1
 cookie=0xab00000000000001, duration=110.318s, table=0, n_packets=37, n_bytes=1554, send_flow_rem priority=50000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535
 cookie=0xac00000000000001, duration=108.928s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=50000,dl_src=ee:ee:ee:ee:ee:02 actions=CONTROLLER:65535
 cookie=0x0, duration=32.293s, table=0, n_packets=0, n_bytes=0, send_flow_rem in_port="s1-eth1" actions=goto_table:1
 cookie=0x0, duration=110.273s, table=0, n_packets=41, n_bytes=4243, send_flow_rem priority=0 actions=CONTROLLER:65535
 cookie=0x0, duration=32.290s, table=1, n_packets=0, n_bytes=0, send_flow_rem in_port="s1-eth1" actions=output:"s1-eth3"
sudo ovs-ofctl -O OpenFlow13 dump-flows s2
 cookie=0xab00000000000002, duration=119.369s, table=0, n_packets=40, n_bytes=1680, send_flow_rem priority=50000,dl_vlan=3799,dl_type=0x88cc actions=CONTROLLER:65535
 cookie=0xac00000000000002, duration=117.923s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=50000,dl_src=ee:ee:ee:ee:ee:01 actions=CONTROLLER:65535
 cookie=0x0, duration=16.511s, table=0, n_packets=1, n_bytes=70, send_flow_rem in_port="s2-eth3" actions=goto_table:2
 cookie=0x0, duration=119.354s, table=0, n_packets=37, n_bytes=3724, send_flow_rem priority=0 actions=CONTROLLER:65535
 cookie=0x0, duration=16.499s, table=2, n_packets=1, n_bytes=70, send_flow_rem in_port="s2-eth3" actions=output:"s2-eth2"
/sdntrace_cp/v1/trace
{
  "trace": {
    "switch": {
      "dpid": "00:00:00:00:00:00:00:01",
      "in_port": 1
    }
  }
}
{
    "result": [
        {
            "dpid": "00:00:00:00:00:00:00:01",
            "port": 1,
            "time": "2023-09-11 15:27:42.440712",
            "type": "starting"
        },
        {
            "dpid": "00:00:00:00:00:00:00:02",
            "port": 3,
            "time": "2023-09-11 15:27:42.440806",
            "type": "last",
            "out": {
                "port": 2
            }
        }
    ]
}

End-to-end test

See PR

gretelliz commented 11 months ago

@viniarck, Thank you. I pushed some updates according to your suggestions.

viniarck commented 11 months ago

Let's ship it. Congrats, @gretelliz. Feel free to merge once e2e is passing as you mentioned on the weekly meeting.