Skip to content

Commit 85f6836

Browse files
tammelatgross35
authored andcommitted
linux: add socket constants up to SO_DEVMEM_DONTNEED
The devmem constants requires headers >= 6.12 on gnu libc. Musl hardcodes these constants into "sys/socket.h", which are not yet present. For reference: https://elixir.bootlin.com/linux/v6.13.5/source/include/uapi/asm-generic/socket.h#L142 Signed-off-by: Pedro Tammela <[email protected]> (backport <#4299>) (cherry picked from commit ae98edd)
1 parent ff17476 commit 85f6836

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

libc-test/build.rs

+27
Original file line numberDiff line numberDiff line change
@@ -4237,6 +4237,26 @@ fn test_linux(target: &str) {
42374237
{
42384238
return true;
42394239
}
4240+
// FIXME(musl): Not in musl yet
4241+
if name == "SO_NETNS_COOKIE"
4242+
|| name == "SO_BUF_LOCK"
4243+
|| name == "SO_RESERVE_MEM"
4244+
|| name == "SO_TXREHASH"
4245+
|| name == "SO_RCVMARK"
4246+
|| name == "SO_PASSPIDFD"
4247+
|| name == "SO_PEERPIDFD"
4248+
|| name == "SO_DEVMEM_LINEAR"
4249+
|| name == "SO_DEVMEM_DMABUF"
4250+
|| name == "SO_DEVMEM_DONTNEED"
4251+
{
4252+
return true;
4253+
}
4254+
// FIXME(musl): Not in musl yet
4255+
if name == "SCM_DEVMEM_LINEAR"
4256+
|| name == "SCM_DEVMEM_DMABUF"
4257+
{
4258+
return true;
4259+
}
42404260
}
42414261
match name {
42424262
// These constants are not available if gnu headers have been included
@@ -4536,6 +4556,13 @@ fn test_linux(target: &str) {
45364556
// FIXME(linux): Requires >= 6.12 kernel headers.
45374557
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,
45384558

4559+
// FIXME(linux): Requires >= 6.12 kernel headers.
4560+
"SO_DEVMEM_LINEAR"
4561+
| "SO_DEVMEM_DMABUF"
4562+
| "SO_DEVMEM_DONTNEED"
4563+
| "SCM_DEVMEM_LINEAR"
4564+
| "SCM_DEVMEM_DMABUF" => true,
4565+
45394566
_ => false,
45404567
}
45414568
});

libc-test/semver/linux.txt

+12
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,8 @@ SCHED_OTHER
26482648
SCHED_RESET_ON_FORK
26492649
SCHED_RR
26502650
SCM_CREDENTIALS
2651+
SCM_DEVMEM_DMABUF
2652+
SCM_DEVMEM_LINEAR
26512653
SCM_J1939_DEST_ADDR
26522654
SCM_J1939_DEST_NAME
26532655
SCM_J1939_ERRQUEUE
@@ -2954,8 +2956,12 @@ SOL_X25
29542956
SOL_XDP
29552957
SOMAXCONN
29562958
SO_BINDTODEVICE
2959+
SO_BUF_LOCK
29572960
SO_BUSY_POLL
29582961
SO_BUSY_POLL_BUDGET
2962+
SO_DEVMEM_DMABUF
2963+
SO_DEVMEM_DONTNEED
2964+
SO_DEVMEM_LINEAR
29592965
SO_DOMAIN
29602966
SO_EE_OFFENDER
29612967
SO_EE_ORIGIN_ICMP
@@ -2969,20 +2975,26 @@ SO_J1939_FILTER
29692975
SO_J1939_PROMISC
29702976
SO_J1939_SEND_PRIO
29712977
SO_MARK
2978+
SO_NETNS_COOKIE
29722979
SO_ORIGINAL_DST
29732980
SO_PASSCRED
2981+
SO_PASSPIDFD
29742982
SO_PASSSEC
29752983
SO_PEEK_OFF
29762984
SO_PEERCRED
2985+
SO_PEERPIDFD
29772986
SO_PEERSEC
29782987
SO_PREFER_BUSY_POLL
29792988
SO_RCVBUFFORCE
2989+
SO_RCVMARK
2990+
SO_RESERVE_MEM
29802991
SO_REUSEPORT
29812992
SO_RXQ_OVFL
29822993
SO_SNDBUFFORCE
29832994
SO_TIMESTAMP
29842995
SO_TIMESTAMPING
29852996
SO_TIMESTAMPNS
2997+
SO_TXREHASH
29862998
SPLICE_F_GIFT
29872999
SPLICE_F_MORE
29883000
SPLICE_F_MOVE

src/unix/linux_like/linux/arch/generic/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ cfg_if! {
147147
}
148148
pub const SO_PREFER_BUSY_POLL: c_int = 69;
149149
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
150+
pub const SO_NETNS_COOKIE: c_int = 71;
151+
pub const SO_BUF_LOCK: c_int = 72;
152+
pub const SO_RESERVE_MEM: c_int = 73;
153+
pub const SO_TXREHASH: c_int = 74;
154+
pub const SO_RCVMARK: c_int = 75;
155+
pub const SO_PASSPIDFD: c_int = 76;
156+
pub const SO_PEERPIDFD: c_int = 77;
157+
pub const SO_DEVMEM_LINEAR: c_int = 78;
158+
pub const SO_DEVMEM_DMABUF: c_int = 79;
159+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
150160

151161
cfg_if! {
152162
if #[cfg(any(
@@ -169,6 +179,9 @@ cfg_if! {
169179
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
170180
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
171181

182+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
183+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
184+
172185
// Ioctl Constants
173186

174187
pub const TCGETS: Ioctl = 0x5401;

src/unix/linux_like/linux/arch/mips/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ cfg_if! {
120120
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
121121
pub const SO_PREFER_BUSY_POLL: c_int = 69;
122122
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
123+
pub const SO_NETNS_COOKIE: c_int = 71;
124+
pub const SO_BUF_LOCK: c_int = 72;
125+
pub const SO_RESERVE_MEM: c_int = 73;
126+
pub const SO_TXREHASH: c_int = 74;
127+
pub const SO_RCVMARK: c_int = 75;
128+
pub const SO_PASSPIDFD: c_int = 76;
129+
pub const SO_PEERPIDFD: c_int = 77;
130+
pub const SO_DEVMEM_LINEAR: c_int = 78;
131+
pub const SO_DEVMEM_DMABUF: c_int = 79;
132+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
123133

124134
pub const FICLONE: c_ulong = 0x80049409;
125135
pub const FICLONERANGE: c_ulong = 0x8020940D;
@@ -129,6 +139,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
129139
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
130140
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
131141

142+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
143+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
144+
132145
// Ioctl Constants
133146

134147
pub const TCGETS: Ioctl = 0x540d;

src/unix/linux_like/linux/arch/powerpc/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ const SO_SNDTIMEO_NEW: c_int = 67;
102102
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
103103
pub const SO_PREFER_BUSY_POLL: c_int = 69;
104104
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
105+
pub const SO_NETNS_COOKIE: c_int = 71;
106+
pub const SO_BUF_LOCK: c_int = 72;
107+
pub const SO_RESERVE_MEM: c_int = 73;
108+
pub const SO_TXREHASH: c_int = 74;
109+
pub const SO_RCVMARK: c_int = 75;
110+
pub const SO_PASSPIDFD: c_int = 76;
111+
pub const SO_PEERPIDFD: c_int = 77;
112+
pub const SO_DEVMEM_LINEAR: c_int = 78;
113+
pub const SO_DEVMEM_DMABUF: c_int = 79;
114+
pub const SO_DEVMEM_DONTNEED: c_int = 80;
105115

106116
pub const FICLONE: c_ulong = 0x80049409;
107117
pub const FICLONERANGE: c_ulong = 0x8020940D;
@@ -111,6 +121,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
111121
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
112122
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
113123

124+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
125+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
126+
114127
// Ioctl Constants
115128

116129
cfg_if! {

src/unix/linux_like/linux/arch/sparc/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,25 @@ pub const SO_TIMESTAMPING: c_int = 0x0023;
9797
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047;
9898
pub const SO_PREFER_BUSY_POLL: c_int = 0x0048;
9999
pub const SO_BUSY_POLL_BUDGET: c_int = 0x0049;
100+
pub const SO_NETNS_COOKIE: c_int = 0x0050;
101+
pub const SO_BUF_LOCK: c_int = 0x0051;
102+
pub const SO_RESERVE_MEM: c_int = 0x0052;
103+
pub const SO_TXREHASH: c_int = 0x0053;
104+
pub const SO_RCVMARK: c_int = 0x0054;
105+
pub const SO_PASSPIDFD: c_int = 0x0055;
106+
pub const SO_PEERPIDFD: c_int = 0x0056;
107+
pub const SO_DEVMEM_LINEAR: c_int = 0x0057;
108+
pub const SO_DEVMEM_DMABUF: c_int = 0x0058;
109+
pub const SO_DEVMEM_DONTNEED: c_int = 0x0059;
100110

101111
// Defined in unix/linux_like/mod.rs
102112
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
103113
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
104114
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
105115

116+
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
117+
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
118+
106119
// Ioctl Constants
107120

108121
pub const TCGETS: Ioctl = 0x40245408;

0 commit comments

Comments
 (0)