Revision 153f02da sysdep/bsd/krt-sock.c

View differences:

sysdep/bsd/krt-sock.c
287 287
#endif
288 288
  {
289 289
    /* Fallback for all other valid cases */
290
    if (!i->addr)
291
    {
292
      log(L_ERR "KRT: interface %s has no IP addess", i->name);
293
      return -1;
294
    }
295 290

  
296 291
#ifdef RTF_CLONING
297 292
    if (cmd == RTM_ADD && (i->flags & IF_MULTIACCESS) != IF_MULTIACCESS)	/* PTP */
298 293
      msg.rtm.rtm_flags |= RTF_CLONING;
299 294
#endif
300 295

  
301
    sockaddr_fill(&gate, ipa_is_ip4(i->addr->ip) ? AF_INET : AF_INET6, i->addr->ip, NULL, 0);
296
    struct ifa *addr = (net->n.addr->type == NET_IP4) ? i->addr4 : (i->addr6 ?: i->llv6);
297

  
298
    if (!addr)
299
    {
300
      log(L_ERR "KRT: interface %s has no IP addess", i->name);
301
      return -1;
302
    }
303

  
304
    sockaddr_fill(&gate, af, addr->ip, i, 0);
302 305
    msg.rtm.rtm_addrs |= RTA_GATEWAY;
303 306
    break;
304 307
  }
......
1124 1127
  krt_buffer_release(&p->p);
1125 1128
}
1126 1129

  
1127

  
1128
struct ifa *
1129
kif_get_primary_ip(struct iface *i UNUSED)
1130
int
1131
kif_update_sysdep_addr(struct iface *i)
1130 1132
{
1131
#if 0
1132 1133
  static int fd = -1;
1133
  
1134

  
1134 1135
  if (fd < 0)
1135 1136
    fd = socket(AF_INET, SOCK_DGRAM, 0);
1136 1137

  
......
1140 1141

  
1141 1142
  int rv = ioctl(fd, SIOCGIFADDR, (char *) &ifr);
1142 1143
  if (rv < 0)
1143
    return NULL;
1144

  
1145
  ip_addr addr;
1146
  struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
1147
  memcpy(&addr, &sin->sin_addr.s_addr, sizeof(ip_addr));
1148
  ipa_ntoh(addr);
1144
    return 0;
1149 1145

  
1150
  struct ifa *a;
1151
  WALK_LIST(a, i->addrs)
1152
  {
1153
    if (ipa_equal(a->ip, addr))
1154
      return a;
1155
  }
1156
#endif
1146
  ip4_addr old = i->sysdep;
1147
  i->sysdep = ip4_from_ipa(ipa_from_sa4(&ifr.ifr_addr);
1157 1148

  
1158
  return NULL;
1149
  return !ip4_equal(i->sysdep, addr);
1159 1150
}

Also available in: Unified diff