https://github.com/xgfone/go-ovs
A simple OVS flow executor.
https://github.com/xgfone/go-ovs
openvswitch ovs ovs-ofctl ovs-vsctl
Last synced: 7 months ago
JSON representation
A simple OVS flow executor.
- Host: GitHub
- URL: https://github.com/xgfone/go-ovs
- Owner: xgfone
- License: apache-2.0
- Created: 2020-09-22T13:02:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-23T01:42:10.000Z (almost 2 years ago)
- Last Synced: 2025-01-31T08:43:48.815Z (9 months ago)
- Topics: openvswitch, ovs, ovs-ofctl, ovs-vsctl
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OVS [](https://travis-ci.com/github/xgfone/go-ovs) [](https://pkg.go.dev/github.com/xgfone/go-ovs) [](https://raw.githubusercontent.com/xgfone/go-ovs/master/LICENSE)
A simple OVS flow executor supporting `Go1.18+`.
## Example
```go
package mainimport (
"context""github.com/xgfone/go-exec"
"github.com/xgfone/go-ovs"
)func main() {
initBridge("br-ovs")
initFlows("br-ovs")
}func must(err error) {
if err != nil {
panic(err)
}
}func initBridge(bridge string) {
must(exec.Execute(context.Background(),
"ovs-vsctl", "--may-exist", "add-br", bridge,
"--", "set-fail-mode", bridge, "secure",
))must(exec.Execute(context.Background(),
"ip", "link", "set", bridge, "up",
))
}func initFlows(bridge string) {
// Table 0
ovs.MustAddFlow(bridge, "table=0,in_port=1,actions=goto_table:1")
ovs.MustAddFlow(bridge, "table=0,in_port=2,actions=goto_table:2")
ovs.MustAddFlow(bridge, "table=0,in_port=3,actions=goto_table:3")
ovs.MustAddFlow(bridge, "table=0,in_port=4,actions=goto_table:4")
ovs.MustAddFlow(bridge, "table=0,priority=0,actions=drop")// TODO ...
}
```