Revision 9b136840 sysdep/bsd/krt-sock.c

View differences:

sysdep/bsd/krt-sock.c
207 207
  msg.rtm.rtm_addrs = RTA_DST;
208 208
  msg.rtm.rtm_flags = RTF_UP | RTF_PROTO1;
209 209

  
210
  if (net->n.pxlen == MAX_PREFIX_LENGTH)
210
  if (net_prefix(net->n.addr) == MAX_PREFIX_LENGTH)
211 211
    msg.rtm.rtm_flags |= RTF_HOST;
212 212
  else
213 213
    msg.rtm.rtm_addrs |= RTA_NETMASK;
......
251 251
    _I0(gw) = 0xfe800000 | (i->index & 0x0000ffff);
252 252
#endif
253 253

  
254
  sockaddr_fill(&dst,  BIRD_AF, net->n.prefix, NULL, 0);
255
  sockaddr_fill(&mask, BIRD_AF, ipa_mkmask(net->n.pxlen), NULL, 0);
256
  sockaddr_fill(&gate, BIRD_AF, gw, NULL, 0);
254
  int af = AF_UNSPEC;
255

  
256
  switch (net->n.addr->type) {
257
    case NET_IP4:
258
      af = AF_INET;
259
      break;
260
    case NET_IP6:
261
      af = AF_INET6;
262
      break;
263
    default:
264
      log(L_ERR "KRT: Not sending VPN route %N to kernel", net->n.addr);
265
      return -1;
266
  }
267

  
268

  
269
  sockaddr_fill(&dst,  af, net_prefix(net->n.addr), NULL, 0);
270
  sockaddr_fill(&mask, af, net_pxmask(net->n.addr), NULL, 0);
271
  sockaddr_fill(&gate, af, gw, NULL, 0);
257 272

  
258 273
  switch (a->dest)
259 274
  {
......
299 314
  msg.rtm.rtm_msglen = l;
300 315

  
301 316
  if ((l = write(p->sys.sk->fd, (char *)&msg, l)) < 0) {
302
    log(L_ERR "KRT: Error sending route %I/%d to kernel: %m", net->n.prefix, net->n.pxlen);
317
    log(L_ERR "KRT: Error sending route %N to kernel: %m", net->n.addr);
303 318
    return -1;
304 319
  }
305 320

  
......
335 350
  net *net;
336 351
  sockaddr dst, gate, mask;
337 352
  ip_addr idst, igate, imask;
353
  net_addr ndst;
338 354
  void *body = (char *)msg->buf;
339 355
  int new = (msg->rtm.rtm_type != RTM_DELETE);
340 356
  char *errmsg = "KRT: Invalid route received";
......
386 402
  if (pxlen < 0)
387 403
    { log(L_ERR "%s (%I) - netmask %I", errmsg, idst, imask); return; }
388 404

  
405
  /* XXXX */
406
  net_fill_ipa(&ndst, idst, pxlen);
407

  
389 408
  if ((flags & RTF_GATEWAY) && ipa_zero(igate))
390
    { log(L_ERR "%s (%I/%d) - missing gateway", errmsg, idst, pxlen); return; }
409
    { log(L_ERR "%s (%N) - missing gateway", errmsg, ndst); return; }
391 410

  
392 411
  u32 self_mask = RTF_PROTO1;
393 412
  u32 alien_mask = RTF_STATIC | RTF_PROTO1 | RTF_GATEWAY;
......
426 445
  else
427 446
    src = KRT_SRC_KERNEL;
428 447

  
429
  net = net_get(p->p.table, idst, pxlen);
448
  net = net_get(p->p.table, &ndst);
430 449

  
431 450
  rta a = {
432 451
    .src = p->p.main_source,
......
455 474
  a.iface = if_find_by_index(msg->rtm.rtm_index);
456 475
  if (!a.iface)
457 476
    {
458
      log(L_ERR "KRT: Received route %I/%d with unknown ifindex %u",
459
	  net->n.prefix, net->n.pxlen, msg->rtm.rtm_index);
477
      log(L_ERR "KRT: Received route %N with unknown ifindex %u",
478
	  net->n.addr, msg->rtm.rtm_index);
460 479
      return;
461 480
    }
462 481

  
......
480 499
        if (ipa_classify(a.gw) == (IADDR_HOST | SCOPE_HOST))
481 500
          return;
482 501

  
483
	log(L_ERR "KRT: Received route %I/%d with strange next-hop %I",
484
	    net->n.prefix, net->n.pxlen, a.gw);
502
	log(L_ERR "KRT: Received route %N with strange next-hop %I",
503
	    net->n.addr, a.gw);
485 504
	return;
486 505
      }
487 506
  }
......
652 671
  imask = ipa_from_sa(&mask);
653 672
  ibrd  = ipa_from_sa(&brd);
654 673

  
655

  
674
  /* XXXX */
656 675
  if ((masklen = ipa_masklen(imask)) < 0)
657 676
  {
658 677
    log(L_ERR "KIF: Invalid masklen %I for %s", imask, iface->name);
......
673 692
  bzero(&ifa, sizeof(ifa));
674 693
  ifa.iface = iface;
675 694
  ifa.ip = iaddr;
676
  ifa.pxlen = masklen;
677 695

  
678 696
  scope = ipa_classify(ifa.ip);
679 697
  if (scope < 0)
......
685 703

  
686 704
  if (masklen < BITS_PER_IP_ADDRESS)
687 705
  {
688
    ifa.prefix = ipa_and(ifa.ip, ipa_mkmask(masklen));
706
    net_fill_ipa(&ifa.prefix, ifa.ip, masklen);
707
    net_normalize(&ifa.prefix);
689 708

  
690 709
    if (masklen == (BITS_PER_IP_ADDRESS - 1))
691 710
      ifa.opposite = ipa_opposite_m1(ifa.ip);
......
703 722
  }
704 723
  else if (!(iface->flags & IF_MULTIACCESS) && ipa_nonzero(ibrd))
705 724
  {
706
    ifa.prefix = ifa.opposite = ibrd;
725
    net_fill_ipa(&ifa.prefix, ibrd, BITS_PER_IP_ADDRESS);
726
    ifa.opposite = ibrd;
707 727
    ifa.flags |= IA_PEER;
708 728
  }
709 729
  else
710 730
  {
711
    ifa.prefix = ifa.ip;
731
    net_fill_ipa(&ifa.prefix, ifa.ip, BITS_PER_IP_ADDRESS);
712 732
    ifa.flags |= IA_HOST;
713 733
  }
714 734

  

Also available in: Unified diff