aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/pg
diff options
context:
space:
mode:
authorKingwel Xie <kingwel.xie@ericsson.com>2019-02-13 02:03:33 -0500
committerDamjan Marion <dmarion@me.com>2019-02-20 17:56:55 +0000
commita052b78da508e180fd92ccdb294909e7a076e669 (patch)
tree6537e7ce72e63597d1fc6d7cac7794324fe5d3c7 /src/vnet/pg
parent58ec0f0420961c28abc76cabb91c0f4ee655b298 (diff)
pg: fix payload hex-string bug
Change-Id: I0ea98bf9c203398d9cf85d22994a10217bb511d2 Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
Diffstat (limited to 'src/vnet/pg')
-rw-r--r--src/vnet/pg/edit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/vnet/pg/edit.c b/src/vnet/pg/edit.c
index 7d4e1713c4c..df057d2ba70 100644
--- a/src/vnet/pg/edit.c
+++ b/src/vnet/pg/edit.c
@@ -129,16 +129,19 @@ 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, ilen;
+ u32 i, node_index, len, max_len;
u8 *v;
v = 0;
- if (unformat (input, "incrementing %d", &ilen))
- ;
+ if (unformat (input, "incrementing %d", &len))
+ {
+ vec_resize (v, len);
+ for (i = 0; i < len; i++)
+ v[i] = i % len;
+ }
else if (unformat (input, "hex 0x%U", unformat_hex_string, &v))
;
-
else if (unformat (input, "%U", unformat_vlib_node, vm, &node_index))
{
pg_node_t *pn = pg_get_node (node_index);
@@ -152,6 +155,7 @@ 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 >= s->max_packet_bytes)
{
/* no payload */
@@ -164,8 +168,6 @@ unformat_pg_payload (unformat_input_t * input, va_list * args)
}
vec_resize (v, len);
- for (i = 0; i < len; i++)
- v[i] = i % ilen;
e = pg_create_edit_group (s, sizeof (e[0]), len, 0);