goto error;
}
+ /* bind before rx ring is cfged so we don't receive packets from other interfaces */
+ memset (&sll, 0, sizeof (sll));
+ sll.sll_family = PF_PACKET;
+ sll.sll_protocol = htons (ETH_P_ALL);
+ sll.sll_ifindex = host_if_index;
+ if ((err = bind (*fd, (struct sockaddr *) &sll, sizeof (sll))) < 0)
+ {
+ DBG_SOCK ("Failed to bind rx packet socket (error %d)", err);
+ ret = VNET_API_ERROR_SYSCALL_ERROR_1;
+ goto error;
+ }
+
if ((err =
setsockopt (*fd, SOL_PACKET, PACKET_VERSION, &ver, sizeof (ver))) < 0)
{
if ((err =
setsockopt (*fd, SOL_PACKET, PACKET_TX_RING, tx_req, req_sz)) < 0)
{
- DBG_SOCK ("Failed to set packet rx ring options");
+ DBG_SOCK ("Failed to set packet tx ring options");
ret = VNET_API_ERROR_SYSCALL_ERROR_1;
goto error;
}
goto error;
}
- memset (&sll, 0, sizeof (sll));
- sll.sll_family = PF_PACKET;
- sll.sll_protocol = htons (ETH_P_ALL);
- sll.sll_ifindex = host_if_index;
-
- if ((err = bind (*fd, (struct sockaddr *) &sll, sizeof (sll))) < 0)
- {
- DBG_SOCK ("Failed to bind rx packet socket (error %d)", err);
- ret = VNET_API_ERROR_SYSCALL_ERROR_1;
- goto error;
- }
-
return 0;
error:
if (*fd >= 0)
p = mhash_get (&apm->if_index_by_host_if_name, host_if_name);
if (p)
{
- return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
+ apif = vec_elt_at_index (apm->interfaces, p[0]);
+ *sw_if_index = apif->sw_if_index;
+ return VNET_API_ERROR_IF_ALREADY_EXISTS;
}
vec_validate (rx_req, 0);
template.file_descriptor = fd;
template.private_data = if_index;
template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED;
+ template.description = format (0, "%U", format_af_packet_device_name,
+ if_index);
apif->clib_file_index = clib_file_add (&file_main, &template);
}
hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ if (hw->dev_class_index != af_packet_device_class.index)
+ return VNET_API_ERROR_INVALID_INTERFACE;
+
if (set)
hw->flags &= ~VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD;
else