X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fpg%2Fedit.c;h=df057d2ba709e3bfc8a55e8b07cec5c49427ce83;hb=d9035a4092bd18259ab00960fe032486bfce61d8;hp=cb4d070fb19af99fd52916049e2fdee7223c824b;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vnet/pg/edit.c b/src/vnet/pg/edit.c index cb4d070fb19..df057d2ba70 100644 --- a/src/vnet/pg/edit.c +++ b/src/vnet/pg/edit.c @@ -138,11 +138,10 @@ unformat_pg_payload (unformat_input_t * input, va_list * args) { vec_resize (v, len); for (i = 0; i < len; i++) - v[i] = 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); @@ -156,21 +155,27 @@ 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) + { + /* no payload */ + len = 0; + } + else { - if (s->max_packet_bytes >= max_len) - _vec_len (v) = s->max_packet_bytes - max_len; - else - _vec_len (v) = 0; + /* make a bigger v to hold the data */ + len = s->max_packet_bytes - max_len; } - e = pg_create_edit_group (s, sizeof (e[0]), vec_len (v), 0); + vec_resize (v, len); + + e = pg_create_edit_group (s, sizeof (e[0]), len, 0); e->type = PG_EDIT_FIXED; - e->n_bits = vec_len (v) * BITS (v[0]); + e->n_bits = len * BITS (v[0]); /* Least significant bit is at end of bitstream, since everything is always bigendian. */ - e->lsb_bit_offset = e->n_bits - BITS (v[0]); + e->lsb_bit_offset = len > 0 ? e->n_bits - BITS (v[0]) : 0; e->values[PG_EDIT_LO] = v;