summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2018-10-28 15:54:28 +0100
committerXavier Simonart <xavier.simonart@intel.com>2018-10-30 11:54:43 +0100
commit7a15b2e3e49cce7c8cfd1d0a03ee5cf82676bdcb (patch)
tree8f2ca437342e89f49bdaffaa2bf7e9a9895299e9 /VNFs/DPPD-PROX
parentffdcfa6b834d3ad00188ee9805370d6aefc44b4b (diff)
Fix potential crash when shuffling mbufs
Change-Id: I70de6345afc6a696906f006c1b0f44540ae4ecec Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX')
-rw-r--r--VNFs/DPPD-PROX/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/VNFs/DPPD-PROX/main.c b/VNFs/DPPD-PROX/main.c
index 2e1616af..ec1ecb58 100644
--- a/VNFs/DPPD-PROX/main.c
+++ b/VNFs/DPPD-PROX/main.c
@@ -571,13 +571,14 @@ static void shuffle_mempool(struct rte_mempool* mempool, uint32_t nb_mbuf)
struct rte_mbuf** pkts = prox_zmalloc(nb_mbuf * sizeof(*pkts), rte_socket_id());
uint64_t got = 0;
- while (rte_mempool_get_bulk(mempool, (void**)(pkts + got), 1) == 0)
+ while ((got < nb_mbuf) && (rte_mempool_get_bulk(mempool, (void**)(pkts + got), 1) == 0))
++got;
+ nb_mbuf = got;
while (got) {
int idx;
do {
- idx = rand() % nb_mbuf - 1;
+ idx = rand() % nb_mbuf;
} while (pkts[idx] == 0);
rte_mempool_put_bulk(mempool, (void**)&pkts[idx], 1);
ref='#n192'>192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280