diff options
Diffstat (limited to 'src/pluto/server.c')
-rw-r--r-- | src/pluto/server.c | 88 |
1 files changed, 14 insertions, 74 deletions
diff --git a/src/pluto/server.c b/src/pluto/server.c index 4d07843c1..167b1d4c7 100644 --- a/src/pluto/server.c +++ b/src/pluto/server.c @@ -222,10 +222,6 @@ use_interface(const char *rifn) } } -#ifndef IPSECDEVPREFIX -# define IPSECDEVPREFIX "ipsec" -#endif - static struct raw_iface * find_raw_ifaces4(void) { @@ -233,7 +229,7 @@ find_raw_ifaces4(void) struct ifconf ifconf; struct ifreq buf[300]; /* for list of interfaces -- arbitrary limit */ struct raw_iface *rifaces = NULL; - int master_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); /* Get a UDP socket */ + int master_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); /* Get a UDP socket */ /* get list of interfaces with assigned IPv4 addresses from system */ @@ -401,7 +397,6 @@ find_raw_ifaces6(void) return rifaces; } -#if 1 static int create_socket(struct raw_iface *ifp, const char *v_name, int port) { @@ -414,7 +409,6 @@ create_socket(struct raw_iface *ifp, const char *v_name, int port) return -1; } -#if 1 /* Set socket Nonblocking */ if ((fcntl_flags=fcntl(fd, F_GETFL)) >= 0) { if (!(fcntl_flags & O_NONBLOCK)) { @@ -422,7 +416,6 @@ create_socket(struct raw_iface *ifp, const char *v_name, int port) fcntl(fd, F_SETFL, fcntl_flags); } } -#endif if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { @@ -467,7 +460,6 @@ create_socket(struct raw_iface *ifp, const char *v_name, int port) } #endif -#if defined(linux) && defined(KERNEL26_SUPPORT) { struct sadb_x_policy policy; int level, opt; @@ -509,7 +501,6 @@ create_socket(struct raw_iface *ifp, const char *v_name, int port) return -1; } } -#endif setportof(htons(port), &ifp->addr); if (bind(fd, sockaddrof(&ifp->addr), sockaddrlenof(&ifp->addr)) < 0) @@ -523,29 +514,21 @@ create_socket(struct raw_iface *ifp, const char *v_name, int port) setportof(htons(pluto_port), &ifp->addr); return fd; } -#endif static void process_raw_ifaces(struct raw_iface *rifaces) { struct raw_iface *ifp; - /* Find all virtual/real interface pairs. - * For each real interface... + /* For each real interface... */ for (ifp = rifaces; ifp != NULL; ifp = ifp->next) { - struct raw_iface *v = NULL; /* matching ipsecX interface */ + struct raw_iface *v = NULL; bool after = FALSE; /* has vfp passed ifp on the list? */ bool bad = FALSE; struct raw_iface *vfp; - /* ignore if virtual (ipsec*) interface */ - if (strneq(ifp->name, IPSECDEVPREFIX, sizeof(IPSECDEVPREFIX)-1)) - { - continue; - } - for (vfp = rifaces; vfp != NULL; vfp = vfp->next) { if (vfp == ifp) @@ -554,74 +537,26 @@ process_raw_ifaces(struct raw_iface *rifaces) } else if (sameaddr(&ifp->addr, &vfp->addr)) { - /* Different entries with matching IP addresses. - * Many interesting cases. + /* ugh: a second interface with the same IP address + * "after" allows us to avoid double reporting. */ - if (strneq(vfp->name, IPSECDEVPREFIX, sizeof(IPSECDEVPREFIX)-1)) + if (after) { - if (v != NULL && !streq(v->name, vfp->name)) - { - loglog(RC_LOG_SERIOUS - , "ipsec interfaces %s and %s share same address %s" - , v->name, vfp->name, ip_str(&ifp->addr)); - bad = TRUE; - } - else - { - v = vfp; /* current winner */ - } - } - else - { - /* ugh: a second real interface with the same IP address - * "after" allows us to avoid double reporting. - */ -#if defined(linux) && defined(KERNEL26_SUPPORT) - { - if (after) - { - bad = TRUE; - break; - } - continue; - } -#endif - if (after) - { - loglog(RC_LOG_SERIOUS - , "IP interfaces %s and %s share address %s!" - , ifp->name, vfp->name, ip_str(&ifp->addr)); - } bad = TRUE; + break; } + continue; } } if (bad) continue; -#if defined(linux) && defined(KERNEL26_SUPPORT) - { - v = ifp; - goto add_entry; - } -#endif - - /* what if we didn't find a virtual interface? */ - if (v == NULL) - { - DBG(DBG_CONTROL, - DBG_log("IP interface %s %s has no matching ipsec* interface -- ignored" - , ifp->name, ip_str(&ifp->addr))); - continue; - } + v = ifp; /* We've got all we need; see if this is a new thing: * search old interfaces list. */ -#if defined(linux) && defined(KERNEL26_SUPPORT) -add_entry: -#endif { struct iface **p = &interfaces; @@ -787,6 +722,7 @@ call_server(void) act.sa_handler = &termhandler; r = sigaction(SIGTERM, &act, NULL); + r = sigaction(SIGINT, &act, NULL); passert(r == 0); } @@ -821,6 +757,7 @@ call_server(void) FD_ZERO(&writefds); FD_SET(ctl_fd, &readfds); +#ifdef ADNS /* the only write file-descriptor of interest */ if (adns_qfd != NULL_FD && unsent_ADNS_queries) { @@ -835,6 +772,7 @@ call_server(void) maxfd = adns_afd; FD_SET(adns_afd, &readfds); } +#endif /* ADNS */ events_fd = pluto->events->get_event_fd(pluto->events); if (maxfd < events_fd) @@ -902,6 +840,7 @@ call_server(void) { /* at least one file descriptor is ready */ +#ifdef ADNS if (adns_qfd != NULL_FD && FD_ISSET(adns_qfd, &writefds)) { passert(ndes > 0); @@ -920,6 +859,7 @@ call_server(void) passert(GLOBALS_ARE_RESET()); ndes--; } +#endif /* ADNS*/ if (FD_ISSET(events_fd, &readfds)) { |