Skip to content

Commit

Permalink
fix --net=wlan
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Jul 25, 2018
1 parent a063ddc commit b78cc58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
8 changes: 0 additions & 8 deletions src/firejail/checkcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,4 @@ void print_compiletime_support(void) {
"disabled"
#endif
);
printf("\t- Wireless interface support is %s\n",
#ifdef IPVLAN_MODE_L2
"enabled"
#else
"disabled"
#endif
);

}
9 changes: 2 additions & 7 deletions src/fnet/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "fnet.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>

int arg_quiet = 0;

Expand Down Expand Up @@ -91,10 +92,7 @@ printf("\n");
else if (argc == 6 && strcmp(argv[1], "create") == 0 && strcmp(argv[2], "macvlan") == 0) {
// use ipvlan for wireless devices
// ipvlan driver was introduced in Linux kernel 3.19
// detect both compile time and run time
#ifndef IPVLAN_MODE_L2 // compile time
net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
#else

// check kernel version
struct utsname u;
int rv = uname(&u);
Expand All @@ -107,8 +105,6 @@ printf("\n");
exit(1);
}

if (arg_debug)
printf("Linux kernel version %d.%d\n", major, minor);
if (major <= 3 && minor < 18)
net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
else {
Expand All @@ -121,7 +117,6 @@ printf("\n");
else // regular ethernet
net_create_macvlan(argv[3], argv[4], atoi(argv[5]));
}
#endif
}
else if (argc == 7 && strcmp(argv[1], "config") == 0 && strcmp(argv[2], "interface") == 0) {
char *dev = argv[3];
Expand Down
9 changes: 7 additions & 2 deletions src/fnet/veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
#include <linux/veth.h>
#include <net/if.h>

// Debian Jessie and distributions before that don't have support for IPVLAN
// in /usr/include/linux/if_link.h. We only need a definition for IPVLAN_MODE_L2.
// The kernel version detection happens at run time.
#ifndef IFLA_IPVLAN_MAX
#define IPVLAN_MODE_L2 0
#endif

struct iplink_req
{
struct nlmsghdr n;
Expand Down Expand Up @@ -176,7 +183,6 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) {
return 0;
}

#ifdef IPVLAN_MODE_L2
int net_create_ipvlan(const char *dev, const char *parent, unsigned pid) {
int len;
struct iplink_req req;
Expand Down Expand Up @@ -238,7 +244,6 @@ int net_create_ipvlan(const char *dev, const char *parent, unsigned pid) {

return 0;
}
#endif

// move the interface dev in namespace of program pid
// when the interface is moved, netlink does not preserve interface configuration
Expand Down

0 comments on commit b78cc58

Please sign in to comment.