Skip to content

Commit f9f72de

Browse files
authored
Merge pull request #3960 from wlynxg/main
feat: add `ioctl` flags in `linux/if_tun.h`
2 parents 7cd18df + c24c516 commit f9f72de

File tree

8 files changed

+189
-0
lines changed

8 files changed

+189
-0
lines changed

libc-test/semver/linux-gnu.txt

+2
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ TIME_WAIT
472472
TMPFS_MAGIC
473473
TMP_MAX
474474
TRACEFS_MAGIC
475+
TUNSETCARRIER
476+
TUNGETDEVNETNS
475477
UDF_SUPER_MAGIC
476478
UNAME26
477479
USBDEVICE_SUPER_MAGIC

libc-test/semver/linux.txt

+26
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,32 @@ IFF_MULTI_QUEUE
962962
IFF_NO_CARRIER
963963
IFF_NOARP
964964
IFF_NOFILTER
965+
TUNSETNOCSUM
966+
TUNSETDEBUG
967+
TUNSETIFF
968+
TUNSETPERSIST
969+
TUNSETOWNER
970+
TUNSETLINK
971+
TUNSETGROUP
972+
TUNGETFEATURES
973+
TUNSETOFFLOAD
974+
TUNSETTXFILTER
975+
TUNGETIFF
976+
TUNGETSNDBUF
977+
TUNSETSNDBUF
978+
TUNATTACHFILTER
979+
TUNDETACHFILTER
980+
TUNGETVNETHDRSZ
981+
TUNSETVNETHDRSZ
982+
TUNSETQUEUE
983+
TUNSETIFINDEX
984+
TUNGETFILTER
985+
TUNSETVNETLE
986+
TUNGETVNETLE
987+
TUNSETVNETBE
988+
TUNGETVNETBE
989+
TUNSETSTEERINGEBPF
990+
TUNSETFILTEREBPF
965991
TUN_TX_TIMESTAMP
966992
TUN_F_CSUM
967993
TUN_F_TSO4

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

+34
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,34 @@ pub const BLKIOMIN: ::Ioctl = 0x1278;
210210
pub const BLKIOOPT: ::Ioctl = 0x1279;
211211
pub const BLKSSZGET: ::Ioctl = 0x1268;
212212
pub const BLKPBSZGET: ::Ioctl = 0x127B;
213+
// linux/if_tun.h
214+
pub const TUNSETNOCSUM: ::Ioctl = 0x400454c8;
215+
pub const TUNSETDEBUG: ::Ioctl = 0x400454c9;
216+
pub const TUNSETIFF: ::Ioctl = 0x400454ca;
217+
pub const TUNSETPERSIST: ::Ioctl = 0x400454cb;
218+
pub const TUNSETOWNER: ::Ioctl = 0x400454cc;
219+
pub const TUNSETLINK: ::Ioctl = 0x400454cd;
220+
pub const TUNSETGROUP: ::Ioctl = 0x400454ce;
221+
pub const TUNGETFEATURES: ::Ioctl = 0x800454cf;
222+
pub const TUNSETOFFLOAD: ::Ioctl = 0x400454d0;
223+
pub const TUNSETTXFILTER: ::Ioctl = 0x400454d1;
224+
pub const TUNGETIFF: ::Ioctl = 0x800454d2;
225+
pub const TUNGETSNDBUF: ::Ioctl = 0x800454d3;
226+
pub const TUNSETSNDBUF: ::Ioctl = 0x400454d4;
227+
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x800454d7;
228+
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x400454d8;
229+
pub const TUNSETQUEUE: ::Ioctl = 0x400454d9;
230+
pub const TUNSETIFINDEX: ::Ioctl = 0x400454da;
231+
pub const TUNSETVNETLE: ::Ioctl = 0x400454dc;
232+
pub const TUNGETVNETLE: ::Ioctl = 0x800454dd;
233+
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
234+
* little-endian hosts. Not all kernel configurations support them, but all
235+
* configurations that support SET also support GET.
236+
*/
237+
pub const TUNSETVNETBE: ::Ioctl = 0x400454de;
238+
pub const TUNGETVNETBE: ::Ioctl = 0x800454df;
239+
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x800454e0;
240+
pub const TUNSETFILTEREBPF: ::Ioctl = 0x800454e1;
213241

214242
cfg_if! {
215243
// Those type are constructed using the _IOC macro
@@ -227,6 +255,9 @@ cfg_if! {
227255
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
228256
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
229257
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
258+
pub const TUNATTACHFILTER: ::Ioctl = 0x400854d5;
259+
pub const TUNDETACHFILTER: ::Ioctl = 0x400854d6;
260+
pub const TUNGETFILTER: ::Ioctl = 0x800854db;
230261
} else if #[cfg(any(target_arch = "x86_64",
231262
target_arch = "riscv64",
232263
target_arch = "aarch64",
@@ -240,6 +271,9 @@ cfg_if! {
240271
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
241272
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
242273
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
274+
pub const TUNATTACHFILTER: ::Ioctl = 0x401054d5;
275+
pub const TUNDETACHFILTER: ::Ioctl = 0x401054d6;
276+
pub const TUNGETFILTER: ::Ioctl = 0x801054db;
243277
}
244278
}
245279

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

+34
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,34 @@ pub const BLKIOMIN: ::Ioctl = 0x20001278;
192192
pub const BLKIOOPT: ::Ioctl = 0x20001279;
193193
pub const BLKSSZGET: ::Ioctl = 0x20001268;
194194
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
195+
// linux/if_tun.h
196+
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
197+
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
198+
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
199+
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
200+
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
201+
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
202+
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
203+
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
204+
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
205+
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
206+
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
207+
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
208+
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
209+
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
210+
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
211+
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
212+
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
213+
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
214+
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
215+
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
216+
* little-endian hosts. Not all kernel configurations support them, but all
217+
* configurations that support SET also support GET.
218+
*/
219+
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
220+
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
221+
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
222+
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;
195223

196224
cfg_if! {
197225
// Those type are constructed using the _IOC macro
@@ -209,6 +237,9 @@ cfg_if! {
209237
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
210238
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
211239
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
240+
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
241+
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
242+
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
212243
} else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] {
213244
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
214245
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
@@ -218,6 +249,9 @@ cfg_if! {
218249
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
219250
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
220251
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
252+
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
253+
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
254+
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
221255
}
222256
}
223257

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

+34
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279;
178178
pub const BLKSSZGET: ::Ioctl = 0x20001268;
179179
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
180180
//pub const FIOQSIZE: ::Ioctl = 0x40086680;
181+
// linux/if_tun.h
182+
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
183+
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
184+
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
185+
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
186+
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
187+
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
188+
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
189+
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
190+
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
191+
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
192+
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
193+
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
194+
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
195+
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
196+
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
197+
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
198+
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
199+
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
200+
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
201+
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
202+
* little-endian hosts. Not all kernel configurations support them, but all
203+
* configurations that support SET also support GET.
204+
*/
205+
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
206+
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
207+
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
208+
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;
181209

182210
cfg_if! {
183211
// Those type are constructed using the _IOC macro
@@ -195,6 +223,9 @@ cfg_if! {
195223
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
196224
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
197225
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
226+
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
227+
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
228+
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
198229
} else if #[cfg(target_arch = "powerpc64")] {
199230
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
200231
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
@@ -204,6 +235,9 @@ cfg_if! {
204235
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
205236
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
206237
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
238+
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
239+
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
240+
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
207241
}
208242
}
209243

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

+35
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,35 @@ pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
183183
//pub const TIOCGRS485: ::Ioctl = 0x40205441;
184184
//pub const TIOCSRS485: ::Ioctl = 0xc0205442;
185185

186+
// linux/if_tun.h
187+
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
188+
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
189+
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
190+
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
191+
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
192+
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
193+
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
194+
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
195+
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
196+
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
197+
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
198+
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
199+
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
200+
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
201+
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
202+
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
203+
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
204+
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
205+
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
206+
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
207+
* little-endian hosts. Not all kernel configurations support them, but all
208+
* configurations that support SET also support GET.
209+
*/
210+
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
211+
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
212+
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
213+
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;
214+
186215
pub const TIOCM_LE: ::c_int = 0x001;
187216
pub const TIOCM_DTR: ::c_int = 0x002;
188217
pub const TIOCM_RTS: ::c_int = 0x004;
@@ -246,6 +275,9 @@ cfg_if! {
246275
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
247276
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
248277
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
278+
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
279+
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
280+
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
249281
} else if #[cfg(target_arch = "sparc64")] {
250282
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
251283
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
@@ -255,5 +287,8 @@ cfg_if! {
255287
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
256288
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
257289
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
290+
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
291+
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
292+
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
258293
}
259294
}

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

+23
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,29 @@ pub const REG_EEND: ::c_int = 14;
12891289
pub const REG_ESIZE: ::c_int = 15;
12901290
pub const REG_ERPAREN: ::c_int = 16;
12911291

1292+
cfg_if! {
1293+
if #[cfg(any(target_arch = "x86",
1294+
target_arch = "x86_64",
1295+
target_arch = "arm",
1296+
target_arch = "aarch64",
1297+
target_arch = "loongarch64",
1298+
target_arch = "riscv64",
1299+
target_arch = "s390x"))] {
1300+
pub const TUNSETCARRIER: ::Ioctl = 0x400454e2;
1301+
pub const TUNGETDEVNETNS: ::Ioctl = 0x54e3;
1302+
} else if #[cfg(any(target_arch = "mips",
1303+
target_arch = "mips64",
1304+
target_arch = "powerpc",
1305+
target_arch = "powerpc64",
1306+
target_arch = "sparc",
1307+
target_arch = "sparc64"))] {
1308+
pub const TUNSETCARRIER: ::Ioctl = 0x800454e2;
1309+
pub const TUNGETDEVNETNS: ::Ioctl = 0x200054e3;
1310+
} else {
1311+
// Unknown target_arch
1312+
}
1313+
}
1314+
12921315
extern "C" {
12931316
pub fn fgetspent_r(
12941317
fp: *mut ::FILE,

src/unix/linux_like/linux/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,7 @@ pub const IFLA_INFO_SLAVE_KIND: ::c_ushort = 4;
23632363
pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5;
23642364

23652365
// linux/if_tun.h
2366+
/* TUNSETIFF ifr flags */
23662367
pub const IFF_TUN: ::c_int = 0x0001;
23672368
pub const IFF_TAP: ::c_int = 0x0002;
23682369
pub const IFF_NAPI: ::c_int = 0x0010;

0 commit comments

Comments
 (0)