Revision 04632fd7 nest/rt-fib.c

View differences:

nest/rt-fib.c
43 43
#define HASH_DEF_ORDER 10
44 44
#define HASH_HI_MARK *4
45 45
#define HASH_HI_STEP 2
46
#define HASH_HI_MAX 16			/* Must be at most 16 */
46
#define HASH_HI_MAX 16
47 47
#define HASH_LO_MARK /5
48 48
#define HASH_LO_STEP 2
49 49
#define HASH_LO_MIN 10
......
266 266
  return b;
267 267
}
268 268

  
269
static void *
270
fib_route_ip4(struct fib *f, const net_addr *n0)
269
static inline void *
270
fib_route_ip4(struct fib *f, net_addr_ip4 *n)
271 271
{
272
  net_addr net;
273
  net_addr_ip4 *n = (net_addr_ip4 *) &net;
274
  void *b;
272
  void *r;
275 273

  
276
  net_copy(&net, n0);
277
  while (!(b = fib_find(f, &net)) && (n->pxlen > 0))
274
  while (!(r = fib_find(f, (net_addr *) n)) && (n->pxlen > 0))
278 275
  {
279 276
    n->pxlen--;
280 277
    ip4_clrbit(&n->prefix, n->pxlen);
281 278
  }
282 279

  
283
  return b;
280
  return r;
284 281
}
285 282

  
286
static void *
287
fib_route_ip6(struct fib *f, const net_addr *n0)
283
static inline void *
284
fib_route_ip6(struct fib *f, net_addr_ip6 *n)
288 285
{
289
  net_addr net;
290
  net_addr_ip6 *n = (net_addr_ip6 *) &net;
291
  void *b;
286
  void *r;
292 287

  
293
  net_copy(&net, n0);
294
  while (!(b = fib_find(f, &net)) && (n->pxlen > 0))
288
  while (!(r = fib_find(f, (net_addr *) n)) && (n->pxlen > 0))
295 289
  {
296 290
    n->pxlen--;
297 291
    ip6_clrbit(&n->prefix, n->pxlen);
298 292
  }
299 293

  
300
  return b;
294
  return r;
301 295
}
302 296

  
303 297
/**
......
314 308
{
315 309
  ASSERT(f->addr_type == n->type);
316 310

  
311
  net_addr *n0 = alloca(n->length);
312
  net_copy(n0, n);
313

  
317 314
  switch (n->type)
318 315
  {
319 316
  case NET_IP4:
320 317
  case NET_VPN4:
321
    return fib_route_ip4(f, n);
318
    return fib_route_ip4(f, (net_addr_ip4 *) n0);
322 319

  
323 320
  case NET_IP6:
324 321
  case NET_VPN6:
325
    return fib_route_ip6(f, n);
322
    return fib_route_ip6(f, (net_addr_ip6 *) n0);
326 323

  
327 324
  default:
328 325
    return NULL;
329 326
  }
330 327
}
331 328

  
329

  
332 330
static inline void
333 331
fib_merge_readers(struct fib_iterator *i, struct fib_node *to)
334 332
{
......
398 396
		}
399 397
	      fib_merge_readers(it, l);
400 398
	    }
401
	  sl_free(f->fib_slab, e);
399

  
400
	  if (f->fib_slab)
401
	    sl_free(f->fib_slab, E);
402
	  else
403
	    mb_free(E);
404

  
402 405
	  if (f->entries-- < f->entries_min)
403 406
	    fib_rehash(f, -HASH_LO_STEP);
404 407
	  return;

Also available in: Unified diff