Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107156374
D31342.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31342.diff
View Options
diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c
--- a/usr.sbin/bhyve/net_backends.c
+++ b/usr.sbin/bhyve/net_backends.c
@@ -46,6 +46,9 @@
#include <sys/uio.h>
#include <net/if.h>
+#if defined(INET6) || defined(INET)
+#include <net/if_tap.h>
+#endif
#include <net/netmap.h>
#include <net/netmap_virt.h>
#define NETMAP_WITH_LIBS
@@ -179,6 +182,17 @@
* The tap backend
*/
+#if defined(INET6) || defined(INET)
+const int pf_list[] = {
+#if defined(INET6)
+ PF_INET6,
+#endif
+#if defined(INET)
+ PF_INET,
+#endif
+};
+#endif
+
struct tap_priv {
struct mevent *mevp;
/*
@@ -211,6 +225,10 @@
struct tap_priv *priv = (struct tap_priv *)be->opaque;
char tbuf[80];
int opt = 1;
+#if defined(INET6) || defined(INET)
+ struct ifreq ifrq;
+ int i, s;
+#endif
#ifndef WITHOUT_CAPSICUM
cap_rights_t rights;
#endif
@@ -238,6 +256,39 @@
goto error;
}
+#if defined(INET6) || defined(INET)
+ /*
+ * Try to UP the interface rather than relying on
+ * net.link.tap.up_on_open.
+ */
+ bzero(&ifrq, sizeof(ifrq));
+ if (ioctl(be->fd, TAPGIFNAME, &ifrq) < 0) {
+ WPRINTF(("Could not get interface name"));
+ goto error;
+ }
+
+ s = -1;
+ for (i = 0; s == -1 && i < nitems(pf_list); i++)
+ s = socket(pf_list[i], SOCK_DGRAM, 0);
+ if (s == -1) {
+ WPRINTF(("Could open socket"));
+ goto error;
+ }
+
+ if (ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
+ (void)close(s);
+ WPRINTF(("Could not get interface flags"));
+ goto error;
+ }
+ ifrq.ifr_flags |= IFF_UP;
+ if (ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) {
+ (void)close(s);
+ WPRINTF(("Could not set interface flags"));
+ goto error;
+ }
+ (void)close(s);
+#endif
+
#ifndef WITHOUT_CAPSICUM
cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE);
if (caph_rights_limit(be->fd, &rights) == -1)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 11:53 PM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15759010
Default Alt Text
D31342.diff (1 KB)
Attached To
Mode
D31342: bhyve: net_backends, automatically IFF_UP tap devices
Attached
Detach File
Event Timeline
Log In to Comment