Skip to content

Commit

Permalink
Fix ipv6 route table base calculation
Browse files Browse the repository at this point in the history
Wrong pointer math made ipv6 route table base to overlap with ipv4 route
table, resulting in unpredictable tables and memory corruption.

Change-Id: Ia31a555cf3abb108af31c1ee74c4cd7384570de6
Closes-BUG: #1439654
  • Loading branch information
anandhk-juniper committed Apr 13, 2015
1 parent 2356473 commit 8a04d5f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dp-core/vr_ip_mtrie.c
Expand Up @@ -1054,8 +1054,7 @@ mtrie_algo_deinit(struct vr_rtable *rtable, struct rtable_fspec *fs, bool soft_r
static int
mtrie_stats_init(struct vr_rtable *rtable)
{
int ret = 0;
unsigned int i;
int ret = 0, i;
unsigned int stats_memory;

stats_memory = sizeof(void *) * rtable->algo_max_vrfs;
Expand Down Expand Up @@ -1132,9 +1131,11 @@ mtrie_algo_init(struct vr_rtable *rtable, struct rtable_fspec *fs)
vr_inet_route_lookup = mtrie_lookup;
vr_inet_vrf_stats = mtrie_stats;
/* local cache */
vn_rtable[0] = (struct ip_mtrie **)rtable->algo_data; // V4 table
vn_rtable[1] = (struct ip_mtrie **)((char*)rtable->algo_data
+ fs->rtb_max_vrfs); // V6 table
/* ipv4 table */
vn_rtable[0] = (struct ip_mtrie **)rtable->algo_data;
/* ipv6 table */
vn_rtable[1] = (struct ip_mtrie **)((unsigned char **)rtable->algo_data
+ fs->rtb_max_vrfs);

mtrie_ip_bkt_info_init(ip4_bkt_info, IP4_PREFIX_LEN);
mtrie_ip_bkt_info_init(ip6_bkt_info, IP6_PREFIX_LEN);
Expand Down

0 comments on commit 8a04d5f

Please sign in to comment.