aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorKingwel Xie <kingwel.xie@ericsson.com>2018-10-26 23:55:47 -0400
committerDamjan Marion <dmarion@me.com>2018-10-27 09:14:30 +0000
commit49cd3bad66cba83f0364d94ed34de2457694f545 (patch)
tree8b11fc08ffb8ad2d411df8d6578bfc3bd3a0e17f /src/vnet
parent4af47092eec97ce88f66174570cfc6a7baad4c6c (diff)
pg: incrementing len should be truncated by
stream->max_packet_bytes This length is the payload length, and will impact the ip length when ip length is not specified. iplen = header_len + payload_len SO, better to make it comply with max_packet_bytes Change-Id: I8b0f7485e29fcaccae656f2d03b3b5e614300fb8 Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/pg/edit.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/vnet/pg/edit.c b/src/vnet/pg/edit.c
index cb4d070fb19..8d1437e96bc 100644
--- a/src/vnet/pg/edit.c
+++ b/src/vnet/pg/edit.c
@@ -129,17 +129,13 @@ unformat_pg_payload (unformat_input_t * input, va_list * args)
pg_stream_t *s = va_arg (*args, pg_stream_t *);
vlib_main_t *vm = vlib_get_main ();
pg_edit_t *e;
- u32 i, node_index, len, max_len;
+ u32 i, node_index, len, max_len, ilen;
u8 *v;
v = 0;
- if (unformat (input, "incrementing %d", &len))
- {
- vec_resize (v, len);
- for (i = 0; i < len; i++)
- v[i] = i;
- }
+ if (unformat (input, "incrementing %d", &ilen))
+ ;
else if (unformat (input, "hex 0x%U", unformat_hex_string, &v))
;
@@ -156,13 +152,20 @@ unformat_pg_payload (unformat_input_t * input, va_list * args)
/* Length not including this payload. */
max_len = pg_edit_group_n_bytes (s, 0);
- if (max_len + vec_len (v) >= s->max_packet_bytes)
+ if (max_len >= s->max_packet_bytes)
{
- if (s->max_packet_bytes >= max_len)
- _vec_len (v) = s->max_packet_bytes - max_len;
- else
- _vec_len (v) = 0;
+ /* no payload */
+ len = 0;
}
+ else
+ {
+ /* make a bigger v to hold the data */
+ len = s->max_packet_bytes - max_len;
+ }
+
+ vec_resize (v, len);
+ for (i = 0; i < len; i++)
+ v[i] = i % ilen;
e = pg_create_edit_group (s, sizeof (e[0]), vec_len (v), 0);