From: Xuelin Shi <xuelin....@freescale.com> struct tbl_entry{ uint8_t next_hop; uint8_t valid :1; uint8_t valid_group :1; uint8_t depth :6 } uint16_t tbl = (uint16_t)tbl_entry; next_hop = (uint8_t)tbl;
next_hop cannot get the correct value of the field if the cpu arch is BIG_ENDIAN. change it to field access. Signed-off-by: Xuelin Shi <xuelin.shi at freescale.com> --- lib/librte_lpm/rte_lpm.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h index 586300b..1af150c 100644 --- a/lib/librte_lpm/rte_lpm.h +++ b/lib/librte_lpm/rte_lpm.h @@ -273,6 +273,7 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) { unsigned tbl24_index = (ip >> 8); uint16_t tbl_entry; + struct rte_lpm_tbl8_entry *entry; /* DEBUG: Check user input arguments. */ RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop == NULL)), -EINVAL); @@ -290,8 +291,10 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop) tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index]; } - *next_hop = (uint8_t)tbl_entry; - return (tbl_entry & RTE_LPM_LOOKUP_SUCCESS) ? 0 : -ENOENT; + entry = (struct rte_lpm_tbl8_entry *)&tbl_entry; + *next_hop = entry->next_hop; + + return (entry->valid) ? 0 : -ENOENT; } /** -- 1.9.1