Revision 62e64905 sysdep/linux/netlink.c

View differences:

sysdep/linux/netlink.c
320 320
  [IFA_ADDRESS]	  = { 1, 1, sizeof(ip4_addr) },
321 321
  [IFA_LOCAL]	  = { 1, 1, sizeof(ip4_addr) },
322 322
  [IFA_BROADCAST] = { 1, 1, sizeof(ip4_addr) },
323
  [IFA_FLAGS]     = { 1, 1, sizeof(u32) },
323 324
};
324 325

  
325 326
static struct nl_want_attrs ifa_attr_want6[BIRD_IFA_MAX] = {
......
543 544

  
544 545
  h->nlmsg_len += sizeof(*via);
545 546

  
546
  if (ipa_is_ip4(ipa)) {
547
    ip4_addr ip4 = ipa_to_ip4(ipa);
548
    ip4 = ip4_hton(ip4);
547
  if (ipa_is_ip4(ipa))
548
  {
549 549
    via->rtvia_family = AF_INET;
550
    memcpy(via->rtvia_addr, &ip4, sizeof(ip4));
551
    h->nlmsg_len += sizeof(ip4);
552
  } else {
553
    ip6_addr ip6 = ipa_to_ip6(ipa);
554
    ip6 = ip6_hton(ip6);
550
    put_ip4(via->rtvia_addr, ipa_to_ip4(ipa));
551
    h->nlmsg_len += sizeof(ip4_addr);
552
  }
553
  else
554
  {
555 555
    via->rtvia_family = AF_INET6;
556
    memcpy(via->rtvia_addr, &ip6, sizeof(ip6));
557
    h->nlmsg_len += sizeof(ip6);
556
    put_ip6(via->rtvia_addr, ipa_to_ip6(ipa));
557
    h->nlmsg_len += sizeof(ip6_addr);
558 558
  }
559 559

  
560 560
  nl_close_attr(h, nest);
......
669 669
	}
670 670
      else
671 671
	rv->gw = IPA_NONE;
672

  
672 673
      if (a[RTA_ENCAP_TYPE])
673 674
	{
674 675
	  if (rta_get_u16(a[RTA_ENCAP_TYPE]) != LWTUNNEL_ENCAP_MPLS) {
......
1092 1093
  rta *a = e->attrs;
1093 1094

  
1094 1095
  switch (a->dest)
1095
    {
1096
  {
1096 1097
    case RTD_UNICAST:
1097
      for (struct nexthop *nh = &(a->nh); nh; nh = nh->next)
1098
	if (nh->iface)
1099
	  return 1;
1100
      return 0;
1101 1098
    case RTD_BLACKHOLE:
1102 1099
    case RTD_UNREACHABLE:
1103 1100
    case RTD_PROHIBIT:
1104
      break;
1101
      return 1;
1102

  
1105 1103
    default:
1106 1104
      return 0;
1107
    }
1108
  return 1;
1105
  }
1109 1106
}
1110 1107

  
1111 1108
static inline int
......
1210 1207

  
1211 1208

  
1212 1209
dest:
1213
  /* a->iface != NULL checked in krt_capable() for router and device routes */
1214 1210
  switch (dest)
1215 1211
    {
1216 1212
    case RTD_UNICAST:
......
1502 1498
  switch (i->rtm_type)
1503 1499
    {
1504 1500
    case RTN_UNICAST:
1501
      ra->dest = RTD_UNICAST;
1505 1502

  
1506 1503
      if (a[RTA_MULTIPATH] && (i->rtm_family == AF_INET))
1507 1504
	{
......
1512 1509
	      return;
1513 1510
	    }
1514 1511

  
1515
	  nexthop_link(ra, nh);
1512
	  ra->nh = *nh;
1516 1513
	  break;
1517 1514
	}
1518 1515

  
......
1698 1695
  else
1699 1696
  {
1700 1697
    /* Merge next hops with the stored route */
1701
    rta *a = s->attrs;
1698
    rta *oa = s->attrs;
1702 1699

  
1703
    nexthop_insert(&a->nh, &ra->nh);
1700
    struct nexthop *nhs = &oa->nh;
1701
    nexthop_insert(&nhs, &ra->nh);
1702

  
1703
    /* Perhaps new nexthop is inserted at the first position */
1704
    if (nhs == &ra->nh)
1705
    {
1706
      /* Swap rtas */
1707
      s->attrs = ra;
1708

  
1709
      /* Keep old eattrs */
1710
      ra->eattrs = oa->eattrs;
1711
    }
1704 1712
  }
1705 1713
}
1706 1714

  

Also available in: Unified diff