1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
/* $OpenBSD: eigrpe.c,v 1.45 2024/11/21 13:17:57 claudio Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <errno.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "eigrpd.h"
#include "eigrpe.h"
#include "rde.h"
#include "log.h"
#include "control.h"
static void eigrpe_sig_handler(int, short, void *);
static __dead void eigrpe_shutdown(void);
static void eigrpe_dispatch_main(int, short, void *);
static void eigrpe_dispatch_rde(int, short, void *);
struct eigrpd_conf *econf;
static struct event ev4;
static struct event ev6;
static struct imsgev *iev_main;
static struct imsgev *iev_rde;
static void
eigrpe_sig_handler(int sig, short event, void *bula)
{
switch (sig) {
case SIGINT:
case SIGTERM:
eigrpe_shutdown();
/* NOTREACHED */
default:
fatalx("unexpected signal");
}
}
/* eigrp engine */
void
eigrpe(int debug, int verbose, char *sockname)
{
struct passwd *pw;
struct event ev_sigint, ev_sigterm;
econf = config_new_empty();
log_init(debug);
log_verbose(verbose);
/* create eigrpd control socket outside chroot */
if (control_init(sockname) == -1)
fatalx("control socket setup failed");
if (inet_pton(AF_INET, AllEIGRPRouters_v4, &global.mcast_addr_v4) != 1)
fatal("inet_pton");
if (inet_pton(AF_INET6, AllEIGRPRouters_v6, &global.mcast_addr_v6) != 1)
fatal("inet_pton");
/* create the raw ipv4 socket */
if ((global.eigrp_socket_v4 = socket(AF_INET,
SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_EIGRP)) == -1)
fatal("error creating raw ipv4 socket");
/* set some defaults */
if (if_set_ipv4_mcast_ttl(global.eigrp_socket_v4, EIGRP_IP_TTL) == -1)
fatal("if_set_ipv4_mcast_ttl");
if (if_set_ipv4_mcast_loop(global.eigrp_socket_v4) == -1)
fatal("if_set_ipv4_mcast_loop");
if (if_set_ipv4_recvif(global.eigrp_socket_v4, 1) == -1)
fatal("if_set_ipv4_recvif");
if (if_set_ipv4_hdrincl(global.eigrp_socket_v4) == -1)
fatal("if_set_ipv4_hdrincl");
if_set_sockbuf(global.eigrp_socket_v4);
/* create the raw ipv6 socket */
if ((global.eigrp_socket_v6 = socket(AF_INET6,
SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_EIGRP)) == -1)
fatal("error creating raw ipv6 socket");
/* set some defaults */
if (if_set_ipv6_mcast_loop(global.eigrp_socket_v6) == -1)
fatal("if_set_ipv6_mcast_loop");
if (if_set_ipv6_pktinfo(global.eigrp_socket_v6, 1) == -1)
fatal("if_set_ipv6_pktinfo");
if (if_set_ipv6_dscp(global.eigrp_socket_v6,
IPTOS_PREC_NETCONTROL) == -1)
fatal("if_set_ipv6_dscp");
if_set_sockbuf(global.eigrp_socket_v6);
if ((pw = getpwnam(EIGRPD_USER)) == NULL)
fatal("getpwnam");
if (chroot(pw->pw_dir) == -1)
fatal("chroot");
if (chdir("/") == -1)
fatal("chdir(\"/\")");
setproctitle("eigrp engine");
log_procname = "eigrpe";
if (setgroups(1, &pw->pw_gid) ||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
fatal("can't drop privileges");
if (pledge("stdio inet mcast recvfd", NULL) == -1)
fatal("pledge");
event_init();
/* setup signal handler */
signal_set(&ev_sigint, SIGINT, eigrpe_sig_handler, NULL);
signal_set(&ev_sigterm, SIGTERM, eigrpe_sig_handler, NULL);
signal_add(&ev_sigint, NULL);
signal_add(&ev_sigterm, NULL);
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN);
/* setup pipe and event handler to the parent process */
if ((iev_main = malloc(sizeof(struct imsgev))) == NULL)
fatal(NULL);
imsgbuf_init(&iev_main->ibuf, 3);
iev_main->handler = eigrpe_dispatch_main;
iev_main->events = EV_READ;
event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events,
iev_main->handler, iev_main);
event_add(&iev_main->ev, NULL);
event_set(&ev4, global.eigrp_socket_v4, EV_READ|EV_PERSIST,
recv_packet, econf);
event_add(&ev4, NULL);
event_set(&ev6, global.eigrp_socket_v6, EV_READ|EV_PERSIST,
recv_packet, econf);
event_add(&ev6, NULL);
/* listen on eigrpd control socket */
control_listen();
event_dispatch();
eigrpe_shutdown();
}
static __dead void
eigrpe_shutdown(void)
{
/* close pipes */
imsgbuf_write(&iev_rde->ibuf);
imsgbuf_clear(&iev_rde->ibuf);
close(iev_rde->ibuf.fd);
imsgbuf_write(&iev_main->ibuf);
imsgbuf_clear(&iev_main->ibuf);
close(iev_main->ibuf.fd);
config_clear(econf, PROC_EIGRP_ENGINE);
event_del(&ev4);
event_del(&ev6);
close(global.eigrp_socket_v4);
close(global.eigrp_socket_v6);
/* clean up */
free(iev_rde);
free(iev_main);
log_info("eigrp engine exiting");
exit(0);
}
/* imesg */
int
eigrpe_imsg_compose_parent(int type, pid_t pid, void *data, uint16_t datalen)
{
return (imsg_compose_event(iev_main, type, 0, pid, -1, data, datalen));
}
int
eigrpe_imsg_compose_rde(int type, uint32_t peerid, pid_t pid,
void *data, uint16_t datalen)
{
return (imsg_compose_event(iev_rde, type, peerid, pid, -1,
data, datalen));
}
static void
eigrpe_dispatch_main(int fd, short event, void *bula)
{
static struct eigrpd_conf *nconf;
static struct iface *niface;
static struct eigrp *neigrp;
struct eigrp_iface *nei;
struct imsg imsg;
struct imsgev *iev = bula;
struct imsgbuf *ibuf = &iev->ibuf;
struct iface *iface = NULL;
struct kif *kif;
struct kaddr *ka;
int n, shut = 0;
if (event & EV_READ) {
if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN)
fatal("imsgbuf_read error");
if (n == 0) /* connection closed */
shut = 1;
}
if (event & EV_WRITE) {
if (imsgbuf_write(ibuf) == -1) {
if (errno == EPIPE) /* connection closed */
shut = 1;
else
fatal("imsgbuf_write");
}
}
for (;;) {
if ((n = imsg_get(ibuf, &imsg)) == -1)
fatal("eigrpe_dispatch_main: imsg_get error");
if (n == 0)
break;
switch (imsg.hdr.type) {
case IMSG_IFINFO:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct kif))
fatalx("IFSTATUS imsg with wrong len");
kif = imsg.data;
iface = if_lookup(econf, kif->ifindex);
if (!iface)
break;
iface->flags = kif->flags;
iface->linkstate = kif->link_state;
if_update(iface, AF_UNSPEC);
break;
case IMSG_NEWADDR:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct kaddr))
fatalx("NEWADDR imsg with wrong len");
ka = imsg.data;
iface = if_lookup(econf, ka->ifindex);
if (iface == NULL)
break;
if_addr_new(iface, ka);
break;
case IMSG_DELADDR:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct kaddr))
fatalx("DELADDR imsg with wrong len");
ka = imsg.data;
iface = if_lookup(econf, ka->ifindex);
if (iface == NULL)
break;
if_addr_del(iface, ka);
break;
case IMSG_SOCKET_IPC:
if (iev_rde) {
log_warnx("%s: received unexpected imsg fd "
"to rde", __func__);
break;
}
if ((fd = imsg_get_fd(&imsg)) == -1) {
log_warnx("%s: expected to receive imsg fd to "
"rde but didn't receive any", __func__);
break;
}
iev_rde = malloc(sizeof(struct imsgev));
if (iev_rde == NULL)
fatal(NULL);
imsgbuf_init(&iev_rde->ibuf, fd);
iev_rde->handler = eigrpe_dispatch_rde;
iev_rde->events = EV_READ;
event_set(&iev_rde->ev, iev_rde->ibuf.fd,
iev_rde->events, iev_rde->handler, iev_rde);
event_add(&iev_rde->ev, NULL);
break;
case IMSG_RECONF_CONF:
if ((nconf = malloc(sizeof(struct eigrpd_conf))) ==
NULL)
fatal(NULL);
memcpy(nconf, imsg.data, sizeof(struct eigrpd_conf));
TAILQ_INIT(&nconf->iface_list);
TAILQ_INIT(&nconf->instances);
break;
case IMSG_RECONF_INSTANCE:
if ((neigrp = malloc(sizeof(struct eigrp))) == NULL)
fatal(NULL);
memcpy(neigrp, imsg.data, sizeof(struct eigrp));
SIMPLEQ_INIT(&neigrp->redist_list);
TAILQ_INIT(&neigrp->ei_list);
RB_INIT(&neigrp->nbrs);
RB_INIT(&neigrp->topology);
TAILQ_INSERT_TAIL(&nconf->instances, neigrp, entry);
break;
case IMSG_RECONF_IFACE:
niface = imsg.data;
niface = if_lookup(nconf, niface->ifindex);
if (niface)
break;
if ((niface = malloc(sizeof(struct iface))) == NULL)
fatal(NULL);
memcpy(niface, imsg.data, sizeof(struct iface));
TAILQ_INIT(&niface->ei_list);
TAILQ_INIT(&niface->addr_list);
TAILQ_INSERT_TAIL(&nconf->iface_list, niface, entry);
break;
case IMSG_RECONF_EIGRP_IFACE:
if (niface == NULL)
break;
if ((nei = malloc(sizeof(struct eigrp_iface))) == NULL)
fatal(NULL);
memcpy(nei, imsg.data, sizeof(struct eigrp_iface));
nei->iface = niface;
nei->eigrp = neigrp;
TAILQ_INIT(&nei->nbr_list);
TAILQ_INIT(&nei->update_list);
TAILQ_INIT(&nei->query_list);
TAILQ_INIT(&nei->summary_list);
TAILQ_INSERT_TAIL(&niface->ei_list, nei, i_entry);
TAILQ_INSERT_TAIL(&neigrp->ei_list, nei, e_entry);
if (RB_INSERT(iface_id_head, &ifaces_by_id, nei) !=
NULL)
fatalx("eigrpe_dispatch_main: "
"RB_INSERT(ifaces_by_id) failed");
break;
case IMSG_RECONF_END:
merge_config(econf, nconf, PROC_EIGRP_ENGINE);
nconf = NULL;
break;
case IMSG_CTL_KROUTE:
case IMSG_CTL_IFINFO:
case IMSG_CTL_END:
control_imsg_relay(&imsg);
break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
break;
}
imsg_free(&imsg);
}
if (!shut)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handler */
event_del(&iev->ev);
event_loopexit(NULL);
}
}
static void
eigrpe_dispatch_rde(int fd, short event, void *bula)
{
struct imsgev *iev = bula;
struct imsgbuf *ibuf = &iev->ibuf;
struct imsg imsg;
struct nbr *nbr;
struct eigrp_iface *ei;
struct rinfo rinfo;
int n, shut = 0;
if (event & EV_READ) {
if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN)
fatal("imsgbuf_read error");
if (n == 0) /* connection closed */
shut = 1;
}
if (event & EV_WRITE) {
if (imsgbuf_write(ibuf) == -1) {
if (errno == EPIPE) /* connection closed */
shut = 1;
else
fatal("imsgbuf_write");
}
}
for (;;) {
if ((n = imsg_get(ibuf, &imsg)) == -1)
fatal("eigrpe_dispatch_rde: imsg_get error");
if (n == 0)
break;
switch (imsg.hdr.type) {
case IMSG_SEND_UPDATE:
case IMSG_SEND_QUERY:
case IMSG_SEND_REPLY:
if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(rinfo))
fatalx("invalid size of rinfo");
memcpy(&rinfo, imsg.data, sizeof(rinfo));
nbr = nbr_find_peerid(imsg.hdr.peerid);
if (nbr == NULL) {
log_debug("%s: cannot find rde neighbor",
__func__);
break;
}
switch (imsg.hdr.type) {
case IMSG_SEND_UPDATE:
message_add(&nbr->update_list, &rinfo);
break;
case IMSG_SEND_QUERY:
message_add(&nbr->query_list, &rinfo);
break;
case IMSG_SEND_REPLY:
message_add(&nbr->reply_list, &rinfo);
break;
}
break;
case IMSG_SEND_MUPDATE:
case IMSG_SEND_MQUERY:
if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(rinfo))
fatalx("invalid size of rinfo");
memcpy(&rinfo, imsg.data, sizeof(rinfo));
ei = eigrp_if_lookup_id(imsg.hdr.peerid);
if (ei == NULL) {
log_debug("%s: cannot find interface",
__func__);
break;
}
switch (imsg.hdr.type) {
case IMSG_SEND_MUPDATE:
message_add(&ei->update_list, &rinfo);
break;
case IMSG_SEND_MQUERY:
message_add(&ei->query_list, &rinfo);
break;
}
break;
case IMSG_SEND_UPDATE_END:
case IMSG_SEND_REPLY_END:
case IMSG_SEND_SIAQUERY_END:
case IMSG_SEND_SIAREPLY_END:
nbr = nbr_find_peerid(imsg.hdr.peerid);
if (nbr == NULL) {
log_debug("%s: cannot find rde neighbor",
__func__);
break;
}
switch (imsg.hdr.type) {
case IMSG_SEND_UPDATE_END:
send_update(nbr->ei, nbr, 0, &nbr->update_list);
message_list_clr(&nbr->update_list);
break;
case IMSG_SEND_REPLY_END:
send_reply(nbr, &nbr->reply_list, 0);
message_list_clr(&nbr->reply_list);
break;
case IMSG_SEND_SIAQUERY_END:
send_query(nbr->ei, nbr, &nbr->query_list, 1);
message_list_clr(&nbr->query_list);
break;
case IMSG_SEND_SIAREPLY_END:
send_reply(nbr, &nbr->reply_list, 1);
message_list_clr(&nbr->reply_list);
break;
}
break;
case IMSG_SEND_MUPDATE_END:
case IMSG_SEND_MQUERY_END:
ei = eigrp_if_lookup_id(imsg.hdr.peerid);
if (ei == NULL) {
log_debug("%s: cannot find interface",
__func__);
break;
}
switch (imsg.hdr.type) {
case IMSG_SEND_MUPDATE_END:
send_update(ei, NULL, 0, &ei->update_list);
message_list_clr(&ei->update_list);
break;
case IMSG_SEND_MQUERY_END:
send_query(ei, NULL, &ei->query_list, 0);
message_list_clr(&ei->query_list);
break;
}
break;
case IMSG_NEIGHBOR_DOWN:
nbr = nbr_find_peerid(imsg.hdr.peerid);
if (nbr == NULL) {
log_debug("%s: cannot find rde neighbor",
__func__);
break;
}
/* announce that this neighborship is dead */
send_peerterm(nbr);
nbr_del(nbr);
break;
case IMSG_CTL_SHOW_TOPOLOGY:
case IMSG_CTL_END:
control_imsg_relay(&imsg);
break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
break;
}
imsg_free(&imsg);
}
if (!shut)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handler */
event_del(&iev->ev);
event_loopexit(NULL);
}
}
void
eigrpe_instance_init(struct eigrp *eigrp)
{
}
void
eigrpe_instance_del(struct eigrp *eigrp)
{
struct eigrp_iface *ei;
while ((ei = TAILQ_FIRST(&eigrp->ei_list)) != NULL)
eigrp_if_del(ei);
free(eigrp);
}
void
message_add(struct rinfo_head *rinfo_list, struct rinfo *rinfo)
{
struct rinfo_entry *re;
re = calloc(1, sizeof(*re));
if (re == NULL)
fatal("message_add");
re->rinfo = *rinfo;
TAILQ_INSERT_TAIL(rinfo_list, re, entry);
}
void
message_list_clr(struct rinfo_head *rinfo_list)
{
struct rinfo_entry *re;
while ((re = TAILQ_FIRST(rinfo_list)) != NULL) {
TAILQ_REMOVE(rinfo_list, re, entry);
free(re);
}
}
void
seq_addr_list_clr(struct seq_addr_head *seq_addr_list)
{
struct seq_addr_entry *sa;
while ((sa = TAILQ_FIRST(seq_addr_list)) != NULL) {
TAILQ_REMOVE(seq_addr_list, sa, entry);
free(sa);
}
}
void
eigrpe_orig_local_route(struct eigrp_iface *ei, struct if_addr *if_addr,
int withdraw)
{
struct rinfo rinfo;
memset(&rinfo, 0, sizeof(rinfo));
rinfo.af = if_addr->af;
rinfo.type = EIGRP_ROUTE_INTERNAL;
rinfo.prefix = if_addr->addr;
rinfo.prefixlen = if_addr->prefixlen;
eigrp_applymask(rinfo.af, &rinfo.prefix, &rinfo.prefix,
rinfo.prefixlen);
if (withdraw)
rinfo.metric.delay = EIGRP_INFINITE_METRIC;
else
rinfo.metric.delay = eigrp_composite_delay(ei->delay);
rinfo.metric.bandwidth = eigrp_composite_bandwidth(ei->bandwidth);
metric_encode_mtu(rinfo.metric.mtu, ei->iface->mtu);
rinfo.metric.hop_count = 0;
rinfo.metric.reliability = DEFAULT_RELIABILITY;
rinfo.metric.load = DEFAULT_LOAD;
rinfo.metric.tag = 0;
rinfo.metric.flags = 0;
eigrpe_imsg_compose_rde(IMSG_RECV_UPDATE, ei->self->peerid, 0,
&rinfo, sizeof(rinfo));
}
void
eigrpe_iface_ctl(struct ctl_conn *c, unsigned int idx)
{
struct eigrp *eigrp;
struct eigrp_iface *ei;
struct ctl_iface *ictl;
TAILQ_FOREACH(eigrp, &econf->instances, entry) {
TAILQ_FOREACH(ei, &eigrp->ei_list, e_entry) {
if (idx == 0 || idx == ei->iface->ifindex) {
ictl = if_to_ctl(ei);
imsg_compose_event(&c->iev,
IMSG_CTL_SHOW_INTERFACE, 0, 0, -1,
ictl, sizeof(struct ctl_iface));
}
}
}
}
void
eigrpe_nbr_ctl(struct ctl_conn *c)
{
struct eigrp *eigrp;
struct nbr *nbr;
struct ctl_nbr *nctl;
TAILQ_FOREACH(eigrp, &econf->instances, entry) {
RB_FOREACH(nbr, nbr_addr_head, &eigrp->nbrs) {
if (nbr->flags & (F_EIGRP_NBR_PENDING|F_EIGRP_NBR_SELF))
continue;
nctl = nbr_to_ctl(nbr);
imsg_compose_event(&c->iev, IMSG_CTL_SHOW_NBR, 0,
0, -1, nctl, sizeof(struct ctl_nbr));
}
}
imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
void
eigrpe_stats_ctl(struct ctl_conn *c)
{
struct eigrp *eigrp;
struct ctl_stats sctl;
TAILQ_FOREACH(eigrp, &econf->instances, entry) {
sctl.af = eigrp->af;
sctl.as = eigrp->as;
sctl.stats = eigrp->stats;
imsg_compose_event(&c->iev, IMSG_CTL_SHOW_STATS, 0,
0, -1, &sctl, sizeof(struct ctl_stats));
}
imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
|