Deleted Added
full compact
ctld.c (265507) ctld.c (265509)
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: stable/10/usr.sbin/ctld/ctld.c 265507 2014-05-07 07:29:39Z trasz $
29 * $FreeBSD: stable/10/usr.sbin/ctld/ctld.c 265509 2014-05-07 07:32:45Z trasz $
30 */
31
32#include <sys/types.h>
33#include <sys/time.h>
34#include <sys/socket.h>
35#include <sys/wait.h>
36#include <netinet/in.h>
37#include <assert.h>

--- 1365 unchanged lines hidden (view full) ---

1403 /*
1404 * We're done with this portal.
1405 */
1406 continue;
1407 }
1408
1409#ifdef ICL_KERNEL_PROXY
1410 if (proxy_mode) {
30 */
31
32#include <sys/types.h>
33#include <sys/time.h>
34#include <sys/socket.h>
35#include <sys/wait.h>
36#include <netinet/in.h>
37#include <assert.h>

--- 1365 unchanged lines hidden (view full) ---

1403 /*
1404 * We're done with this portal.
1405 */
1406 continue;
1407 }
1408
1409#ifdef ICL_KERNEL_PROXY
1410 if (proxy_mode) {
1411 log_debugx("listening on %s, portal-group \"%s\" using ICL proxy",
1412 newp->p_listen, newpg->pg_name);
1413 kernel_listen(newp->p_ai, newp->p_iser);
1411 newpg->pg_conf->conf_portal_id++;
1412 newp->p_id = newpg->pg_conf->conf_portal_id;
1413 log_debugx("listening on %s, portal-group "
1414 "\"%s\", portal id %d, using ICL proxy",
1415 newp->p_listen, newpg->pg_name, newp->p_id);
1416 kernel_listen(newp->p_ai, newp->p_iser,
1417 newp->p_id);
1414 continue;
1415 }
1416#endif
1417 assert(proxy_mode == false);
1418 assert(newp->p_iser == false);
1419
1420 log_debugx("listening on %s, portal-group \"%s\"",
1421 newp->p_listen, newpg->pg_name);

--- 244 unchanged lines hidden (view full) ---

1666
1667static void
1668main_loop(struct conf *conf, bool dont_fork)
1669{
1670 struct portal_group *pg;
1671 struct portal *portal;
1672#ifdef ICL_KERNEL_PROXY
1673 int connection_id;
1418 continue;
1419 }
1420#endif
1421 assert(proxy_mode == false);
1422 assert(newp->p_iser == false);
1423
1424 log_debugx("listening on %s, portal-group \"%s\"",
1425 newp->p_listen, newpg->pg_name);

--- 244 unchanged lines hidden (view full) ---

1670
1671static void
1672main_loop(struct conf *conf, bool dont_fork)
1673{
1674 struct portal_group *pg;
1675 struct portal *portal;
1676#ifdef ICL_KERNEL_PROXY
1677 int connection_id;
1678 int portal_id;
1674#endif
1675 fd_set fdset;
1676 int error, nfds, client_fd;
1677
1678 pidfile_write(conf->conf_pidfh);
1679
1680 for (;;) {
1681 if (sighup_received || sigterm_received)
1682 return;
1683
1684#ifdef ICL_KERNEL_PROXY
1685 if (proxy_mode) {
1679#endif
1680 fd_set fdset;
1681 int error, nfds, client_fd;
1682
1683 pidfile_write(conf->conf_pidfh);
1684
1685 for (;;) {
1686 if (sighup_received || sigterm_received)
1687 return;
1688
1689#ifdef ICL_KERNEL_PROXY
1690 if (proxy_mode) {
1686 connection_id = kernel_accept();
1687 if (connection_id == 0)
1688 continue;
1691 kernel_accept(&connection_id, &portal_id);
1689
1692
1690 /*
1691 * XXX: This is obviously temporary.
1692 */
1693 pg = TAILQ_FIRST(&conf->conf_portal_groups);
1694 portal = TAILQ_FIRST(&pg->pg_portals);
1693 log_debugx("incoming connection, id %d, portal id %d",
1694 connection_id, portal_id);
1695 TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {
1696 TAILQ_FOREACH(portal, &pg->pg_portals, p_next) {
1697 if (portal->p_id == portal_id) {
1698 goto found;
1699 }
1700 }
1701 }
1695
1702
1703 log_errx(1, "kernel returned invalid portal_id %d",
1704 portal_id);
1705
1706found:
1696 handle_connection(portal, connection_id, dont_fork);
1697 } else {
1698#endif
1699 assert(proxy_mode == false);
1700
1701 FD_ZERO(&fdset);
1702 nfds = 0;
1703 TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {

--- 195 unchanged lines hidden ---
1707 handle_connection(portal, connection_id, dont_fork);
1708 } else {
1709#endif
1710 assert(proxy_mode == false);
1711
1712 FD_ZERO(&fdset);
1713 nfds = 0;
1714 TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {

--- 195 unchanged lines hidden ---