summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKingwel Xie <kingwel.xie@ericsson.com>2019-01-24 03:24:26 -0500
committerDave Barach <openvpp@barachs.net>2019-01-25 15:30:56 +0000
commit8eb102c28aacb6ebd935ac90a8fc6ec2c5585790 (patch)
treeb44bcfa06bdc67975bdb69af7ca76ff3cfa480e2
parent5c1f559b1bf32acd528664e7674a2d46f2aed947 (diff)
pg: bugfix for pg paylod hdr-size
it was specified to 0 after https://gerrit.fd.io/r/16909 causes unformat_pg_ip4_header to wrongly set ip header len. do more check when assigning e->lsb_bit_offset to avoid negative value Change-Id: Ib772c7135cdeb355f0d60f1ee11602f6b5a0ff21 Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
-rw-r--r--src/vnet/pg/edit.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/vnet/pg/edit.c b/src/vnet/pg/edit.c
index a0aab1fb566..7d4e1713c4c 100644
--- a/src/vnet/pg/edit.c
+++ b/src/vnet/pg/edit.c
@@ -167,13 +167,13 @@ unformat_pg_payload (unformat_input_t * input, va_list * args)
for (i = 0; i < len; i++)
v[i] = i % ilen;
- e = pg_create_edit_group (s, sizeof (e[0]), 0, 0);
+ 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;