Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
virtio: fix the out of order descriptors in tx
[vpp.git]
/
src
/
vnet
/
unix
/
tuntap.c
diff --git
a/src/vnet/unix/tuntap.c
b/src/vnet/unix/tuntap.c
index
fc1ecb2
..
72c4f73
100644
(file)
--- a/
src/vnet/unix/tuntap.c
+++ b/
src/vnet/unix/tuntap.c
@@
-146,7
+146,7
@@
static tuntap_main_t tuntap_main = {
static uword
tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
{
static uword
tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 *buffers = vlib_frame_args (frame);
+ u32 *buffers = vlib_frame_
vector_
args (frame);
uword n_packets = frame->n_vectors;
tuntap_main_t *tm = &tuntap_main;
vnet_main_t *vnm = vnet_get_main ();
uword n_packets = frame->n_vectors;
tuntap_main_t *tm = &tuntap_main;
vnet_main_t *vnm = vnet_get_main ();
@@
-166,7
+166,8
@@
tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
if (tm->is_ether && (!tm->have_normal_interface))
{
vlib_buffer_reset (b);
if (tm->is_ether && (!tm->have_normal_interface))
{
vlib_buffer_reset (b);
- clib_memcpy (vlib_buffer_get_current (b), tm->ether_dst_mac, 6);
+ clib_memcpy_fast (vlib_buffer_get_current (b), tm->ether_dst_mac,
+ 6);
}
/* Re-set iovecs if present. */
}
/* Re-set iovecs if present. */
@@
-242,7
+243,7
@@
tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
tuntap_main_t *tm = &tuntap_main;
vlib_buffer_t *b;
u32 bi;
tuntap_main_t *tm = &tuntap_main;
vlib_buffer_t *b;
u32 bi;
- const uword buffer_size =
VLIB_BUFFER_DATA_SIZE
;
+ const uword buffer_size =
vlib_buffer_get_default_data_size (vm)
;
u16 thread_index = vm->thread_index;
/** Make sure we have some RX buffers. */
u16 thread_index = vm->thread_index;
/** Make sure we have some RX buffers. */
@@
-397,6
+398,7
@@
static char *tuntap_rx_error_strings[] = {
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (tuntap_rx_node,static) = {
.function = tuntap_rx,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (tuntap_rx_node,static) = {
.function = tuntap_rx,
+ .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
.name = "tuntap-rx",
.sibling_of = "device-input",
.type = VLIB_NODE_TYPE_INPUT,
.name = "tuntap-rx",
.sibling_of = "device-input",
.type = VLIB_NODE_TYPE_INPUT,
@@
-445,7
+447,7
@@
tuntap_exit (vlib_main_t * vm)
if (sfd < 0)
clib_unix_warning ("provisioning socket");
if (sfd < 0)
clib_unix_warning ("provisioning socket");
- memset (&ifr, 0, sizeof (ifr));
+
clib_
memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
/* get flags, modify to bring down interface... */
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
/* get flags, modify to bring down interface... */
@@
-489,7
+491,7
@@
tuntap_config (vlib_main_t * vm, unformat_input_t * input)
u8 *name;
int flags = IFF_TUN | IFF_NO_PI;
int is_enabled = 0, is_ether = 0, have_normal_interface = 0;
u8 *name;
int flags = IFF_TUN | IFF_NO_PI;
int is_enabled = 0, is_ether = 0, have_normal_interface = 0;
- const uword buffer_size =
VLIB_BUFFER_DATA_SIZE
;
+ const uword buffer_size =
vlib_buffer_get_default_data_size (vm)
;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@
-535,7
+537,7
@@
tuntap_config (vlib_main_t * vm, unformat_input_t * input)
goto done;
}
goto done;
}
- memset (&ifr, 0, sizeof (ifr));
+
clib_
memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
ifr.ifr_flags = flags;
if (ioctl (tm->dev_net_tun_fd, TUNSETIFF, (void *) &ifr) < 0)
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
ifr.ifr_flags = flags;
if (ioctl (tm->dev_net_tun_fd, TUNSETIFF, (void *) &ifr) < 0)
@@
-563,7
+565,7
@@
tuntap_config (vlib_main_t * vm, unformat_input_t * input)
struct ifreq ifr;
struct sockaddr_ll sll;
struct ifreq ifr;
struct sockaddr_ll sll;
- memset (&ifr, 0, sizeof (ifr));
+
clib_
memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
if (ioctl (tm->dev_tap_fd, SIOCGIFINDEX, &ifr) < 0)
{
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
if (ioctl (tm->dev_tap_fd, SIOCGIFINDEX, &ifr) < 0)
{
@@
-572,7
+574,7
@@
tuntap_config (vlib_main_t * vm, unformat_input_t * input)
}
/* Bind the provisioning socket to the interface. */
}
/* Bind the provisioning socket to the interface. */
- memset (&sll, 0, sizeof (sll));
+
clib_
memset (&sll, 0, sizeof (sll));
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons (ETH_P_ALL);
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons (ETH_P_ALL);
@@
-626,7
+628,7
@@
tuntap_config (vlib_main_t * vm, unformat_input_t * input)
goto done;
}
else
goto done;
}
else
- clib_memcpy (tm->ether_dst_mac, ifr.ifr_hwaddr.sa_data, 6);
+ clib_memcpy
_fast
(tm->ether_dst_mac, ifr.ifr_hwaddr.sa_data, 6);
}
if (have_normal_interface)
}
if (have_normal_interface)
@@
-711,7
+713,7
@@
tuntap_ip4_add_del_interface_address (ip4_main_t * im,
/* if the address is being applied to an interface that is not in
* the same table/VRF as this tap, then ignore it.
/* if the address is being applied to an interface that is not in
* the same table/VRF as this tap, then ignore it.
- * If we don't do this overlapping address spaces in the diferent tables
+ * If we don't do this overlapping address spaces in the dif
f
erent tables
* breaks the linux host's routing tables */
if (fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4,
sw_if_index) !=
* breaks the linux host's routing tables */
if (fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4,
sw_if_index) !=
@@
-719,9
+721,9
@@
tuntap_ip4_add_del_interface_address (ip4_main_t * im,
return;
/** See if we already know about this subif */
return;
/** See if we already know about this subif */
- memset (&subif_addr, 0, sizeof (subif_addr));
+
clib_
memset (&subif_addr, 0, sizeof (subif_addr));
subif_addr.sw_if_index = sw_if_index;
subif_addr.sw_if_index = sw_if_index;
- clib_memcpy (&subif_addr.addr, address, sizeof (*address));
+ clib_memcpy
_fast
(&subif_addr.addr, address, sizeof (*address));
p = mhash_get (&tm->subif_mhash, &subif_addr);
p = mhash_get (&tm->subif_mhash, &subif_addr);
@@
-735,7
+737,7
@@
tuntap_ip4_add_del_interface_address (ip4_main_t * im,
}
/* Use subif pool index to select alias device. */
}
/* Use subif pool index to select alias device. */
- memset (&ifr, 0, sizeof (ifr));
+
clib_
memset (&ifr, 0, sizeof (ifr));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));
@@
-753,7
+755,7
@@
tuntap_ip4_add_del_interface_address (ip4_main_t * im,
/* Set ipv4 address, netmask. */
sin->sin_family = AF_INET;
/* Set ipv4 address, netmask. */
sin->sin_family = AF_INET;
- clib_memcpy (&sin->sin_addr.s_addr, address, 4);
+ clib_memcpy
_fast
(&sin->sin_addr.s_addr, address, 4);
if (ioctl (tm->dev_tap_fd, SIOCSIFADDR, &ifr) < 0)
clib_unix_warning ("ioctl SIOCSIFADDR");
if (ioctl (tm->dev_tap_fd, SIOCSIFADDR, &ifr) < 0)
clib_unix_warning ("ioctl SIOCSIFADDR");
@@
-796,7
+798,7
@@
struct in6_ifreq
* @brief Add or Del tun/tap interface address.
*
* Both the v6 interface address API and the way ifconfig
* @brief Add or Del tun/tap interface address.
*
* Both the v6 interface address API and the way ifconfig
- * displays subinterfaces differ from their v4 couterparts.
+ * displays subinterfaces differ from their v4 cou
n
terparts.
* The code given here seems to work but YMMV.
*
* @param *im - ip6_main_t
* The code given here seems to work but YMMV.
*
* @param *im - ip6_main_t
@@
-827,7
+829,7
@@
tuntap_ip6_add_del_interface_address (ip6_main_t * im,
/* if the address is being applied to an interface that is not in
* the same table/VRF as this tap, then ignore it.
/* if the address is being applied to an interface that is not in
* the same table/VRF as this tap, then ignore it.
- * If we don't do this overlapping address spaces in the diferent tables
+ * If we don't do this overlapping address spaces in the dif
f
erent tables
* breaks the linux host's routing tables */
if (fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP6,
sw_if_index) !=
* breaks the linux host's routing tables */
if (fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP6,
sw_if_index) !=
@@
-835,10
+837,10
@@
tuntap_ip6_add_del_interface_address (ip6_main_t * im,
return;
/* See if we already know about this subif */
return;
/* See if we already know about this subif */
- memset (&subif_addr, 0, sizeof (subif_addr));
+
clib_
memset (&subif_addr, 0, sizeof (subif_addr));
subif_addr.sw_if_index = sw_if_index;
subif_addr.is_v6 = 1;
subif_addr.sw_if_index = sw_if_index;
subif_addr.is_v6 = 1;
- clib_memcpy (&subif_addr.addr, address, sizeof (*address));
+ clib_memcpy
_fast
(&subif_addr.addr, address, sizeof (*address));
p = mhash_get (&tm->subif_mhash, &subif_addr);
p = mhash_get (&tm->subif_mhash, &subif_addr);
@@
-852,8
+854,8
@@
tuntap_ip6_add_del_interface_address (ip6_main_t * im,
}
/* Use subif pool index to select alias device. */
}
/* Use subif pool index to select alias device. */
- memset (&ifr, 0, sizeof (ifr));
- memset (&ifr6, 0, sizeof (ifr6));
+
clib_
memset (&ifr, 0, sizeof (ifr));
+
clib_
memset (&ifr6, 0, sizeof (ifr6));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));
@@
-874,7
+876,7
@@
tuntap_ip6_add_del_interface_address (ip6_main_t * im,
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = address_length;
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = address_length;
- clib_memcpy (&ifr6.ifr6_addr, address, 16);
+ clib_memcpy
_fast
(&ifr6.ifr6_addr, address, 16);
if (ioctl (sockfd, SIOCSIFADDR, &ifr6) < 0)
clib_unix_warning ("set address");
if (ioctl (sockfd, SIOCSIFADDR, &ifr6) < 0)
clib_unix_warning ("set address");
@@
-893,7
+895,7
@@
tuntap_ip6_add_del_interface_address (ip6_main_t * im,
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = address_length;
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = address_length;
- clib_memcpy (&ifr6.ifr6_addr, address, 16);
+ clib_memcpy
_fast
(&ifr6.ifr6_addr, address, 16);
if (ioctl (sockfd, SIOCDIFADDR, &ifr6) < 0)
clib_unix_warning ("del address");
if (ioctl (sockfd, SIOCDIFADDR, &ifr6) < 0)
clib_unix_warning ("del address");
@@
-934,7
+936,7
@@
static void
tuntap_nopunt_frame (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
tuntap_nopunt_frame (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- u32 *buffers = vlib_frame_args (frame);
+ u32 *buffers = vlib_frame_
vector_
args (frame);
uword n_packets = frame->n_vectors;
vlib_buffer_free (vm, buffers, n_packets);
vlib_frame_free (vm, node, frame);
uword n_packets = frame->n_vectors;
vlib_buffer_free (vm, buffers, n_packets);
vlib_frame_free (vm, node, frame);
@@
-980,7
+982,7
@@
tuntap_intfc_tx (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
tuntap_main_t *tm = &tuntap_main;
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
tuntap_main_t *tm = &tuntap_main;
- u32 *buffers = vlib_frame_args (frame);
+ u32 *buffers = vlib_frame_
vector_
args (frame);
uword n_buffers = frame->n_vectors;
/* Normal interface transmit happens only on the normal interface... */
uword n_buffers = frame->n_vectors;
/* Normal interface transmit happens only on the normal interface... */
@@
-1010,7
+1012,6
@@
VNET_DEVICE_CLASS (tuntap_dev_class,static) = {
static clib_error_t *
tuntap_init (vlib_main_t * vm)
{
static clib_error_t *
tuntap_init (vlib_main_t * vm)
{
- clib_error_t *error;
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
ip4_add_del_interface_address_callback_t cb4;
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
ip4_add_del_interface_address_callback_t cb4;
@@
-1018,10
+1019,6
@@
tuntap_init (vlib_main_t * vm)
tuntap_main_t *tm = &tuntap_main;
vlib_thread_main_t *m = vlib_get_thread_main ();
tuntap_main_t *tm = &tuntap_main;
vlib_thread_main_t *m = vlib_get_thread_main ();
- error = vlib_call_init_function (vm, ip4_init);
- if (error)
- return error;
-
mhash_init (&tm->subif_mhash, sizeof (u32), sizeof (subif_address_t));
cb4.function = tuntap_ip4_add_del_interface_address;
mhash_init (&tm->subif_mhash, sizeof (u32), sizeof (subif_address_t));
cb4.function = tuntap_ip4_add_del_interface_address;
@@
-1037,7
+1034,12
@@
tuntap_init (vlib_main_t * vm)
return 0;
}
return 0;
}
-VLIB_INIT_FUNCTION (tuntap_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (tuntap_init) =
+{
+ .runs_after = VLIB_INITS("ip4_init"),
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
/*
* fd.io coding-style-patch-verification: ON