lpm: use atomic store to avoid partial update
authorRuifeng Wang <ruifeng.wang@arm.com>
Thu, 18 Jul 2019 06:22:30 +0000 (14:22 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 19 Jul 2019 10:37:14 +0000 (12:37 +0200)
commit316095eb41ed22da808b5826404c398917c83c89
treef8d02d7ceaea619b7d6df8db3e7ef4424a09ef24
parentbe8c9ad0c2b8415f6c723d0ce87a2ee7a8c2a082
lpm: use atomic store to avoid partial update

Compiler could generate non-atomic stores for whole table entry
updating. This may cause incorrect nexthop to be returned, if
the byte with valid flag is updated prior to the byte with nexthop
is updated.
Besides, field by field updating of table entries follow
read-modify-write sequences. The operations are not atomic,
nor efficient. And could cause entries out of synchronization.

Changed to use atomic store to update whole table entry.

Suggested-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Suggested-by: Gavin Hu <gavin.hu@arm.com>
Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
lib/librte_lpm/rte_lpm.c