* updated firefox (133.0.3 -> 134.0.2)
[t2sde.git] / package / emulators / gxemul / linux-tap.patch
blobb8e331bc65b71f70ef9beb1b70f6778db36ed248
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/gxemul/linux-tap.patch
3 # Copyright (C) 2022 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
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
16 @@ -45,6 +45,9 @@
17 #include <string.h>
18 #include <unistd.h>
20 +#include <net/if.h>
21 +#include <linux/if_tun.h>
23 #include "misc.h"
24 #include "net.h"
26 @@ -163,13 +163,36 @@
28 bool net_tap_init(struct net *net, const char *tapdev)
30 - int fd;
31 + int fd, ret, features;
32 int one = 1;
34 - fd = open(tapdev, O_RDWR);
35 + fd = open("/dev/net/tun", O_RDWR);
36 if (fd < 0) {
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));
41 + return false;
42 + }
44 + if (ioctl(fd, TUNGETFEATURES, &features) == -1) {
45 + debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR, "%s", strerror(errno));
46 + features = 0;
47 + }
49 + struct ifreq ifr;
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;
55 + }
57 + strcpy(ifr.ifr_name, tapdev);
59 + ret = ioctl(fd, TUNSETIFF, (void *)&ifr);
60 + if (ret != 0) {
61 + debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR,
62 + "unable to configure tap device '%s': %s",
63 tapdev, strerror(errno));
64 return false;