diff options
Diffstat (limited to 'src/fnet/veth.c')
-rw-r--r-- | src/fnet/veth.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/fnet/veth.c b/src/fnet/veth.c index 86d9d5190..d37c93a19 100644 --- a/src/fnet/veth.c +++ b/src/fnet/veth.c | |||
@@ -1,16 +1,16 @@ | |||
1 | /* code based on iproute2 ip/iplink.c, modified to be included in firejail project | 1 | /* code based on iproute2 ip/iplink.c, modified to be included in firejail project |
2 | * | 2 | * |
3 | * Original source code: | 3 | * Original source code: |
4 | * | 4 | * |
5 | * Information: | 5 | * Information: |
6 | * http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 | 6 | * http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 |
7 | * | 7 | * |
8 | * Download: | 8 | * Download: |
9 | * http://www.kernel.org/pub/linux/utils/net/iproute2/ | 9 | * http://www.kernel.org/pub/linux/utils/net/iproute2/ |
10 | * | 10 | * |
11 | * Repository: | 11 | * Repository: |
12 | * git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git | 12 | * git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git |
13 | * | 13 | * |
14 | * License: GPL v2 | 14 | * License: GPL v2 |
15 | * | 15 | * |
16 | * Original copyright header | 16 | * Original copyright header |
@@ -112,7 +112,7 @@ int net_create_veth(const char *dev, const char *nsdev, unsigned pid) { | |||
112 | exit(2); | 112 | exit(2); |
113 | 113 | ||
114 | rtnl_close(&rth); | 114 | rtnl_close(&rth); |
115 | 115 | ||
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
@@ -134,13 +134,13 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) { | |||
134 | req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL; | 134 | req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL; |
135 | req.n.nlmsg_type = RTM_NEWLINK; | 135 | req.n.nlmsg_type = RTM_NEWLINK; |
136 | req.i.ifi_family = 0; | 136 | req.i.ifi_family = 0; |
137 | 137 | ||
138 | // find parent ifindex | 138 | // find parent ifindex |
139 | int parent_ifindex = if_nametoindex(parent); | 139 | int parent_ifindex = if_nametoindex(parent); |
140 | if (parent_ifindex <= 0) { | 140 | if (parent_ifindex <= 0) { |
141 | fprintf(stderr, "Error: cannot find network device %s\n", parent); | 141 | fprintf(stderr, "Error: cannot find network device %s\n", parent); |
142 | exit(1); | 142 | exit(1); |
143 | } | 143 | } |
144 | 144 | ||
145 | // add parent | 145 | // add parent |
146 | addattr_l(&req.n, sizeof(req), IFLA_LINK, &parent_ifindex, 4); | 146 | addattr_l(&req.n, sizeof(req), IFLA_LINK, &parent_ifindex, 4); |
@@ -148,7 +148,7 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) { | |||
148 | // add new interface name | 148 | // add new interface name |
149 | len = strlen(dev) + 1; | 149 | len = strlen(dev) + 1; |
150 | addattr_l(&req.n, sizeof(req), IFLA_IFNAME, dev, len); | 150 | addattr_l(&req.n, sizeof(req), IFLA_IFNAME, dev, len); |
151 | 151 | ||
152 | // place the interface in child namespace | 152 | // place the interface in child namespace |
153 | addattr_l (&req.n, sizeof(req), IFLA_NET_NS_PID, &pid, 4); | 153 | addattr_l (&req.n, sizeof(req), IFLA_NET_NS_PID, &pid, 4); |
154 | 154 | ||
@@ -176,7 +176,7 @@ int net_create_macvlan(const char *dev, const char *parent, unsigned pid) { | |||
176 | exit(2); | 176 | exit(2); |
177 | 177 | ||
178 | rtnl_close(&rth); | 178 | rtnl_close(&rth); |
179 | 179 | ||
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | 182 | ||
@@ -197,7 +197,7 @@ int net_move_interface(const char *dev, unsigned pid) { | |||
197 | req.n.nlmsg_flags = NLM_F_REQUEST; | 197 | req.n.nlmsg_flags = NLM_F_REQUEST; |
198 | req.n.nlmsg_type = RTM_NEWLINK; | 198 | req.n.nlmsg_type = RTM_NEWLINK; |
199 | req.i.ifi_family = 0; | 199 | req.i.ifi_family = 0; |
200 | 200 | ||
201 | // find ifindex | 201 | // find ifindex |
202 | int ifindex = if_nametoindex(dev); | 202 | int ifindex = if_nametoindex(dev); |
203 | if (ifindex <= 0) { | 203 | if (ifindex <= 0) { |
@@ -205,7 +205,7 @@ int net_move_interface(const char *dev, unsigned pid) { | |||
205 | exit(1); | 205 | exit(1); |
206 | } | 206 | } |
207 | req.i.ifi_index = ifindex; | 207 | req.i.ifi_index = ifindex; |
208 | 208 | ||
209 | // place the interface in child namespace | 209 | // place the interface in child namespace |
210 | addattr_l (&req.n, sizeof(req), IFLA_NET_NS_PID, &pid, 4); | 210 | addattr_l (&req.n, sizeof(req), IFLA_NET_NS_PID, &pid, 4); |
211 | 211 | ||
@@ -214,7 +214,7 @@ int net_move_interface(const char *dev, unsigned pid) { | |||
214 | exit(2); | 214 | exit(2); |
215 | 215 | ||
216 | rtnl_close(&rth); | 216 | rtnl_close(&rth); |
217 | 217 | ||
218 | return 0; | 218 | return 0; |
219 | } | 219 | } |
220 | 220 | ||
@@ -233,4 +233,4 @@ int main(int argc, char **argv) { | |||
233 | 233 | ||
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | */ \ No newline at end of file | 236 | */ |