From 2aca3c2d33dd1a19daf44168e90a5f64bd4095b0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 20 May 2009 17:35:21 +0200 Subject: made imdiag *just* compile & some cleanup imdiag was never finished (not even really begun), but now I need it. I made the few things that are available compile, but more serious work is required. --- plugins/imdiag/imdiag.c | 36 ++++++++++++++++++++---------------- tcpsrv.c | 17 ++++++----------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c index 3cd2dcf8..90c5d9ee 100644 --- a/plugins/imdiag/imdiag.c +++ b/plugins/imdiag/imdiag.c @@ -7,7 +7,7 @@ * * File begun on 2008-07-25 by RGerhards * - * Copyright 2008 Rainer Gerhards and Adiscon GmbH. + * Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -48,6 +48,7 @@ #include "module-template.h" #include "net.h" #include "netstrm.h" +#include "netstrms.h" #include "errmsg.h" MODULE_TYPE_INPUT @@ -56,12 +57,13 @@ MODULE_TYPE_INPUT DEF_IMOD_STATIC_DATA DEFobjCurrIf(net) DEFobjCurrIf(netstrm) +DEFobjCurrIf(netstrms) DEFobjCurrIf(errmsg) /* Module static data */ netstrms_t *pNS; /**< pointer to network stream subsystem */ -netstrm_t **ppLstn[10]; /**< our netstream listners */ -int iLstnMax = 0; /**< max nbr of listeners currently supported */ +netstrm_t *arrLstn[10]; /**< our netstream listners */ +int iLstnMax = 0; /**< max nbr of listeners currently supported */ /* config settings */ @@ -71,16 +73,16 @@ int iLstnMax = 0; /**< max nbr of listeners currently supported */ * invoked from the netstrm class. -- rgerhards, 2008-04-23 */ static rsRetVal -addTcpLstn(void *pUsr, netstrm_t *pLstn) +addTcpLstn(netstrm_t *pLstn) { DEFiRet; ISOBJ_TYPE_assert(pLstn, netstrm); - if(iLstnMax >= sizeof(ppLstn)/sizeof(netstrm_t)) + if((unsigned)iLstnMax >= sizeof(arrLstn)/sizeof(netstrm_t*)) ABORT_FINALIZE(RS_RET_MAX_LSTN_REACHED); - ppLstn[pThis->iLstnMax] = pLstn; + arrLstn[iLstnMax] = pLstn; ++iLstnMax; finalize_it: @@ -100,15 +102,15 @@ initNetstrm(void) //CHKiRet(netstrms.SetDrvrAuthMode(pThis->pNS, pThis->pszDrvrAuthMode)); //CHKiRet(netstrms.SetDrvrPermPeers(pThis->pNS, pThis->pPermPeers)); // TODO: set driver! - CHKiRet(netstrms.ConstructFinalize(pThis->pNS)); + CHKiRet(netstrms.ConstructFinalize(&pNS)); /* set up listeners */ - CHKiRet(netstrm.LstnInit(pNS, NULL, addTcpLstn, "127.0.0.1", "44514", 1)); + CHKiRet(netstrm.LstnInit(pNS, NULL, addTcpLstn, "127.0.0.1", (uchar*)"44514", 1)); finalize_it: if(iRet != RS_RET_OK) { - if(pThis->pNS != NULL) - netstrms.Destruct(&pThis->pNS); + if(pNS != NULL) + netstrms.Destruct(&pNS); } RETiRet; } @@ -130,11 +132,12 @@ ENDwillRun BEGINafterRun + int i; CODESTARTafterRun /* do cleanup here */ /* finally close our listen streams */ for(i = 0 ; i < iLstnMax ; ++i) { - netstrm.Destruct(ppLstn + i); + netstrm.Destruct(arrLstn[i]); } /* destruct netstream subsystem */ @@ -146,7 +149,8 @@ BEGINmodExit CODESTARTmodExit /* release objects we used */ objRelease(net, LM_NET_FILENAME); - objRelease(netstrm, LM_NETSTRMS_FILENAME); + objRelease(netstrm, DONT_LOAD_LIB); + objRelease(netstrms, LM_NETSTRMS_FILENAME); objRelease(errmsg, CORE_COMPONENT); ENDmodExit @@ -169,14 +173,14 @@ BEGINmodInit() CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr - pOurTcpsrv = NULL; /* request objects we use */ CHKiRet(objUse(net, LM_NET_FILENAME)); - CHKiRet(objUse(netstrm, LM_NETSTRMS_FILENAME)); + CHKiRet(objUse(netstrms, LM_NETSTRMS_FILENAME)); + CHKiRet(objUse(netstrm, DONT_LOAD_LIB)); CHKiRet(objUse(errmsg, CORE_COMPONENT)); -#if 0 /* register config file handlers */ +#if 0 CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverrun", 0, eCmdHdlrGetWord, addTCPListener, NULL, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpmaxsessions", 0, eCmdHdlrInt, @@ -187,9 +191,9 @@ CODEmodInit_QueryRegCFSLineHdlr eCmdHdlrGetWord, NULL, &pszStrmDrvrAuthMode, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverstreamdriverpermittedpeer", 0, eCmdHdlrGetWord, setPermittedPeer, NULL, STD_LOADABLE_MODULE_ID)); +#endif CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); -#endif ENDmodInit diff --git a/tcpsrv.c b/tcpsrv.c index b9434398..7af45d3c 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -17,7 +17,7 @@ * * File begun on 2007-12-21 by RGerhards (extracted from syslogd.c) * - * Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2008, 2009 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -219,8 +219,7 @@ static void deinit_tcp_listener(tcpsrv_t *pThis) pThis->pSessions = NULL; /* just to make sure... */ } - if(pThis->TCPLstnPort != NULL) - free(pThis->TCPLstnPort); + free(pThis->TCPLstnPort); /* finally close our listen streams */ for(i = 0 ; i < pThis->iLstnMax ; ++i) { @@ -557,12 +556,9 @@ CODESTARTobjDestruct(tcpsrv) if(pThis->pNS != NULL) netstrms.Destruct(&pThis->pNS); - if(pThis->pszDrvrAuthMode != NULL) - free(pThis->pszDrvrAuthMode); - if(pThis->ppLstn != NULL) - free(pThis->ppLstn); - if(pThis->pszInputName != NULL) - free(pThis->pszInputName); + free(pThis->pszDrvrAuthMode); + free(pThis->ppLstn); + free(pThis->pszInputName); ENDobjDestruct(tcpsrv) @@ -683,8 +679,7 @@ SetInputName(tcpsrv_t *pThis, uchar *name) pszName = NULL; else CHKmalloc(pszName = (uchar*)strdup((char*)name)); - if(pThis->pszInputName != NULL) - free(pThis->pszInputName); + free(pThis->pszInputName); pThis->pszInputName = pszName; finalize_it: RETiRet; -- cgit v1.2.3 From aba90e82484118f3568ec51c01de5ba845da589a Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 22 May 2009 17:06:52 +0200 Subject: added capability to run multiple tcp listeners (on different ports) Well, actually this and a lot of related things. I improved the testbench so that the new capabilities are automatically tested and also did some general cleanup. The current multiple tcp listener solution will probably receive some further cleanup, too, but looks quite OK so far. I also reviewed the way tcpsrv et all work, in preparation of using this code for imdiag. I need to document the findings, especially as the code is rather complicated "thanks" to the combination of plain tcp and gssapi transport modes. --- ChangeLog | 1 + doc/imtcp.html | 6 +- plugins/imfile/imfile.c | 5 +- plugins/imgssapi/imgssapi.c | 4 +- plugins/imklog/imklog.c | 7 +- plugins/imtcp/imtcp.c | 35 ++++---- plugins/imudp/imudp.c | 5 +- runtime/Makefile.am | 1 + runtime/datetime.c | 12 +-- runtime/datetime.h | 4 +- runtime/msg.c | 104 +++++++++------------ runtime/msg.h | 8 +- runtime/netstrm.c | 4 +- runtime/netstrm.h | 1 + runtime/parser.c | 2 +- runtime/rsyslog.h | 3 + runtime/unicode-helper.h | 54 +++++++++++ tcps_sess.c | 17 +++- tcps_sess.h | 11 ++- tcpsrv.c | 150 +++++++++++++++++++++---------- tcpsrv.h | 16 +++- tests/Makefile.am | 15 +++- tests/fieldtest.sh | 13 +++ tests/imtcp-multiport.sh | 80 +++++++++++++++++ tests/inputname.sh | 20 +++++ tests/killrsyslog.sh | 7 ++ tests/nettester.c | 101 +++++++++++++++------ tests/omod-if-array.sh | 6 +- tests/parsertest.sh | 6 +- tests/tcpflood.c | 2 - tests/testsuites/1.field1 | 3 + tests/testsuites/1.inputname_imtcp_12514 | 3 + tests/testsuites/1.inputname_imtcp_12515 | 3 + tests/testsuites/1.inputname_imtcp_12516 | 3 + tests/testsuites/field1.conf | 8 ++ tests/testsuites/imtcp-multiport.conf | 13 +++ tests/testsuites/inputname_imtcp.conf | 19 ++++ tools/syslogd.c | 53 +++++------ 38 files changed, 584 insertions(+), 221 deletions(-) create mode 100644 runtime/unicode-helper.h create mode 100755 tests/fieldtest.sh create mode 100755 tests/imtcp-multiport.sh create mode 100755 tests/inputname.sh create mode 100755 tests/killrsyslog.sh create mode 100644 tests/testsuites/1.field1 create mode 100644 tests/testsuites/1.inputname_imtcp_12514 create mode 100644 tests/testsuites/1.inputname_imtcp_12515 create mode 100644 tests/testsuites/1.inputname_imtcp_12516 create mode 100644 tests/testsuites/field1.conf create mode 100644 tests/testsuites/imtcp-multiport.conf create mode 100644 tests/testsuites/inputname_imtcp.conf diff --git a/ChangeLog b/ChangeLog index 30fb7bff..b7a0a67a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ --------------------------------------------------------------------------- Version 4.3.1 [DEVEL] (rgerhards), 2009-04-?? +- added capability to run multiple tcp listeners (on different ports) - performance enhancement: imtcp calls parser no longer on input thread but rather inside on of the potentially many main msg queue worker threads (an enhancement scheduled for all input plugins where this is diff --git a/doc/imtcp.html b/doc/imtcp.html index 0ee0f96a..9ea7efa1 100644 --- a/doc/imtcp.html +++ b/doc/imtcp.html @@ -14,9 +14,10 @@ Encryption can be provided by using stunnel (an alternative is the use the imgssapi modul).

-

In the future, multiple receivers may be configured by +

Multiple receivers may be configured by specifying -$InputTCPServerRun multiple times. This is not currently supported. +$InputTCPServerRun multiple times. This is available since version 4.3.1, earlier +versions do NOT support it.

Configuration Directives: