blob: bf5d00c79a651ad837e3f4d6cc26c4395d0d62f4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
#include "../net-util.h"
#include <assert.h>
#include <errno.h>
#include <sched.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/if_tun.h>
int main(void)
{
char name[IFNAMSIZ] = "tap%d";
struct ifreq ifr;
int fd;
unshare(CLONE_NEWUSER|CLONE_NEWNET);
fd = tap_open(name, 0);
if (fd == -1 && (errno == EPERM || errno == ENOENT))
return 77;
assert(!ioctl(fd, (unsigned)TUNGETIFF, &ifr));
assert(!strcmp(name, ifr.ifr_name));
}
|