implement down
This commit is contained in:
parent
d9f197c06f
commit
c04eeac00f
@ -31,6 +31,7 @@ func main() {
|
|||||||
case "report":
|
case "report":
|
||||||
|
|
||||||
case "down":
|
case "down":
|
||||||
|
dsnet.Down()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
help()
|
help()
|
||||||
|
24
down.go
Normal file
24
down.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package dsnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vishvananda/netlink"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Down() {
|
||||||
|
conf := MustLoadDsnetConfig()
|
||||||
|
DelLink(conf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DelLink(conf *DsnetConfig) {
|
||||||
|
linkAttrs := netlink.NewLinkAttrs()
|
||||||
|
linkAttrs.Name = conf.InterfaceName
|
||||||
|
|
||||||
|
link := &netlink.GenericLink{
|
||||||
|
LinkAttrs: linkAttrs,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := netlink.LinkDel(link)
|
||||||
|
if err != nil {
|
||||||
|
ExitFail("Could not delete interface '%s' (%v)", conf.InterfaceName, err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user