lpm: avoid race conditions for v20
authorRuifeng Wang <ruifeng.wang@arm.com>
Thu, 18 Jul 2019 06:22:29 +0000 (14:22 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 19 Jul 2019 10:37:09 +0000 (12:37 +0200)
commitbe8c9ad0c2b8415f6c723d0ce87a2ee7a8c2a082
tree05286461826800606429d470a0201a18f26fa0c8
parentdd728f9fe1ddb9aa80c26f8afc1dd641e0710618
lpm: avoid race conditions for v20

When a tbl8 group is getting attached to a tbl24 entry, lookup
might fail even though the entry is configured in the table.

For ex: consider a LPM table configured with 10.10.10.1/24.
When a new entry 10.10.10.32/28 is being added, a new tbl8
group is allocated and tbl24 entry is changed to point to
the tbl8 group. If the tbl24 entry is written without the tbl8
group entries updated, a lookup on 10.10.10.9 will return
failure.

Correct memory orderings are required to ensure that the
store to tbl24 does not happen before the stores to tbl8 group
entries complete.

Besides, explicit structure alignment is used to address atomic
operation building issue with older version clang.

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