1 From 2ea12d8b6d2a36c5d49df1ae97b86ba287835249 Mon Sep 17 00:00:00 2001
2 From: Jeremie Koenig <jk@jk.fr.eu.org>
3 Date: Thu, 27 May 2010 15:46:25 +0200
4 Subject: [PATCH 9/9] tcpsvd,udpsvd: conditionalize usage of SO_ORIGINAL_DST
6 On systems without this call, $TCPORIGDSTADDR is not set.
8 Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 networking/Config.src | 2 --
12 networking/tcpudp.c | 5 +++++
13 2 files changed, 5 insertions(+), 2 deletions(-)
15 diff --git a/networking/Config.src b/networking/Config.src
16 index fc613e8..2d29c42 100644
17 --- a/networking/Config.src
18 +++ b/networking/Config.src
19 @@ -733,7 +733,6 @@ config SLATTACH
23 - depends on PLATFORM_LINUX
25 tcpsvd listens on a TCP port and runs a program for each new
27 @@ -966,7 +965,6 @@ config IFUPDOWN_UDHCPC_CMD_OPTIONS
31 - depends on PLATFORM_LINUX
33 udpsvd listens on an UDP port and runs a program for each new
35 diff --git a/networking/tcpudp.c b/networking/tcpudp.c
36 index 53e622b..40f6825 100644
37 --- a/networking/tcpudp.c
38 +++ b/networking/tcpudp.c
44 /* Wants <limits.h> etc, thus included after libbb.h: */
46 #include <linux/types.h> /* for __be32 etc */
47 #include <linux/netfilter_ipv4.h>
50 // TODO: move into this file:
51 #include "tcpudp_perhost.h"
52 @@ -464,6 +467,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
54 const char *proto = tcp ? "TCP" : "UDP";
56 +#ifdef SO_ORIGINAL_DST
57 /* Extract "original" destination addr:port
58 * from Linux firewall. Useful when you redirect
59 * an outbond connection to local handler, and it needs
60 @@ -473,6 +477,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
61 xsetenv_plain("TCPORIGDSTADDR", addr);
65 xsetenv_plain("PROTO", proto);
66 xsetenv_proto(proto, "LOCALADDR", local_addr);
67 xsetenv_proto(proto, "REMOTEADDR", remote_addr);