View | Details | Raw Unified | Return to bug 273557 | Differences between
and this patch

Collapse All | Expand All

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

Return to bug 273557