tcpudp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /* Based on ipsvd utilities written by Gerrit Pape <pape@smarden.org>
  2. * which are released into public domain by the author.
  3. * Homepage: http://smarden.sunsite.dk/ipsvd/
  4. *
  5. * Copyright (C) 2007 Denys Vlasenko.
  6. *
  7. * Licensed under GPLv2, see file LICENSE in this tarball for details.
  8. */
  9. /* Based on ipsvd-0.12.1. This tcpsvd accepts all options
  10. * which are supported by one from ipsvd-0.12.1, but not all are
  11. * functional. See help text at the end of this file for details.
  12. *
  13. * Code inside "#ifdef SSLSVD" is for sslsvd and is currently unused.
  14. *
  15. * Busybox version exports TCPLOCALADDR instead of
  16. * TCPLOCALIP + TCPLOCALPORT pair. ADDR more closely matches reality
  17. * (which is "struct sockaddr_XXX". Port is not a separate entity,
  18. * it's just a part of (AF_INET[6]) sockaddr!).
  19. *
  20. * TCPORIGDSTADDR is Busybox-specific addition.
  21. *
  22. * udp server is hacked up by reusing TCP code. It has the following
  23. * limitation inherent in Unix DGRAM sockets implementation:
  24. * - local IP address is retrieved (using recvmsg voodoo) but
  25. * child's socket is not bound to it (bind cannot be called on
  26. * already bound socket). Thus it still can emit outgoing packets
  27. * with wrong source IP...
  28. * - don't know how to retrieve ORIGDST for udp.
  29. */
  30. #include "libbb.h"
  31. /* Wants <limits.h> etc, thus included after libbb.h: */
  32. #include <linux/types.h> /* for __be32 etc */
  33. #include <linux/netfilter_ipv4.h>
  34. // TODO: move into this file:
  35. #include "tcpudp_perhost.h"
  36. #ifdef SSLSVD
  37. #include "matrixSsl.h"
  38. #include "ssl_io.h"
  39. #endif
  40. struct globals {
  41. unsigned verbose;
  42. unsigned max_per_host;
  43. unsigned cur_per_host;
  44. unsigned cnum;
  45. unsigned cmax;
  46. char **env_cur;
  47. char *env_var[1]; /* actually bigger */
  48. };
  49. #define G (*(struct globals*)&bb_common_bufsiz1)
  50. #define verbose (G.verbose )
  51. #define max_per_host (G.max_per_host)
  52. #define cur_per_host (G.cur_per_host)
  53. #define cnum (G.cnum )
  54. #define cmax (G.cmax )
  55. #define env_cur (G.env_cur )
  56. #define env_var (G.env_var )
  57. #define INIT_G() do { \
  58. cmax = 30; \
  59. env_cur = &env_var[0]; \
  60. } while (0)
  61. /* We have to be careful about leaking memory in repeated setenv's */
  62. static void xsetenv_plain(const char *n, const char *v)
  63. {
  64. char *var = xasprintf("%s=%s", n, v);
  65. *env_cur++ = var;
  66. putenv(var);
  67. }
  68. static void xsetenv_proto(const char *proto, const char *n, const char *v)
  69. {
  70. char *var = xasprintf("%s%s=%s", proto, n, v);
  71. *env_cur++ = var;
  72. putenv(var);
  73. }
  74. static void undo_xsetenv(void)
  75. {
  76. char **pp = env_cur = &env_var[0];
  77. while (*pp) {
  78. char *var = *pp;
  79. *strchrnul(var, '=') = '\0';
  80. unsetenv(var);
  81. free(var);
  82. *pp++ = NULL;
  83. }
  84. }
  85. static void sig_term_handler(int sig)
  86. {
  87. if (verbose)
  88. bb_error_msg("got signal %u, exit", sig);
  89. kill_myself_with_sig(sig);
  90. }
  91. /* Little bloated, but tries to give accurate info how child exited.
  92. * Makes easier to spot segfaulting children etc... */
  93. static void print_waitstat(unsigned pid, int wstat)
  94. {
  95. unsigned e = 0;
  96. const char *cause = "?exit";
  97. if (WIFEXITED(wstat)) {
  98. cause++;
  99. e = WEXITSTATUS(wstat);
  100. } else if (WIFSIGNALED(wstat)) {
  101. cause = "signal";
  102. e = WTERMSIG(wstat);
  103. }
  104. bb_error_msg("end %d %s %d", pid, cause, e);
  105. }
  106. /* Must match getopt32 in main! */
  107. enum {
  108. OPT_c = (1 << 0),
  109. OPT_C = (1 << 1),
  110. OPT_i = (1 << 2),
  111. OPT_x = (1 << 3),
  112. OPT_u = (1 << 4),
  113. OPT_l = (1 << 5),
  114. OPT_E = (1 << 6),
  115. OPT_b = (1 << 7),
  116. OPT_h = (1 << 8),
  117. OPT_p = (1 << 9),
  118. OPT_t = (1 << 10),
  119. OPT_v = (1 << 11),
  120. OPT_V = (1 << 12),
  121. OPT_U = (1 << 13), /* from here: sslsvd only */
  122. OPT_slash = (1 << 14),
  123. OPT_Z = (1 << 15),
  124. OPT_K = (1 << 16),
  125. };
  126. static void connection_status(void)
  127. {
  128. /* "only 1 client max" desn't need this */
  129. if (cmax > 1)
  130. bb_error_msg("status %u/%u", cnum, cmax);
  131. }
  132. static void sig_child_handler(int sig ATTRIBUTE_UNUSED)
  133. {
  134. int wstat;
  135. int pid;
  136. while ((pid = wait_any_nohang(&wstat)) > 0) {
  137. if (max_per_host)
  138. ipsvd_perhost_remove(pid);
  139. if (cnum)
  140. cnum--;
  141. if (verbose)
  142. print_waitstat(pid, wstat);
  143. }
  144. if (verbose)
  145. connection_status();
  146. }
  147. int tcpudpsvd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  148. int tcpudpsvd_main(int argc ATTRIBUTE_UNUSED, char **argv)
  149. {
  150. char *str_C, *str_t;
  151. char *user;
  152. struct hcc *hccp;
  153. const char *instructs;
  154. char *msg_per_host = NULL;
  155. unsigned len_per_host = len_per_host; /* gcc */
  156. #ifndef SSLSVD
  157. struct bb_uidgid_t ugid;
  158. #endif
  159. bool tcp;
  160. uint16_t local_port;
  161. char *preset_local_hostname = NULL;
  162. char *remote_hostname = remote_hostname; /* for compiler */
  163. char *remote_addr = remote_addr; /* for compiler */
  164. len_and_sockaddr *lsa;
  165. len_and_sockaddr local, remote;
  166. socklen_t sa_len;
  167. int pid;
  168. int sock;
  169. int conn;
  170. unsigned backlog = 20;
  171. INIT_G();
  172. tcp = (applet_name[0] == 't');
  173. /* 3+ args, -i at most once, -p implies -h, -v is counter, -b N, -c N */
  174. opt_complementary = "-3:i--i:ph:vv:b+:c+";
  175. #ifdef SSLSVD
  176. getopt32(argv, "+c:C:i:x:u:l:Eb:hpt:vU:/:Z:K:",
  177. &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname,
  178. &backlog, &str_t, &ssluser, &root, &cert, &key, &verbose
  179. );
  180. #else
  181. /* "+": stop on first non-option */
  182. getopt32(argv, "+c:C:i:x:u:l:Eb:hpt:v",
  183. &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname,
  184. &backlog, &str_t, &verbose
  185. );
  186. #endif
  187. if (option_mask32 & OPT_C) { /* -C n[:message] */
  188. max_per_host = bb_strtou(str_C, &str_C, 10);
  189. if (str_C[0]) {
  190. if (str_C[0] != ':')
  191. bb_show_usage();
  192. msg_per_host = str_C + 1;
  193. len_per_host = strlen(msg_per_host);
  194. }
  195. }
  196. if (max_per_host > cmax)
  197. max_per_host = cmax;
  198. if (option_mask32 & OPT_u) {
  199. if (!get_uidgid(&ugid, user, 1))
  200. bb_error_msg_and_die("unknown user/group: %s", user);
  201. }
  202. #ifdef SSLSVD
  203. if (option_mask32 & OPT_U) ssluser = optarg;
  204. if (option_mask32 & OPT_slash) root = optarg;
  205. if (option_mask32 & OPT_Z) cert = optarg;
  206. if (option_mask32 & OPT_K) key = optarg;
  207. #endif
  208. argv += optind;
  209. if (!argv[0][0] || LONE_CHAR(argv[0], '0'))
  210. argv[0] = (char*)"0.0.0.0";
  211. /* Per-IP flood protection is not thought-out for UDP */
  212. if (!tcp)
  213. max_per_host = 0;
  214. bb_sanitize_stdio(); /* fd# 0,1,2 must be opened */
  215. #ifdef SSLSVD
  216. sslser = user;
  217. client = 0;
  218. if ((getuid() == 0) && !(option_mask32 & OPT_u)) {
  219. xfunc_exitcode = 100;
  220. bb_error_msg_and_die("-U ssluser must be set when running as root");
  221. }
  222. if (option_mask32 & OPT_u)
  223. if (!uidgid_get(&sslugid, ssluser, 1)) {
  224. if (errno) {
  225. bb_perror_msg_and_die("fatal: cannot get user/group: %s", ssluser);
  226. }
  227. bb_error_msg_and_die("unknown user/group '%s'", ssluser);
  228. }
  229. if (!cert) cert = "./cert.pem";
  230. if (!key) key = cert;
  231. if (matrixSslOpen() < 0)
  232. fatal("cannot initialize ssl");
  233. if (matrixSslReadKeys(&keys, cert, key, 0, ca) < 0) {
  234. if (client)
  235. fatal("cannot read cert, key, or ca file");
  236. fatal("cannot read cert or key file");
  237. }
  238. if (matrixSslNewSession(&ssl, keys, 0, SSL_FLAGS_SERVER) < 0)
  239. fatal("cannot create ssl session");
  240. #endif
  241. sig_block(SIGCHLD);
  242. signal(SIGCHLD, sig_child_handler);
  243. bb_signals(BB_FATAL_SIGS, sig_term_handler);
  244. signal(SIGPIPE, SIG_IGN);
  245. if (max_per_host)
  246. ipsvd_perhost_init(cmax);
  247. local_port = bb_lookup_port(argv[1], tcp ? "tcp" : "udp", 0);
  248. lsa = xhost2sockaddr(argv[0], local_port);
  249. argv += 2;
  250. sock = xsocket(lsa->u.sa.sa_family, tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
  251. setsockopt_reuseaddr(sock);
  252. sa_len = lsa->len; /* I presume sockaddr len stays the same */
  253. xbind(sock, &lsa->u.sa, sa_len);
  254. if (tcp)
  255. xlisten(sock, backlog);
  256. else /* udp: needed for recv_from_to to work: */
  257. socket_want_pktinfo(sock);
  258. /* ndelay_off(sock); - it is the default I think? */
  259. #ifndef SSLSVD
  260. if (option_mask32 & OPT_u) {
  261. /* drop permissions */
  262. xsetgid(ugid.gid);
  263. xsetuid(ugid.uid);
  264. }
  265. #endif
  266. if (verbose) {
  267. char *addr = xmalloc_sockaddr2dotted(&lsa->u.sa);
  268. bb_error_msg("listening on %s, starting", addr);
  269. free(addr);
  270. #ifndef SSLSVD
  271. if (option_mask32 & OPT_u)
  272. printf(", uid %u, gid %u",
  273. (unsigned)ugid.uid, (unsigned)ugid.gid);
  274. #endif
  275. }
  276. /* Main accept() loop */
  277. again:
  278. hccp = NULL;
  279. while (cnum >= cmax)
  280. wait_for_any_sig(); /* expecting SIGCHLD */
  281. /* Accept a connection to fd #0 */
  282. again1:
  283. close(0);
  284. again2:
  285. sig_unblock(SIGCHLD);
  286. local.len = remote.len = sa_len;
  287. if (tcp) {
  288. conn = accept(sock, &remote.u.sa, &remote.len);
  289. } else {
  290. /* In case recv_from_to won't be able to recover local addr.
  291. * Also sets port - recv_from_to is unable to do it. */
  292. local = *lsa;
  293. conn = recv_from_to(sock, NULL, 0, MSG_PEEK,
  294. &remote.u.sa, &local.u.sa, sa_len);
  295. }
  296. sig_block(SIGCHLD);
  297. if (conn < 0) {
  298. if (errno != EINTR)
  299. bb_perror_msg(tcp ? "accept" : "recv");
  300. goto again2;
  301. }
  302. xmove_fd(tcp ? conn : sock, 0);
  303. if (max_per_host) {
  304. /* Drop connection immediately if cur_per_host > max_per_host
  305. * (minimizing load under SYN flood) */
  306. remote_addr = xmalloc_sockaddr2dotted_noport(&remote.u.sa);
  307. cur_per_host = ipsvd_perhost_add(remote_addr, max_per_host, &hccp);
  308. if (cur_per_host > max_per_host) {
  309. /* ipsvd_perhost_add detected that max is exceeded
  310. * (and did not store ip in connection table) */
  311. free(remote_addr);
  312. if (msg_per_host) {
  313. /* don't block or test for errors */
  314. send(0, msg_per_host, len_per_host, MSG_DONTWAIT);
  315. }
  316. goto again1;
  317. }
  318. /* NB: remote_addr is not leaked, it is stored in conn table */
  319. }
  320. if (!tcp) {
  321. /* Voodoo magic: making udp sockets each receive its own
  322. * packets is not trivial, and I still not sure
  323. * I do it 100% right.
  324. * 1) we have to do it before fork()
  325. * 2) order is important - is it right now? */
  326. /* Open new non-connected UDP socket for further clients... */
  327. sock = xsocket(lsa->u.sa.sa_family, SOCK_DGRAM, 0);
  328. setsockopt_reuseaddr(sock);
  329. /* Make plain write/send work for old socket by supplying default
  330. * destination address. This also restricts incoming packets
  331. * to ones coming from this remote IP. */
  332. xconnect(0, &remote.u.sa, sa_len);
  333. /* hole? at this point we have no wildcard udp socket...
  334. * can this cause clients to get "port unreachable" icmp?
  335. * Yup, time window is very small, but it exists (is it?) */
  336. /* ..."open new socket", continued */
  337. xbind(sock, &lsa->u.sa, sa_len);
  338. socket_want_pktinfo(sock);
  339. /* Doesn't work:
  340. * we cannot replace fd #0 - we will lose pending packet
  341. * which is already buffered for us! And we cannot use fd #1
  342. * instead - it will "intercept" all following packets, but child
  343. * does not expect data coming *from fd #1*! */
  344. #if 0
  345. /* Make it so that local addr is fixed to localp->u.sa
  346. * and we don't accidentally accept packets to other local IPs. */
  347. /* NB: we possibly bind to the _very_ same_ address & port as the one
  348. * already bound in parent! This seems to work in Linux.
  349. * (otherwise we can move socket to fd #0 only if bind succeeds) */
  350. close(0);
  351. set_nport(localp, htons(local_port));
  352. xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0);
  353. setsockopt_reuseaddr(0); /* crucial */
  354. xbind(0, &localp->u.sa, localp->len);
  355. #endif
  356. }
  357. pid = vfork();
  358. if (pid == -1) {
  359. bb_perror_msg("vfork");
  360. goto again;
  361. }
  362. if (pid != 0) {
  363. /* Parent */
  364. cnum++;
  365. if (verbose)
  366. connection_status();
  367. if (hccp)
  368. hccp->pid = pid;
  369. /* clean up changes done by vforked child */
  370. undo_xsetenv();
  371. goto again;
  372. }
  373. /* Child: prepare env, log, and exec prog */
  374. /* Closing tcp listening socket */
  375. if (tcp)
  376. close(sock);
  377. { /* vfork alert! every xmalloc in this block should be freed! */
  378. char *local_hostname = local_hostname; /* for compiler */
  379. char *local_addr = NULL;
  380. char *free_me0 = NULL;
  381. char *free_me1 = NULL;
  382. char *free_me2 = NULL;
  383. if (verbose || !(option_mask32 & OPT_E)) {
  384. if (!max_per_host) /* remote_addr is not yet known */
  385. free_me0 = remote_addr = xmalloc_sockaddr2dotted(&remote.u.sa);
  386. if (option_mask32 & OPT_h) {
  387. free_me1 = remote_hostname = xmalloc_sockaddr2host_noport(&remote.u.sa);
  388. if (!remote_hostname) {
  389. bb_error_msg("cannot look up hostname for %s", remote_addr);
  390. remote_hostname = remote_addr;
  391. }
  392. }
  393. /* Find out local IP peer connected to.
  394. * Errors ignored (I'm not paranoid enough to imagine kernel
  395. * which doesn't know local IP). */
  396. if (tcp)
  397. getsockname(0, &local.u.sa, &local.len);
  398. /* else: for UDP it is done earlier by parent */
  399. local_addr = xmalloc_sockaddr2dotted(&local.u.sa);
  400. if (option_mask32 & OPT_h) {
  401. local_hostname = preset_local_hostname;
  402. if (!local_hostname) {
  403. free_me2 = local_hostname = xmalloc_sockaddr2host_noport(&local.u.sa);
  404. if (!local_hostname)
  405. bb_error_msg_and_die("cannot look up hostname for %s", local_addr);
  406. }
  407. /* else: local_hostname is not NULL, but is NOT malloced! */
  408. }
  409. }
  410. if (verbose) {
  411. pid = getpid();
  412. if (max_per_host) {
  413. bb_error_msg("concurrency %s %u/%u",
  414. remote_addr,
  415. cur_per_host, max_per_host);
  416. }
  417. bb_error_msg((option_mask32 & OPT_h)
  418. ? "start %u %s-%s (%s-%s)"
  419. : "start %u %s-%s",
  420. pid,
  421. local_addr, remote_addr,
  422. local_hostname, remote_hostname);
  423. }
  424. if (!(option_mask32 & OPT_E)) {
  425. /* setup ucspi env */
  426. const char *proto = tcp ? "TCP" : "UDP";
  427. /* Extract "original" destination addr:port
  428. * from Linux firewall. Useful when you redirect
  429. * an outbond connection to local handler, and it needs
  430. * to know where it originally tried to connect */
  431. if (tcp && getsockopt(0, SOL_IP, SO_ORIGINAL_DST, &local.u.sa, &local.len) == 0) {
  432. char *addr = xmalloc_sockaddr2dotted(&local.u.sa);
  433. xsetenv_plain("TCPORIGDSTADDR", addr);
  434. free(addr);
  435. }
  436. xsetenv_plain("PROTO", proto);
  437. xsetenv_proto(proto, "LOCALADDR", local_addr);
  438. xsetenv_proto(proto, "REMOTEADDR", remote_addr);
  439. if (option_mask32 & OPT_h) {
  440. xsetenv_proto(proto, "LOCALHOST", local_hostname);
  441. xsetenv_proto(proto, "REMOTEHOST", remote_hostname);
  442. }
  443. //compat? xsetenv_proto(proto, "REMOTEINFO", "");
  444. /* additional */
  445. if (cur_per_host > 0) /* can not be true for udp */
  446. xsetenv_plain("TCPCONCURRENCY", utoa(cur_per_host));
  447. }
  448. free(local_addr);
  449. free(free_me0);
  450. free(free_me1);
  451. free(free_me2);
  452. }
  453. xdup2(0, 1);
  454. signal(SIGTERM, SIG_DFL);
  455. signal(SIGPIPE, SIG_DFL);
  456. signal(SIGCHLD, SIG_DFL);
  457. sig_unblock(SIGCHLD);
  458. #ifdef SSLSVD
  459. strcpy(id, utoa(pid));
  460. ssl_io(0, argv);
  461. #else
  462. BB_EXECVP(argv[0], argv);
  463. #endif
  464. bb_perror_msg_and_die("exec '%s'", argv[0]);
  465. }
  466. /*
  467. tcpsvd [-hpEvv] [-c n] [-C n:msg] [-b n] [-u user] [-l name]
  468. [-i dir|-x cdb] [ -t sec] host port prog
  469. tcpsvd creates a TCP/IP socket, binds it to the address host:port,
  470. and listens on the socket for incoming connections.
  471. On each incoming connection, tcpsvd conditionally runs a program,
  472. with standard input reading from the socket, and standard output
  473. writing to the socket, to handle this connection. tcpsvd keeps
  474. listening on the socket for new connections, and can handle
  475. multiple connections simultaneously.
  476. tcpsvd optionally checks for special instructions depending
  477. on the IP address or hostname of the client that initiated
  478. the connection, see ipsvd-instruct(5).
  479. host
  480. host either is a hostname, or a dotted-decimal IP address,
  481. or 0. If host is 0, tcpsvd accepts connections to any local
  482. IP address.
  483. * busybox accepts IPv6 addresses and host:port pairs too
  484. In this case second parameter is ignored
  485. port
  486. tcpsvd accepts connections to host:port. port may be a name
  487. from /etc/services or a number.
  488. prog
  489. prog consists of one or more arguments. For each connection,
  490. tcpsvd normally runs prog, with file descriptor 0 reading from
  491. the network, and file descriptor 1 writing to the network.
  492. By default it also sets up TCP-related environment variables,
  493. see tcp-environ(5)
  494. -i dir
  495. read instructions for handling new connections from the instructions
  496. directory dir. See ipsvd-instruct(5) for details.
  497. * ignored by busyboxed version
  498. -x cdb
  499. read instructions for handling new connections from the constant database
  500. cdb. The constant database normally is created from an instructions
  501. directory by running ipsvd-cdb(8).
  502. * ignored by busyboxed version
  503. -t sec
  504. timeout. This option only takes effect if the -i option is given.
  505. While checking the instructions directory, check the time of last access
  506. of the file that matches the clients address or hostname if any, discard
  507. and remove the file if it wasn't accessed within the last sec seconds;
  508. tcpsvd does not discard or remove a file if the user's write permission
  509. is not set, for those files the timeout is disabled. Default is 0,
  510. which means that the timeout is disabled.
  511. * ignored by busyboxed version
  512. -l name
  513. local hostname. Do not look up the local hostname in DNS, but use name
  514. as hostname. This option must be set if tcpsvd listens on port 53
  515. to avoid loops.
  516. -u user[:group]
  517. drop permissions. Switch user ID to user's UID, and group ID to user's
  518. primary GID after creating and binding to the socket. If user is followed
  519. by a colon and a group name, the group ID is switched to the GID of group
  520. instead. All supplementary groups are removed.
  521. -c n
  522. concurrency. Handle up to n connections simultaneously. Default is 30.
  523. If there are n connections active, tcpsvd defers acceptance of a new
  524. connection until an active connection is closed.
  525. -C n[:msg]
  526. per host concurrency. Allow only up to n connections from the same IP
  527. address simultaneously. If there are n active connections from one IP
  528. address, new incoming connections from this IP address are closed
  529. immediately. If n is followed by :msg, the message msg is written
  530. to the client if possible, before closing the connection. By default
  531. msg is empty. See ipsvd-instruct(5) for supported escape sequences in msg.
  532. For each accepted connection, the current per host concurrency is
  533. available through the environment variable TCPCONCURRENCY. n and msg
  534. can be overwritten by ipsvd(7) instructions, see ipsvd-instruct(5).
  535. By default tcpsvd doesn't keep track of connections.
  536. -h
  537. Look up the client's hostname in DNS.
  538. -p
  539. paranoid. After looking up the client's hostname in DNS, look up the IP
  540. addresses in DNS for that hostname, and forget about the hostname
  541. if none of the addresses match the client's IP address. You should
  542. set this option if you use hostname based instructions. The -p option
  543. implies the -h option.
  544. * ignored by busyboxed version
  545. -b n
  546. backlog. Allow a backlog of approximately n TCP SYNs. On some systems n
  547. is silently limited. Default is 20.
  548. -E
  549. no special environment. Do not set up TCP-related environment variables.
  550. -v
  551. verbose. Print verbose messsages to standard output.
  552. -vv
  553. more verbose. Print more verbose messages to standard output.
  554. * no difference between -v and -vv in busyboxed version
  555. */