Sprinkel in some #ifndef SMALL to make slaacd smaller for the
authorflorian <florian@openbsd.org>
Thu, 6 Jul 2017 15:02:53 +0000 (15:02 +0000)
committerflorian <florian@openbsd.org>
Thu, 6 Jul 2017 15:02:53 +0000 (15:02 +0000)
installer.

This removes the control socket handling which is useless because we
won't have slaacctl in the installer.

Also deraadt@ pointed out that this would be the first use of log.c in
the installer where we don't have syslogd running so it's rather
pointless. So this completely neuters logging.

The log.h change doesn't interfere with benno@'s efforts of unifying
log.c

The installer version of slaacd won't even compile control.c and log.c

sbin/slaacd/control.h
sbin/slaacd/engine.c
sbin/slaacd/frontend.c
sbin/slaacd/frontend.h
sbin/slaacd/log.h
sbin/slaacd/slaacd.c
sbin/slaacd/slaacd.h

index 49d6bd8..52b576c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: control.h,v 1.1 2017/06/03 10:00:29 florian Exp $     */
+/*     $OpenBSD: control.h,v 1.2 2017/07/06 15:02:53 florian Exp $     */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -16,6 +16,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifndef        SMALL
 struct {
        struct event    ev;
        struct event    evt;
@@ -33,3 +34,4 @@ void  control_accept(int, short, void *);
 void   control_dispatch_imsg(int, short, void *);
 int    control_imsg_relay(struct imsg *);
 void   control_cleanup(char *);
+#endif /* SMALL */
index 8a2befa..d71b36a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: engine.c,v 1.3 2017/07/05 20:18:11 florian Exp $      */
+/*     $OpenBSD: engine.c,v 1.4 2017/07/06 15:02:53 florian Exp $      */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -218,8 +218,10 @@ __dead void                 engine_shutdown(void);
 void                    engine_sig_handler(int sig, short, void *);
 void                    engine_dispatch_frontend(int, short, void *);
 void                    engine_dispatch_main(int, short, void *);
+#ifndef        SMALL
 void                    send_interface_info(struct slaacd_iface *, pid_t);
 void                    engine_showinfo_ctl(struct imsg *, uint32_t);
+#endif /* SMALL */
 struct slaacd_iface    *get_slaacd_iface_by_id(uint32_t);
 void                    remove_slaacd_iface(uint32_t);
 void                    free_ra(struct radv *);
@@ -382,7 +384,10 @@ engine_dispatch_frontend(int fd, short event, void *bula)
        struct dfr_proposal             *dfr_proposal = NULL;
        struct imsg_del_addr             del_addr;
        ssize_t                          n;
-       int                              shut = 0, verbose;
+       int                              shut = 0;
+#ifndef        SMALL
+       int                              verbose;
+#endif /* SMALL */
        uint32_t                         if_index;
 
        if (event & EV_READ) {
@@ -405,6 +410,7 @@ engine_dispatch_frontend(int fd, short event, void *bula)
                        break;
 
                switch (imsg.hdr.type) {
+#ifndef        SMALL
                case IMSG_CTL_LOG_VERBOSE:
                        /* Already checked by frontend. */
                        memcpy(&verbose, imsg.data, sizeof(verbose));
@@ -417,6 +423,7 @@ engine_dispatch_frontend(int fd, short event, void *bula)
                        memcpy(&if_index, imsg.data, sizeof(if_index));
                        engine_showinfo_ctl(&imsg, if_index);
                        break;
+#endif /* SMALL */
                case IMSG_UPDATE_IF:
                        if (imsg.hdr.len != IMSG_HEADER_SIZE +
                            sizeof(imsg_ifinfo))
@@ -669,6 +676,7 @@ engine_dispatch_main(int fd, short event, void *bula)
        }
 }
 
+#ifndef        SMALL
 void
 send_interface_info(struct slaacd_iface *iface, pid_t pid)
 {
@@ -830,6 +838,7 @@ engine_showinfo_ctl(struct imsg *imsg, uint32_t if_index)
                break;
        }
 }
+#endif /* SMALL */
 
 struct slaacd_iface*
 get_slaacd_iface_by_id(uint32_t if_index)
index 44e5809..28524e4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: frontend.c,v 1.2 2017/07/03 19:02:04 florian Exp $    */
+/*     $OpenBSD: frontend.c,v 1.3 2017/07/06 15:02:53 florian Exp $    */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -121,9 +121,11 @@ frontend(int debug, int verbose, char *sockname)
        log_init(debug, LOG_DAEMON);
        log_setverbose(verbose);
 
+#ifndef        SMALL
        /* Create slaacd control socket outside chroot. */
        if (control_init(sockname) == -1)
                fatalx("control socket setup failed");
+#endif /* SMALL */
 
        if ((pw = getpwnam(SLAACD_USER)) == NULL)
                fatal("getpwnam");
@@ -195,9 +197,11 @@ frontend(int debug, int verbose, char *sockname)
            iev_main->handler, iev_main);
        event_add(&iev_main->ev, NULL);
 
+#ifndef        SMALL
        /* Listen on control socket. */
        TAILQ_INIT(&ctl_conns);
        control_listen();
+#endif /* SMALL */
 
        event_set(&ev_route, routesock, EV_READ | EV_PERSIST, route_receive,
            NULL);
@@ -371,9 +375,11 @@ frontend_dispatch_main(int fd, short event, void *bula)
                case IMSG_STARTUP:
                        frontend_startup();
                        break;
+#ifndef        SMALL
                case IMSG_CTL_END:
                        control_imsg_relay(&imsg);
                        break;
+#endif /* SMALL */
                default:
                        log_debug("%s: error handling imsg %d", __func__,
                            imsg.hdr.type);
@@ -420,6 +426,7 @@ frontend_dispatch_engine(int fd, short event, void *bula)
                        break;
 
                switch (imsg.hdr.type) {
+#ifndef        SMALL
                case IMSG_CTL_END:
                case IMSG_CTL_SHOW_INTERFACE_INFO:
                case IMSG_CTL_SHOW_INTERFACE_INFO_RA:
@@ -432,6 +439,7 @@ frontend_dispatch_engine(int fd, short event, void *bula)
                case IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL:
                        control_imsg_relay(&imsg);
                        break;
+#endif /* SMALL */
                case IMSG_CTL_SEND_SOLICITATION:
                        if_index = *((uint32_t *)imsg.data);
                        send_solicitation(if_index);
index ced99d3..531d720 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: frontend.h,v 1.1 2017/06/03 10:00:29 florian Exp $    */
+/*     $OpenBSD: frontend.h,v 1.2 2017/07/06 15:02:53 florian Exp $    */
 
 /*
  * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -16,7 +16,9 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifndef        SMALL
 TAILQ_HEAD(ctl_conns, ctl_conn)        ctl_conns;
+#endif /* SMALL */
 
 void            frontend(int, int, char *);
 void            frontend_dispatch_main(int, short, void *);
index 8653cff..6657ba6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: log.h,v 1.1 2017/06/03 10:00:29 florian Exp $ */
+/*     $OpenBSD: log.h,v 1.2 2017/07/06 15:02:53 florian Exp $ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -22,6 +22,7 @@
 #include <stdarg.h>
 #include <sys/cdefs.h>
 
+#ifndef        SMALL
 void   log_init(int, int);
 void   log_procinit(const char *);
 void   log_setverbose(int);
@@ -42,5 +43,18 @@ __dead void fatal(const char *, ...)
            __attribute__((__format__ (printf, 1, 2)));
 __dead void fatalx(const char *, ...)
            __attribute__((__format__ (printf, 1, 2)));
+#else
+#define log_init(x...)         do {} while(0)
+#define log_procinit(x...)     do {} while(0)
+#define log_setverbose(x...)   do {} while(0)
+#define log_warn(x...)         do {} while(0)
+#define log_warnx(x...)                do {} while(0)
+#define log_info(x...)         do {} while(0)
+#define log_debug(x...)                do {} while(0)
+#define logit(x...)            do {} while(0)
+#define vlog(x...)             do {} while(0)
+#define fatal(x...)            exit(1)
+#define fatalx(x...)           exit(1)
+#endif /* SMALL */
 
 #endif /* LOG_H */
index 4d0cb7a..482ebf4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: slaacd.c,v 1.3 2017/07/06 14:57:29 florian Exp $      */
+/*     $OpenBSD: slaacd.c,v 1.4 2017/07/06 15:02:53 florian Exp $      */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -50,6 +50,7 @@
 #include "engine.h"
 #include "control.h"
 
+#ifndef        SMALL
 const char* imsg_type_name[] = {
        "IMSG_NONE",
        "IMSG_CTL_LOG_VERBOSE",
@@ -77,6 +78,7 @@ const char* imsg_type_name[] = {
        "IMSG_CONFIGURE_DFR",
        "IMSG_WITHDRAW_DFR",
 };
+#endif /* SMALL */
 
 __dead void    usage(void);
 __dead void    main_shutdown(void);
@@ -308,7 +310,9 @@ main_shutdown(void)
        free(iev_frontend);
        free(iev_engine);
 
+#ifndef        SMALL
        control_cleanup(csock);
+#endif /* SMALL */
 
        log_info("terminating");
        exit(0);
@@ -366,7 +370,10 @@ main_dispatch_frontend(int fd, short event, void *bula)
        struct imsgbuf          *ibuf;
        struct imsg              imsg;
        ssize_t                  n;
-       int                      shut = 0, verbose;
+       int                      shut = 0;
+#ifndef        SMALL
+       int                      verbose;
+#endif /* SMALL */
 
        ibuf = &iev->ibuf;
 
@@ -390,11 +397,13 @@ main_dispatch_frontend(int fd, short event, void *bula)
                        break;
 
                switch (imsg.hdr.type) {
+#ifndef        SMALL
                case IMSG_CTL_LOG_VERBOSE:
                        /* Already checked by frontend. */
                        memcpy(&verbose, imsg.data, sizeof(verbose));
                        log_setverbose(verbose);
                        break;
+#endif /* SMALL */
                default:
                        log_debug("%s: error handling imsg %d", __func__,
                            imsg.hdr.type);
index ba8a8cc..ecc192c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: slaacd.h,v 1.4 2017/07/06 14:57:29 florian Exp $      */
+/*     $OpenBSD: slaacd.h,v 1.5 2017/07/06 15:02:53 florian Exp $      */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -45,6 +45,7 @@ struct imsgev {
 
 enum imsg_type {
        IMSG_NONE,
+#ifndef        SMALL
        IMSG_CTL_LOG_VERBOSE,
        IMSG_CTL_SHOW_INTERFACE_INFO,
        IMSG_CTL_SHOW_INTERFACE_INFO_RA,
@@ -56,6 +57,7 @@ enum imsg_type {
        IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSALS,
        IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL,
        IMSG_CTL_END,
+#endif /* SMALL */
        IMSG_CTL_SEND_SOLICITATION,
        IMSG_SOCKET_IPC,
        IMSG_STARTUP,
@@ -85,6 +87,7 @@ enum rpref {
        HIGH,
 };
 
+#ifndef        SMALL
 struct ctl_engine_info {
        uint32_t                if_index;
        int                     running;
@@ -151,6 +154,7 @@ struct ctl_engine_info_dfr_proposal {
        uint32_t                 router_lifetime;
        char                     rpref[sizeof("MEDIUM")];
 };
+#endif /* SMALL */
 
 struct imsg_ifinfo {
        uint32_t                if_index;