mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-27 04:05:59 +08:00
Use package empty handle for pkg APIs (#117)
- Package methods only need an empty handle. Not a regular Handle with a couple of sockets creation/delete. Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:

committed by
Vish Ishaya

parent
e361359783
commit
f116a3048a
@@ -11,12 +11,7 @@ import (
|
||||
// RuleAdd adds a rule to the system.
|
||||
// Equivalent to: ip rule add
|
||||
func RuleAdd(rule *Rule) error {
|
||||
h, err := NewHandle()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer h.Delete()
|
||||
return h.RuleAdd(rule)
|
||||
return pkgHandle.RuleAdd(rule)
|
||||
}
|
||||
|
||||
// RuleAdd adds a rule to the system.
|
||||
@@ -29,12 +24,7 @@ func (h *Handle) RuleAdd(rule *Rule) error {
|
||||
// RuleDel deletes a rule from the system.
|
||||
// Equivalent to: ip rule del
|
||||
func RuleDel(rule *Rule) error {
|
||||
h, err := NewHandle()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer h.Delete()
|
||||
return h.RuleDel(rule)
|
||||
return pkgHandle.RuleDel(rule)
|
||||
}
|
||||
|
||||
// RuleDel deletes a rule from the system.
|
||||
@@ -150,12 +140,7 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
|
||||
// RuleList lists rules in the system.
|
||||
// Equivalent to: ip rule list
|
||||
func RuleList(family int) ([]Rule, error) {
|
||||
h, err := NewHandle()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer h.Delete()
|
||||
return h.RuleList(family)
|
||||
return pkgHandle.RuleList(family)
|
||||
}
|
||||
|
||||
// RuleList lists rules in the system.
|
||||
|
Reference in New Issue
Block a user