Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e358a7

Browse files
committedNov 27, 2024··
move AF_XDP structs and constants to linux/mod.rs
1 parent 8075133 commit 9e358a7

File tree

6 files changed

+139
-276
lines changed

6 files changed

+139
-276
lines changed
 

‎libc-test/semver/linux-gnu.txt

-24
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ SOL_PPPOL2TP
411411
SOL_RAW
412412
SOL_RDS
413413
SOL_RXRPC
414-
SOL_XDP
415414
STATX_ALL
416415
STATX_ATIME
417416
STATX_ATTR_APPEND
@@ -478,31 +477,8 @@ UDF_SUPER_MAGIC
478477
UNAME26
479478
USBDEVICE_SUPER_MAGIC
480479
USER_PROCESS
481-
XDP_COPY
482-
XDP_MMAP_OFFSETS
483-
XDP_OPTIONS
484-
XDP_OPTIONS_ZEROCOPY
485-
XDP_PGOFF_RX_RING
486-
XDP_PGOFF_TX_RING
487-
XDP_PKT_CONTD
488-
XDP_RING_NEED_WAKEUP
489-
XDP_RX_RING
490-
XDP_SHARED_UMEM
491-
XDP_STATISTICS
492-
XDP_TX_RING
493-
XDP_UMEM_COMPLETION_RING
494-
XDP_UMEM_FILL_RING
495-
XDP_UMEM_PGOFF_COMPLETION_RING
496-
XDP_UMEM_PGOFF_FILL_RING
497-
XDP_UMEM_REG
498-
XDP_UMEM_UNALIGNED_CHUNK_FLAG
499-
XDP_USE_NEED_WAKEUP
500-
XDP_USE_SG
501-
XDP_ZEROCOPY
502480
XENFS_SUPER_MAGIC
503481
XFS_SUPER_MAGIC
504-
XSK_UNALIGNED_BUF_ADDR_MASK
505-
XSK_UNALIGNED_BUF_OFFSET_SHIFT
506482
_CS_GNU_LIBC_VERSION
507483
_CS_GNU_LIBPTHREAD_VERSION
508484
_CS_V6_ENV

‎libc-test/semver/linux-musl.txt

-24
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,7 @@ RWF_DSYNC
3535
RWF_HIPRI
3636
RWF_NOWAIT
3737
RWF_SYNC
38-
SOL_XDP
3938
USER_PROCESS
40-
XDP_COPY
41-
XDP_MMAP_OFFSETS
42-
XDP_OPTIONS
43-
XDP_OPTIONS_ZEROCOPY
44-
XDP_PGOFF_RX_RING
45-
XDP_PGOFF_TX_RING
46-
XDP_PKT_CONTD
47-
XDP_RING_NEED_WAKEUP
48-
XDP_RX_RING
49-
XDP_SHARED_UMEM
50-
XDP_STATISTICS
51-
XDP_TX_RING
52-
XDP_UMEM_COMPLETION_RING
53-
XDP_UMEM_FILL_RING
54-
XDP_UMEM_PGOFF_COMPLETION_RING
55-
XDP_UMEM_PGOFF_FILL_RING
56-
XDP_UMEM_REG
57-
XDP_UMEM_UNALIGNED_CHUNK_FLAG
58-
XDP_USE_NEED_WAKEUP
59-
XDP_USE_SG
60-
XDP_ZEROCOPY
61-
XSK_UNALIGNED_BUF_ADDR_MASK
62-
XSK_UNALIGNED_BUF_OFFSET_SHIFT
6339
_CS_V6_ENV
6440
_CS_V7_ENV
6541
adjtimex

‎libc-test/semver/linux.txt

+24
Original file line numberDiff line numberDiff line change
@@ -2892,6 +2892,7 @@ SOL_TIPC
28922892
SOL_TLS
28932893
SOL_UDP
28942894
SOL_X25
2895+
SOL_XDP
28952896
SOMAXCONN
28962897
SO_BINDTODEVICE
28972898
SO_BUSY_POLL
@@ -3400,11 +3401,34 @@ W_EXITCODE
34003401
W_STOPCODE
34013402
XATTR_CREATE
34023403
XATTR_REPLACE
3404+
XDP_COPY
3405+
XDP_MMAP_OFFSETS
3406+
XDP_OPTIONS
3407+
XDP_OPTIONS_ZEROCOPY
3408+
XDP_PGOFF_RX_RING
3409+
XDP_PGOFF_TX_RING
3410+
XDP_PKT_CONTD
3411+
XDP_RING_NEED_WAKEUP
3412+
XDP_RX_RING
3413+
XDP_SHARED_UMEM
3414+
XDP_STATISTICS
34033415
XDP_TXMD_FLAGS_CHECKSUM
34043416
XDP_TXMD_FLAGS_TIMESTAMP
34053417
XDP_TX_METADATA
3418+
XDP_TX_RING
3419+
XDP_UMEM_COMPLETION_RING
3420+
XDP_UMEM_FILL_RING
3421+
XDP_UMEM_PGOFF_COMPLETION_RING
3422+
XDP_UMEM_PGOFF_FILL_RING
3423+
XDP_UMEM_REG
34063424
XDP_UMEM_TX_METADATA_LEN
34073425
XDP_UMEM_TX_SW_CSUM
3426+
XDP_UMEM_UNALIGNED_CHUNK_FLAG
3427+
XDP_USE_NEED_WAKEUP
3428+
XDP_USE_SG
3429+
XDP_ZEROCOPY
3430+
XSK_UNALIGNED_BUF_ADDR_MASK
3431+
XSK_UNALIGNED_BUF_OFFSET_SHIFT
34083432
XTABS
34093433
YESEXPR
34103434
YESSTR

‎src/unix/linux_like/linux/gnu/mod.rs

-111
Original file line numberDiff line numberDiff line change
@@ -311,84 +311,6 @@ s! {
311311
pub u: __c_anonymous_ptrace_syscall_info_data,
312312
}
313313

314-
// linux/if_xdp.h
315-
316-
pub struct sockaddr_xdp {
317-
pub sxdp_family: crate::__u16,
318-
pub sxdp_flags: crate::__u16,
319-
pub sxdp_ifindex: crate::__u32,
320-
pub sxdp_queue_id: crate::__u32,
321-
pub sxdp_shared_umem_fd: crate::__u32,
322-
}
323-
324-
pub struct xdp_ring_offset {
325-
pub producer: crate::__u64,
326-
pub consumer: crate::__u64,
327-
pub desc: crate::__u64,
328-
pub flags: crate::__u64,
329-
}
330-
331-
pub struct xdp_mmap_offsets {
332-
pub rx: xdp_ring_offset,
333-
pub tx: xdp_ring_offset,
334-
pub fr: xdp_ring_offset,
335-
pub cr: xdp_ring_offset,
336-
}
337-
338-
pub struct xdp_ring_offset_v1 {
339-
pub producer: crate::__u64,
340-
pub consumer: crate::__u64,
341-
pub desc: crate::__u64,
342-
}
343-
344-
pub struct xdp_mmap_offsets_v1 {
345-
pub rx: xdp_ring_offset_v1,
346-
pub tx: xdp_ring_offset_v1,
347-
pub fr: xdp_ring_offset_v1,
348-
pub cr: xdp_ring_offset_v1,
349-
}
350-
351-
pub struct xdp_umem_reg {
352-
pub addr: crate::__u64,
353-
pub len: crate::__u64,
354-
pub chunk_size: crate::__u32,
355-
pub headroom: crate::__u32,
356-
pub flags: crate::__u32,
357-
pub tx_metadata_len: crate::__u32,
358-
}
359-
360-
pub struct xdp_umem_reg_v1 {
361-
pub addr: crate::__u64,
362-
pub len: crate::__u64,
363-
pub chunk_size: crate::__u32,
364-
pub headroom: crate::__u32,
365-
}
366-
367-
pub struct xdp_statistics {
368-
pub rx_dropped: crate::__u64,
369-
pub rx_invalid_descs: crate::__u64,
370-
pub tx_invalid_descs: crate::__u64,
371-
pub rx_ring_full: crate::__u64,
372-
pub rx_fill_ring_empty_descs: crate::__u64,
373-
pub tx_ring_empty_descs: crate::__u64,
374-
}
375-
376-
pub struct xdp_statistics_v1 {
377-
pub rx_dropped: crate::__u64,
378-
pub rx_invalid_descs: crate::__u64,
379-
pub tx_invalid_descs: crate::__u64,
380-
}
381-
382-
pub struct xdp_options {
383-
pub flags: crate::__u32,
384-
}
385-
386-
pub struct xdp_desc {
387-
pub addr: crate::__u64,
388-
pub len: crate::__u32,
389-
pub options: crate::__u32,
390-
}
391-
392314
pub struct iocb {
393315
pub aio_data: crate::__u64,
394316
#[cfg(target_endian = "little")]
@@ -814,7 +736,6 @@ pub const SOL_RDS: c_int = 276;
814736
pub const SOL_IUCV: c_int = 277;
815737
pub const SOL_CAIF: c_int = 278;
816738
pub const SOL_NFC: c_int = 280;
817-
pub const SOL_XDP: c_int = 283;
818739

819740
pub const MSG_TRYHARD: c_int = 4;
820741

@@ -1055,38 +976,6 @@ pub const GENL_UNS_ADMIN_PERM: c_int = 0x10;
1055976
pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1;
1056977
pub const GENL_ID_PMCRAID: c_int = crate::NLMSG_MIN_TYPE + 2;
1057978

1058-
// linux/if_xdp.h
1059-
pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
1060-
pub const XDP_COPY: crate::__u16 = 1 << 1;
1061-
pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
1062-
pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
1063-
pub const XDP_USE_SG: crate::__u16 = 1 << 4;
1064-
1065-
pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;
1066-
1067-
pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;
1068-
1069-
pub const XDP_MMAP_OFFSETS: c_int = 1;
1070-
pub const XDP_RX_RING: c_int = 2;
1071-
pub const XDP_TX_RING: c_int = 3;
1072-
pub const XDP_UMEM_REG: c_int = 4;
1073-
pub const XDP_UMEM_FILL_RING: c_int = 5;
1074-
pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
1075-
pub const XDP_STATISTICS: c_int = 7;
1076-
pub const XDP_OPTIONS: c_int = 8;
1077-
1078-
pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;
1079-
1080-
pub const XDP_PGOFF_RX_RING: off_t = 0;
1081-
pub const XDP_PGOFF_TX_RING: off_t = 0x80000000;
1082-
pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000;
1083-
pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000;
1084-
1085-
pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48;
1086-
pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
1087-
1088-
pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
1089-
1090979
pub const ELFOSABI_ARM_AEABI: u8 = 64;
1091980

1092981
// linux/sched.h

‎src/unix/linux_like/linux/mod.rs

+115-5
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,83 @@ s! {
12131213
}
12141214

12151215
// linux/if_xdp.h
1216+
1217+
pub struct sockaddr_xdp {
1218+
pub sxdp_family: crate::__u16,
1219+
pub sxdp_flags: crate::__u16,
1220+
pub sxdp_ifindex: crate::__u32,
1221+
pub sxdp_queue_id: crate::__u32,
1222+
pub sxdp_shared_umem_fd: crate::__u32,
1223+
}
1224+
1225+
pub struct xdp_ring_offset {
1226+
pub producer: crate::__u64,
1227+
pub consumer: crate::__u64,
1228+
pub desc: crate::__u64,
1229+
pub flags: crate::__u64,
1230+
}
1231+
1232+
pub struct xdp_mmap_offsets {
1233+
pub rx: xdp_ring_offset,
1234+
pub tx: xdp_ring_offset,
1235+
pub fr: xdp_ring_offset,
1236+
pub cr: xdp_ring_offset,
1237+
}
1238+
1239+
pub struct xdp_ring_offset_v1 {
1240+
pub producer: crate::__u64,
1241+
pub consumer: crate::__u64,
1242+
pub desc: crate::__u64,
1243+
}
1244+
1245+
pub struct xdp_mmap_offsets_v1 {
1246+
pub rx: xdp_ring_offset_v1,
1247+
pub tx: xdp_ring_offset_v1,
1248+
pub fr: xdp_ring_offset_v1,
1249+
pub cr: xdp_ring_offset_v1,
1250+
}
1251+
1252+
pub struct xdp_umem_reg {
1253+
pub addr: crate::__u64,
1254+
pub len: crate::__u64,
1255+
pub chunk_size: crate::__u32,
1256+
pub headroom: crate::__u32,
1257+
pub flags: crate::__u32,
1258+
pub tx_metadata_len: crate::__u32,
1259+
}
1260+
1261+
pub struct xdp_umem_reg_v1 {
1262+
pub addr: crate::__u64,
1263+
pub len: crate::__u64,
1264+
pub chunk_size: crate::__u32,
1265+
pub headroom: crate::__u32,
1266+
}
1267+
1268+
pub struct xdp_statistics {
1269+
pub rx_dropped: crate::__u64,
1270+
pub rx_invalid_descs: crate::__u64,
1271+
pub tx_invalid_descs: crate::__u64,
1272+
pub rx_ring_full: crate::__u64,
1273+
pub rx_fill_ring_empty_descs: crate::__u64,
1274+
pub tx_ring_empty_descs: crate::__u64,
1275+
}
1276+
1277+
pub struct xdp_statistics_v1 {
1278+
pub rx_dropped: crate::__u64,
1279+
pub rx_invalid_descs: crate::__u64,
1280+
pub tx_invalid_descs: crate::__u64,
1281+
}
1282+
1283+
pub struct xdp_options {
1284+
pub flags: crate::__u32,
1285+
}
1286+
1287+
pub struct xdp_desc {
1288+
pub addr: crate::__u64,
1289+
pub len: crate::__u32,
1290+
pub options: crate::__u32,
1291+
}
1292+
12161293
pub struct xsk_tx_metadata_completion {
12171294
pub tx_timestamp: crate::__u64,
12181295
}
@@ -5641,13 +5718,46 @@ pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20;
56415718
pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40;
56425719

56435720
// linux/if_xdp.h
5644-
pub const XDP_UMEM_TX_SW_CSUM: __u32 = 1 << 1;
5645-
pub const XDP_UMEM_TX_METADATA_LEN: __u32 = 1 << 2;
5721+
pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
5722+
pub const XDP_COPY: crate::__u16 = 1 << 1;
5723+
pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
5724+
pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
5725+
pub const XDP_USE_SG: crate::__u16 = 1 << 4;
5726+
5727+
pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;
5728+
5729+
pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;
5730+
5731+
pub const XDP_MMAP_OFFSETS: c_int = 1;
5732+
pub const XDP_RX_RING: c_int = 2;
5733+
pub const XDP_TX_RING: c_int = 3;
5734+
pub const XDP_UMEM_REG: c_int = 4;
5735+
pub const XDP_UMEM_FILL_RING: c_int = 5;
5736+
pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
5737+
pub const XDP_STATISTICS: c_int = 7;
5738+
pub const XDP_OPTIONS: c_int = 8;
5739+
5740+
pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;
5741+
5742+
pub const XDP_PGOFF_RX_RING: crate::off_t = 0;
5743+
pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000;
5744+
pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000;
5745+
pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000;
5746+
5747+
pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48;
5748+
pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
5749+
5750+
pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
5751+
5752+
pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1;
5753+
pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2;
5754+
5755+
pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0;
5756+
pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1;
56465757

5647-
pub const XDP_TXMD_FLAGS_TIMESTAMP: __u32 = 1 << 0;
5648-
pub const XDP_TXMD_FLAGS_CHECKSUM: __u32 = 1 << 1;
5758+
pub const XDP_TX_METADATA: crate::__u32 = 1 << 1;
56495759

5650-
pub const XDP_TX_METADATA: __u32 = 1 << 1;
5760+
pub const SOL_XDP: c_int = 283;
56515761

56525762
// linux/mount.h
56535763
pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001;

‎src/unix/linux_like/linux/musl/mod.rs

-112
Original file line numberDiff line numberDiff line change
@@ -295,84 +295,6 @@ s! {
295295
pub esterror: c_long,
296296
}
297297

298-
// linux/if_xdp.h
299-
300-
pub struct sockaddr_xdp {
301-
pub sxdp_family: crate::__u16,
302-
pub sxdp_flags: crate::__u16,
303-
pub sxdp_ifindex: crate::__u32,
304-
pub sxdp_queue_id: crate::__u32,
305-
pub sxdp_shared_umem_fd: crate::__u32,
306-
}
307-
308-
pub struct xdp_ring_offset {
309-
pub producer: crate::__u64,
310-
pub consumer: crate::__u64,
311-
pub desc: crate::__u64,
312-
pub flags: crate::__u64,
313-
}
314-
315-
pub struct xdp_mmap_offsets {
316-
pub rx: xdp_ring_offset,
317-
pub tx: xdp_ring_offset,
318-
pub fr: xdp_ring_offset,
319-
pub cr: xdp_ring_offset,
320-
}
321-
322-
pub struct xdp_ring_offset_v1 {
323-
pub producer: crate::__u64,
324-
pub consumer: crate::__u64,
325-
pub desc: crate::__u64,
326-
}
327-
328-
pub struct xdp_mmap_offsets_v1 {
329-
pub rx: xdp_ring_offset_v1,
330-
pub tx: xdp_ring_offset_v1,
331-
pub fr: xdp_ring_offset_v1,
332-
pub cr: xdp_ring_offset_v1,
333-
}
334-
335-
pub struct xdp_umem_reg {
336-
pub addr: crate::__u64,
337-
pub len: crate::__u64,
338-
pub chunk_size: crate::__u32,
339-
pub headroom: crate::__u32,
340-
pub flags: crate::__u32,
341-
pub tx_metadata_len: crate::__u32,
342-
}
343-
344-
pub struct xdp_umem_reg_v1 {
345-
pub addr: crate::__u64,
346-
pub len: crate::__u64,
347-
pub chunk_size: crate::__u32,
348-
pub headroom: crate::__u32,
349-
}
350-
351-
pub struct xdp_statistics {
352-
pub rx_dropped: crate::__u64,
353-
pub rx_invalid_descs: crate::__u64,
354-
pub tx_invalid_descs: crate::__u64,
355-
pub rx_ring_full: crate::__u64,
356-
pub rx_fill_ring_empty_descs: crate::__u64,
357-
pub tx_ring_empty_descs: crate::__u64,
358-
}
359-
360-
pub struct xdp_statistics_v1 {
361-
pub rx_dropped: crate::__u64,
362-
pub rx_invalid_descs: crate::__u64,
363-
pub tx_invalid_descs: crate::__u64,
364-
}
365-
366-
pub struct xdp_options {
367-
pub flags: crate::__u32,
368-
}
369-
370-
pub struct xdp_desc {
371-
pub addr: crate::__u64,
372-
pub len: crate::__u32,
373-
pub options: crate::__u32,
374-
}
375-
376298
// netinet/tcp.h
377299

378300
pub struct tcp_info {
@@ -961,40 +883,6 @@ pub const TIME_ERROR: c_int = 5;
961883
pub const TIME_BAD: c_int = TIME_ERROR;
962884
pub const MAXTC: c_long = 6;
963885

964-
pub const SOL_XDP: c_int = 283;
965-
966-
// linux/if_xdp.h
967-
pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
968-
pub const XDP_COPY: crate::__u16 = 1 << 1;
969-
pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
970-
pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
971-
pub const XDP_USE_SG: crate::__u16 = 1 << 4;
972-
973-
pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;
974-
975-
pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;
976-
977-
pub const XDP_MMAP_OFFSETS: c_int = 1;
978-
pub const XDP_RX_RING: c_int = 2;
979-
pub const XDP_TX_RING: c_int = 3;
980-
pub const XDP_UMEM_REG: c_int = 4;
981-
pub const XDP_UMEM_FILL_RING: c_int = 5;
982-
pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
983-
pub const XDP_STATISTICS: c_int = 7;
984-
pub const XDP_OPTIONS: c_int = 8;
985-
986-
pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;
987-
988-
pub const XDP_PGOFF_RX_RING: off_t = 0;
989-
pub const XDP_PGOFF_TX_RING: off_t = 0x80000000;
990-
pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000;
991-
pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000;
992-
993-
pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48;
994-
pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
995-
996-
pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
997-
998886
pub const _CS_V6_ENV: c_int = 1148;
999887
pub const _CS_V7_ENV: c_int = 1149;
1000888

0 commit comments

Comments
 (0)
Please sign in to comment.