Revision fe9f1a6d proto/rip/rip.c

View differences:

proto/rip/rip.c
92 92
 *	RIP routes
93 93
 */
94 94

  
95
static void
96
rip_init_entry(struct fib_node *fn)
97
{
98
  // struct rip_entry *en = (void) *fn;
99

  
100
  const uint offset = OFFSETOF(struct rip_entry, routes);
101
  memset((byte *)fn + offset, 0, sizeof(struct rip_entry) - offset);
102
}
103

  
104 95
static struct rip_rte *
105 96
rip_add_rte(struct rip_proto *p, struct rip_rte **rp, struct rip_rte *src)
106 97
{
......
152 143
  if (rt)
153 144
  {
154 145
    /* Update */
155
    net *n = net_get(p->p.table, en->n.prefix, en->n.pxlen);
146
    net *n = net_get(p->p.table, en->n.addr);
156 147

  
157 148
    rta a0 = {
158 149
      .src = p->p.main_source,
......
221 212
  else
222 213
  {
223 214
    /* Withdraw */
224
    net *n = net_find(p->p.table, en->n.prefix, en->n.pxlen);
215
    net *n = net_find(p->p.table, en->n.addr);
225 216
    rte_update(&p->p, n, NULL);
226 217
  }
227 218
}
......
229 220
/**
230 221
 * rip_update_rte - enter a route update to RIP routing table
231 222
 * @p: RIP instance
232
 * @prefix: network prefix
233
 * @pxlen: network prefix length
223
 * @addr: network address
234 224
 * @new: a &rip_rte representing the new route
235 225
 *
236 226
 * The function is called by the RIP packet processing code whenever it receives
......
240 230
 * rip_withdraw_rte() should be called instead of rip_update_rte().
241 231
 */
242 232
void
243
rip_update_rte(struct rip_proto *p, ip_addr *prefix, int pxlen, struct rip_rte *new)
233
rip_update_rte(struct rip_proto *p, net_addr *n, struct rip_rte *new)
244 234
{
245
  struct rip_entry *en = fib_get(&p->rtable, prefix, pxlen);
235
  struct rip_entry *en = fib_get(&p->rtable, n);
246 236
  struct rip_rte *rt, **rp;
247 237
  int changed = 0;
248 238

  
......
282 272
/**
283 273
 * rip_withdraw_rte - enter a route withdraw to RIP routing table
284 274
 * @p: RIP instance
285
 * @prefix: network prefix
286
 * @pxlen: network prefix length
275
 * @addr: network address
287 276
 * @from: a &rip_neighbor propagating the withdraw
288 277
 *
289 278
 * The function is called by the RIP packet processing code whenever it receives
......
291 280
 * removed. Eventually, the change is also propagated by rip_announce_rte().
292 281
 */
293 282
void
294
rip_withdraw_rte(struct rip_proto *p, ip_addr *prefix, int pxlen, struct rip_neighbor *from)
283
rip_withdraw_rte(struct rip_proto *p, net_addr *n, struct rip_neighbor *from)
295 284
{
296
  struct rip_entry *en = fib_find(&p->rtable, prefix, pxlen);
285
  struct rip_entry *en = fib_find(&p->rtable, n);
297 286
  struct rip_rte *rt, **rp;
298 287

  
299 288
  if (!en)
......
335 324

  
336 325
    if (rt_metric > p->infinity)
337 326
    {
338
      log(L_WARN "%s: Invalid rip_metric value %u for route %I/%d",
339
	  p->p.name, rt_metric, net->n.prefix, net->n.pxlen);
327
      log(L_WARN "%s: Invalid rip_metric value %u for route %N",
328
	  p->p.name, rt_metric, net->n.addr);
340 329
      rt_metric = p->infinity;
341 330
    }
342 331

  
343 332
    if (rt_tag > 0xffff)
344 333
    {
345
      log(L_WARN "%s: Invalid rip_tag value %u for route %I/%d",
346
	  p->p.name, rt_tag, net->n.prefix, net->n.pxlen);
334
      log(L_WARN "%s: Invalid rip_tag value %u for route %N",
335
	  p->p.name, rt_tag, net->n.addr);
347 336
      rt_metric = p->infinity;
348 337
      rt_tag = 0;
349 338
    }
......
355 344
     * collection.
356 345
     */
357 346

  
358
    en = fib_get(&p->rtable, &net->n.prefix, net->n.pxlen);
347
    en = fib_get(&p->rtable, net->n.addr);
359 348

  
360 349
    old_metric = en->valid ? en->metric : -1;
361 350

  
......
369 358
  else
370 359
  {
371 360
    /* Withdraw */
372
    en = fib_find(&p->rtable, &net->n.prefix, net->n.pxlen);
361
    en = fib_find(&p->rtable, net->n.addr);
373 362

  
374 363
    if (!en || en->valid != RIP_ENTRY_VALID)
375 364
      return;
......
875 864

  
876 865
      if (expires <= now)
877 866
      {
878
	// TRACE(D_EVENTS, "entry is too old: %I/%d", en->n.prefix, en->n.pxlen);
867
	// TRACE(D_EVENTS, "entry is too old: %N", en->n.addr);
879 868
	en->valid = 0;
880 869
      }
881 870
      else
......
1108 1097
  struct rip_config *cf = (void *) (P->cf);
1109 1098

  
1110 1099
  init_list(&p->iface_list);
1111
  fib_init(&p->rtable, P->pool, sizeof(struct rip_entry), 0, rip_init_entry);
1100
  fib_init(&p->rtable, P->pool, rip_is_v2(p) ? NET_IP4 : NET_IP6,
1101
	   sizeof(struct rip_entry), OFFSETOF(struct rip_entry, n), 0, NULL);
1112 1102
  p->rte_slab = sl_new(P->pool, sizeof(struct rip_rte));
1113 1103
  p->timer = tm_new_set(P->pool, rip_timer, p, 0, 0);
1114 1104

  
......
1257 1247
  FIB_WALK(&p->rtable, e)
1258 1248
  {
1259 1249
    struct rip_entry *en = (struct rip_entry *) e;
1260
    debug("RIP: entry #%d: %I/%d via %I dev %s valid %d metric %d age %d s\n",
1261
	  i++, en->n.prefix, en->n.pxlen, en->next_hop, en->iface->name,
1250
    debug("RIP: entry #%d: %N via %I dev %s valid %d metric %d age %d s\n",
1251
	  i++, en->n.addr, en->next_hop, en->iface->name,
1262 1252
	  en->valid, en->metric, now - en->changed);
1263 1253
  }
1264 1254
  FIB_WALK_END;

Also available in: Unified diff