Skip to content

Commit a3d0958

Browse files
Added additional linux AF_PACKET functionality
1 parent 01eb85d commit a3d0958

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",
@@ -3405,6 +3405,42 @@ fn test_linux(target: &str) {
34053405
if (musl || sparc64) && ty.starts_with("uinput_") {
34063406
return true;
34073407
}
3408+
3409+
// 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
3410+
if (musl || sparc64) && ty == "sockaddr_pkt" {
3411+
return true;
3412+
}
3413+
3414+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3415+
if sparc64 && ty == "tpacket_auxdata" {
3416+
return true;
3417+
}
3418+
3419+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3420+
if sparc64 && ty == "tpacket_hdr_variant1" {
3421+
return true;
3422+
}
3423+
3424+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3425+
if sparc64 && ty == "tpacket_req3" {
3426+
return true;
3427+
}
3428+
3429+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3430+
if sparc64 && ty == "tpacket_stats_v3" {
3431+
return true;
3432+
}
3433+
3434+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3435+
if sparc64 && ty == "tpacket_req_u" {
3436+
return true;
3437+
}
3438+
3439+
// FIXME: sparc64 is 64-bit big endian, which doesn't play well with structs that are not multiples of 64 bits
3440+
if sparc64 && ty == "tpacket3_hdr" {
3441+
return true;
3442+
}
3443+
34083444
// FIXME(https://github.com/rust-lang/libc/issues/1558): passing by
34093445
// value corrupts the value for reasons not understood.
34103446
if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") {
@@ -3423,6 +3459,9 @@ fn test_linux(target: &str) {
34233459
// FIXME: This is actually a union, not a struct
34243460
"sigval" => true,
34253461

3462+
// FIXME: remove these once musl/sparc64 CI versions are upgraded (currently not a recognized struct)
3463+
"fanout_args" if musl || sparc64 => true,
3464+
34263465
// This type is tested in the `linux_termios.rs` file since there
34273466
// are header conflicts when including them with all the other
34283467
// structs.
@@ -3641,6 +3680,9 @@ fn test_linux(target: &str) {
36413680
// present in recent kernels only >= 5.19
36423681
"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,
36433682

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

@@ -3929,6 +3971,10 @@ fn test_linux(target: &str) {
39293971
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
39303972
// the `ifr_ifru` field is an anonymous union
39313973
(struct_ == "ifreq" && field == "ifr_ifru") ||
3974+
// the `hdr_variant` field is an anonymous union
3975+
(struct_ == "tpacket3_hdr" && field == "hdr_variant") ||
3976+
// the `ts_subsec` field is an anonymous union
3977+
(struct_ == "tpacket_bd_ts" && field == "ts_subsec") ||
39323978
// glibc uses a single array `uregs` instead of individual fields.
39333979
(struct_ == "user_regs" && arm)
39343980
});

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)