Skip to content

Commit

Permalink
rib: fix insertion in some cases
Browse files Browse the repository at this point in the history
[ upstream commit e682b02 ]

According to GCC documentation for __builtin_clz:
Returns the number of leading 0-bits in x,
starting at the most significant bit position.
If x is 0, the result is undefined.
__builtin_clz will be called with 0 if the existing
prefix address matches the one we want to insert.

Fixes: 5a5793a ("rib: add RIB library")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  • Loading branch information
vmedvedk authored and bluca committed Feb 2, 2021
1 parent 862b67b commit 73db17f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librte_rib/rte_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ rte_rib_insert(struct rte_rib *rib, uint32_t ip, uint8_t depth)
/* closest node found, new_node should be inserted in the middle */
common_depth = RTE_MIN(depth, (*tmp)->depth);
common_prefix = ip ^ (*tmp)->ip;
d = __builtin_clz(common_prefix);
d = (common_prefix == 0) ? 32 : __builtin_clz(common_prefix);

common_depth = RTE_MIN(d, common_depth);
common_prefix = ip & rte_rib_depth_to_mask(common_depth);
Expand Down

0 comments on commit 73db17f

Please sign in to comment.