Revision 48e5f32d proto/ospf/iface.c

View differences:

proto/ospf/iface.c
36 36
  struct ospf_iface *ifa = (struct ospf_iface *) timer->data;
37 37
  struct proto *p = &ifa->oa->po->proto;
38 38

  
39
  OSPF_TRACE(D_EVENTS, "Wait timer fired on interface %s.", ifa->iface->name);
39
  OSPF_TRACE(D_EVENTS, "Wait timer fired on interface %s.", ifa->ifname);
40 40
  ospf_iface_sm(ifa, ISM_WAITF);
41 41
}
42 42

  
43
static void ospf_iface_change_mtu(struct proto_ospf *po, struct ospf_iface *ifa);
43
static inline uint
44
ifa_tx_length(struct ospf_iface *ifa)
45
{
46
  return ifa->cf->tx_length ?: ifa->iface->mtu; 
47
}
44 48

  
45
u32
46
rxbufsize(struct ospf_iface *ifa)
49
static inline uint
50
ifa_bufsize(struct ospf_iface *ifa)
47 51
{
48
  switch(ifa->rxbuf)
49
  {
50
    case OSPF_RXBUF_NORMAL:
51
      return (ifa->iface->mtu * 2);
52
      break;
53
    case OSPF_RXBUF_LARGE:
54
      return OSPF_MAX_PKT_SIZE;
55
      break;
56
    default:
57
      return ifa->rxbuf;
58
      break;
59
  }
52
  uint bsize = ifa->cf->rx_buffer ?: ifa->iface->mtu;
53
  return MAX(bsize, ifa->tx_length);
60 54
}
61 55

  
56
int
57
ospf_iface_assure_bufsize(struct ospf_iface *ifa, uint plen)
58
{
59
  plen += SIZE_OF_IP_HEADER;
60

  
61
#ifdef OSPFv2
62
  if (ifa->autype == OSPF_AUTH_CRYPT)
63
    plen += OSPF_AUTH_CRYPT_SIZE;
64
#endif
65

  
66
  if (plen <= ifa->sk->tbsize)
67
    return 0;
68

  
69
  if (ifa->cf->rx_buffer || (plen > 0xffff))
70
    return -1;
71

  
72
  plen = BIRD_ALIGN(plen, 1024);
73
  plen = MIN(plen, 0xffff);
74
  sk_set_tbsize(ifa->sk, plen);
75
  return 1;
76
}
77

  
78

  
62 79
struct nbma_node *
63 80
find_nbma_node_in(list *nnl, ip_addr ip)
64 81
{
......
69 86
  return NULL;
70 87
}
71 88

  
89

  
72 90
static int
73 91
ospf_sk_open(struct ospf_iface *ifa)
74 92
{
75 93
  sock *sk = sk_new(ifa->pool);
76 94
  sk->type = SK_IP;
77 95
  sk->dport = OSPF_PROTO;
78
  sk->saddr = IPA_NONE;
96
  sk->saddr = ifa->addr->ip;
97
  sk->iface = ifa->iface;
79 98

  
80 99
  sk->tos = ifa->cf->tx_tos;
81 100
  sk->priority = ifa->cf->tx_priority;
82 101
  sk->rx_hook = ospf_rx_hook;
83
  sk->tx_hook = ospf_tx_hook;
102
  // sk->tx_hook = ospf_tx_hook;
84 103
  sk->err_hook = ospf_err_hook;
85
  sk->iface = ifa->iface;
86
  sk->rbsize = rxbufsize(ifa);
87
  sk->tbsize = rxbufsize(ifa);
104
  sk->rbsize = sk->tbsize = ifa_bufsize(ifa);
88 105
  sk->data = (void *) ifa;
89 106
  sk->flags = SKF_LADDR_RX | (ifa->check_ttl ? SKF_TTL_RX : 0);
90
  sk->ttl = ifa->cf->ttl_security ? 255 : -1;
107
  sk->ttl = ifa->cf->ttl_security ? 255 : 1;
91 108

  
92
  if (sk_open(sk) != 0)
109
  if (sk_open(sk) < 0)
93 110
    goto err;
94 111

  
95 112
#ifdef OSPFv3
......
98 115
    goto err;
99 116
#endif
100 117

  
101
  /*
102
   * For OSPFv2: When sending a packet, it is important to have a
103
   * proper source address. We expect that when we send one-hop
104
   * unicast packets, OS chooses a source address according to the
105
   * destination address (to be in the same prefix). We also expect
106
   * that when we send multicast packets, OS uses the source address
107
   * from sk->saddr registered to OS by sk_setup_multicast(). This
108
   * behavior is needed to implement multiple virtual ifaces (struct
109
   * ospf_iface) on one physical iface and is signalized by
110
   * CONFIG_MC_PROPER_SRC.
111
   *
112
   * If this behavior is not available (for example on BSD), we create
113
   * non-stub iface just for the primary IP address (see
114
   * ospf_iface_stubby()) and we expect OS to use primary IP address
115
   * as a source address for both unicast and multicast packets.
116
   *
117
   * FIXME: the primary IP address is currently just the
118
   * lexicographically smallest address on an interface, it should be
119
   * signalized by sysdep code which one is really the primary.
120
   */
121

  
122
  sk->saddr = ifa->addr->ip;
123 118
  if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_PTP))
124 119
  {
125 120
    if (ifa->cf->real_bcast)
......
132 127
    else
133 128
    {
134 129
      ifa->all_routers = AllSPFRouters;
135
      sk->ttl = ifa->cf->ttl_security ? 255 : 1;
136 130

  
137 131
      if (sk_setup_multicast(sk) < 0)
138 132
        goto err;
......
171 165
  ifa->sk_dr = 0;
172 166
}
173 167

  
168
void
169
ospf_open_vlink_sk(struct proto_ospf *po)
170
{
171
  struct proto *p = &po->proto;
172

  
173
  sock *sk = sk_new(po->proto.pool);
174
  sk->type = SK_IP;
175
  sk->dport = OSPF_PROTO;
176

  
177
  /* FIXME: configurable tos/priority ? */
178
  sk->tos = IP_PREC_INTERNET_CONTROL;
179
  sk->priority = sk_priority_control;
180
  sk->err_hook = ospf_verr_hook;
181

  
182
  sk->rbsize = 0;
183
  sk->tbsize = OSPF_VLINK_MTU;
184
  sk->data = (void *) po;
185
  sk->flags = 0;
186

  
187
  if (sk_open(sk) < 0)
188
    goto err;
189

  
190
#ifdef OSPFv3
191
  /* 12 is an offset of the checksum in an OSPF packet */
192
  if (sk_set_ipv6_checksum(sk, 12) < 0)
193
    goto err;
194
#endif
195

  
196
  po->vlink_sk = sk;
197
  return;
198

  
199
 err:
200
  rfree(sk);
201
  log(L_ERR "%s: Cannot open virtual link socket", p->name);
202
}
203

  
174 204
static void
175 205
ospf_iface_down(struct ospf_iface *ifa)
176 206
{
......
183 213
  {
184 214
#ifdef OSPFv2
185 215
    OSPF_TRACE(D_EVENTS, "Removing interface %s (%I/%d) from area %R",
186
	       ifa->iface->name, ifa->addr->prefix, ifa->addr->pxlen, ifa->oa->areaid);
216
	       ifa->ifname, ifa->addr->prefix, ifa->addr->pxlen, ifa->oa->areaid);
187 217
#else
188 218
    OSPF_TRACE(D_EVENTS, "Removing interface %s (IID %d) from area %R",
189
	       ifa->iface->name, ifa->instance_id, ifa->oa->areaid);
219
	       ifa->ifname, ifa->instance_id, ifa->oa->areaid);
190 220
#endif
191 221

  
192 222
    /* First of all kill all the related vlinks */
......
215 245
  if (ifa->type == OSPF_IT_VLINK)
216 246
  {
217 247
    ifa->vifa = NULL;
218
    ifa->iface = NULL;
219 248
    ifa->addr = NULL;
220
    ifa->sk = NULL;
221 249
    ifa->cost = 0;
222 250
    ifa->vip = IPA_NONE;
223 251
  }
......
276 304
	       ifa->vid, ospf_is[oldstate], ospf_is[state]);
277 305
  else
278 306
    OSPF_TRACE(D_EVENTS, "Changing state of iface %s from %s to %s",
279
	       ifa->iface->name, ospf_is[oldstate], ospf_is[state]);
307
	       ifa->ifname, ospf_is[oldstate], ospf_is[state]);
280 308

  
281 309
  if ((ifa->type == OSPF_IT_BCAST) && !ifa->cf->real_bcast && ifa->sk)
282 310
  {
......
318 346
void
319 347
ospf_iface_sm(struct ospf_iface *ifa, int event)
320 348
{
321
  DBG("SM on %s %s. Event is '%s'\n", (ifa->type == OSPF_IT_VLINK) ? "vlink" : "iface",
322
    ifa->iface ? ifa->iface->name : "(none)" , ospf_ism[event]);
349
  DBG("SM on iface %s. Event is '%s'\n", ifa->ifname, ospf_ism[event]);
323 350

  
324 351
  switch (event)
325 352
  {
......
436 463
  /* Open socket if interface is not stub */
437 464
  if (! ifa->stub && ! ospf_sk_open(ifa))
438 465
  {
439
    log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->iface->name);
466
    log(L_ERR "%s: Socket open failed on interface %s, declaring as stub", p->name, ifa->ifname);
440 467
    ifa->ioprob = OSPF_I_SK;
441 468
    ifa->stub = 1;
442 469
  }
......
469 496
static int
470 497
ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr)
471 498
{
472
  if (! addr)
473
    return 0;
474

  
475 499
  /* a host address */
476 500
  if (addr->flags & IA_HOST)
477 501
    return 1;
......
481 505
    return 1;
482 506

  
483 507
  /*
484
   * We cannot properly support multiple OSPF ifaces on real iface
485
   * with multiple prefixes, therefore we force OSPF ifaces with
486
   * non-primary IP prefixes to be stub.
508
   * For compatibility reasons on BSD systems, we force OSPF
509
   * interfaces with non-primary IP prefixes to be stub.
487 510
   */
488 511
#if defined(OSPFv2) && !defined(CONFIG_MC_PROPER_SRC)
489
  if (! (addr->flags & IA_PRIMARY))
512
  if (!ip->bsd_secondary && !(addr->flags & IA_PRIMARY))
490 513
    return 1;
491 514
#endif
492 515

  
......
497 520
ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *ip)
498 521
{
499 522
  struct proto *p = &oa->po->proto;
500
  struct iface *iface = addr ? addr->iface : NULL;
501
  struct pool *pool;
502

  
523
  struct iface *iface = addr->iface;
503 524
  struct ospf_iface *ifa;
504
  struct nbma_node *nb;
505
  struct object_lock *lock;
525
  struct pool *pool;
506 526

  
507
  if (ip->type == OSPF_IT_VLINK)
508
    OSPF_TRACE(D_EVENTS, "Adding vlink to %R via area %R", ip->vid, ip->voa);
509
  else
510
  {
511 527
#ifdef OSPFv2
512
    OSPF_TRACE(D_EVENTS, "Adding interface %s (%I/%d) to area %R",
513
	       iface->name, addr->prefix, addr->pxlen, oa->areaid);
528
  OSPF_TRACE(D_EVENTS, "Adding interface %s (%I/%d) to area %R",
529
	     iface->name, addr->prefix, addr->pxlen, oa->areaid);
514 530
#else
515
    OSPF_TRACE(D_EVENTS, "Adding interface %s (IID %d) to area %R",
516
	       iface->name, ip->instance_id, oa->areaid);
531
  OSPF_TRACE(D_EVENTS, "Adding interface %s (IID %d) to area %R",
532
	     iface->name, ip->instance_id, oa->areaid);
517 533
#endif
518
  }
519 534

  
520 535
  pool = rp_new(p->pool, "OSPF Interface");
521 536
  ifa = mb_allocz(pool, sizeof(struct ospf_iface));
......
525 540
  ifa->cf = ip;
526 541
  ifa->pool = pool;
527 542

  
543
  ifa->iface_id = iface->index;
544
  ifa->ifname = iface->name;
545

  
528 546
  ifa->cost = ip->cost;
529 547
  ifa->rxmtint = ip->rxmtint;
530 548
  ifa->inftransdelay = ip->inftransdelay;
......
536 554
  ifa->deadint = ip->deadint;
537 555
  ifa->stub = ospf_iface_stubby(ip, addr);
538 556
  ifa->ioprob = OSPF_I_OK;
539
  ifa->rxbuf = ip->rxbuf;
557

  
558
  ifa->tx_length = ifa_tx_length(ifa);
540 559
  ifa->check_link = ip->check_link;
541 560
  ifa->ecmp_weight = ip->ecmp_weight;
542 561
  ifa->check_ttl = (ip->ttl_security == 1);
......
545 564
#ifdef OSPFv2
546 565
  ifa->autype = ip->autype;
547 566
  ifa->passwords = ip->passwords;
548
  ifa->ptp_netmask = addr ? !(addr->flags & IA_PEER) : 0;
567
  ifa->ptp_netmask = !(addr->flags & IA_PEER);
549 568
  if (ip->ptp_netmask < 2)
550 569
    ifa->ptp_netmask = ip->ptp_netmask;
551 570
#endif
......
554 573
  ifa->instance_id = ip->instance_id;
555 574
#endif
556 575

  
576

  
557 577
  ifa->type = ospf_iface_classify(ip->type, addr);
558 578

  
559 579
  /* Check validity of interface type */
......
578 598
    log(L_WARN "%s: Cannot use interface %s as %s, forcing %s",
579 599
	p->name, iface->name, ospf_it[old_type], ospf_it[ifa->type]);
580 600

  
581
  /* Assign iface ID, for vlinks, this is ugly hack */
582
  ifa->iface_id = (ifa->type != OSPF_IT_VLINK) ? iface->index : oa->po->last_vlink_id++;
583 601

  
602
  ifa->state = OSPF_IS_DOWN;
584 603
  init_list(&ifa->neigh_list);
585 604
  init_list(&ifa->nbma_list);
586 605

  
606
  struct nbma_node *nb;
587 607
  WALK_LIST(nb, ip->nbma_list)
588 608
  {
589 609
    /* In OSPFv3, addr is link-local while configured neighbors could
......
602 622
    add_nbma_node(ifa, nb, 0);
603 623
  }
604 624

  
605
  ifa->state = OSPF_IS_DOWN;
606 625
  add_tail(&oa->po->iface_list, NODE ifa);
607 626

  
608
  if (ifa->type == OSPF_IT_VLINK)
609
  {
610
    ifa->voa = ospf_find_area(oa->po, ip->voa);
611
    ifa->vid = ip->vid;
612

  
613
    ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
614

  
615
    return;			/* Don't lock, don't add sockets */
616
  }
617

  
618 627
  /*
619 628
   * In some cases we allow more ospf_ifaces on one physical iface.
620 629
   * In OSPFv2, if they use different IP address prefix.
......
622 631
   * Therefore, we store such info to lock->addr field.
623 632
   */
624 633

  
625
  lock = olock_new(pool);
634
  struct object_lock *lock = olock_new(pool);
626 635
#ifdef OSPFv2
627 636
  lock->addr = ifa->addr->prefix;
628 637
#else /* OSPFv3 */
......
637 646
  olock_acquire(lock);
638 647
}
639 648

  
649
void
650
ospf_iface_new_vlink(struct proto_ospf *po, struct ospf_iface_patt *ip)
651
{
652
  struct proto *p = &po->proto;
653
  struct ospf_iface *ifa;
654
  struct pool *pool;
655

  
656
  if (!po->vlink_sk)
657
    return;
658

  
659
  OSPF_TRACE(D_EVENTS, "Adding vlink to %R via area %R", ip->vid, ip->voa);
660

  
661
  /* Vlink ifname is stored just after the ospf_iface structure */
662

  
663
  pool = rp_new(p->pool, "OSPF Vlink");
664
  ifa = mb_allocz(pool, sizeof(struct ospf_iface) + 16);
665
  ifa->oa = po->backbone;
666
  ifa->cf = ip;
667
  ifa->pool = pool;
668

  
669
  /* Assign iface ID, for vlinks, this is ugly hack */
670
  u32 vlink_id = po->last_vlink_id++;
671
  ifa->iface_id = vlink_id + OSPF_VLINK_ID_OFFSET;
672
  ifa->ifname = (void *) (ifa + 1);
673
  bsprintf(ifa->ifname, "vlink%d", vlink_id);
674

  
675
  ifa->voa = ospf_find_area(po, ip->voa);
676
  ifa->vid = ip->vid;
677
  ifa->sk = po->vlink_sk;
678

  
679
  ifa->helloint = ip->helloint;
680
  ifa->rxmtint = ip->rxmtint;
681
  ifa->waitint = ip->waitint;
682
  ifa->deadint = ip->deadint;
683
  ifa->inftransdelay = ip->inftransdelay;
684
  ifa->tx_length = OSPF_VLINK_MTU;
685

  
686
#ifdef OSPFv2
687
  ifa->autype = ip->autype;
688
  ifa->passwords = ip->passwords;
689
#endif
690

  
691
#ifdef OSPFv3
692
  ifa->instance_id = ip->instance_id;
693
#endif
694

  
695
  ifa->type = OSPF_IT_VLINK;
696

  
697
  ifa->state = OSPF_IS_DOWN;
698
  init_list(&ifa->neigh_list);
699
  init_list(&ifa->nbma_list);
700

  
701
  add_tail(&po->iface_list, NODE ifa);
702

  
703
  ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
704
}
705

  
640 706
static void
641 707
ospf_iface_change_timer(timer *tm, unsigned val)
642 708
{
......
653 719
ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
654 720
{
655 721
  struct proto *p = &ifa->oa->po->proto;
656
  struct nbma_node *nb, *nbx;
657
  char *ifname = (ifa->type != OSPF_IT_VLINK) ? ifa->iface->name : "vlink";
722
  struct ospf_iface_patt *old = ifa->cf;
723
  char *ifname = ifa->ifname;
658 724

  
659 725
  /* Type could be changed in ospf_iface_new(),
660 726
     but if config values are same then also results are same */
661
  int old_type = ospf_iface_classify(ifa->cf->type, ifa->addr);
727
  int old_type = ospf_iface_classify(old->type, ifa->addr);
662 728
  int new_type = ospf_iface_classify(new->type, ifa->addr);
663 729
  if (old_type != new_type)
664 730
    return 0;
......
668 734
    return 0;
669 735

  
670 736
  /* Change of these options would require to reset the iface socket */
671
  if ((new->real_bcast != ifa->cf->real_bcast) ||
672
      (new->tx_tos != ifa->cf->tx_tos) ||
673
      (new->tx_priority != ifa->cf->tx_priority) ||
674
      (new->ttl_security != ifa->cf->ttl_security))
737
  if ((new->real_bcast != old->real_bcast) ||
738
      (new->tx_tos != old->tx_tos) ||
739
      (new->tx_priority != old->tx_priority) ||
740
      (new->ttl_security != old->ttl_security))
675 741
    return 0;
676 742

  
677 743
  ifa->cf = new;
......
775 841
    ifa->strictnbma = new->strictnbma;
776 842
  }
777 843

  
844
  struct nbma_node *nb, *nbx;
845

  
778 846
  /* NBMA LIST - remove or update old */
779 847
  WALK_LIST_DELSAFE(nb, nbx, ifa->nbma_list)
780 848
  {
......
817 885
    }
818 886
  }
819 887

  
820
  /* RX BUFF */
821
  if (ifa->rxbuf != new->rxbuf)
888
  int update_buffers = 0;
889

  
890
  /* TX LENGTH */
891
  if (old->tx_length != new->tx_length)
892
  {
893
    OSPF_TRACE(D_EVENTS, "Changing TX length on interface %s from %d to %d",
894
	       ifname, old->tx_length, new->tx_length);
895

  
896
    /* ifa cannot be vlink */
897
    ifa->tx_length = ifa_tx_length(ifa);
898
    update_buffers = 1;
899
  }
900

  
901
  /* RX BUFFER */
902
  if (old->rx_buffer != new->rx_buffer)
903
  {
904
    OSPF_TRACE(D_EVENTS, "Changing buffer size on interface %s from %d to %d",
905
	       ifname, old->rx_buffer, new->rx_buffer);
906

  
907
    /* ifa cannot be vlink */
908
    update_buffers = 1;
909
  }
910

  
911
  /* Buffer size depends on both tx_length and rx_buffer options */
912
  if (update_buffers && ifa->sk)
822 913
  {
823
    OSPF_TRACE(D_EVENTS, "Changing rxbuf interface %s from %d to %d",
824
	       ifname, ifa->rxbuf, new->rxbuf);
825
    ifa->rxbuf = new->rxbuf;
826
    ospf_iface_change_mtu(ifa->oa->po, ifa);
914
    uint bsize = ifa_bufsize(ifa);
915
    sk_set_rbsize(ifa->sk, bsize);
916
    sk_set_tbsize(ifa->sk, bsize);
827 917
  }
828 918

  
829 919
  /* LINK */
......
833 923
	       new->check_link ? "Enabling" : "Disabling", ifname);
834 924
    ifa->check_link = new->check_link;
835 925

  
926
    /* ifa cannot be vlink */
836 927
    if (!(ifa->iface->flags & IF_LINK_UP))
837 928
      ospf_iface_sm(ifa, ifa->check_link ? ISM_LOOP : ISM_UNLOOP);
838 929
  }
......
929 1020
void
930 1021
ospf_ifaces_reconfigure(struct ospf_area *oa, struct ospf_area_config *nac)
931 1022
{
1023
  struct proto *p = &oa->po->proto;
932 1024
  struct ospf_iface_patt *ip;
933 1025
  struct iface *iface;
934 1026
  struct ifa *a;
......
956 1048
	    continue;
957 1049

  
958 1050
	  /* Hard restart */
1051
	  log(L_INFO "%s: Restarting interface %s (%I/%d) in area %R",
1052
	      p->name, ifa->ifname, a->prefix, a->pxlen, oa->areaid);
959 1053
	  ospf_iface_shutdown(ifa);
960 1054
	  ospf_iface_remove(ifa);
961 1055
	}
......
1062 1156
void
1063 1157
ospf_ifaces_reconfigure(struct ospf_area *oa, struct ospf_area_config *nac)
1064 1158
{
1159
  struct proto *p = &oa->po->proto;
1065 1160
  struct ospf_iface_patt *ip;
1066 1161
  struct iface *iface;
1067 1162
  struct ifa *a;
......
1092 1187
	    continue;
1093 1188

  
1094 1189
	  /* Hard restart */
1190
	  log(L_INFO "%s: Restarting interface %s (IID %d) in area %R",
1191
	      p->name, ifa->ifname, ifa->instance_id, oa->areaid);
1095 1192
	  ospf_iface_shutdown(ifa);
1096 1193
	  ospf_iface_remove(ifa);
1097 1194
	}
......
1108 1205
ospf_iface_change_mtu(struct proto_ospf *po, struct ospf_iface *ifa)
1109 1206
{
1110 1207
  struct proto *p = &po->proto;
1111
  struct ospf_packet *op;
1112
  struct ospf_neighbor *n;
1113
  OSPF_TRACE(D_EVENTS, "Changing MTU on interface %s", ifa->iface->name);
1114 1208

  
1115
  if (ifa->sk)
1116
  {
1117
    ifa->sk->rbsize = rxbufsize(ifa);
1118
    ifa->sk->tbsize = rxbufsize(ifa);
1119
    sk_reallocate(ifa->sk);
1120
  }
1209
  /* ifa is not vlink */
1121 1210

  
1122
  WALK_LIST(n, ifa->neigh_list)
1123
  {
1124
    op = (struct ospf_packet *) n->ldbdes;
1125
    n->ldbdes = mb_allocz(n->pool, ifa->iface->mtu);
1211
  OSPF_TRACE(D_EVENTS, "Changing MTU on interface %s", ifa->ifname);
1126 1212

  
1127
    if (ntohs(op->length) <= ifa->iface->mtu)	/* If the packet in old buffer is bigger, let it filled by zeros */
1128
      memcpy(n->ldbdes, op, ifa->iface->mtu);	/* If the packet is old is same or smaller, copy it */
1213
  ifa->tx_length = ifa_tx_length(ifa);
1129 1214

  
1130
    mb_free(op);
1131
  }
1215
  if (!ifa->sk)
1216
    return;
1217

  
1218
  /* We do not shrink dynamic buffers */
1219
  uint bsize = ifa_bufsize(ifa);
1220
  if (bsize > ifa->sk->rbsize)
1221
    sk_set_rbsize(ifa->sk, bsize);
1222
  if (bsize > ifa->sk->tbsize)
1223
    sk_set_tbsize(ifa->sk, bsize);
1132 1224
}
1133 1225

  
1134 1226
static void
1135 1227
ospf_iface_notify(struct proto_ospf *po, unsigned flags, struct ospf_iface *ifa)
1136 1228
{
1229
  /* ifa is not vlink */
1230

  
1137 1231
  if (flags & IF_CHANGE_DOWN)
1138 1232
  {
1139 1233
    ospf_iface_remove(ifa);
......
1163 1257

  
1164 1258
  struct ospf_iface *ifa, *ifx;
1165 1259
  WALK_LIST_DELSAFE(ifa, ifx, po->iface_list)
1166
    if ((ifa->type != OSPF_IT_VLINK) && (ifa->iface == iface))
1260
    if (ifa->iface == iface)
1167 1261
      ospf_iface_notify(po, flags, ifa);
1168 1262

  
1169 1263
  /* We use here that even shutting down iface also shuts down
......
1186 1280

  
1187 1281
  if (ifa->type == OSPF_IT_VLINK)
1188 1282
  {
1189
    cli_msg(-1015, "Virtual link to %R:", ifa->vid);
1283
    cli_msg(-1015, "Virtual link %s to %R:", ifa->ifname, ifa->vid);
1190 1284
    cli_msg(-1015, "\tPeer IP: %I", ifa->vip);
1191
    cli_msg(-1015, "\tTransit area: %R (%u)", ifa->voa->areaid,
1192
	    ifa->voa->areaid);
1193
    cli_msg(-1015, "\tInterface: \"%s\"",
1194
	    (ifa->iface ? ifa->iface->name : "(none)"));
1285
    cli_msg(-1015, "\tTransit area: %R (%u)", ifa->voa->areaid, ifa->voa->areaid);
1195 1286
  }
1196 1287
  else
1197 1288
  {
1198 1289
#ifdef OSPFv2
1199 1290
    if (ifa->addr->flags & IA_PEER)
1200
      cli_msg(-1015, "Interface %s (peer %I)", ifa->iface->name, ifa->addr->opposite);
1291
      cli_msg(-1015, "Interface %s (peer %I)", ifa->ifname, ifa->addr->opposite);
1201 1292
    else
1202
      cli_msg(-1015, "Interface %s (%I/%d)", ifa->iface->name, ifa->addr->prefix, ifa->addr->pxlen);
1293
      cli_msg(-1015, "Interface %s (%I/%d)", ifa->ifname, ifa->addr->prefix, ifa->addr->pxlen);
1203 1294
#else /* OSPFv3 */
1204
    cli_msg(-1015, "Interface %s (IID %d)", ifa->iface->name, ifa->instance_id);
1295
    cli_msg(-1015, "Interface %s (IID %d)", ifa->ifname, ifa->instance_id);
1205 1296
#endif
1206 1297
    cli_msg(-1015, "\tType: %s%s", ospf_it[ifa->type], more);
1207 1298
    cli_msg(-1015, "\tArea: %R (%u)", ifa->oa->areaid, ifa->oa->areaid);

Also available in: Unified diff