Lines 227-236
tap_init(struct net_backend *be, const char *devname,
Link Here
|
227 |
struct tap_priv *priv = NET_BE_PRIV(be); |
227 |
struct tap_priv *priv = NET_BE_PRIV(be); |
228 |
char tbuf[80]; |
228 |
char tbuf[80]; |
229 |
int opt = 1; |
229 |
int opt = 1; |
230 |
#if defined(INET6) || defined(INET) |
230 |
|
231 |
struct ifreq ifrq; |
|
|
232 |
int s; |
233 |
#endif |
234 |
#ifndef WITHOUT_CAPSICUM |
231 |
#ifndef WITHOUT_CAPSICUM |
235 |
cap_rights_t rights; |
232 |
cap_rights_t rights; |
236 |
#endif |
233 |
#endif |
Lines 258-295
tap_init(struct net_backend *be, const char *devname,
Link Here
|
258 |
goto error; |
255 |
goto error; |
259 |
} |
256 |
} |
260 |
|
257 |
|
261 |
#if defined(INET6) || defined(INET) |
258 |
int up = IFF_UP; |
262 |
/* |
259 |
if (ioctl(be->fd, VMIO_SIOCSIFFLAGS, &up)) { |
263 |
* Try to UP the interface rather than relying on |
260 |
WPRINTF(("tap device link up failed")); |
264 |
* net.link.tap.up_on_open. |
|
|
265 |
*/ |
266 |
bzero(&ifrq, sizeof(ifrq)); |
267 |
if (ioctl(be->fd, TAPGIFNAME, &ifrq) < 0) { |
268 |
WPRINTF(("Could not get interface name")); |
269 |
goto error; |
270 |
} |
271 |
|
272 |
s = -1; |
273 |
for (size_t i = 0; s == -1 && i < nitems(pf_list); i++) |
274 |
s = socket(pf_list[i], SOCK_DGRAM, 0); |
275 |
if (s == -1) { |
276 |
WPRINTF(("Could open socket")); |
277 |
goto error; |
278 |
} |
279 |
|
280 |
if (ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { |
281 |
(void)close(s); |
282 |
WPRINTF(("Could not get interface flags")); |
283 |
goto error; |
261 |
goto error; |
284 |
} |
262 |
} |
285 |
ifrq.ifr_flags |= IFF_UP; |
|
|
286 |
if (ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) { |
287 |
(void)close(s); |
288 |
WPRINTF(("Could not set interface flags")); |
289 |
goto error; |
290 |
} |
291 |
(void)close(s); |
292 |
#endif |
293 |
|
263 |
|
294 |
#ifndef WITHOUT_CAPSICUM |
264 |
#ifndef WITHOUT_CAPSICUM |
295 |
cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE); |
265 |
cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE); |
296 |
- |
|
|