+ /*
+ * make sure host side of interface is 'UP' before binding AF_PACKET
+ * socket on it.
+ */
+ if ((fd2 = socket (AF_UNIX, SOCK_DGRAM, 0)) < 0)
+ {
+ vlib_log_debug (apm->log_class, "Failed to create socket");
+ ret = VNET_API_ERROR_SYSCALL_ERROR_1;
+ goto error;
+ }
+
+ clib_memcpy (ifr.ifr_name, (const char *) host_if_name,
+ vec_len (host_if_name));
+ if ((ret = ioctl (fd2, SIOCGIFINDEX, &ifr)) < 0)
+ {
+ vlib_log_debug (apm->log_class, "af_packet_create error: %d", ret);
+ close (fd2);
+ return VNET_API_ERROR_INVALID_INTERFACE;
+ }
+
+ host_if_index = ifr.ifr_ifindex;
+ if ((ret = ioctl (fd2, SIOCGIFFLAGS, &ifr)) < 0)
+ {
+ vlib_log_warn (apm->log_class, "af_packet_create error: %d", ret);
+ goto error;
+ }
+
+ if (!(ifr.ifr_flags & IFF_UP))
+ {
+ ifr.ifr_flags |= IFF_UP;
+ if ((ret = ioctl (fd2, SIOCSIFFLAGS, &ifr)) < 0)
+ {
+ vlib_log_warn (apm->log_class, "af_packet_create error: %d", ret);
+ goto error;
+ }
+ }
+
+ if (fd2 > -1)
+ close (fd2);
+
+ ret = create_packet_v2_sock (host_if_index, rx_req, tx_req, &fd, &ring);