Revision bcbd8cc3 sysdep/unix/sync-if.c

View differences:

sysdep/unix/sync-if.c
42 42
      bzero(&i, sizeof(i));
43 43
      DBG("%s\n", r->ifr_ifrn.ifrn_name);
44 44
      strncpy(i.name, r->ifr_ifrn.ifrn_name, sizeof(i.name) - 1);
45
      i.name[sizeof(i.name) - 1] = 0;
46 45
      get_sockaddr((struct sockaddr_in *) &r->ifr_addr, &i.ip, NULL);
47
      l = ipa_classify(i.ip);
48
      if (l < 0 || !(l & IADDR_HOST))
46
      if (ipa_nonzero(i.ip))
49 47
	{
50
	  log(L_ERR "%s: Invalid interface address", i.name);
51
	  goto bad;
48
	  l = ipa_classify(i.ip);
49
	  if (l < 0 || !(l & IADDR_HOST))
50
	    {
51
	      log(L_ERR "%s: Invalid interface address", i.name);
52
	      i.ip = IPA_NONE;
53
	    }
54
	  else if ((l & IADDR_SCOPE_MASK) == SCOPE_HOST)
55
	    i.flags |= IF_LOOPBACK | IF_IGNORE;
52 56
	}
53
      if ((l & IADDR_SCOPE_MASK) == SCOPE_HOST)
54
	i.flags |= IF_LOOPBACK | IF_IGNORE;
55 57

  
56 58
      if (ioctl(if_scan_sock, SIOCGIFFLAGS, r) < 0)
57 59
	{
......
59 61
	faulty:
60 62
	  log(L_ERR "%s(%s): %m", err, i.name);
61 63
	bad:
62
	  i.flags = (i.flags & ~IF_UP) | IF_ADMIN_DOWN;
64
	  i.flags = (i.flags & ~IF_LINK_UP) | IF_ADMIN_DOWN;
63 65
	  continue;
64 66
	}
65 67
      fl = r->ifr_flags;
66 68
      if (fl & IFF_UP)
67
	i.flags |= IF_UP;
69
	i.flags |= IF_LINK_UP;
68 70

  
69 71
      if (ioctl(if_scan_sock, SIOCGIFNETMASK, r) < 0)
70 72
	{ err = "SIOCGIFNETMASK"; goto faulty; }
......
120 122
	DBG("SIOCGIFINDEX failed: %m\n");
121 123
      else
122 124
	i.index = r->ifr_ifindex;
125
#else
126
      /* FIXME: What else? Guess ifindex (we need it at least for OSPF on unnumbered links)? */
123 127
#endif
124 128

  
125 129
      if_update(&i);

Also available in: Unified diff