2020-03-04 23:11:08 +01:00
|
|
|
package dsnet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/vishvananda/netlink"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Down() {
|
|
|
|
conf := MustLoadDsnetConfig()
|
|
|
|
DelLink(conf)
|
2020-11-18 23:37:32 +01:00
|
|
|
RunPostDown(conf)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RunPostDown(conf *DsnetConfig) {
|
|
|
|
ShellOut(conf.PostDown, "PostDown")
|
2020-03-04 23:11:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|