github.com/vishvananda/netlink@v1.3.0/socket.go (about) 1 package netlink 2 3 import "net" 4 5 // SocketID identifies a single socket. 6 type SocketID struct { 7 SourcePort uint16 8 DestinationPort uint16 9 Source net.IP 10 Destination net.IP 11 Interface uint32 12 Cookie [2]uint32 13 } 14 15 // Socket represents a netlink socket. 16 type Socket struct { 17 Family uint8 18 State uint8 19 Timer uint8 20 Retrans uint8 21 ID SocketID 22 Expires uint32 23 RQueue uint32 24 WQueue uint32 25 UID uint32 26 INode uint32 27 } 28 29 // UnixSocket represents a netlink unix socket. 30 type UnixSocket struct { 31 Type uint8 32 Family uint8 33 State uint8 34 pad uint8 35 INode uint32 36 Cookie [2]uint32 37 } 38 39 // XDPSocket represents an XDP socket (and the common diagnosis part in 40 // particular). Please note that in contrast to [UnixSocket] the XDPSocket type 41 // does not feature “State” information. 42 type XDPSocket struct { 43 // xdp_diag_msg 44 // https://elixir.bootlin.com/linux/v6.2/source/include/uapi/linux/xdp_diag.h#L21 45 Family uint8 46 Type uint8 47 pad uint16 48 Ino uint32 49 Cookie [2]uint32 50 } 51 52 type XDPInfo struct { 53 // XDP_DIAG_INFO/xdp_diag_info 54 // https://elixir.bootlin.com/linux/v6.2/source/include/uapi/linux/xdp_diag.h#L51 55 Ifindex uint32 56 QueueID uint32 57 58 // XDP_DIAG_UID 59 UID uint32 60 61 // XDP_RX_RING 62 // https://elixir.bootlin.com/linux/v6.2/source/include/uapi/linux/xdp_diag.h#L56 63 RxRingEntries uint32 64 TxRingEntries uint32 65 UmemFillRingEntries uint32 66 UmemCompletionRingEntries uint32 67 68 // XDR_DIAG_UMEM 69 Umem *XDPDiagUmem 70 71 // XDR_DIAG_STATS 72 Stats *XDPDiagStats 73 } 74 75 const ( 76 XDP_DU_F_ZEROCOPY = 1 << iota 77 ) 78 79 // XDPDiagUmem describes the umem attached to an XDP socket. 80 // 81 // https://elixir.bootlin.com/linux/v6.2/source/include/uapi/linux/xdp_diag.h#L62 82 type XDPDiagUmem struct { 83 Size uint64 84 ID uint32 85 NumPages uint32 86 ChunkSize uint32 87 Headroom uint32 88 Ifindex uint32 89 QueueID uint32 90 Flags uint32 91 Refs uint32 92 } 93 94 // XDPDiagStats contains ring statistics for an XDP socket. 95 // 96 // https://elixir.bootlin.com/linux/v6.2/source/include/uapi/linux/xdp_diag.h#L74 97 type XDPDiagStats struct { 98 RxDropped uint64 99 RxInvalid uint64 100 RxFull uint64 101 FillRingEmpty uint64 102 TxInvalid uint64 103 TxRingEmpty uint64 104 }