aboutsummaryrefslogtreecommitdiffstats
path: root/src/fnet
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-07-25 10:21:19 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2018-07-25 10:21:19 -0400
commitb78cc5869307ddb93a7b1795af992356a54d1d21 (patch)
tree025fa10749d4e5c0cf29805ecde5698a59ef3d41 /src/fnet
parentAdd profile for patch and shellcheck (diff)
downloadfirejail-b78cc5869307ddb93a7b1795af992356a54d1d21.tar.gz
firejail-b78cc5869307ddb93a7b1795af992356a54d1d21.tar.zst
firejail-b78cc5869307ddb93a7b1795af992356a54d1d21.zip
fix --net=wlan
Diffstat (limited to 'src/fnet')
-rw-r--r--src/fnet/main.c9
-rw-r--r--src/fnet/veth.c9
2 files changed, 9 insertions, 9 deletions
diff --git a/src/fnet/main.c b/src/fnet/main.c
index 5be15bc75..ec8b2cade 100644
--- a/src/fnet/main.c
+++ b/src/fnet/main.c
@@ -20,6 +20,7 @@
20#include "fnet.h" 20#include "fnet.h"
21#include <sys/types.h> 21#include <sys/types.h>
22#include <sys/stat.h> 22#include <sys/stat.h>
23#include <sys/utsname.h>
23 24
24int arg_quiet = 0; 25int arg_quiet = 0;
25 26
@@ -91,10 +92,7 @@ printf("\n");
91 else if (argc == 6 && strcmp(argv[1], "create") == 0 && strcmp(argv[2], "macvlan") == 0) { 92 else if (argc == 6 && strcmp(argv[1], "create") == 0 && strcmp(argv[2], "macvlan") == 0) {
92 // use ipvlan for wireless devices 93 // use ipvlan for wireless devices
93 // ipvlan driver was introduced in Linux kernel 3.19 94 // ipvlan driver was introduced in Linux kernel 3.19
94 // detect both compile time and run time 95
95#ifndef IPVLAN_MODE_L2 // compile time
96 net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
97#else
98 // check kernel version 96 // check kernel version
99 struct utsname u; 97 struct utsname u;
100 int rv = uname(&u); 98 int rv = uname(&u);
@@ -107,8 +105,6 @@ printf("\n");
107 exit(1); 105 exit(1);
108 } 106 }
109 107
110 if (arg_debug)
111 printf("Linux kernel version %d.%d\n", major, minor);
112 if (major <= 3 && minor < 18) 108 if (major <= 3 && minor < 18)
113 net_create_macvlan(argv[3], argv[4], atoi(argv[5])); 109 net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
114 else { 110 else {
@@ -121,7 +117,6 @@ printf("\n");
121 else // regular ethernet 117 else // regular ethernet
122 net_create_macvlan(argv[3], argv[4], atoi(argv[5])); 118 net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
123 } 119 }
124#endif
125 } 120 }
126 else if (argc == 7 && strcmp(argv[1], "config") == 0 && strcmp(argv[2], "interface") == 0) { 121 else if (argc == 7 && strcmp(argv[1], "config") == 0 && strcmp(argv[2], "interface") == 0) {
127 char *dev = argv[3]; 122 char *dev = argv[3];
diff --git a/src/fnet/veth.c b/src/fnet/veth.c
index 36362f1c1..39a4f35d8 100644
--- a/src/fnet/veth.c
+++ b/src/fnet/veth.c
@@ -50,6 +50,13 @@
50#include <linux/veth.h> 50#include <linux/veth.h>
51#include <net/if.h> 51#include <net/if.h>
52 52
53// Debian Jessie and distributions before that don't have support for IPVLAN
54// in /usr/include/linux/if_link.h. We only need a definition for IPVLAN_MODE_L2.
55// The kernel version detection happens at run time.
56#ifndef IFLA_IPVLAN_MAX
57#define IPVLAN_MODE_L2 0
58#endif
59
53struct iplink_req 60struct iplink_req
54{ 61{
55 struct nlmsghdr n; 62 struct nlmsghdr n;
@@ -176,7 +183,6 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) {
176 return 0; 183 return 0;
177} 184}
178 185
179#ifdef IPVLAN_MODE_L2
180int net_create_ipvlan(const char *dev, const char *parent, unsigned pid) { 186int net_create_ipvlan(const char *dev, const char *parent, unsigned pid) {
181 int len; 187 int len;
182 struct iplink_req req; 188 struct iplink_req req;
@@ -238,7 +244,6 @@ int net_create_ipvlan(const char *dev, const char *parent, unsigned pid) {
238 244
239 return 0; 245 return 0;
240} 246}
241#endif
242 247
243// move the interface dev in namespace of program pid 248// move the interface dev in namespace of program pid
244// when the interface is moved, netlink does not preserve interface configuration 249// when the interface is moved, netlink does not preserve interface configuration