]> git.ipfire.org Git - thirdparty/bird.git/blob - proto/ospf/iface.c
Bugfix in latest OSPF changes.
[thirdparty/bird.git] / proto / ospf / iface.c
1 /*
2 * BIRD -- OSPF
3 *
4 * (c) 1999--2005 Ondrej Filip <feela@network.cz>
5 * (c) 2009--2014 Ondrej Zajicek <santiago@crfreenet.org>
6 * (c) 2009--2014 CZ.NIC z.s.p.o.
7 *
8 * Can be freely distributed and used under the terms of the GNU GPL.
9 */
10
11 #include "ospf.h"
12
13
14 const char *ospf_is_names[] = {
15 "Down", "Loopback", "Waiting", "PtP", "DROther", "Backup", "DR"
16 };
17
18 const char *ospf_ism_names[] = {
19 "InterfaceUp", "WaitTimer", "BackupSeen", "NeighborChange",
20 "LoopInd", "UnloopInd", "InterfaceDown"
21 };
22
23 const char *ospf_it[] = { "broadcast", "nbma", "ptp", "ptmp", "virtual link" };
24
25
26 static void
27 poll_timer_hook(timer * timer)
28 {
29 ospf_send_hello(timer->data, OHS_POLL, NULL);
30 }
31
32 static void
33 hello_timer_hook(timer * timer)
34 {
35 ospf_send_hello(timer->data, OHS_HELLO, NULL);
36 }
37
38 static void
39 wait_timer_hook(timer * timer)
40 {
41 struct ospf_iface *ifa = (struct ospf_iface *) timer->data;
42 struct ospf_proto *p = ifa->oa->po;
43
44 OSPF_TRACE(D_EVENTS, "Wait timer fired on %s", ifa->ifname);
45 ospf_iface_sm(ifa, ISM_WAITF);
46 }
47
48 static inline uint
49 ifa_tx_length(struct ospf_iface *ifa)
50 {
51 return ifa->cf->tx_length ?: ifa->iface->mtu;
52 }
53
54 static inline uint
55 ifa_bufsize(struct ospf_iface *ifa)
56 {
57 uint bsize = ifa->cf->rx_buffer ?: ifa->iface->mtu;
58 return MAX(bsize, ifa->tx_length);
59 }
60
61 static inline uint
62 ifa_flood_queue_size(struct ospf_iface *ifa)
63 {
64 return ifa->tx_length / 24;
65 }
66
67 int
68 ospf_iface_assure_bufsize(struct ospf_iface *ifa, uint plen)
69 {
70 plen += SIZE_OF_IP_HEADER;
71
72 /* This is relevant just for OSPFv2 */
73 if (ifa->autype == OSPF_AUTH_CRYPT)
74 plen += OSPF_AUTH_CRYPT_SIZE;
75
76 if (plen <= ifa->sk->tbsize)
77 return 0;
78
79 if (ifa->cf->rx_buffer || (plen > 0xffff))
80 return -1;
81
82 plen = BIRD_ALIGN(plen, 1024);
83 plen = MIN(plen, 0xffff);
84 sk_set_tbsize(ifa->sk, plen);
85 return 1;
86 }
87
88
89 struct nbma_node *
90 find_nbma_node_(list *nnl, ip_addr ip)
91 {
92 struct nbma_node *nn;
93
94 WALK_LIST(nn, *nnl)
95 if (ipa_equal(nn->ip, ip))
96 return nn;
97
98 return NULL;
99 }
100
101
102 static int
103 ospf_sk_open(struct ospf_iface *ifa)
104 {
105 struct ospf_proto *p = ifa->oa->po;
106
107 sock *sk = sk_new(ifa->pool);
108 sk->type = SK_IP;
109 sk->dport = OSPF_PROTO;
110 sk->saddr = ifa->addr->ip;
111 sk->iface = ifa->iface;
112
113 sk->tos = ifa->cf->tx_tos;
114 sk->priority = ifa->cf->tx_priority;
115 sk->rx_hook = ospf_rx_hook;
116 // sk->tx_hook = ospf_tx_hook;
117 sk->err_hook = ospf_err_hook;
118 sk->rbsize = sk->tbsize = ifa_bufsize(ifa);
119 sk->data = (void *) ifa;
120 sk->flags = SKF_LADDR_RX | (ifa->check_ttl ? SKF_TTL_RX : 0);
121 sk->ttl = ifa->cf->ttl_security ? 255 : 1;
122
123 if (sk_open(sk) < 0)
124 goto err;
125
126 /* 12 is an offset of the checksum in an OSPFv3 packet */
127 if (ospf_is_v3(p))
128 if (sk_set_ipv6_checksum(sk, 12) < 0)
129 goto err;
130
131 if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_PTP))
132 {
133 if (ifa->cf->real_bcast)
134 {
135 ifa->all_routers = ifa->addr->brd;
136 ifa->des_routers = IPA_NONE;
137
138 if (sk_setup_broadcast(sk) < 0)
139 goto err;
140 }
141 else
142 {
143 ifa->all_routers = ospf_is_v2(p) ? IP4_OSPF_ALL_ROUTERS : IP6_OSPF_ALL_ROUTERS;
144 ifa->des_routers = ospf_is_v2(p) ? IP4_OSPF_DES_ROUTERS : IP6_OSPF_DES_ROUTERS;
145
146 if (sk_setup_multicast(sk) < 0)
147 goto err;
148
149 if (sk_join_group(sk, ifa->all_routers) < 0)
150 goto err;
151 }
152 }
153
154 ifa->sk = sk;
155 ifa->sk_dr = 0;
156 return 1;
157
158 err:
159 sk_log_error(sk, p->p.name);
160 rfree(sk);
161 return 0;
162 }
163
164 static inline void
165 ospf_sk_join_dr(struct ospf_iface *ifa)
166 {
167 if (ifa->sk_dr)
168 return;
169
170 if (sk_join_group(ifa->sk, ifa->des_routers) < 0)
171 sk_log_error(ifa->sk, ifa->oa->po->p.name);
172
173 ifa->sk_dr = 1;
174 }
175
176 static inline void
177 ospf_sk_leave_dr(struct ospf_iface *ifa)
178 {
179 if (!ifa->sk_dr)
180 return;
181
182 if (sk_leave_group(ifa->sk, ifa->des_routers) < 0)
183 sk_log_error(ifa->sk, ifa->oa->po->p.name);
184
185 ifa->sk_dr = 0;
186 }
187
188 void
189 ospf_open_vlink_sk(struct ospf_proto *p)
190 {
191 sock *sk = sk_new(p->p.pool);
192 sk->type = SK_IP;
193 sk->dport = OSPF_PROTO;
194
195 /* FIXME: configurable tos/priority ? */
196 sk->tos = IP_PREC_INTERNET_CONTROL;
197 sk->priority = sk_priority_control;
198 sk->err_hook = ospf_verr_hook;
199
200 sk->rbsize = 0;
201 sk->tbsize = ospf_is_v2(p) ? IP4_MIN_MTU : IP6_MIN_MTU;
202 sk->data = (void *) p;
203 sk->flags = 0;
204
205 if (sk_open(sk) < 0)
206 goto err;
207
208 /* 12 is an offset of the checksum in an OSPFv3 packet */
209 if (ospf_is_v3(p))
210 if (sk_set_ipv6_checksum(sk, 12) < 0)
211 goto err;
212
213 p->vlink_sk = sk;
214 return;
215
216 err:
217 sk_log_error(sk, p->p.name);
218 log(L_ERR "%s: Cannot open virtual link socket", p->p.name);
219 rfree(sk);
220 }
221
222 static void
223 ospf_iface_down(struct ospf_iface *ifa)
224 {
225 struct ospf_proto *p = ifa->oa->po;
226 struct ospf_neighbor *n, *nx;
227 struct ospf_iface *iff;
228
229 if (ifa->type != OSPF_IT_VLINK)
230 {
231 if (ospf_is_v3(ifa->oa->po))
232 OSPF_TRACE(D_EVENTS, "Removing interface %s (IID %d) from area %R",
233 ifa->ifname, ifa->instance_id, ifa->oa->areaid);
234 else if (ifa->addr->flags & IA_PEER)
235 OSPF_TRACE(D_EVENTS, "Removing interface %s (peer %I) from area %R",
236 ifa->ifname, ifa->addr->opposite, ifa->oa->areaid);
237 else
238 OSPF_TRACE(D_EVENTS, "Removing interface %s (%I/%d) from area %R",
239 ifa->ifname, ifa->addr->prefix, ifa->addr->pxlen, ifa->oa->areaid);
240
241 /* First of all kill all the related vlinks */
242 WALK_LIST(iff, p->iface_list)
243 {
244 if ((iff->type == OSPF_IT_VLINK) && (iff->vifa == ifa))
245 ospf_iface_sm(iff, ISM_DOWN);
246 }
247 }
248
249 WALK_LIST_DELSAFE(n, nx, ifa->neigh_list)
250 ospf_neigh_sm(n, INM_KILLNBR);
251
252 if (ifa->hello_timer)
253 tm_stop(ifa->hello_timer);
254
255 if (ifa->poll_timer)
256 tm_stop(ifa->poll_timer);
257
258 if (ifa->wait_timer)
259 tm_stop(ifa->wait_timer);
260
261 ospf_flush2_lsa(p, &ifa->link_lsa);
262 ospf_flush2_lsa(p, &ifa->net_lsa);
263 ospf_flush2_lsa(p, &ifa->pxn_lsa);
264
265 if (ifa->type == OSPF_IT_VLINK)
266 {
267 ifa->vifa = NULL;
268 ifa->addr = NULL;
269 ifa->cost = 0;
270 ifa->vip = IPA_NONE;
271 }
272
273 ifa->rt_pos_beg = 0;
274 ifa->rt_pos_end = 0;
275 ifa->px_pos_beg = 0;
276 ifa->px_pos_end = 0;
277 }
278
279
280 void
281 ospf_iface_remove(struct ospf_iface *ifa)
282 {
283 struct ospf_proto *p = ifa->oa->po;
284 int i;
285
286 if (ifa->type == OSPF_IT_VLINK)
287 OSPF_TRACE(D_EVENTS, "Removing vlink to %R via area %R", ifa->vid, ifa->voa->areaid);
288
289 /* Release LSAs from flood queue */
290 if (!ifa->stub)
291 for (i = 0; i < ifa->flood_queue_used; i++)
292 ifa->flood_queue[i]->ret_count--;
293
294 ospf_iface_sm(ifa, ISM_DOWN);
295 rem_node(NODE ifa);
296 rfree(ifa->pool);
297 }
298
299 void
300 ospf_iface_shutdown(struct ospf_iface *ifa)
301 {
302 if (ifa->state > OSPF_IS_DOWN)
303 ospf_send_hello(ifa, OHS_SHUTDOWN, NULL);
304 }
305
306 /**
307 * ospf_iface_chstate - handle changes of interface state
308 * @ifa: OSPF interface
309 * @state: new state
310 *
311 * Many actions must be taken according to interface state changes. New network
312 * LSAs must be originated, flushed, new multicast sockets to listen for messages for
313 * %ALLDROUTERS have to be opened, etc.
314 */
315 void
316 ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
317 {
318 struct ospf_proto *p = ifa->oa->po;
319 u8 oldstate = ifa->state;
320
321 if (state == oldstate)
322 return;
323
324 OSPF_TRACE(D_EVENTS, "Interface %s changed state from %s to %s",
325 ifa->ifname, ospf_is_names[oldstate], ospf_is_names[state]);
326
327 ifa->state = state;
328
329 if ((ifa->type == OSPF_IT_BCAST) && ipa_nonzero(ifa->des_routers) && ifa->sk)
330 {
331 if ((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR))
332 ospf_sk_join_dr(ifa);
333 else
334 ospf_sk_leave_dr(ifa);
335 }
336
337 if ((oldstate > OSPF_IS_LOOP) && (state <= OSPF_IS_LOOP))
338 ospf_iface_down(ifa);
339
340 /* RFC 2328 12.4 Event 2 - iface state change */
341 ospf_notify_rt_lsa(ifa->oa);
342
343 /* RFC 5340 4.4.3 Event 1 - iface state change */
344 ospf_notify_link_lsa(ifa);
345
346 /* RFC 2328 12.4 Event 3 - iface enters/leaves DR state */
347 ospf_notify_net_lsa(ifa);
348 }
349
350 /**
351 * ospf_iface_sm - OSPF interface state machine
352 * @ifa: OSPF interface
353 * @event: event comming to state machine
354 *
355 * This fully respects 9.3 of RFC 2328 except we have slightly
356 * different handling of %DOWN and %LOOP state. We remove intefaces
357 * that are %DOWN. %DOWN state is used when an interface is waiting
358 * for a lock. %LOOP state is used when an interface does not have a
359 * link.
360 */
361 void
362 ospf_iface_sm(struct ospf_iface *ifa, int event)
363 {
364 DBG("SM on %s. Event is '%s'\n", ifa->ifname, ospf_ism_names[event]);
365
366 switch (event)
367 {
368 case ISM_UP:
369 if (ifa->state <= OSPF_IS_LOOP)
370 {
371 /* Now, nothing should be adjacent */
372 if ((ifa->type == OSPF_IT_PTP) ||
373 (ifa->type == OSPF_IT_PTMP) ||
374 (ifa->type == OSPF_IT_VLINK))
375 {
376 ospf_iface_chstate(ifa, OSPF_IS_PTP);
377 }
378 else
379 {
380 if (ifa->priority == 0)
381 ospf_iface_chstate(ifa, OSPF_IS_DROTHER);
382 else
383 {
384 ospf_iface_chstate(ifa, OSPF_IS_WAITING);
385 if (ifa->wait_timer)
386 tm_start(ifa->wait_timer, ifa->waitint);
387 }
388 }
389
390 if (ifa->hello_timer)
391 tm_start(ifa->hello_timer, ifa->helloint);
392
393 if (ifa->poll_timer)
394 tm_start(ifa->poll_timer, ifa->pollint);
395
396 ospf_send_hello(ifa, OHS_HELLO, NULL);
397 }
398 break;
399
400 case ISM_BACKS:
401 case ISM_WAITF:
402 if (ifa->state == OSPF_IS_WAITING)
403 ospf_dr_election(ifa);
404 break;
405
406 case ISM_NEICH:
407 if (ifa->state >= OSPF_IS_DROTHER)
408 ospf_dr_election(ifa);
409 break;
410
411 case ISM_LOOP:
412 if ((ifa->state > OSPF_IS_LOOP) && ifa->check_link)
413 ospf_iface_chstate(ifa, OSPF_IS_LOOP);
414 break;
415
416 case ISM_UNLOOP:
417 /* Immediate go UP */
418 if (ifa->state == OSPF_IS_LOOP)
419 ospf_iface_sm(ifa, ISM_UP);
420 break;
421
422 case ISM_DOWN:
423 ospf_iface_chstate(ifa, OSPF_IS_DOWN);
424 break;
425
426 default:
427 bug("OSPF_I_SM - Unknown event?");
428 break;
429 }
430
431 }
432
433 static u8
434 ospf_iface_classify_(struct iface *ifa, struct ifa *addr)
435 {
436 if (ipa_nonzero(addr->opposite))
437 return (ifa->flags & IF_MULTICAST) ? OSPF_IT_PTP : OSPF_IT_PTMP;
438
439 if ((ifa->flags & (IF_MULTIACCESS | IF_MULTICAST)) ==
440 (IF_MULTIACCESS | IF_MULTICAST))
441 return OSPF_IT_BCAST;
442
443 if ((ifa->flags & (IF_MULTIACCESS | IF_MULTICAST)) == IF_MULTIACCESS)
444 return OSPF_IT_NBMA;
445
446 return OSPF_IT_PTP;
447 }
448
449 static inline u8
450 ospf_iface_classify(u8 type, struct ifa *addr)
451 {
452 return (type != OSPF_IT_UNDEF) ? type : ospf_iface_classify_(addr->iface, addr);
453 }
454
455
456 struct ospf_iface *
457 ospf_iface_find(struct ospf_proto *p, struct iface *what)
458 {
459 struct ospf_iface *ifa;
460
461 WALK_LIST(ifa, p->iface_list)
462 if ((ifa->iface == what) && (ifa->type != OSPF_IT_VLINK))
463 return ifa;
464
465 return NULL;
466 }
467
468 static void
469 ospf_iface_add(struct object_lock *lock)
470 {
471 struct ospf_iface *ifa = lock->data;
472 struct ospf_proto *p = ifa->oa->po;
473
474 /* Open socket if interface is not stub */
475 if (! ifa->stub && ! ospf_sk_open(ifa))
476 {
477 log(L_ERR "%s: Cannot open socket for %s, declaring as stub", p->p.name, ifa->ifname);
478 ifa->ioprob = OSPF_I_SK;
479 ifa->stub = 1;
480 }
481
482 if (! ifa->stub)
483 {
484 ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
485
486 if (ifa->type == OSPF_IT_NBMA)
487 ifa->poll_timer = tm_new_set(ifa->pool, poll_timer_hook, ifa, 0, ifa->pollint);
488
489 if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
490 ifa->wait_timer = tm_new_set(ifa->pool, wait_timer_hook, ifa, 0, 0);
491
492 ifa->flood_queue_size = ifa_flood_queue_size(ifa);
493 ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
494 }
495
496 /* Do iface UP, unless there is no link and we use link detection */
497 ospf_iface_sm(ifa, (ifa->check_link && !(ifa->iface->flags & IF_LINK_UP)) ? ISM_LOOP : ISM_UP);
498 }
499
500 static inline void
501 add_nbma_node(struct ospf_iface *ifa, struct nbma_node *src, int found)
502 {
503 struct nbma_node *n = mb_alloc(ifa->pool, sizeof(struct nbma_node));
504 add_tail(&ifa->nbma_list, NODE n);
505 n->ip = src->ip;
506 n->eligible = src->eligible;
507 n->found = found;
508 }
509
510 static int
511 ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr)
512 {
513 /* a host address */
514 if (addr->flags & IA_HOST)
515 return 1;
516
517 /* a loopback iface */
518 if (addr->iface->flags & IF_LOOPBACK)
519 return 1;
520
521 /*
522 * For compatibility reasons on BSD systems, we force OSPF
523 * interfaces with non-primary IP prefixes to be stub.
524 */
525 #if defined(OSPFv2) && !defined(CONFIG_MC_PROPER_SRC)
526 if (!ip->bsd_secondary && !(addr->flags & IA_PRIMARY))
527 return 1;
528 #endif
529
530 return ip->stub;
531 }
532
533 void
534 ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *ip)
535 {
536 struct ospf_proto *p = oa->po;
537 struct iface *iface = addr->iface;
538 struct ospf_iface *ifa;
539 struct pool *pool;
540
541 if (ospf_is_v3(p))
542 OSPF_TRACE(D_EVENTS, "Adding interface %s (IID %d) to area %R",
543 iface->name, ip->instance_id, oa->areaid);
544 else if (addr->flags & IA_PEER)
545 OSPF_TRACE(D_EVENTS, "Adding interface %s (peer %I) to area %R",
546 iface->name, addr->opposite, oa->areaid);
547 else
548 OSPF_TRACE(D_EVENTS, "Adding interface %s (%I/%d) to area %R",
549 iface->name, addr->prefix, addr->pxlen, oa->areaid);
550
551 pool = rp_new(p->p.pool, "OSPF Interface");
552 ifa = mb_allocz(pool, sizeof(struct ospf_iface));
553 ifa->iface = iface;
554 ifa->addr = addr;
555 ifa->oa = oa;
556 ifa->cf = ip;
557 ifa->pool = pool;
558
559 ifa->iface_id = iface->index;
560 ifa->ifname = iface->name;
561
562 ifa->cost = ip->cost;
563 ifa->rxmtint = ip->rxmtint;
564 ifa->inftransdelay = ip->inftransdelay;
565 ifa->priority = ip->priority;
566 ifa->helloint = ip->helloint;
567 ifa->pollint = ip->pollint;
568 ifa->strictnbma = ip->strictnbma;
569 ifa->waitint = ip->waitint;
570 ifa->deadint = ip->deadint;
571 ifa->stub = ospf_iface_stubby(ip, addr);
572 ifa->ioprob = OSPF_I_OK;
573 ifa->tx_length = ifa_tx_length(ifa);
574 ifa->check_link = ip->check_link;
575 ifa->ecmp_weight = ip->ecmp_weight;
576 ifa->check_ttl = (ip->ttl_security == 1);
577 ifa->bfd = ip->bfd;
578 ifa->autype = ip->autype;
579 ifa->passwords = ip->passwords;
580 ifa->instance_id = ip->instance_id;
581
582 ifa->ptp_netmask = !(addr->flags & IA_PEER);
583 if (ip->ptp_netmask < 2)
584 ifa->ptp_netmask = ip->ptp_netmask;
585
586
587 ifa->type = ospf_iface_classify(ip->type, addr);
588
589 /* Check validity of interface type */
590 int old_type = ifa->type;
591 u32 if_multi_flag = ip->real_bcast ? IF_BROADCAST : IF_MULTICAST;
592
593 if (ospf_is_v2(p) && (ifa->type == OSPF_IT_BCAST) && (addr->flags & IA_PEER))
594 ifa->type = OSPF_IT_PTP;
595
596 if (ospf_is_v2(p) && (ifa->type == OSPF_IT_NBMA) && (addr->flags & IA_PEER))
597 ifa->type = OSPF_IT_PTMP;
598
599 if ((ifa->type == OSPF_IT_BCAST) && !(iface->flags & if_multi_flag))
600 ifa->type = OSPF_IT_NBMA;
601
602 if ((ifa->type == OSPF_IT_PTP) && !(iface->flags & if_multi_flag))
603 ifa->type = OSPF_IT_PTMP;
604
605 if (ifa->type != old_type)
606 log(L_WARN "%s: Cannot use interface %s as %s, forcing %s",
607 p->p.name, iface->name, ospf_it[old_type], ospf_it[ifa->type]);
608
609
610 if ((ifa->type == OSPF_IT_PTP) || (ifa->type == OSPF_IT_PTMP))
611 ifa->link_lsa_suppression = ip->link_lsa_suppression;
612
613 ifa->state = OSPF_IS_DOWN;
614 init_list(&ifa->neigh_list);
615 init_list(&ifa->nbma_list);
616
617 struct nbma_node *nb;
618 WALK_LIST(nb, ip->nbma_list)
619 {
620 /* In OSPFv3, addr is link-local while configured neighbors could
621 have global IP (although RFC 5340 C.5 says link-local addresses
622 should be used). Because OSPFv3 iface is not subnet-specific,
623 there is no need for ipa_in_net() check */
624
625 if (ospf_is_v2(p) && !ipa_in_net(nb->ip, addr->prefix, addr->pxlen))
626 continue;
627
628 if (ospf_is_v3(p) && !ipa_is_link_local(nb->ip))
629 log(L_WARN "%s: Configured neighbor address (%I) should be link-local",
630 p->p.name, nb->ip);
631
632 add_nbma_node(ifa, nb, 0);
633 }
634
635 add_tail(&oa->po->iface_list, NODE ifa);
636
637 struct object_lock *lock = olock_new(pool);
638 lock->addr = ospf_is_v2(p) ? ifa->addr->prefix : IPA_NONE;
639 lock->type = OBJLOCK_IP;
640 lock->port = OSPF_PROTO;
641 lock->inst = ifa->instance_id;
642 lock->iface = iface;
643 lock->data = ifa;
644 lock->hook = ospf_iface_add;
645
646 olock_acquire(lock);
647 }
648
649 void
650 ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
651 {
652 struct ospf_iface *ifa;
653 struct pool *pool;
654
655 if (!p->vlink_sk)
656 return;
657
658 OSPF_TRACE(D_EVENTS, "Adding vlink to %R via area %R", ip->vid, ip->voa);
659
660 /* Vlink ifname is stored just after the ospf_iface structure */
661
662 pool = rp_new(p->p.pool, "OSPF Vlink");
663 ifa = mb_allocz(pool, sizeof(struct ospf_iface) + 16);
664 ifa->oa = p->backbone;
665 ifa->cf = ip;
666 ifa->pool = pool;
667
668 /* Assign iface ID, for vlinks, this is ugly hack */
669 u32 vlink_id = p->last_vlink_id++;
670 ifa->iface_id = vlink_id + OSPF_VLINK_ID_OFFSET;
671 ifa->ifname = (void *) (ifa + 1);
672 bsprintf(ifa->ifname, "vlink%d", vlink_id);
673
674 ifa->voa = ospf_find_area(p, ip->voa);
675 ifa->vid = ip->vid;
676 ifa->sk = p->vlink_sk;
677
678 ifa->helloint = ip->helloint;
679 ifa->rxmtint = ip->rxmtint;
680 ifa->waitint = ip->waitint;
681 ifa->deadint = ip->deadint;
682 ifa->inftransdelay = ip->inftransdelay;
683 ifa->tx_length = ospf_is_v2(p) ? IP4_MIN_MTU : IP6_MIN_MTU;
684 ifa->autype = ip->autype;
685 ifa->passwords = ip->passwords;
686 ifa->instance_id = ip->instance_id;
687
688 ifa->type = OSPF_IT_VLINK;
689
690 ifa->state = OSPF_IS_DOWN;
691 init_list(&ifa->neigh_list);
692 init_list(&ifa->nbma_list);
693
694 add_tail(&p->iface_list, NODE ifa);
695
696 ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
697
698 ifa->flood_queue_size = ifa_flood_queue_size(ifa);
699 ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
700 }
701
702 static void
703 ospf_iface_change_timer(timer *tm, uint val)
704 {
705 if (!tm)
706 return;
707
708 tm->recurrent = val;
709
710 if (tm->expires)
711 tm_start(tm, val);
712 }
713
714 static inline void
715 ospf_iface_update_flood_queue_size(struct ospf_iface *ifa)
716 {
717 uint old_size = ifa->flood_queue_size;
718 uint new_size = ifa_flood_queue_size(ifa);
719
720 if (new_size <= old_size)
721 return;
722
723 ifa->flood_queue_size = new_size;
724 ifa->flood_queue = mb_realloc(ifa->flood_queue, new_size * sizeof(void *));
725 bzero(ifa->flood_queue + old_size, (new_size - old_size) * sizeof(void *));
726 }
727
728 int
729 ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
730 {
731 struct ospf_proto *p = ifa->oa->po;
732 struct ospf_iface_patt *old = ifa->cf;
733 char *ifname = ifa->ifname;
734
735 /* Type could be changed in ospf_iface_new(),
736 but if config values are same then also results are same */
737 int old_type = ospf_iface_classify(old->type, ifa->addr);
738 int new_type = ospf_iface_classify(new->type, ifa->addr);
739 if (old_type != new_type)
740 return 0;
741
742 int new_stub = ospf_iface_stubby(new, ifa->addr);
743 if (ifa->stub != new_stub)
744 return 0;
745
746 /* Change of these options would require to reset the iface socket */
747 if ((new->real_bcast != old->real_bcast) ||
748 (new->tx_tos != old->tx_tos) ||
749 (new->tx_priority != old->tx_priority) ||
750 (new->ttl_security != old->ttl_security))
751 return 0;
752
753 ifa->cf = new;
754 ifa->marked = 0;
755
756
757 /* HELLO TIMER */
758 if (ifa->helloint != new->helloint)
759 {
760 OSPF_TRACE(D_EVENTS, "Changing hello interval of %s from %d to %d",
761 ifname, ifa->helloint, new->helloint);
762
763 ifa->helloint = new->helloint;
764 ospf_iface_change_timer(ifa->hello_timer, ifa->helloint);
765 }
766
767 /* RXMT TIMER */
768 if (ifa->rxmtint != new->rxmtint)
769 {
770 OSPF_TRACE(D_EVENTS, "Changing retransmit interval of %s from %d to %d",
771 ifname, ifa->rxmtint, new->rxmtint);
772
773 ifa->rxmtint = new->rxmtint;
774 /* FIXME: Update neighbors' timers */
775 }
776
777 /* POLL TIMER */
778 if (ifa->pollint != new->pollint)
779 {
780 OSPF_TRACE(D_EVENTS, "Changing poll interval of %s from %d to %d",
781 ifname, ifa->pollint, new->pollint);
782
783 ifa->pollint = new->pollint;
784 ospf_iface_change_timer(ifa->poll_timer, ifa->pollint);
785 }
786
787 /* WAIT TIMER */
788 if (ifa->waitint != new->waitint)
789 {
790 OSPF_TRACE(D_EVENTS, "Changing wait interval of %s from %d to %d",
791 ifname, ifa->waitint, new->waitint);
792
793 ifa->waitint = new->waitint;
794 if (ifa->wait_timer && ifa->wait_timer->expires)
795 tm_start(ifa->wait_timer, ifa->waitint);
796 }
797
798 /* DEAD TIMER */
799 if (ifa->deadint != new->deadint)
800 {
801 OSPF_TRACE(D_EVENTS, "Changing dead interval of %s from %d to %d",
802 ifname, ifa->deadint, new->deadint);
803 ifa->deadint = new->deadint;
804 }
805
806 /* INFTRANS */
807 if (ifa->inftransdelay != new->inftransdelay)
808 {
809 OSPF_TRACE(D_EVENTS, "Changing transmit delay of %s from %d to %d",
810 ifname, ifa->inftransdelay, new->inftransdelay);
811 ifa->inftransdelay = new->inftransdelay;
812 }
813
814 /* AUTHENTICATION */
815 if (ifa->autype != new->autype)
816 {
817 OSPF_TRACE(D_EVENTS, "Changing authentication type of %s", ifname);
818 ifa->autype = new->autype;
819 }
820
821 /* Update passwords */
822 ifa->passwords = new->passwords;
823
824 /* Remaining options are just for proper interfaces */
825 if (ifa->type == OSPF_IT_VLINK)
826 return 1;
827
828
829 /* COST */
830 if (ifa->cost != new->cost)
831 {
832 OSPF_TRACE(D_EVENTS, "Changing cost of %s from %d to %d",
833 ifname, ifa->cost, new->cost);
834
835 ifa->cost = new->cost;
836 }
837
838 /* PRIORITY */
839 if (ifa->priority != new->priority)
840 {
841 OSPF_TRACE(D_EVENTS, "Changing priority of %s from %d to %d",
842 ifname, ifa->priority, new->priority);
843
844 ifa->priority = new->priority;
845 ospf_notify_link_lsa(ifa);
846 }
847
848 /* STRICT NBMA */
849 if (ifa->strictnbma != new->strictnbma)
850 {
851 OSPF_TRACE(D_EVENTS, "Changing NBMA strictness of %s from %d to %d",
852 ifname, ifa->strictnbma, new->strictnbma);
853 ifa->strictnbma = new->strictnbma;
854 }
855
856 struct nbma_node *nb, *nbx;
857
858 /* NBMA LIST - remove or update old */
859 WALK_LIST_DELSAFE(nb, nbx, ifa->nbma_list)
860 {
861 struct nbma_node *nb2 = find_nbma_node_(&new->nbma_list, nb->ip);
862 if (nb2)
863 {
864 if (nb->eligible != nb2->eligible)
865 {
866 OSPF_TRACE(D_EVENTS, "Changing eligibility of NBMA neighbor %I on %s",
867 nb->ip, ifname);
868 nb->eligible = nb2->eligible;
869 }
870 }
871 else
872 {
873 OSPF_TRACE(D_EVENTS, "Removing NBMA neighbor %I on %s",
874 nb->ip, ifname);
875 rem_node(NODE nb);
876 mb_free(nb);
877 }
878 }
879
880 /* NBMA LIST - add new */
881 WALK_LIST(nb, new->nbma_list)
882 {
883 /* See related note in ospf_iface_new() */
884 if (ospf_is_v2(p) && !ipa_in_net(nb->ip, ifa->addr->prefix, ifa->addr->pxlen))
885 continue;
886
887 if (ospf_is_v3(p) && !ipa_is_link_local(nb->ip))
888 log(L_WARN "%s: Configured neighbor address (%I) should be link-local",
889 p->p.name, nb->ip);
890
891 if (! find_nbma_node(ifa, nb->ip))
892 {
893 OSPF_TRACE(D_EVENTS, "Adding NBMA neighbor %I on %s",
894 nb->ip, ifname);
895 add_nbma_node(ifa, nb, !!find_neigh_by_ip(ifa, nb->ip));
896 }
897 }
898
899 int update_buffers = 0;
900
901 /* TX LENGTH */
902 if (old->tx_length != new->tx_length)
903 {
904 OSPF_TRACE(D_EVENTS, "Changing TX length of %s from %d to %d",
905 ifname, old->tx_length, new->tx_length);
906
907 /* ifa cannot be vlink */
908 ifa->tx_length = ifa_tx_length(ifa);
909 update_buffers = 1;
910
911 if (!ifa->stub)
912 ospf_iface_update_flood_queue_size(ifa);
913 }
914
915 /* RX BUFFER */
916 if (old->rx_buffer != new->rx_buffer)
917 {
918 OSPF_TRACE(D_EVENTS, "Changing buffer size of %s from %d to %d",
919 ifname, old->rx_buffer, new->rx_buffer);
920
921 /* ifa cannot be vlink */
922 update_buffers = 1;
923 }
924
925 /* Buffer size depends on both tx_length and rx_buffer options */
926 if (update_buffers && ifa->sk)
927 {
928 uint bsize = ifa_bufsize(ifa);
929 sk_set_rbsize(ifa->sk, bsize);
930 sk_set_tbsize(ifa->sk, bsize);
931 }
932
933 /* LINK */
934 if (ifa->check_link != new->check_link)
935 {
936 OSPF_TRACE(D_EVENTS, "%s link check for %s",
937 new->check_link ? "Enabling" : "Disabling", ifname);
938 ifa->check_link = new->check_link;
939
940 /* ifa cannot be vlink */
941 if (!(ifa->iface->flags & IF_LINK_UP))
942 ospf_iface_sm(ifa, ifa->check_link ? ISM_LOOP : ISM_UNLOOP);
943 }
944
945 /* ECMP weight */
946 if (ifa->ecmp_weight != new->ecmp_weight)
947 {
948 OSPF_TRACE(D_EVENTS, "Changing ECMP weight of %s from %d to %d",
949 ifname, (int)ifa->ecmp_weight + 1, (int)new->ecmp_weight + 1);
950 ifa->ecmp_weight = new->ecmp_weight;
951 }
952
953 /* Link LSA suppression */
954 if (((ifa->type == OSPF_IT_PTP) || (ifa->type == OSPF_IT_PTMP)) &&
955 (ifa->link_lsa_suppression != new->link_lsa_suppression))
956 {
957 OSPF_TRACE(D_EVENTS, "Changing link LSA suppression of %s from %d to %d",
958 ifname, ifa->link_lsa_suppression, new->link_lsa_suppression);
959
960 ifa->link_lsa_suppression = new->link_lsa_suppression;
961 ospf_notify_link_lsa(ifa);
962 }
963
964 /* BFD */
965 if (ifa->bfd != new->bfd)
966 {
967 OSPF_TRACE(D_EVENTS, "%s BFD for %s",
968 new->bfd ? "Enabling" : "Disabling", ifname);
969 ifa->bfd = new->bfd;
970
971 struct ospf_neighbor *n;
972 WALK_LIST(n, ifa->neigh_list)
973 ospf_neigh_update_bfd(n, ifa->bfd);
974 }
975
976
977 /* instance_id is not updated - it is part of key */
978
979 return 1;
980 }
981
982
983 /*
984 * State for matching iface pattterns walk
985 *
986 * This is significantly different in OSPFv2 and OSPFv3.
987 * In OSPFv2, OSPF ifaces are created for each IP prefix (struct ifa)
988 * In OSPFv3, OSPF ifaces are created based on real iface (struct iface)
989 * We support instance_id for both OSPFv2 (RFC 6549) and OSPFv3.
990 *
991 * We process one ifa/iface and match it for all configured instance IDs. We
992 * maintain bitfields to track whether given instance ID was already matched.
993 * We have two bitfields, one global (active) and one per area (ignore), to
994 * detect misconfigured cases where one iface with one instance ID matches in
995 * multiple areas.
996 */
997
998 struct ospf_mip_walk {
999 u32 active[8]; /* Bitfield of active instance IDs */
1000 u32 ignore[8]; /* Bitfield of instance IDs matched in current area */
1001 struct ospf_area *oa; /* Current area */
1002 struct ospf_iface_patt *ip; /* Current iface pattern */
1003 struct iface *iface; /* Specified iface (input) */
1004 struct ifa *a; /* Specified ifa (input) */
1005 int warn; /* Whether iface matched in multiple areas */
1006 };
1007
1008 static int
1009 ospf_walk_matching_iface_patts(struct ospf_proto *p, struct ospf_mip_walk *s)
1010 {
1011 int id;
1012
1013 if (s->ip)
1014 goto step;
1015
1016 WALK_LIST(s->oa, p->area_list)
1017 {
1018 if (s->oa->marked)
1019 continue;
1020
1021 WALK_LIST(s->ip, s->oa->ac->patt_list)
1022 {
1023 id = s->ip->instance_id;
1024 if (BIT32_TEST(s->ignore, id))
1025 continue;
1026
1027 if (iface_patt_match(&s->ip->i, s->iface, s->a))
1028 {
1029 /* Now we matched ifa/iface/instance_id for the first time in current area */
1030 BIT32_SET(s->ignore, id);
1031
1032 /* If we already found it in previous areas, ignore it and add warning */
1033 if (BIT32_TEST(s->active, id))
1034 { s->warn = 1; continue; }
1035
1036 BIT32_SET(s->active, id);
1037 return 1;
1038 step:
1039 ;
1040 }
1041 }
1042 BIT32_ZERO(s->ignore, 256);
1043 }
1044
1045 if (s->warn)
1046 log(L_WARN "%s: Interface %s matches for multiple areas", p->p.name, s->iface->name);
1047
1048 return 0;
1049 }
1050
1051
1052 static struct ospf_iface *
1053 ospf_iface_find_by_key(struct ospf_proto *p, struct ifa *a, int instance_id)
1054 {
1055 struct ospf_iface *ifa;
1056
1057 WALK_LIST(ifa, p->iface_list)
1058 if ((ifa->addr == a) && (ifa->instance_id == instance_id) &&
1059 (ifa->type != OSPF_IT_VLINK))
1060 return ifa;
1061
1062 return NULL;
1063 }
1064
1065
1066 void
1067 ospf_ifa_notify2(struct proto *P, uint flags, struct ifa *a)
1068 {
1069 struct ospf_proto *p = (struct ospf_proto *) P;
1070
1071 if (a->flags & IA_SECONDARY)
1072 return;
1073
1074 if (a->scope <= SCOPE_LINK)
1075 return;
1076
1077 /* In OSPFv2, we create OSPF iface for each address. */
1078 if (flags & IF_CHANGE_UP)
1079 {
1080 struct ospf_mip_walk s = { .iface = a->iface, .a = a };
1081 while (ospf_walk_matching_iface_patts(p, &s))
1082 ospf_iface_new(s.oa, a, s.ip);
1083 }
1084
1085 if (flags & IF_CHANGE_DOWN)
1086 {
1087 struct ospf_iface *ifa, *ifx;
1088 WALK_LIST_DELSAFE(ifa, ifx, p->iface_list)
1089 if ((ifa->type != OSPF_IT_VLINK) && (ifa->addr == a))
1090 ospf_iface_remove(ifa);
1091 /* See a note in ospf_iface_notify() */
1092 }
1093 }
1094
1095 void
1096 ospf_ifa_notify3(struct proto *P, uint flags, struct ifa *a)
1097 {
1098 struct ospf_proto *p = (struct ospf_proto *) P;
1099
1100 if (a->flags & IA_SECONDARY)
1101 return;
1102
1103 if (a->scope < SCOPE_LINK)
1104 return;
1105
1106 /* In OSPFv3, we create OSPF iface for link-local address,
1107 other addresses are used for link-LSA. */
1108 if (a->scope == SCOPE_LINK)
1109 {
1110 if (flags & IF_CHANGE_UP)
1111 {
1112 struct ospf_mip_walk s = { .iface = a->iface };
1113 while (ospf_walk_matching_iface_patts(p, &s))
1114 ospf_iface_new(s.oa, a, s.ip);
1115 }
1116
1117 if (flags & IF_CHANGE_DOWN)
1118 {
1119 struct ospf_iface *ifa, *ifx;
1120 WALK_LIST_DELSAFE(ifa, ifx, p->iface_list)
1121 if ((ifa->addr == a) && (ifa->type != OSPF_IT_VLINK))
1122 ospf_iface_remove(ifa);
1123 }
1124 }
1125 else
1126 {
1127 struct ospf_iface *ifa;
1128 WALK_LIST(ifa, p->iface_list)
1129 if (ifa->iface == a->iface)
1130 {
1131 /* RFC 5340 4.4.3 Event 5 - prefix added/deleted */
1132 ospf_notify_link_lsa(ifa);
1133 ospf_notify_rt_lsa(ifa->oa);
1134 }
1135 }
1136 }
1137
1138
1139 static void
1140 ospf_reconfigure_ifaces2(struct ospf_proto *p)
1141 {
1142 struct iface *iface;
1143 struct ifa *a;
1144
1145 WALK_LIST(iface, iface_list)
1146 {
1147 if (! (iface->flags & IF_UP))
1148 continue;
1149
1150 WALK_LIST(a, iface->addrs)
1151 {
1152 if (a->flags & IA_SECONDARY)
1153 continue;
1154
1155 if (a->scope <= SCOPE_LINK)
1156 continue;
1157
1158 struct ospf_mip_walk s = { .iface = iface, .a = a };
1159 while (ospf_walk_matching_iface_patts(p, &s))
1160 {
1161 /* Main inner loop */
1162 struct ospf_iface *ifa = ospf_iface_find_by_key(p, a, s.ip->instance_id);
1163 if (ifa)
1164 {
1165 if ((ifa->oa == s.oa) && (ifa->marked < 2) &&
1166 ospf_iface_reconfigure(ifa, s.ip))
1167 continue;
1168
1169 /* Hard restart */
1170 log(L_INFO "%s: Restarting interface %s (%I/%d) in area %R",
1171 p->p.name, ifa->ifname, a->prefix, a->pxlen, s.oa->areaid);
1172 ospf_iface_shutdown(ifa);
1173 ospf_iface_remove(ifa);
1174 }
1175
1176 ospf_iface_new(s.oa, a, s.ip);
1177 }
1178 }
1179 }
1180 }
1181
1182 static void
1183 ospf_reconfigure_ifaces3(struct ospf_proto *p)
1184 {
1185 struct iface *iface;
1186 struct ifa *a;
1187
1188 WALK_LIST(iface, iface_list)
1189 {
1190 if (! (iface->flags & IF_UP))
1191 continue;
1192
1193 WALK_LIST(a, iface->addrs)
1194 {
1195 if (a->flags & IA_SECONDARY)
1196 continue;
1197
1198 if (a->scope != SCOPE_LINK)
1199 continue;
1200
1201 struct ospf_mip_walk s = { .iface = iface };
1202 while (ospf_walk_matching_iface_patts(p, &s))
1203 {
1204 /* Main inner loop */
1205 struct ospf_iface *ifa = ospf_iface_find_by_key(p, a, s.ip->instance_id);
1206 if (ifa)
1207 {
1208 if ((ifa->oa == s.oa) && (ifa->marked < 2) &&
1209 ospf_iface_reconfigure(ifa, s.ip))
1210 continue;
1211
1212 /* Hard restart */
1213 log(L_INFO "%s: Restarting interface %s (IID %d) in area %R",
1214 p->p.name, ifa->ifname, ifa->instance_id, s.oa->areaid);
1215 ospf_iface_shutdown(ifa);
1216 ospf_iface_remove(ifa);
1217 }
1218
1219 ospf_iface_new(s.oa, a, s.ip);
1220 }
1221 }
1222 }
1223 }
1224
1225 void
1226 ospf_reconfigure_ifaces(struct ospf_proto *p)
1227 {
1228 if (ospf_is_v2(p))
1229 ospf_reconfigure_ifaces2(p);
1230 else
1231 ospf_reconfigure_ifaces3(p);
1232 }
1233
1234
1235 static void
1236 ospf_iface_change_mtu(struct ospf_proto *p, struct ospf_iface *ifa)
1237 {
1238 /* ifa is not vlink */
1239
1240 OSPF_TRACE(D_EVENTS, "Interface %s changed MTU to %d", ifa->iface->mtu);
1241
1242 ifa->tx_length = ifa_tx_length(ifa);
1243
1244 if (!ifa->sk)
1245 return;
1246
1247 /* We do not shrink dynamic buffers */
1248 uint bsize = ifa_bufsize(ifa);
1249 if (bsize > ifa->sk->rbsize)
1250 sk_set_rbsize(ifa->sk, bsize);
1251 if (bsize > ifa->sk->tbsize)
1252 sk_set_tbsize(ifa->sk, bsize);
1253
1254 if (!ifa->stub)
1255 ospf_iface_update_flood_queue_size(ifa);
1256 }
1257
1258 static void
1259 ospf_iface_notify(struct ospf_proto *p, uint flags, struct ospf_iface *ifa)
1260 {
1261 /* ifa is not vlink */
1262
1263 if (flags & IF_CHANGE_DOWN)
1264 {
1265 ospf_iface_remove(ifa);
1266 return;
1267 }
1268
1269 if (flags & IF_CHANGE_LINK)
1270 ospf_iface_sm(ifa, (ifa->iface->flags & IF_LINK_UP) ? ISM_UNLOOP : ISM_LOOP);
1271
1272 if (flags & IF_CHANGE_MTU)
1273 ospf_iface_change_mtu(p, ifa);
1274 }
1275
1276 void
1277 ospf_if_notify(struct proto *P, uint flags, struct iface *iface)
1278 {
1279 struct ospf_proto *p = (struct ospf_proto *) P;
1280
1281 /*
1282 if (iface->flags & IF_IGNORE)
1283 return;
1284 */
1285
1286 /* Going up means that there are no such ifaces yet */
1287 if (flags & IF_CHANGE_UP)
1288 return;
1289
1290 struct ospf_iface *ifa, *ifx;
1291 WALK_LIST_DELSAFE(ifa, ifx, p->iface_list)
1292 if (ifa->iface == iface)
1293 ospf_iface_notify(p, flags, ifa);
1294
1295 /* We use here that even shutting down iface also shuts down
1296 the vlinks, but vlinks are not freed and stays in the
1297 iface_list even when down */
1298 }
1299
1300 void
1301 ospf_iface_info(struct ospf_iface *ifa)
1302 {
1303 char *more = "";
1304
1305 if (ifa->strictnbma &&
1306 ((ifa->type == OSPF_IT_NBMA) || (ifa->type == OSPF_IT_PTMP)))
1307 more = " (strict)";
1308
1309 if (ifa->cf->real_bcast &&
1310 ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_PTP)))
1311 more = " (real)";
1312
1313 if (ifa->type == OSPF_IT_VLINK)
1314 {
1315 cli_msg(-1015, "Virtual link %s to %R", ifa->ifname, ifa->vid);
1316 cli_msg(-1015, "\tPeer IP: %I", ifa->vip);
1317 cli_msg(-1015, "\tTransit area: %R (%u)", ifa->voa->areaid, ifa->voa->areaid);
1318 }
1319 else
1320 {
1321 if (ospf_is_v3(ifa->oa->po))
1322 cli_msg(-1015, "Interface %s (IID %d)", ifa->ifname, ifa->instance_id);
1323 else if (ifa->addr->flags & IA_PEER)
1324 cli_msg(-1015, "Interface %s (peer %I)", ifa->ifname, ifa->addr->opposite);
1325 else
1326 cli_msg(-1015, "Interface %s (%I/%d)", ifa->ifname, ifa->addr->prefix, ifa->addr->pxlen);
1327
1328 cli_msg(-1015, "\tType: %s%s", ospf_it[ifa->type], more);
1329 cli_msg(-1015, "\tArea: %R (%u)", ifa->oa->areaid, ifa->oa->areaid);
1330 }
1331 cli_msg(-1015, "\tState: %s%s", ospf_is_names[ifa->state], ifa->stub ? " (stub)" : "");
1332 cli_msg(-1015, "\tPriority: %u", ifa->priority);
1333 cli_msg(-1015, "\tCost: %u", ifa->cost);
1334 if (ifa->oa->po->ecmp)
1335 cli_msg(-1015, "\tECMP weight: %d", ((int) ifa->ecmp_weight) + 1);
1336 cli_msg(-1015, "\tHello timer: %u", ifa->helloint);
1337
1338 if (ifa->type == OSPF_IT_NBMA)
1339 {
1340 cli_msg(-1015, "\tPoll timer: %u", ifa->pollint);
1341 }
1342 cli_msg(-1015, "\tWait timer: %u", ifa->waitint);
1343 cli_msg(-1015, "\tDead timer: %u", ifa->deadint);
1344 cli_msg(-1015, "\tRetransmit timer: %u", ifa->rxmtint);
1345 if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
1346 {
1347 cli_msg(-1015, "\tDesigned router (ID): %R", ifa->drid);
1348 cli_msg(-1015, "\tDesigned router (IP): %I", ifa->drip);
1349 cli_msg(-1015, "\tBackup designed router (ID): %R", ifa->bdrid);
1350 cli_msg(-1015, "\tBackup designed router (IP): %I", ifa->bdrip);
1351 }
1352 }