Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for missing TUN/TAP parameters from Linux kernel #1066

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions link.go
Original file line number Diff line number Diff line change
@@ -348,13 +348,14 @@ type TuntapFlag uint16
// Tuntap links created via /dev/tun/tap, but can be destroyed via netlink
type Tuntap struct {
LinkAttrs
Mode TuntapMode
Flags TuntapFlag
NonPersist bool
Queues int
Fds []*os.File
Owner uint32
Group uint32
Mode TuntapMode
Flags TuntapFlag
NonPersist bool
Queues int
DisabledQueues int
Fds []*os.File
Owner uint32
Group uint32
}

func (tuntap *Tuntap) Attrs() *LinkAttrs {
16 changes: 16 additions & 0 deletions link_linux.go
Original file line number Diff line number Diff line change
@@ -3903,11 +3903,27 @@ func parseTuntapData(link Link, data []syscall.NetlinkRouteAttr) {
tuntap.Group = native.Uint32(datum.Value)
case nl.IFLA_TUN_TYPE:
tuntap.Mode = TuntapMode(uint8(datum.Value[0]))
case nl.IFLA_TUN_PI:
if datum.Value[0] == 0 {
tuntap.Flags |= TUNTAP_NO_PI
}
case nl.IFLA_TUN_VNET_HDR:
if datum.Value[0] == 1 {
tuntap.Flags |= TUNTAP_VNET_HDR
}
case nl.IFLA_TUN_PERSIST:
tuntap.NonPersist = false
if uint8(datum.Value[0]) == 0 {
tuntap.NonPersist = true
}
case nl.IFLA_TUN_MULTI_QUEUE:
if datum.Value[0] == 1 {
tuntap.Flags |= TUNTAP_MULTI_QUEUE
}
case nl.IFLA_TUN_NUM_QUEUES:
tuntap.Queues = int(native.Uint32(datum.Value))
case nl.IFLA_TUN_NUM_DISABLED_QUEUES:
tuntap.DisabledQueues = int(native.Uint32(datum.Value))
}
}
}