Revision bcbd8cc3 nest/iface.c

View differences:

nest/iface.c
31 31
static int
32 32
if_connected(ip_addr *a, struct iface *i) /* -1=error, 1=match, 0=no match */
33 33
{
34
  if (i->flags & (IF_ADMIN_DOWN | IF_IGNORE))
34
  if (!(i->flags & IF_UP))
35 35
    return 0;
36 36
  if ((i->flags & IF_UNNUMBERED) && ipa_equal(*a, i->opposite))
37 37
    return 1;
......
41 41
      ipa_equal(*a, i->brd) ||		/* Broadcast */
42 42
      ipa_equal(*a, i->ip))		/* Our own address */
43 43
    return -1;
44
  if (!(i->flags & IF_UP))
45
    return 0;
46 44
  return 1;
47 45
}
48 46

  
......
197 195
    debug(" ADMIN-DOWN");
198 196
  if (i->flags & IF_UP)
199 197
    debug(" UP");
198
  else
199
    debug(" DOWN");
200
  if (i->flags & IF_LINK_UP)
201
    debug(" LINK-UP");
200 202
  if (i->flags & IF_MULTIACCESS)
201 203
    debug(" MA");
202 204
  if (i->flags & IF_UNNUMBERED)
......
229 231
static inline int
230 232
if_change_too_big_p(struct iface *i, struct iface *j)
231 233
{
232
  if (!ipa_equal(i->ip, j->ip) ||
234
  if ((i->flags ^ j->flags) & IF_UP)	/* Going up/down is always OK */
235
    return 0;
236
  if (!ipa_equal(i->ip, j->ip) ||	/* Address change isn't */
233 237
      !ipa_equal(i->prefix, j->prefix) ||
234 238
      i->pxlen != j->pxlen ||
235 239
      !ipa_equal(i->brd, j->brd) ||
236 240
      !ipa_equal(i->opposite, j->opposite))
237
    return 1;				/* Changed addresses */
238
  if ((i->flags ^ j->flags) & ~(IF_UP | IF_ADMIN_DOWN | IF_UPDATED))
239 241
    return 1;
242
  if ((i->flags ^ j->flags) & ~(IF_UP | IF_ADMIN_DOWN | IF_UPDATED | IF_LINK_UP))
243
    return 1;				/* Interface type change isn't as well */
240 244
  return 0;
241 245
}
242 246

  
......
295 299
  struct iface *i;
296 300
  unsigned c;
297 301

  
302
  if ((new->flags & IF_LINK_UP) && !(new->flags & IF_ADMIN_DOWN) && ipa_nonzero(new->ip))
303
    new->flags |= IF_UP;
304
  else
305
    new->flags &= ~IF_UP;
306

  
298 307
  WALK_LIST(i, iface_list)
299 308
    if (!strcmp(new->name, i->name))
300 309
      {
......
337 346
    else
338 347
      {
339 348
	memcpy(&j, i, sizeof(struct iface));
340
	i->flags = (i->flags & ~IF_UP) | IF_ADMIN_DOWN;
341
	if_notify_change(IF_CHANGE_DOWN | IF_CHANGE_FLAGS, &j, i);
349
	i->flags = (i->flags & ~(IF_LINK_UP | IF_UP)) | IF_ADMIN_DOWN;
350
	if (i->flags != j.flags)
351
	  if_notify_change(IF_CHANGE_DOWN | IF_CHANGE_FLAGS, &j, i);
342 352
      }
343 353
}
344 354

  
......
362 372
  j = NULL;
363 373
  WALK_LIST(i, iface_list)
364 374
    if ((i->flags & IF_UP) &&
365
	!(i->flags & (IF_UNNUMBERED | IF_LOOPBACK | IF_IGNORE)) &&
375
	!(i->flags & (IF_UNNUMBERED | IF_IGNORE)) &&
366 376
	(!j || ipa_to_u32(i->ip) < ipa_to_u32(j->ip)))
367 377
      j = i;
368 378
  if (!j)

Also available in: Unified diff