Revision ab164971

View differences:

nest/rt-table.c
374 374

  
375 375
  if ((n->n.pxlen > BITS_PER_IP_ADDRESS) || !ip_is_prefix(n->n.prefix,n->n.pxlen))
376 376
    {
377
      log(L_BUG "Ignoring bogus prefix %I/%d received via %s",
377
      log(L_WARN "Ignoring bogus prefix %I/%d received via %s",
378 378
	  n->n.prefix, n->n.pxlen, e->sender->name);
379 379
      return 0;
380 380
    }
proto/ospf/ospf.h
587 587
  if (pxl > 96)
588 588
    _I3(*addr) = *buf++;
589 589

  
590
  /* Clean up remaining bits */
591
  if (pxl < 128)
592
    addr->addr[pxl / 32] &= u32_mkmask(pxl % 32);
593

  
590 594
  return buf;
591 595
}
592 596

  
proto/ospf/packet.c
269 269
  struct proto_ospf *po = ifa->oa->po;
270 270
  // struct proto *p = &po->proto;
271 271

  
272
  int src_local = ipa_in_net(sk->faddr, ifa->addr->prefix, ifa->addr->pxlen);
273
  int dst_local = ipa_equal(sk->laddr, ifa->addr->ip);
274
  int dst_mcast = ipa_equal(sk->laddr, AllSPFRouters) || ipa_equal(sk->laddr, AllDRouters);
272
  int src_local, dst_local UNUSED, dst_mcast; 
273
  src_local = ipa_in_net(sk->faddr, ifa->addr->prefix, ifa->addr->pxlen);
274
  dst_local = ipa_equal(sk->laddr, ifa->addr->ip);
275
  dst_mcast = ipa_equal(sk->laddr, AllSPFRouters) || ipa_equal(sk->laddr, AllDRouters);
275 276

  
276 277
#ifdef OSPFv2
277 278
  /* First, we eliminate packets with strange address combinations.
proto/ospf/rt.c
245 245
    .nhs = en->nhs
246 246
  };
247 247

  
248
  if (pxlen < 0 || pxlen > MAX_PREFIX_LENGTH)
249
  {
250
    log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
251
	oa->po->proto.name, en->lsa.type, en->lsa.id, en->lsa.rt);
252
    return;
253
  }
254

  
248 255
  if (en == oa->rt)
249 256
  {
250 257
    /* 
......
336 343
{
337 344
  // struct proto *p = &oa->po->proto;
338 345
  struct proto_ospf *po = oa->po;
339
  int i;
346
  ip_addr prefix UNUSED;
347
  int pxlen UNUSED, i;
340 348

  
341 349
  struct ospf_lsa_rt *rt = en->lsa_body;
342 350
  struct ospf_lsa_rt_link *rr = (struct ospf_lsa_rt_link *) (rt + 1);
......
357 365
	   * the same result by handing them here because add_network()
358 366
	   * will keep the best (not the first) found route.
359 367
	   */
360
	  add_network(oa, ipa_from_u32(rtl->id),
361
		      ipa_mklen(ipa_from_u32(rtl->data)),
362
		      act->dist + rtl->metric, act, i);
368
	  prefix = ipa_from_u32(rtl->id & rtl->data);
369
	  pxlen = ipa_mklen(ipa_from_u32(rtl->data));
370
	  add_network(oa, prefix, pxlen, act->dist + rtl->metric, act, i);
363 371
	  break;
364 372
#endif
365 373

  
......
398 406
  struct ospf_lsa_rt *rt;
399 407
  struct ospf_lsa_net *ln;
400 408
  struct top_hash_entry *act, *tmp;
409
  ip_addr prefix UNUSED;
410
  int pxlen UNUSED;
401 411
  u32 i, *rts;
402 412
  node *n;
403 413

  
......
470 480
      ln = act->lsa_body;
471 481

  
472 482
#ifdef OSPFv2
473
      add_network(oa, ipa_and(ipa_from_u32(act->lsa.id), ln->netmask),
474
		  ipa_mklen(ln->netmask), act->dist, act, -1);
483
      prefix = ipa_and(ipa_from_u32(act->lsa.id), ln->netmask);
484
      pxlen = ipa_mklen(ln->netmask);
485
      add_network(oa, prefix, pxlen, act->dist, act, -1);
475 486
#endif
476 487

  
477 488
      rts = (u32 *) (ln + 1);
......
618 629
    {
619 630
#ifdef OSPFv2
620 631
      struct ospf_lsa_sum *ls = en->lsa_body;
621
      pxlen = ipa_mklen(ls->netmask);
622 632
      ip = ipa_and(ipa_from_u32(en->lsa.id), ls->netmask);
633
      pxlen = ipa_mklen(ls->netmask);
623 634
#else /* OSPFv3 */
624 635
      u8 pxopts;
625 636
      u16 rest;
......
630 641
	continue;
631 642
#endif
632 643

  
644
      if (pxlen < 0 || pxlen > MAX_PREFIX_LENGTH)
645
      {
646
	log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
647
	    p->name, en->lsa.type, en->lsa.id, en->lsa.rt);
648
	continue;
649
      }
650

  
633 651
      metric = ls->metric & METRIC_MASK;
634 652
      options = 0;
635 653
      type = ORT_NET;
......
695 713
static void
696 714
ospf_rt_sum_tr(struct ospf_area *oa)
697 715
{
698
  // struct proto *p = &oa->po->proto;
716
  struct proto *p = &oa->po->proto;
699 717
  struct proto_ospf *po = oa->po;
700 718
  struct ospf_area *bb = po->backbone;
701 719
  ip_addr abrip;
......
728 746
      int pxlen;
729 747
#ifdef OSPFv2
730 748
      struct ospf_lsa_sum *ls = en->lsa_body;
731
      pxlen = ipa_mklen(ls->netmask);
732 749
      ip = ipa_and(ipa_from_u32(en->lsa.id), ls->netmask);
750
      pxlen = ipa_mklen(ls->netmask);
733 751
#else /* OSPFv3 */
734 752
      u8 pxopts;
735 753
      u16 rest;
......
740 758
	continue;
741 759
#endif
742 760

  
761
      if (pxlen < 0 || pxlen > MAX_PREFIX_LENGTH)
762
      {
763
	log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
764
	    p->name, en->lsa.type, en->lsa.id, en->lsa.rt);
765
	continue;
766
      }
767

  
743 768
      metric = ls->metric & METRIC_MASK;
744 769
      re = fib_find(&po->rtf, &ip, pxlen);
745 770
    }
......
1139 1164
      rt_tag = 0;
1140 1165
#endif
1141 1166

  
1142
    if (pxlen < 0)
1167
    if (pxlen < 0 || pxlen > MAX_PREFIX_LENGTH)
1143 1168
    {
1144
      log(L_WARN "%s: Invalid mask in LSA (Type: %04x, Id: %R, Rt: %R)",
1169
      log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
1145 1170
	  p->name, en->lsa.type, en->lsa.id, en->lsa.rt);
1146 1171
      continue;
1147 1172
    }
......
1703 1728
	e->net = ne;
1704 1729
	e->pref = p->preference;
1705 1730

  
1706

  
1707

  
1708 1731
	DBG("Mod rte type %d - %I/%d via %I on iface %s, met %d\n",
1709 1732
	    a0.source, nf->fn.prefix, nf->fn.pxlen, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1);
1710 1733
	rte_update(p->table, ne, p, p, e);

Also available in: Unified diff