Revision fe9f1a6d proto/ospf/topology.c

View differences:

proto/ospf/topology.c
283 283

  
284 284
  if (en->nf != lsa->nf)
285 285
  {
286
    log(L_ERR "%s: LSA ID collision for %I/%d",
287
	p->p.name, lsa->nf->fn.prefix, lsa->nf->fn.pxlen);
286
    log(L_ERR "%s: LSA ID collision for %N",
287
	p->p.name, lsa->nf->fn.addr);
288 288

  
289 289
    en = NULL;
290 290
    goto drop;
......
520 520
  /*
521 521
   * In OSPFv2, We have to map IP prefixes to u32 in such manner that resulting
522 522
   * u32 interpreted as IP address is a member of given prefix. Therefore, /32
523
   * prefix have to be mapped on itself.  All received prefixes have to be
524
   * mapped on different u32s.
523
   * prefix has to be mapped on itself.  All received prefixes have to be mapped
524
   * on different u32s.
525 525
   *
526 526
   * We have an assumption that if there is nontrivial (non-/32) network prefix,
527 527
   * then there is not /32 prefix for the first and the last IP address of the
......
551 551
  if (ospf_is_v3(p))
552 552
    return nf->fn.uid;
553 553

  
554
  u32 id = ipa_to_u32(nf->fn.prefix);
555
  int pxlen = nf->fn.pxlen;
554
  net_addr_ip4 *net = (void *) nf->fn.addr;
555
  u32 id = ip4_to_u32(net->prefix);
556
  int pxlen = net->pxlen;
556 557

  
557 558
  if ((pxlen == 0) || (pxlen == 32))
558 559
    return id;
......
999 1000
{
1000 1001
  struct ospf_lsa_sum3_net *sum;
1001 1002

  
1002
  sum = lsab_allocz(p, sizeof(struct ospf_lsa_sum3_net) + IPV6_PREFIX_SPACE(nf->fn.pxlen));
1003
  sum = lsab_allocz(p, sizeof(struct ospf_lsa_sum3_net) +
1004
		    IPV6_PREFIX_SPACE(nf->fn.addr->pxlen));
1003 1005
  sum->metric = metric;
1004
  put_ipv6_prefix(sum->prefix, nf->fn.prefix, nf->fn.pxlen, 0, 0);
1006
  ospf_put_ipv6_prefix(sum->prefix, nf->fn.addr, 0, 0);
1005 1007
}
1006 1008

  
1007 1009
static inline void
......
1028 1030
  };
1029 1031

  
1030 1032
  if (ospf_is_v2(p))
1031
    prepare_sum2_lsa_body(p, nf->fn.pxlen, metric);
1033
    prepare_sum2_lsa_body(p, nf->fn.addr->pxlen, metric);
1032 1034
  else
1033 1035
    prepare_sum3_net_lsa_body(p, nf, metric);
1034 1036

  
......
1036 1038
}
1037 1039

  
1038 1040
void
1039
ospf_originate_sum_rt_lsa(struct ospf_proto *p, struct ospf_area *oa, ort *nf, int metric, u32 options)
1041
ospf_originate_sum_rt_lsa(struct ospf_proto *p, struct ospf_area *oa, u32 drid, int metric, u32 options)
1040 1042
{
1041 1043
  struct ospf_new_lsa lsa = {
1042 1044
    .type = LSA_T_SUM_RT,
1043 1045
    .mode = LSA_M_RTCALC,
1044 1046
    .dom  = oa->areaid,
1045
    .id   = ipa_to_rid(nf->fn.prefix),	/* Router ID of ASBR, irrelevant for OSPFv3 */
1047
    .id   = drid,	/* Router ID of ASBR, irrelevant for OSPFv3 */
1046 1048
    .opts = oa->options
1047 1049
  };
1048 1050

  
1049 1051
  if (ospf_is_v2(p))
1050 1052
    prepare_sum2_lsa_body(p, 0, metric);
1051 1053
  else
1052
    prepare_sum3_rt_lsa_body(p, lsa.id, metric, options & LSA_OPTIONS_MASK);
1054
    prepare_sum3_rt_lsa_body(p, drid, metric, options & LSA_OPTIONS_MASK);
1053 1055

  
1054 1056
  ospf_originate_lsa(p, &lsa);
1055 1057
}
......
1082 1084
{
1083 1085
  struct ospf_lsa_ext3 *ext;
1084 1086
  int bsize = sizeof(struct ospf_lsa_ext3)
1085
    + IPV6_PREFIX_SPACE(nf->fn.pxlen)
1087
    + IPV6_PREFIX_SPACE(nf->fn.addr->pxlen)
1086 1088
    + (ipa_nonzero(fwaddr) ? 16 : 0)
1087 1089
    + (tag ? 4 : 0);
1088 1090

  
......
1090 1092
  ext->metric = metric & LSA_METRIC_MASK;
1091 1093
  u32 *buf = ext->rest;
1092 1094

  
1093
  buf = put_ipv6_prefix(buf, nf->fn.prefix, nf->fn.pxlen, pbit ? OPT_PX_P : 0, 0);
1095
  buf = ospf_put_ipv6_prefix(buf, nf->fn.addr, pbit ? OPT_PX_P : 0, 0);
1094 1096

  
1095 1097
  if (ebit)
1096 1098
    ext->metric |= LSA_EXT3_EBIT;
......
1098 1100
  if (ipa_nonzero(fwaddr))
1099 1101
  {
1100 1102
    ext->metric |= LSA_EXT3_FBIT;
1101
    buf = put_ipv6_addr(buf, fwaddr);
1103
    buf = ospf_put_ipv6_addr(buf, fwaddr);
1102 1104
  }
1103 1105

  
1104 1106
  if (tag)
......
1140 1142
  };
1141 1143

  
1142 1144
  if (ospf_is_v2(p))
1143
    prepare_ext2_lsa_body(p, nf->fn.pxlen, metric, ebit, fwaddr, tag);
1145
    prepare_ext2_lsa_body(p, nf->fn.addr->pxlen, metric, ebit, fwaddr, tag);
1144 1146
  else
1145 1147
    prepare_ext3_lsa_body(p, nf, metric, ebit, fwaddr, tag, oa && pbit);
1146 1148

  
......
1253 1255

  
1254 1256
  if (!new)
1255 1257
  {
1256
    nf = (ort *) fib_find(&p->rtf, &n->n.prefix, n->n.pxlen);
1258
    nf = fib_find(&p->rtf, n->n.addr);
1257 1259

  
1258 1260
    if (!nf || !nf->external_rte)
1259 1261
      return;
......
1290 1292

  
1291 1293
    if (ipa_zero(fwd))
1292 1294
    {
1293
      log(L_ERR "%s: Cannot find forwarding address for NSSA-LSA %I/%d",
1294
	  p->p.name, n->n.prefix, n->n.pxlen);
1295
      log(L_ERR "%s: Cannot find forwarding address for NSSA-LSA %N",
1296
	  p->p.name, n->n.addr);
1295 1297
      return;
1296 1298
    }
1297 1299
  }
1298 1300

  
1299
  nf = (ort *) fib_get(&p->rtf, &n->n.prefix, n->n.pxlen);
1301
  nf = fib_get(&p->rtf, n->n.addr);
1300 1302
  ospf_originate_ext_lsa(p, oa, nf, LSA_M_EXPORT, metric, ebit, fwd, tag, 1);
1301 1303
  nf->external_rte = 1;
1302 1304
}
......
1308 1310
 */
1309 1311

  
1310 1312
static inline void
1311
lsab_put_prefix(struct ospf_proto *p, ip_addr prefix, u32 pxlen, u32 cost)
1313
lsab_put_prefix(struct ospf_proto *p, ip6_addr prefix, u32 pxlen, u32 cost)
1312 1314
{
1315
  net_addr_ip6 net = NET_ADDR_IP6(prefix, pxlen);
1313 1316
  void *buf = lsab_alloc(p, IPV6_PREFIX_SPACE(pxlen));
1314
  u8 flags = (pxlen < MAX_PREFIX_LENGTH) ? 0 : OPT_PX_LA;
1315
  put_ipv6_prefix(buf, prefix, pxlen, flags, cost);
1317
  u8 flags = (pxlen < IP6_MAX_PREFIX_LENGTH) ? 0 : OPT_PX_LA;
1318
  ospf_put_ipv6_prefix(buf, (net_addr *) &net, flags, cost);
1316 1319
}
1317 1320

  
1318 1321
static void
......
1406 1409
	  (a->scope <= SCOPE_LINK))
1407 1410
	continue;
1408 1411

  
1409
      if (((a->pxlen < MAX_PREFIX_LENGTH) && net_lsa) ||
1412
      if (((a->pxlen < IP6_MAX_PREFIX_LENGTH) && net_lsa) ||
1410 1413
	  configured_stubnet(oa, a))
1411 1414
	continue;
1412 1415

  
......
1414 1417
	  (ifa->state == OSPF_IS_LOOP) ||
1415 1418
	  (ifa->type == OSPF_IT_PTMP))
1416 1419
      {
1417
	lsab_put_prefix(p, a->ip, MAX_PREFIX_LENGTH, 0);
1420
	lsab_put_prefix(p, a->ip, IP6_MAX_PREFIX_LENGTH, 0);
1418 1421
	host_addr = 1;
1419 1422
      }
1420 1423
      else
......
1430 1433
    if (!sn->hidden)
1431 1434
    {
1432 1435
      lsab_put_prefix(p, sn->px.addr, sn->px.len, sn->cost);
1433
      if (sn->px.len == MAX_PREFIX_LENGTH)
1436
      if (sn->px.len == IP6_MAX_PREFIX_LENGTH)
1434 1437
	host_addr = 1;
1435 1438
      i++;
1436 1439
    }
......
1451 1454
	  continue;
1452 1455

  
1453 1456
	/* Found some IP */
1454
	lsab_put_prefix(p, a->ip, MAX_PREFIX_LENGTH, 0);
1457
	lsab_put_prefix(p, a->ip, IP6_MAX_PREFIX_LENGTH, 0);
1455 1458
	i++;
1456 1459
	goto done;
1457 1460
      }

Also available in: Unified diff