]> git.ipfire.org Git - thirdparty/bird.git/blob - sysdep/unix/main.c
Protocols have their own explicit init routines
[thirdparty/bird.git] / sysdep / unix / main.c
1 /*
2 * BIRD Internet Routing Daemon -- Unix Entry Point
3 *
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #undef LOCAL_DEBUG
10
11 #ifndef _GNU_SOURCE
12 #define _GNU_SOURCE
13 #endif
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <fcntl.h>
18 #include <unistd.h>
19 #include <signal.h>
20 #include <pwd.h>
21 #include <grp.h>
22 #include <sys/stat.h>
23 #include <sys/utsname.h>
24 #include <libgen.h>
25
26 #include "nest/bird.h"
27 #include "lib/lists.h"
28 #include "lib/resource.h"
29 #include "lib/socket.h"
30 #include "lib/event.h"
31 #include "lib/timer.h"
32 #include "lib/string.h"
33 #include "nest/route.h"
34 #include "nest/protocol.h"
35 #include "nest/iface.h"
36 #include "nest/cli.h"
37 #include "nest/locks.h"
38 #include "conf/conf.h"
39 #include "filter/filter.h"
40 #include "filter/data.h"
41
42 #include "unix.h"
43 #include "krt.h"
44
45 /*
46 * Debugging
47 */
48
49 void
50 async_dump(void)
51 {
52 debug("INTERNAL STATE DUMP\n\n");
53
54 rdump(&root_pool);
55 sk_dump_all();
56 // XXXX tm_dump_all();
57 if_dump_all();
58 neigh_dump_all();
59 rta_dump_all();
60 rt_dump_all();
61 protos_dump_all();
62
63 debug("\n");
64 }
65
66 /*
67 * Dropping privileges
68 */
69
70 #ifdef CONFIG_RESTRICTED_PRIVILEGES
71 #include CONFIG_INCLUDE_SYSPRIV_H
72 #else
73
74 static inline void
75 drop_uid(uid_t uid UNUSED)
76 {
77 die("Cannot change user on this platform");
78 }
79
80 #endif
81
82 static inline void
83 drop_gid(gid_t gid)
84 {
85 if (setgid(gid) < 0)
86 die("setgid: %m");
87
88 if (setgroups(0, NULL) < 0)
89 die("setgroups: %m");
90 }
91
92 /*
93 * Hostname
94 */
95
96 char *
97 get_hostname(linpool *lp)
98 {
99 struct utsname uts = {};
100
101 if (uname(&uts) < 0)
102 return NULL;
103
104 return lp_strdup(lp, uts.nodename);
105 }
106
107 /*
108 * Reading the Configuration
109 */
110
111 #ifdef PATH_IPROUTE_DIR
112
113 static inline void
114 add_num_const(char *name, int val, const char *file, const uint line)
115 {
116 struct f_val *v = cfg_alloc(sizeof(struct f_val));
117 *v = (struct f_val) { .type = T_INT, .val.i = val };
118 struct symbol *sym = cf_get_symbol(name);
119 if (sym->class && (sym->scope == conf_this_scope))
120 cf_error("Error reading value for %s from %s:%d: already defined", name, file, line);
121
122 cf_define_symbol(sym, SYM_CONSTANT | T_INT, val, v);
123 }
124
125 /* the code of read_iproute_table() is based on
126 rtnl_tab_initialize() from iproute2 package */
127 static void
128 read_iproute_table(char *file, char *prefix, uint max)
129 {
130 char buf[512], namebuf[512];
131 char *name;
132 uint val;
133 FILE *fp;
134
135 strcpy(namebuf, prefix);
136 name = namebuf + strlen(prefix);
137
138 fp = fopen(file, "r");
139 if (!fp)
140 return;
141
142 for (uint line = 1; fgets(buf, sizeof(buf), fp); line++)
143 {
144 char *p = buf;
145
146 while (*p == ' ' || *p == '\t')
147 p++;
148
149 if (*p == '#' || *p == '\n' || *p == 0)
150 continue;
151
152 if (sscanf(p, "0x%x %s\n", &val, name) != 2 &&
153 sscanf(p, "0x%x %s #", &val, name) != 2 &&
154 sscanf(p, "%u %s\n", &val, name) != 2 &&
155 sscanf(p, "%u %s #", &val, name) != 2)
156 continue;
157
158 if (val > max)
159 continue;
160
161 for(p = name; *p; p++)
162 if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && (*p != '_'))
163 *p = '_';
164
165 add_num_const(namebuf, val, file, line);
166 }
167
168 fclose(fp);
169 }
170
171 #endif // PATH_IPROUTE_DIR
172
173
174 static char *config_name = PATH_CONFIG_FILE;
175
176 static int
177 cf_read(byte *dest, uint len, int fd)
178 {
179 int l = read(fd, dest, len);
180 if (l < 0)
181 cf_error("Read error");
182 return l;
183 }
184
185 void
186 sysdep_preconfig(struct config *c)
187 {
188 init_list(&c->logfiles);
189
190 c->latency_limit = UNIX_DEFAULT_LATENCY_LIMIT;
191 c->watchdog_warning = UNIX_DEFAULT_WATCHDOG_WARNING;
192
193 #ifdef PATH_IPROUTE_DIR
194 read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 255);
195 read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 0xffffffff);
196 read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 255);
197 read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 0xffffffff);
198 #endif
199 }
200
201 int
202 sysdep_commit(struct config *new, struct config *old UNUSED)
203 {
204 log_switch(0, &new->logfiles, new->syslog_name);
205 return 0;
206 }
207
208 static int
209 unix_read_config(struct config **cp, const char *name)
210 {
211 struct config *conf = config_alloc(name);
212 int ret;
213
214 *cp = conf;
215 conf->file_fd = open(name, O_RDONLY);
216 if (conf->file_fd < 0)
217 return 0;
218 cf_read_hook = cf_read;
219 ret = config_parse(conf);
220 close(conf->file_fd);
221 return ret;
222 }
223
224 static struct config *
225 read_config(void)
226 {
227 struct config *conf;
228
229 if (!unix_read_config(&conf, config_name))
230 {
231 if (conf->err_msg)
232 die("%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
233 else
234 die("Unable to open configuration file %s: %m", config_name);
235 }
236
237 return conf;
238 }
239
240 void
241 async_config(void)
242 {
243 struct config *conf;
244
245 log(L_INFO "Reconfiguration requested by SIGHUP");
246 if (!unix_read_config(&conf, config_name))
247 {
248 if (conf->err_msg)
249 log(L_ERR "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
250 else
251 log(L_ERR "Unable to open configuration file %s: %m", config_name);
252 config_free(conf);
253 }
254 else
255 config_commit(conf, RECONFIG_HARD, 0);
256 }
257
258 static struct config *
259 cmd_read_config(const char *name)
260 {
261 struct config *conf;
262
263 if (!name)
264 name = config_name;
265
266 cli_msg(-2, "Reading configuration from %s", name);
267 if (!unix_read_config(&conf, name))
268 {
269 if (conf->err_msg)
270 cli_msg(8002, "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
271 else
272 cli_msg(8002, "%s: %m", name);
273 config_free(conf);
274 conf = NULL;
275 }
276
277 return conf;
278 }
279
280 void
281 cmd_check_config(const char *name)
282 {
283 struct config *conf = cmd_read_config(name);
284 if (!conf)
285 return;
286
287 cli_msg(20, "Configuration OK");
288 config_free(conf);
289 }
290
291 static void
292 cmd_reconfig_msg(int r)
293 {
294 switch (r)
295 {
296 case CONF_DONE: cli_msg( 3, "Reconfigured"); break;
297 case CONF_PROGRESS: cli_msg( 4, "Reconfiguration in progress"); break;
298 case CONF_QUEUED: cli_msg( 5, "Reconfiguration already in progress, queueing new config"); break;
299 case CONF_UNQUEUED: cli_msg(17, "Reconfiguration already in progress, removing queued config"); break;
300 case CONF_CONFIRM: cli_msg(18, "Reconfiguration confirmed"); break;
301 case CONF_SHUTDOWN: cli_msg( 6, "Reconfiguration ignored, shutting down"); break;
302 case CONF_NOTHING: cli_msg(19, "Nothing to do"); break;
303 default: break;
304 }
305 }
306
307 /* Hack for scheduled undo notification */
308 cli *cmd_reconfig_stored_cli;
309
310 void
311 cmd_reconfig_undo_notify(void)
312 {
313 if (cmd_reconfig_stored_cli)
314 {
315 cli *c = cmd_reconfig_stored_cli;
316 cli_printf(c, CLI_ASYNC_CODE, "Config timeout expired, starting undo");
317 cli_write_trigger(c);
318 }
319 }
320
321 void
322 cmd_reconfig(const char *name, int type, uint timeout)
323 {
324 if (cli_access_restricted())
325 return;
326
327 struct config *conf = cmd_read_config(name);
328 if (!conf)
329 return;
330
331 int r = config_commit(conf, type, timeout);
332
333 if ((r >= 0) && (timeout > 0))
334 {
335 cmd_reconfig_stored_cli = this_cli;
336 cli_msg(-22, "Undo scheduled in %d s", timeout);
337 }
338
339 cmd_reconfig_msg(r);
340 }
341
342 void
343 cmd_reconfig_confirm(void)
344 {
345 if (cli_access_restricted())
346 return;
347
348 int r = config_confirm();
349 cmd_reconfig_msg(r);
350 }
351
352 void
353 cmd_reconfig_undo(void)
354 {
355 if (cli_access_restricted())
356 return;
357
358 cli_msg(-21, "Undo requested");
359
360 int r = config_undo();
361 cmd_reconfig_msg(r);
362 }
363
364 void
365 cmd_reconfig_status(void)
366 {
367 int s = config_status();
368 btime t = config_timer_status();
369
370 switch (s)
371 {
372 case CONF_DONE: cli_msg(-3, "Daemon is up and running"); break;
373 case CONF_PROGRESS: cli_msg(-4, "Reconfiguration in progress"); break;
374 case CONF_QUEUED: cli_msg(-5, "Reconfiguration in progress, next one enqueued"); break;
375 case CONF_SHUTDOWN: cli_msg(-6, "Shutdown in progress"); break;
376 default: break;
377 }
378
379 if (t >= 0)
380 cli_msg(-22, "Configuration unconfirmed, undo in %t s", t);
381
382 cli_msg(0, "");
383 }
384
385
386 /*
387 * Command-Line Interface
388 */
389
390 static sock *cli_sk;
391 static char *path_control_socket = PATH_CONTROL_SOCKET;
392
393
394 static void
395 cli_write(cli *c)
396 {
397 sock *s = c->priv;
398
399 while (c->tx_pos)
400 {
401 struct cli_out *o = c->tx_pos;
402
403 int len = o->wpos - o->outpos;
404 s->tbuf = o->outpos;
405 o->outpos = o->wpos;
406
407 if (sk_send(s, len) <= 0)
408 return;
409
410 c->tx_pos = o->next;
411 }
412
413 /* Everything is written */
414 s->tbuf = NULL;
415 cli_written(c);
416 }
417
418 void
419 cli_write_trigger(cli *c)
420 {
421 sock *s = c->priv;
422
423 if (s->tbuf == NULL)
424 cli_write(c);
425 }
426
427 static void
428 cli_tx(sock *s)
429 {
430 cli_write(s->data);
431 }
432
433 int
434 cli_get_command(cli *c)
435 {
436 sock *s = c->priv;
437 byte *t = c->rx_aux ? : s->rbuf;
438 byte *tend = s->rpos;
439 byte *d = c->rx_pos;
440 byte *dend = c->rx_buf + CLI_RX_BUF_SIZE - 2;
441
442 while (t < tend)
443 {
444 if (*t == '\r')
445 t++;
446 else if (*t == '\n')
447 {
448 t++;
449 c->rx_pos = c->rx_buf;
450 c->rx_aux = t;
451 *d = 0;
452 return (d < dend) ? 1 : -1;
453 }
454 else if (d < dend)
455 *d++ = *t++;
456 }
457 c->rx_aux = s->rpos = s->rbuf;
458 c->rx_pos = d;
459 return 0;
460 }
461
462 static int
463 cli_rx(sock *s, uint size UNUSED)
464 {
465 cli_kick(s->data);
466 return 0;
467 }
468
469 static void
470 cli_err(sock *s, int err)
471 {
472 if (config->cli_debug)
473 {
474 if (err)
475 log(L_INFO "CLI connection dropped: %s", strerror(err));
476 else
477 log(L_INFO "CLI connection closed");
478 }
479 cli_free(s->data);
480 }
481
482 static void
483 cli_connect_err(sock *s UNUSED, int err)
484 {
485 ASSERT_DIE(err);
486 if (config->cli_debug)
487 log(L_INFO "Failed to accept CLI connection: %s", strerror(err));
488 }
489
490 static int
491 cli_connect(sock *s, uint size UNUSED)
492 {
493 cli *c;
494
495 if (config->cli_debug)
496 log(L_INFO "CLI connect");
497 s->rx_hook = cli_rx;
498 s->tx_hook = cli_tx;
499 s->err_hook = cli_err;
500 s->data = c = cli_new(s);
501 s->pool = c->pool; /* We need to have all the socket buffers allocated in the cli pool */
502 s->fast_rx = 1;
503 c->rx_pos = c->rx_buf;
504 c->rx_aux = NULL;
505 rmove(s, c->pool);
506 return 1;
507 }
508
509 static void
510 cli_init_unix(uid_t use_uid, gid_t use_gid)
511 {
512 sock *s;
513
514 cli_init();
515 s = cli_sk = sk_new(cli_pool);
516 s->type = SK_UNIX_PASSIVE;
517 s->rx_hook = cli_connect;
518 s->err_hook = cli_connect_err;
519 s->rbsize = 1024;
520 s->fast_rx = 1;
521
522 /* Return value intentionally ignored */
523 unlink(path_control_socket);
524
525 if (sk_open_unix(s, path_control_socket) < 0)
526 die("Cannot create control socket %s: %m", path_control_socket);
527
528 if (use_uid || use_gid)
529 if (chown(path_control_socket, use_uid, use_gid) < 0)
530 die("chown: %m");
531
532 if (chmod(path_control_socket, 0660) < 0)
533 die("chmod: %m");
534 }
535
536 /*
537 * PID file
538 */
539
540 static char *pid_file;
541 static int pid_fd;
542
543 static inline void
544 open_pid_file(void)
545 {
546 if (!pid_file)
547 return;
548
549 pid_fd = open(pid_file, O_WRONLY|O_CREAT, 0664);
550 if (pid_fd < 0)
551 die("Cannot create PID file %s: %m", pid_file);
552 }
553
554 static inline void
555 write_pid_file(void)
556 {
557 int pl, rv;
558 char ps[24];
559
560 if (!pid_file)
561 return;
562
563 /* We don't use PID file for uniqueness, so no need for locking */
564
565 pl = bsnprintf(ps, sizeof(ps), "%ld\n", (s64) getpid());
566 if (pl < 0)
567 bug("PID buffer too small");
568
569 rv = ftruncate(pid_fd, 0);
570 if (rv < 0)
571 die("fruncate: %m");
572
573 rv = write(pid_fd, ps, pl);
574 if(rv < 0)
575 die("write: %m");
576
577 close(pid_fd);
578 }
579
580 static inline void
581 unlink_pid_file(void)
582 {
583 if (pid_file)
584 unlink(pid_file);
585 }
586
587
588 /*
589 * Shutdown
590 */
591
592 void
593 cmd_shutdown(void)
594 {
595 if (cli_access_restricted())
596 return;
597
598 cli_msg(7, "Shutdown requested");
599 order_shutdown(0);
600 }
601
602 void
603 async_shutdown(void)
604 {
605 DBG("Shutting down...\n");
606 order_shutdown(0);
607 }
608
609 void
610 sysdep_shutdown_done(void)
611 {
612 unlink_pid_file();
613 unlink(path_control_socket);
614 log_msg(L_FATAL "Shutdown completed");
615 exit(0);
616 }
617
618 void
619 cmd_graceful_restart(void)
620 {
621 if (cli_access_restricted())
622 return;
623
624 cli_msg(25, "Graceful restart requested");
625 order_shutdown(1);
626 }
627
628
629 /*
630 * Signals
631 */
632
633 volatile sig_atomic_t async_config_flag;
634 volatile sig_atomic_t async_dump_flag;
635 volatile sig_atomic_t async_shutdown_flag;
636
637 static void
638 handle_sighup(int sig UNUSED)
639 {
640 DBG("Caught SIGHUP...\n");
641 async_config_flag = 1;
642 }
643
644 static void
645 handle_sigusr(int sig UNUSED)
646 {
647 DBG("Caught SIGUSR...\n");
648 async_dump_flag = 1;
649 }
650
651 static void
652 handle_sigterm(int sig UNUSED)
653 {
654 DBG("Caught SIGTERM...\n");
655 async_shutdown_flag = 1;
656 }
657
658 void watchdog_sigalrm(int sig UNUSED);
659
660 static void
661 signal_init(void)
662 {
663 struct sigaction sa;
664
665 bzero(&sa, sizeof(sa));
666 sa.sa_handler = handle_sigusr;
667 sa.sa_flags = SA_RESTART;
668 sigaction(SIGUSR1, &sa, NULL);
669 sa.sa_handler = handle_sighup;
670 sa.sa_flags = SA_RESTART;
671 sigaction(SIGHUP, &sa, NULL);
672 sa.sa_handler = handle_sigterm;
673 sa.sa_flags = SA_RESTART;
674 sigaction(SIGTERM, &sa, NULL);
675 sa.sa_handler = watchdog_sigalrm;
676 sa.sa_flags = 0;
677 sigaction(SIGALRM, &sa, NULL);
678 signal(SIGPIPE, SIG_IGN);
679 }
680
681 /*
682 * Parsing of command-line arguments
683 */
684
685 static char *opt_list = "bc:dD:ps:P:u:g:flRh";
686 int parse_and_exit;
687 char *bird_name;
688 static char *use_user;
689 static char *use_group;
690 static int run_in_foreground = 0;
691
692 static void
693 display_usage(void)
694 {
695 fprintf(stderr, "Usage: %s [--version] [--help] [-c <config-file>] [OPTIONS]\n", bird_name);
696 }
697
698 static void
699 display_help(void)
700 {
701 display_usage();
702
703 fprintf(stderr,
704 "\n"
705 "Options: \n"
706 " -c <config-file> Use given configuration file instead of\n"
707 " " PATH_CONFIG_FILE "\n"
708 " -d Enable debug messages and run bird in foreground\n"
709 " -D <debug-file> Log debug messages to given file instead of stderr\n"
710 " -f Run bird in foreground\n"
711 " -g <group> Use given group ID\n"
712 " -h, --help Display this information\n"
713 " -l Look for a configuration file and a control socket\n"
714 " in the current working directory\n"
715 " -p Test configuration file and exit without start\n"
716 " -P <pid-file> Create a PID file with given filename\n"
717 " -R Apply graceful restart recovery after start\n"
718 " -s <control-socket> Use given filename for a control socket\n"
719 " -u <user> Drop privileges and use given user ID\n"
720 " --version Display version of BIRD\n");
721
722 exit(0);
723 }
724
725 static void
726 display_version(void)
727 {
728 fprintf(stderr, "BIRD version " BIRD_VERSION "\n");
729 exit(0);
730 }
731
732 static inline char *
733 get_bird_name(char *s, char *def)
734 {
735 char *t;
736 if (!s)
737 return def;
738 t = strrchr(s, '/');
739 if (!t)
740 return s;
741 if (!t[1])
742 return def;
743 return t+1;
744 }
745
746 static inline uid_t
747 get_uid(const char *s)
748 {
749 struct passwd *pw;
750 char *endptr;
751 long int rv;
752
753 if (!s)
754 return 0;
755
756 errno = 0;
757 rv = strtol(s, &endptr, 10);
758
759 if (!errno && !*endptr)
760 return rv;
761
762 pw = getpwnam(s);
763 if (!pw)
764 die("Cannot find user '%s'", s);
765
766 return pw->pw_uid;
767 }
768
769 static inline gid_t
770 get_gid(const char *s)
771 {
772 struct group *gr;
773 char *endptr;
774 long int rv;
775
776 if (!s)
777 return 0;
778
779 errno = 0;
780 rv = strtol(s, &endptr, 10);
781
782 if (!errno && !*endptr)
783 return rv;
784
785 gr = getgrnam(s);
786 if (!gr)
787 die("Cannot find group '%s'", s);
788
789 return gr->gr_gid;
790 }
791
792 static void
793 parse_args(int argc, char **argv)
794 {
795 int config_changed = 0;
796 int socket_changed = 0;
797 int c;
798
799 bird_name = get_bird_name(argv[0], "bird");
800 if (argc == 2)
801 {
802 if (!strcmp(argv[1], "--version"))
803 display_version();
804 if (!strcmp(argv[1], "--help"))
805 display_help();
806 }
807 while ((c = getopt(argc, argv, opt_list)) >= 0)
808 switch (c)
809 {
810 case 'c':
811 config_name = optarg;
812 config_changed = 1;
813 break;
814 case 'd':
815 log_init_debug("");
816 run_in_foreground = 1;
817 break;
818 case 'D':
819 log_init_debug(optarg);
820 break;
821 case 'p':
822 parse_and_exit = 1;
823 break;
824 case 's':
825 path_control_socket = optarg;
826 socket_changed = 1;
827 break;
828 case 'P':
829 pid_file = optarg;
830 break;
831 case 'u':
832 use_user = optarg;
833 break;
834 case 'g':
835 use_group = optarg;
836 break;
837 case 'f':
838 run_in_foreground = 1;
839 break;
840 case 'l':
841 if (!config_changed)
842 config_name = xbasename(config_name);
843 if (!socket_changed)
844 path_control_socket = xbasename(path_control_socket);
845 break;
846 case 'R':
847 graceful_restart_recovery();
848 break;
849 case 'h':
850 display_help();
851 break;
852 default:
853 fputc('\n', stderr);
854 display_usage();
855 exit(1);
856 }
857 if (optind < argc)
858 {
859 display_usage();
860 exit(1);
861 }
862 }
863
864 /*
865 * Hic Est main()
866 */
867
868 int
869 main(int argc, char **argv)
870 {
871 #ifdef HAVE_LIBDMALLOC
872 if (!getenv("DMALLOC_OPTIONS"))
873 dmalloc_debug(0x2f03d00);
874 #endif
875
876 parse_args(argc, argv);
877 log_switch(1, NULL, NULL);
878
879 random_init();
880 net_init();
881 resource_init();
882 timer_init();
883 olock_init();
884 io_init();
885 rt_init();
886 if_init();
887 // roa_init();
888 config_init();
889
890 uid_t use_uid = get_uid(use_user);
891 gid_t use_gid = get_gid(use_group);
892
893 if (!parse_and_exit)
894 {
895 test_old_bird(path_control_socket);
896 cli_init_unix(use_uid, use_gid);
897 }
898
899 if (use_gid)
900 drop_gid(use_gid);
901
902 if (use_uid)
903 drop_uid(use_uid);
904
905 if (!parse_and_exit)
906 open_pid_file();
907
908 protos_build();
909
910 struct config *conf = read_config();
911
912 if (parse_and_exit)
913 exit(0);
914
915 if (!run_in_foreground)
916 {
917 pid_t pid = fork();
918 if (pid < 0)
919 die("fork: %m");
920 if (pid)
921 return 0;
922 setsid();
923 close(0);
924 if (open("/dev/null", O_RDWR) < 0)
925 die("Cannot open /dev/null: %m");
926 dup2(0, 1);
927 dup2(0, 2);
928 }
929
930 main_thread_init();
931
932 write_pid_file();
933
934 signal_init();
935
936 config_commit(conf, RECONFIG_HARD, 0);
937
938 graceful_restart_init();
939
940 #ifdef LOCAL_DEBUG
941 async_dump_flag = 1;
942 #endif
943
944 log(L_INFO "Started");
945 DBG("Entering I/O loop.\n");
946
947 io_loop();
948 bug("I/O loop died");
949 }