Uploaded image for project: 'vpp'
  1. vpp
  2. VPP-980

nat Bisearch algorithm in snat_static_mapping_match has issue

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • 17.10
    • None
    • S-NAT
    • None

      if (vec_len (m->locals))
              {
                hi = vec_len (m->locals) - 1;
                rand = 1 + (random_u32 (&sm->random_seed) % m->locals[hi].prefix);
                while (lo < hi)
                  {
                    mid = ((hi - 1) >> 1) + lo;    ----Mabe there is some mistake here, it should be hi -lo, or it will couse dead loop here.
                    (rand > m->locals[mid].prefix) ? (lo = mid + 1) : (hi = mid);
                  }
                if (!(m->locals[lo].prefix >= rand))
                  return 1;
                mapping->addr = m->locals[lo].addr;
                mapping->port = clib_host_to_net_u16 (m->locals[lo].port);
              }

            flyingeagle23 hui wang
            flyingeagle23 hui wang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: