Skip to content

Commit 5bcad1d

Browse files
committed
handle: move lookupByDump from HandleOptions to Handle
This is not really a configuration option, but rather an internal cache for remembering the lookup fallback behaviour. Signed-off-by: Timo Beckers <timo@incline.eu>
1 parent d6ba755 commit 5bcad1d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

handle_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
var pkgHandle = &Handle{}
1414

1515
type HandleOptions struct {
16-
lookupByDump bool
1716
collectVFInfo bool
1817
retryInterrupted bool
1918
}
@@ -25,6 +24,8 @@ type HandleOptions struct {
2524
type Handle struct {
2625
sockets map[int]*nl.SocketHandle
2726
options HandleOptions
27+
28+
lookupByDump bool
2829
}
2930

3031
// DisableVFInfoCollection configures the handle to skip VF information fetching

link_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ func LinkByName(name string) (Link, error) {
20202020
// filtering a dump of all link names. In this case, if the returned error is
20212021
// [ErrDumpInterrupted] the result may be missing or outdated.
20222022
func (h *Handle) LinkByName(name string) (Link, error) {
2023-
if h.options.lookupByDump {
2023+
if h.lookupByDump {
20242024
return h.linkByNameDump(name)
20252025
}
20262026

@@ -2044,7 +2044,7 @@ func (h *Handle) LinkByName(name string) (Link, error) {
20442044
if err == unix.EINVAL {
20452045
// older kernels don't support looking up via IFLA_IFNAME
20462046
// so fall back to dumping all links
2047-
h.options.lookupByDump = true
2047+
h.lookupByDump = true
20482048
return h.linkByNameDump(name)
20492049
}
20502050

@@ -2068,7 +2068,7 @@ func LinkByAlias(alias string) (Link, error) {
20682068
// filtering a dump of all link names. In this case, if the returned error is
20692069
// [ErrDumpInterrupted] the result may be missing or outdated.
20702070
func (h *Handle) LinkByAlias(alias string) (Link, error) {
2071-
if h.options.lookupByDump {
2071+
if h.lookupByDump {
20722072
return h.linkByAliasDump(alias)
20732073
}
20742074

@@ -2089,7 +2089,7 @@ func (h *Handle) LinkByAlias(alias string) (Link, error) {
20892089
if err == unix.EINVAL {
20902090
// older kernels don't support looking up via IFLA_IFALIAS
20912091
// so fall back to dumping all links
2092-
h.options.lookupByDump = true
2092+
h.lookupByDump = true
20932093
return h.linkByAliasDump(alias)
20942094
}
20952095

0 commit comments

Comments
 (0)