1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/gxemul/linux-tap.patch
3 # Copyright (C) 2022 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 --- gxemul-0.7.0/src/net/net_tap.c.vanilla 2022-07-19 12:56:49.595843435 +0200
15 +++ gxemul-0.7.0/src/net/net_tap.c 2022-07-19 13:06:28.069820370 +0200
21 +#include <linux/if_tun.h>
28 bool net_tap_init(struct net *net, const char *tapdev)
31 + int fd, ret, features;
34 - fd = open(tapdev, O_RDWR);
35 + fd = open("/dev/net/tun", O_RDWR);
37 debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR,
38 - "unable to open tap device '%s': %s",
39 + "unable to open tap device '%s': %s",
40 + tapdev, strerror(errno));
44 + if (ioctl(fd, TUNGETFEATURES, &features) == -1) {
45 + debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR, "%s", strerror(errno));
50 + memset(&ifr, 0, sizeof(ifr));
51 + ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
53 + if (features & IFF_ONE_QUEUE) {
54 + ifr.ifr_flags |= IFF_ONE_QUEUE;
57 + strcpy(ifr.ifr_name, tapdev);
59 + ret = ioctl(fd, TUNSETIFF, (void *)&ifr);
61 + debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR,
62 + "unable to configure tap device '%s': %s",
63 tapdev, strerror(errno));