Skip to content

Commit 9fbadf8

Browse files
committed
Auto merge of #3120 - nathaniel-bennett:master, r=JohnTitor
Additional linux AF_PACKET functionality Added socket options, structs and other miscellaneous constants that make memory-mapped packet sockets possible in Linux (PACKET_TX_RING, PACKET_RX_RING, etc.).
2 parents 66e988b + a3d0958 commit 9fbadf8

File tree

3 files changed

+432
-1
lines changed

3 files changed

+432
-1
lines changed

libc-test/build.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -3168,7 +3168,6 @@ fn test_linux(target: &str) {
31683168
"netinet/ip.h",
31693169
"netinet/tcp.h",
31703170
"netinet/udp.h",
3171-
"netpacket/packet.h",
31723171
"poll.h",
31733172
"pthread.h",
31743173
"pty.h",
@@ -3267,6 +3266,7 @@ fn test_linux(target: &str) {
32673266
"linux/if_addr.h",
32683267
"linux/if_alg.h",
32693268
"linux/if_ether.h",
3269+
"linux/if_packet.h",
32703270
"linux/if_tun.h",
32713271
"linux/input.h",
32723272
"linux/ipv6.h",
@@ -3409,6 +3409,42 @@ fn test_linux(target: &str) {
34093409
if sparc64 && (ty == "uinput_ff_erase" || ty == "uinput_abs_setup") {
34103410
return true;
34113411
}
3412+
3413+
// FIXME: sparc64 and musl CI images are big endian, which doesn't play well with structs that are not multiples of 32 or 64 bits
3414+
if (musl || sparc64) && ty == "sockaddr_pkt" {
3415+
return true;
3416+
}
3417+
3418+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3419+
if sparc64 && ty == "tpacket_auxdata" {
3420+
return true;
3421+
}
3422+
3423+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3424+
if sparc64 && ty == "tpacket_hdr_variant1" {
3425+
return true;
3426+
}
3427+
3428+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3429+
if sparc64 && ty == "tpacket_req3" {
3430+
return true;
3431+
}
3432+
3433+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3434+
if sparc64 && ty == "tpacket_stats_v3" {
3435+
return true;
3436+
}
3437+
3438+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3439+
if sparc64 && ty == "tpacket_req_u" {
3440+
return true;
3441+
}
3442+
3443+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3444+
if sparc64 && ty == "tpacket3_hdr" {
3445+
return true;
3446+
}
3447+
34123448
// FIXME(https://github.com/rust-lang/libc/issues/1558): passing by
34133449
// value corrupts the value for reasons not understood.
34143450
if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") {
@@ -3427,6 +3463,9 @@ fn test_linux(target: &str) {
34273463
// FIXME: This is actually a union, not a struct
34283464
"sigval" => true,
34293465

3466+
// FIXME: remove these once musl/sparc64 CI versions are upgraded (currently not a recognized struct)
3467+
"fanout_args" if musl || sparc64 => true,
3468+
34303469
// This type is tested in the `linux_termios.rs` file since there
34313470
// are header conflicts when including them with all the other
34323471
// structs.
@@ -3642,6 +3681,9 @@ fn test_linux(target: &str) {
36423681
// present in recent kernels only >= 5.19
36433682
"PR_SME_SET_VL" | "PR_SME_GET_VL" | "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" => true,
36443683

3684+
// FIXME: Alignment issues with tpacket3_hdr struct
3685+
"TPACKET3_HDRLEN" if sparc64 => true,
3686+
36453687
// Added in Linux 5.14
36463688
"FUTEX_LOCK_PI2" => true,
36473689

@@ -3901,6 +3943,10 @@ fn test_linux(target: &str) {
39013943
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
39023944
// the `ifr_ifru` field is an anonymous union
39033945
(struct_ == "ifreq" && field == "ifr_ifru") ||
3946+
// the `hdr_variant` field is an anonymous union
3947+
(struct_ == "tpacket3_hdr" && field == "hdr_variant") ||
3948+
// the `ts_subsec` field is an anonymous union
3949+
(struct_ == "tpacket_bd_ts" && field == "ts_subsec") ||
39043950
// glibc uses a single array `uregs` instead of individual fields.
39053951
(struct_ == "user_regs" && arm)
39063952
});

libc-test/semver/linux.txt

+63
Original file line numberDiff line numberDiff line change
@@ -1713,11 +1713,40 @@ O_RSYNC
17131713
O_SYNC
17141714
O_TMPFILE
17151715
PACKET_ADD_MEMBERSHIP
1716+
PACKET_AUXDATA
1717+
PACKET_BROADCAST
17161718
PACKET_DROP_MEMBERSHIP
1719+
PACKET_FANOUT
1720+
PACKET_HOST
1721+
PACKET_KERNEL
1722+
PACKET_LOOPBACK
1723+
PACKET_LOSS
17171724
PACKET_MR_ALLMULTI
17181725
PACKET_MR_MULTICAST
17191726
PACKET_MR_PROMISC
17201727
PACKET_MR_UNICAST
1728+
PACKET_MULTICAST
1729+
PACKET_OTHERHOST
1730+
PACKET_OUTGOING
1731+
PACKET_QDISC_BYPASS
1732+
PACKET_RESERVE
1733+
PACKET_RX_RING
1734+
PACKET_STATISTICS
1735+
PACKET_TIMESTAMP
1736+
PACKET_TX_RING
1737+
PACKET_USER
1738+
PACKET_VERSION
1739+
PACKET_FANOUT_CBPF
1740+
PACKET_FANOUT_CPU
1741+
PACKET_FANOUT_EBPF
1742+
PACKET_FANOUT_FLAG_DEFRAG
1743+
PACKET_FANOUT_FLAG_ROLLOVER
1744+
PACKET_FANOUT_FLAG_UNIQUEID
1745+
PACKET_FANOUT_HASH
1746+
PACKET_FANOUT_LB
1747+
PACKET_FANOUT_QM
1748+
PACKET_FANOUT_RND
1749+
PACKET_FANOUT_ROLLOVER
17211750
PENDIN
17221751
PF_ALG
17231752
PF_APPLETALK
@@ -2828,6 +2857,22 @@ TIOCSCTTY
28282857
TIOCSPGRP
28292858
TIOCSSOFTCAR
28302859
TIOCSTI
2860+
TP_STATUS_AVAILABLE
2861+
TP_STATUS_BLK_TMO
2862+
TP_STATUS_COPY
2863+
TP_STATUS_CSUMNOTREADY
2864+
TP_STATUS_CSUM_VALID
2865+
TP_STATUS_KERNEL
2866+
TP_STATUS_LOSING
2867+
TP_STATUS_SENDING
2868+
TP_STATUS_SEND_REQUEST
2869+
TP_STATUS_TS_RAW_HARDWARE
2870+
TP_STATUS_TS_SOFTWARE
2871+
TP_STATUS_TS_SYS_HARDWARE
2872+
TP_STATUS_USER
2873+
TP_STATUS_VLAN_TPID_VALID
2874+
TP_STATUS_VLAN_VALID
2875+
TP_STATUS_WRONG_FORMAT
28312876
TUN_READQ_SIZE
28322877
TUN_TAP_DEV
28332878
TUN_TUN_DEV
@@ -3089,6 +3134,7 @@ fanotify_event_metadata
30893134
fanotify_init
30903135
fanotify_mark
30913136
fanotify_response
3137+
fanout_args
30923138
fchdir
30933139
fdatasync
30943140
fdopendir
@@ -3442,6 +3488,7 @@ sockaddr_alg
34423488
sockaddr_can
34433489
sockaddr_ll
34443490
sockaddr_nl
3491+
sockaddr_pkt
34453492
sockaddr_vm
34463493
splice
34473494
spwd
@@ -3476,6 +3523,22 @@ timer_getoverrun
34763523
timer_gettime
34773524
timer_settime
34783525
tmpfile64
3526+
tpacket2_hdr
3527+
tpacket3_hdr
3528+
tpacket_auxdata
3529+
tpacket_bd_header_u
3530+
tpacket_bd_ts
3531+
tpacket_block_desc
3532+
tpacket_hdr
3533+
tpacket_hdr_v1
3534+
tpacket_hdr_variant1
3535+
tpacket_req
3536+
tpacket_req3
3537+
tpacket_req_u
3538+
tpacket_rollover_stats
3539+
tpacket_stats
3540+
tpacket_stats_v3
3541+
tpacket_versions
34793542
truncate
34803543
truncate64
34813544
ttyname_r

0 commit comments

Comments
 (0)