Skip to content

Commit 298a362

Browse files
vanytsvetkovaboch
authored andcommitted
tuntap: parse additional netlink attributes for flags and queues
Signed-off-by: Ivan Tsvetkov <[email protected]>
1 parent 7740709 commit 298a362

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

link.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,14 @@ type TuntapFlag uint16
348348
// Tuntap links created via /dev/tun/tap, but can be destroyed via netlink
349349
type Tuntap struct {
350350
LinkAttrs
351-
Mode TuntapMode
352-
Flags TuntapFlag
353-
NonPersist bool
354-
Queues int
355-
Fds []*os.File
356-
Owner uint32
357-
Group uint32
351+
Mode TuntapMode
352+
Flags TuntapFlag
353+
NonPersist bool
354+
Queues int
355+
DisabledQueues int
356+
Fds []*os.File
357+
Owner uint32
358+
Group uint32
358359
}
359360

360361
func (tuntap *Tuntap) Attrs() *LinkAttrs {

link_linux.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,11 +3903,27 @@ func parseTuntapData(link Link, data []syscall.NetlinkRouteAttr) {
39033903
tuntap.Group = native.Uint32(datum.Value)
39043904
case nl.IFLA_TUN_TYPE:
39053905
tuntap.Mode = TuntapMode(uint8(datum.Value[0]))
3906+
case nl.IFLA_TUN_PI:
3907+
if datum.Value[0] == 0 {
3908+
tuntap.Flags |= TUNTAP_NO_PI
3909+
}
3910+
case nl.IFLA_TUN_VNET_HDR:
3911+
if datum.Value[0] == 1 {
3912+
tuntap.Flags |= TUNTAP_VNET_HDR
3913+
}
39063914
case nl.IFLA_TUN_PERSIST:
39073915
tuntap.NonPersist = false
39083916
if uint8(datum.Value[0]) == 0 {
39093917
tuntap.NonPersist = true
39103918
}
3919+
case nl.IFLA_TUN_MULTI_QUEUE:
3920+
if datum.Value[0] == 1 {
3921+
tuntap.Flags |= TUNTAP_MULTI_QUEUE
3922+
}
3923+
case nl.IFLA_TUN_NUM_QUEUES:
3924+
tuntap.Queues = int(native.Uint32(datum.Value))
3925+
case nl.IFLA_TUN_NUM_DISABLED_QUEUES:
3926+
tuntap.DisabledQueues = int(native.Uint32(datum.Value))
39113927
}
39123928
}
39133929
}

0 commit comments

Comments
 (0)