aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/pg/stream.c
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2024-02-19 11:26:23 +0100
committerDave Barach <vpp@barachs.net>2024-02-20 17:20:43 +0000
commit7217dcdb54c8d66cec28ca71697b808099a7bd85 (patch)
tree2f65ecbbc005d014940fd3dbf94ed39da308000a /src/vnet/pg/stream.c
parent088d1a0168cdf0e3ca651cf07012025ba6eab3fa (diff)
pg: fix stream pg interface
When an other interface is specified to generate packets from, we should bind its sw_if_index to the pg interface to use. Fix if_index_by_sw_if_index variable name, and force to specify a pg interface to source traffic from. Type: fix Change-Id: Ib3e6dca92774b307def82926fc09945b7998267d Signed-off-by: Maxime Peim <mpeim@cisco.com>
Diffstat (limited to 'src/vnet/pg/stream.c')
-rw-r--r--src/vnet/pg/stream.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index 112cc09ae97..d68551b1371 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -249,7 +249,7 @@ VNET_HW_INTERFACE_CLASS (pg_tun_hw_interface_class) = {
};
u32
-pg_interface_add_or_get (pg_main_t *pg, uword if_id, u8 gso_enabled,
+pg_interface_add_or_get (pg_main_t *pg, u32 if_id, u8 gso_enabled,
u32 gso_size, u8 coalesce_enabled,
pg_interface_mode_t mode)
{
@@ -315,8 +315,8 @@ pg_interface_add_or_get (pg_main_t *pg, uword if_id, u8 gso_enabled,
hash_set (pg->if_index_by_if_id, if_id, i);
- vec_validate (pg->if_id_by_sw_if_index, hi->sw_if_index);
- pg->if_id_by_sw_if_index[hi->sw_if_index] = i;
+ vec_validate (pg->if_index_by_sw_if_index, hi->sw_if_index);
+ pg->if_index_by_sw_if_index[hi->sw_if_index] = i;
if (vlib_num_workers ())
{
@@ -560,6 +560,11 @@ pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
*/
s->sw_if_index[VLIB_RX] = pi->sw_if_index;
}
+ else if (vec_len (pg->if_index_by_sw_if_index) <= s->sw_if_index[VLIB_RX])
+ {
+ vec_validate (pg->if_index_by_sw_if_index, s->sw_if_index[VLIB_RX]);
+ pg->if_index_by_sw_if_index[s->sw_if_index[VLIB_RX]] = s->pg_if_index;
+ }
/* Connect the graph. */
s->next_index = vlib_node_add_next (vm, device_input_node.index,