diff options
author | Jieqiang Wang <jieqiang.wang@arm.com> | 2021-08-03 16:07:52 +0000 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2021-10-20 18:17:20 +0000 |
commit | cfdb15b3724d22d9c74e95ce0e7dabead7dfef45 (patch) | |
tree | f0318e344e7f6978e875af0c2e0139018cf7eb8c /src/vnet/ip | |
parent | d9e7ac3c9a02083485a898be5e7a977fcffe8a29 (diff) |
ip6: fix IPv6 address calculation error using "ip route add" CLI
Using VPP CLI "ip route add" to add static IPv6 entries outputs wrong
results. Fix this error by correctly calculating IPv6 addresses with
different increased ranges and grouping ip4/ip6 prefix calculation
functionality into two functions.
Type: fix
Signed-off-by: Jieqiang Wang <jieqiang.wang@arm.com>
Reviewed-by: Lijian Zhang <lijian.zhang@arm.com>
Reviewed-by: Tianyu Li <tianyu.li@arm.com>
Change-Id: If954876301ca2095f9331799a086f75db936f246
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/lookup.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index 192c4c7cebc..2bb667bc65a 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -304,20 +304,17 @@ vnet_ip_route_cmd (vlib_main_t * vm, } else if (0 < vec_len (rpaths)) { - u32 k, n, incr; - ip46_address_t dst = prefixs[i].fp_addr; + u32 k, n; f64 t[2]; n = count; t[0] = vlib_time_now (vm); - incr = 1 << ((FIB_PROTOCOL_IP4 == prefixs[0].fp_proto ? 32 : 128) - - prefixs[i].fp_len); for (k = 0; k < n; k++) { fib_prefix_t rpfx = { .fp_len = prefixs[i].fp_len, .fp_proto = prefixs[i].fp_proto, - .fp_addr = dst, + .fp_addr = prefixs[i].fp_addr, }; if (is_del) @@ -329,21 +326,7 @@ vnet_ip_route_cmd (vlib_main_t * vm, FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE, rpaths); - if (FIB_PROTOCOL_IP4 == prefixs[0].fp_proto) - { - dst.ip4.as_u32 = - clib_host_to_net_u32 (incr + - clib_net_to_host_u32 (dst. - ip4.as_u32)); - } - else - { - int bucket = (incr < 64 ? 0 : 1); - dst.ip6.as_u64[bucket] = - clib_host_to_net_u64 (incr + - clib_net_to_host_u64 (dst.ip6.as_u64 - [bucket])); - } + fib_prefix_increment (&prefixs[i]); } t[1] = vlib_time_now (vm); |