aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/veth.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/firejail/veth.c b/src/firejail/veth.c
index 803d8d503..0db55709b 100644
--- a/src/firejail/veth.c
+++ b/src/firejail/veth.c
@@ -136,8 +136,14 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) {
136 req.n.nlmsg_type = RTM_NEWLINK; 136 req.n.nlmsg_type = RTM_NEWLINK;
137 req.i.ifi_family = 0; 137 req.i.ifi_family = 0;
138 138
139 // we start with the parent 139 // find parent ifindex
140 int parent_ifindex = 2; 140 int parent_ifindex = if_nametoindex(parent);
141 if (parent_ifindex <= 0) {
142 fprintf(stderr, "Error: cannot find network device %s\n", parent);
143 exit(1);
144 }
145
146 // add parent
141 addattr_l(&req.n, sizeof(req), IFLA_LINK, &parent_ifindex, 4); 147 addattr_l(&req.n, sizeof(req), IFLA_LINK, &parent_ifindex, 4);
142 148
143 // add new interface name 149 // add new interface name
@@ -173,6 +179,7 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) {
173 return 0; 179 return 0;
174} 180}
175 181
182
176/* 183/*
177int main(int argc, char **argv) { 184int main(int argc, char **argv) {
178 printf("Hello\n"); 185 printf("Hello\n");