From 537a5aa90a3b6e89b2802ffd0d3369d456544034 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 3 Nov 2014 17:05:18 +0100 Subject: [PATCH] undo commit 077d59c2c7984eb0273be949969585be241408c8 due to regression There is a regression in this feature-add commit and I don't have the time to search for it. Refering it back to contributor. see also https://github.com/rsyslog/rsyslog/pull/145 --- plugins/imtcp/imtcp.c | 65 ++++++------------------------------------- runtime/netstrm.c | 7 ++--- runtime/netstrm.h | 8 ++---- runtime/nsd.h | 6 ++-- runtime/nsd_gtls.c | 7 ++--- runtime/nsd_ptcp.c | 61 ++-------------------------------------- runtime/nsd_ptcp.h | 5 ---- runtime/strmsrv.c | 2 +- tcpsrv.c | 21 ++++++-------- tcpsrv.h | 14 ++-------- 10 files changed, 32 insertions(+), 164 deletions(-) diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index 55833f52e..51697574e 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -92,9 +91,6 @@ static struct configSettings_s { int bSuppOctetFram; int iStrmDrvrMode; int bKeepAlive; - int iKeepAliveIntvl; - int iKeepAliveProbes; - int iKeepAliveTime; int bEmitMsgOnClose; int iAddtlFrameDelim; int bDisableLFDelim; @@ -113,10 +109,6 @@ struct instanceConf_s { int ratelimitInterval; int ratelimitBurst; int bSuppOctetFram; - int bKeepAlive; /* use socket layer KEEPALIVE packets? (see tcp(7)) */ - int iKeepAliveIntvl; /* tcp_keepalive_intvl (see tcp(7)) */ - int iKeepAliveProbes; /* tcp_keepalive_probes (see tcp(7)) */ - int iKeepAliveTime; /* tcp_keepalive_time (see tcp(7)) */ struct instanceConf_s *next; }; @@ -131,6 +123,7 @@ struct modConfData_s { int bSuppOctetFram; sbool bDisableLFDelim; /* disable standard LF delimiter */ sbool bUseFlowControl; /* use flow control, what means indicate ourselfs a "light delayable" */ + sbool bKeepAlive; sbool bEmitMsgOnClose; /* emit an informational message on close by remote peer */ uchar *pszStrmDrvrName; /* stream driver to use */ uchar *pszStrmDrvrAuthMode; /* authentication mode to use */ @@ -155,6 +148,7 @@ static struct cnfparamdescr modpdescr[] = { { "streamdriver.authmode", eCmdHdlrString, 0 }, { "streamdriver.name", eCmdHdlrString, 0 }, { "permittedpeer", eCmdHdlrArray, 0 }, + { "keepalive", eCmdHdlrBinary, 0 } }; static struct cnfparamblk modpblk = { CNFPARAMBLK_VERSION, @@ -170,11 +164,7 @@ static struct cnfparamdescr inppdescr[] = { { "ruleset", eCmdHdlrString, 0 }, { "supportOctetCountedFraming", eCmdHdlrBinary, 0 }, { "ratelimit.interval", eCmdHdlrInt, 0 }, - { "ratelimit.burst", eCmdHdlrInt, 0 }, - { "keepalive", eCmdHdlrBinary, 0 }, - { "keepalive.probes", eCmdHdlrInt, 0 }, - { "keepalive.time", eCmdHdlrInt, 0 }, - { "keepalive.interval", eCmdHdlrInt, 0 }, + { "ratelimit.burst", eCmdHdlrInt, 0 } }; static struct cnfparamblk inppblk = { CNFPARAMBLK_VERSION, @@ -273,10 +263,6 @@ createInstance(instanceConf_t **pinst) inst->bSuppOctetFram = 1; inst->ratelimitInterval = 0; inst->ratelimitBurst = 10000; - inst->bKeepAlive = 0; - inst->iKeepAliveIntvl = 0; - inst->iKeepAliveProbes = 0; - inst->iKeepAliveTime = 0; /* node created, let's add to config */ if(loadModConf->tail == NULL) { @@ -317,10 +303,6 @@ static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal) CHKmalloc(inst->pszInputName = ustrdup(cs.pszInputName)); } inst->bSuppOctetFram = cs.bSuppOctetFram; - inst->bKeepAlive = cs.bKeepAlive; - inst->iKeepAliveIntvl = cs.iKeepAliveIntvl; - inst->iKeepAliveProbes = cs.iKeepAliveProbes; - inst->iKeepAliveTime = cs.iKeepAliveTime; finalize_it: free(pNewVal); @@ -342,6 +324,7 @@ addListner(modConfData_t *modConf, instanceConf_t *inst) CHKiRet(tcpsrv.SetCBOnRegularClose(pOurTcpsrv, onRegularClose)); CHKiRet(tcpsrv.SetCBOnErrClose(pOurTcpsrv, onErrClose)); /* params */ + CHKiRet(tcpsrv.SetKeepAlive(pOurTcpsrv, modConf->bKeepAlive)); CHKiRet(tcpsrv.SetSessMax(pOurTcpsrv, modConf->iTCPSessMax)); CHKiRet(tcpsrv.SetLstnMax(pOurTcpsrv, modConf->iTCPLstnMax)); CHKiRet(tcpsrv.SetDrvrMode(pOurTcpsrv, modConf->iStrmDrvrMode)); @@ -368,7 +351,6 @@ addListner(modConfData_t *modConf, instanceConf_t *inst) UCHAR_CONSTANT("imtcp") : inst->pszInputName)); CHKiRet(tcpsrv.SetDfltTZ(pOurTcpsrv, (inst->dfltTZ == NULL) ? (uchar*)"" : inst->dfltTZ)); CHKiRet(tcpsrv.SetLinuxLikeRatelimiters(pOurTcpsrv, inst->ratelimitInterval, inst->ratelimitBurst)); - CHKiRet(tcpsrv.SetKeepAlive(pOurTcpsrv, inst->bKeepAlive, inst->iKeepAliveIntvl, inst->iKeepAliveProbes, inst->iKeepAliveTime)); tcpsrv.configureTCPListen(pOurTcpsrv, inst->pszBindPort, inst->bSuppOctetFram); finalize_it: @@ -417,29 +399,11 @@ CODESTARTnewInpInst inst->ratelimitBurst = (int) pvals[i].val.d.n; } else if(!strcmp(inppblk.descr[i].name, "ratelimit.interval")) { inst->ratelimitInterval = (int) pvals[i].val.d.n; - } else if(!strcmp(inppblk.descr[i].name, "keepalive")) { - inst->bKeepAlive = (int) pvals[i].val.d.n; - } else if(!strcmp(inppblk.descr[i].name, "keepalive.probes")) { - inst->iKeepAliveProbes = (int) pvals[i].val.d.n; - } else if(!strcmp(inppblk.descr[i].name, "keepalive.time")) { - inst->iKeepAliveTime = (int) pvals[i].val.d.n; - } else if(!strcmp(inppblk.descr[i].name, "keepalive.interval")) { - inst->iKeepAliveIntvl = (int) pvals[i].val.d.n; } else { dbgprintf("imtcp: program error, non-handled " "param '%s'\n", inppblk.descr[i].name); } } - -# ifndef TCP_KEEPCNT - if(inst->iKeepAliveIntvl > 0 - || inst->iKeepAliveTime > 0 - || inst->iKeepAliveProbes > 0) { - errmsg.LogError(0, NO_ERRCODE, "Setting keepalive parameters is " - "not supported"); - } -# endif - finalize_it: CODE_STD_FINALIZERnewInpInst cnfparamvalsDestruct(pvals, &inppblk); @@ -456,6 +420,7 @@ CODESTARTbeginCnfLoad loadModConf->bSuppOctetFram = 1; loadModConf->iStrmDrvrMode = 0; loadModConf->bUseFlowControl = 1; + loadModConf->bKeepAlive = 0; loadModConf->bEmitMsgOnClose = 0; loadModConf->iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER; loadModConf->bDisableLFDelim = 0; @@ -504,6 +469,8 @@ CODESTARTsetModCnf } else if(!strcmp(modpblk.descr[i].name, "maxlisteners") || !strcmp(modpblk.descr[i].name, "maxlistners")) { /* keep old name for a while */ loadModConf->iTCPLstnMax = (int) pvals[i].val.d.n; + } else if(!strcmp(modpblk.descr[i].name, "keepalive")) { + loadModConf->bKeepAlive = (int) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "streamdriver.mode")) { loadModConf->iStrmDrvrMode = (int) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "streamdriver.authmode")) { @@ -532,14 +499,6 @@ ENDsetModCnf BEGINendCnfLoad CODESTARTendCnfLoad -# ifndef TCP_KEEPCNT - if(cs.iKeepAliveIntvl > 0 - || cs.iKeepAliveProbes > 0 - || cs.iKeepAliveTime > 0) { - errmsg.LogError(0, NO_ERRCODE, "Setting keepalive parameters is not supported"); - } -# endif - if(!loadModConf->configSetViaV2Method) { /* persist module-specific settings from legacy config system */ pModConf->iTCPSessMax = cs.iTCPSessMax; @@ -550,6 +509,7 @@ CODESTARTendCnfLoad pModConf->iAddtlFrameDelim = cs.iAddtlFrameDelim; pModConf->bDisableLFDelim = cs.bDisableLFDelim; pModConf->bUseFlowControl = cs.bUseFlowControl; + pModConf->bKeepAlive = cs.bKeepAlive; if((cs.pszStrmDrvrAuthMode == NULL) || (cs.pszStrmDrvrAuthMode[0] == '\0')) { loadModConf->pszStrmDrvrAuthMode = NULL; } else { @@ -689,9 +649,6 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus cs.iStrmDrvrMode = 0; cs.bUseFlowControl = 1; cs.bKeepAlive = 0; - cs.iKeepAliveIntvl = 0; - cs.iKeepAliveProbes = 0; - cs.iKeepAliveTime = 0; cs.bEmitMsgOnClose = 0; cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER; cs.bDisableLFDelim = 0; @@ -744,12 +701,6 @@ CODEmodInit_QueryRegCFSLineHdlr NULL, &cs.pszStrmDrvrAuthMode, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpserverkeepalive"), 0, eCmdHdlrBinary, NULL, &cs.bKeepAlive, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); - CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpserverkeepalive_interval"), 0, eCmdHdlrInt, - NULL, &cs.iKeepAliveIntvl, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); - CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpserverkeepalive_probes"), 0, eCmdHdlrInt, - NULL, &cs.iKeepAliveProbes, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); - CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpserverkeepalive_time"), 0, eCmdHdlrInt, - NULL, &cs.iKeepAliveTime, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpflowcontrol"), 0, eCmdHdlrBinary, NULL, &cs.bUseFlowControl, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted)); CHKiRet(regCfSysLineHdlr2(UCHAR_CONSTANT("inputtcpserverdisablelfdelimiter"), 0, eCmdHdlrBinary, diff --git a/runtime/netstrm.c b/runtime/netstrm.c index af67b08c1..c046cf521 100644 --- a/runtime/netstrm.c +++ b/runtime/netstrm.c @@ -141,8 +141,7 @@ finalize_it: */ static rsRetVal LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), - uchar *pLstnPort, uchar *pLstnIP, int iSessMax, int bKeepAlive, - int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime) + uchar *pLstnPort, uchar *pLstnIP, int iSessMax) { DEFiRet; @@ -150,9 +149,7 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), assert(fAddLstn != NULL); assert(pLstnPort != NULL); - CHKiRet(pNS->Drvr.LstnInit(pNS, pUsr, fAddLstn, pLstnPort, pLstnIP, - iSessMax, bKeepAlive, iKeepAliveIntvl, iKeepAliveProbes, - iKeepAliveTime)); + CHKiRet(pNS->Drvr.LstnInit(pNS, pUsr, fAddLstn, pLstnPort, pLstnIP, iSessMax)); finalize_it: RETiRet; diff --git a/runtime/netstrm.h b/runtime/netstrm.h index 18226a642..4ef24229e 100644 --- a/runtime/netstrm.h +++ b/runtime/netstrm.h @@ -43,8 +43,7 @@ BEGINinterface(netstrm) /* name must also be changed in ENDinterface macro! */ rsRetVal (*Destruct)(netstrm_t **ppThis); rsRetVal (*AbortDestruct)(netstrm_t **ppThis); rsRetVal (*LstnInit)(netstrms_t *pNS, void *pUsr, rsRetVal(*)(void*,netstrm_t*), - uchar *pLstnPort, uchar *pLstnIP, int iSessMax, int bKeepAlive, - int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime); + uchar *pLstnPort, uchar *pLstnIP, int iSessMax); rsRetVal (*AcceptConnReq)(netstrm_t *pThis, netstrm_t **ppNew); rsRetVal (*Rcv)(netstrm_t *pThis, uchar *pRcvBuf, ssize_t *pLenBuf); rsRetVal (*Send)(netstrm_t *pThis, uchar *pBuf, ssize_t *pLenBuf); @@ -73,13 +72,12 @@ BEGINinterface(netstrm) /* name must also be changed in ENDinterface macro! */ /* v4 */ rsRetVal (*EnableKeepAlive)(netstrm_t *pThis); ENDinterface(netstrm) -#define netstrmCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */ +#define netstrmCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */ /* interface version 3 added GetRemAddr() * interface version 4 added EnableKeepAlive() -- rgerhards, 2009-06-02 * interface version 5 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06 * interface version 6 changed signature of GetRemoteIP() -- rgerhards, 2013-01-21 - * interface version 7 added new parameters to LstnInit() - this should, in practice, make the EnableKeepAlive() interface obsolete - */ + * */ /* prototypes */ PROTOTYPEObj(netstrm); diff --git a/runtime/nsd.h b/runtime/nsd.h index 59a782fd1..aa3662a49 100644 --- a/runtime/nsd.h +++ b/runtime/nsd.h @@ -56,8 +56,7 @@ BEGINinterface(nsd) /* name must also be changed in ENDinterface macro! */ rsRetVal (*Send)(nsd_t *pThis, uchar *pBuf, ssize_t *pLenBuf); rsRetVal (*Connect)(nsd_t *pThis, int family, unsigned char *port, unsigned char *host); rsRetVal (*LstnInit)(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), - uchar *pLstnPort, uchar *pLstnIP, int iSessMax, int bKeepAlive, - int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime); + uchar *pLstnPort, uchar *pLstnIP, int iSessMax); rsRetVal (*AcceptConnReq)(nsd_t *pThis, nsd_t **ppThis); rsRetVal (*GetRemoteHName)(nsd_t *pThis, uchar **pszName); rsRetVal (*GetRemoteIP)(nsd_t *pThis, prop_t **ip); @@ -81,12 +80,11 @@ BEGINinterface(nsd) /* name must also be changed in ENDinterface macro! */ /* v5 */ rsRetVal (*EnableKeepAlive)(nsd_t *pThis); ENDinterface(nsd) -#define nsdCURR_IF_VERSION 8 /* increment whenever you change the interface structure! */ +#define nsdCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */ /* interface version 4 added GetRemAddr() * interface version 5 added EnableKeepAlive() -- rgerhards, 2009-06-02 * interface version 6 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06 * interface version 7 changed signature ofGetRempoteIP() -- rgerhards, 2013-01-21 - * interface version 8 added new parameters to LstnInit() - this should, in practice, make the EnableKeepAlive() interface obsolete */ /* interface for the select call */ diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c index dec256fa1..8a2b682dd 100644 --- a/runtime/nsd_gtls.c +++ b/runtime/nsd_gtls.c @@ -1318,14 +1318,11 @@ Abort(nsd_t *pNsd) */ static rsRetVal LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), - uchar *pLstnPort, uchar *pLstnIP, int iSessMax, int bKeepAlive, - int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime) + uchar *pLstnPort, uchar *pLstnIP, int iSessMax) { DEFiRet; CHKiRet(gtlsGlblInitLstn()); - iRet = nsd_ptcp.LstnInit(pNS, pUsr, fAddLstn, pLstnPort, pLstnIP, - iSessMax, bKeepAlive, iKeepAliveIntvl, iKeepAliveProbes, - iKeepAliveTime); + iRet = nsd_ptcp.LstnInit(pNS, pUsr, fAddLstn, pLstnPort, pLstnIP, iSessMax); finalize_it: RETiRet; } diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c index 3d0c416f8..f889a00eb 100644 --- a/runtime/nsd_ptcp.c +++ b/runtime/nsd_ptcp.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "syslogd-types.h" #include "module-template.h" @@ -274,7 +273,6 @@ finalize_it: RETiRet; } -static rsRetVal EnableKeepAlive(nsd_t *pNsd); /* accept an incoming connection request * rgerhards, 2008-04-22 @@ -329,15 +327,6 @@ AcceptConnReq(nsd_t *pNsd, nsd_t **ppNew) } pNew->sock = iNewSock; - - if(pThis->bKeepAlive) { - pNew->bKeepAlive = pThis->bKeepAlive; - pNew->iKeepAliveIntvl = pThis->iKeepAliveIntvl; - pNew->iKeepAliveProbes = pThis->iKeepAliveProbes; - pNew->iKeepAliveTime = pThis->iKeepAliveTime; - CHKiRet(EnableKeepAlive((nsd_t*) pNew)); - } - *ppNew = (nsd_t*) pNew; finalize_it: @@ -361,8 +350,7 @@ finalize_it: */ static rsRetVal LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), - uchar *pLstnPort, uchar *pLstnIP, int iSessMax, int bKeepAlive, - int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime) + uchar *pLstnPort, uchar *pLstnIP, int iSessMax) { DEFiRet; netstrm_t *pNewStrm = NULL; @@ -497,12 +485,8 @@ LstnInit(netstrms_t *pNS, void *pUsr, rsRetVal(*fAddLstn)(void*,netstrm_t*), CHKiRet(pNS->Drvr.SetMode(pNewNsd, netstrms.GetDrvrMode(pNS))); CHKiRet(pNS->Drvr.SetAuthMode(pNewNsd, netstrms.GetDrvrAuthMode(pNS))); CHKiRet(pNS->Drvr.SetPermPeers(pNewNsd, netstrms.GetDrvrPermPeers(pNS))); - ((nsd_ptcp_t *) pNewNsd)->bKeepAlive = bKeepAlive; - ((nsd_ptcp_t *) pNewNsd)->iKeepAliveIntvl = iKeepAliveIntvl; - ((nsd_ptcp_t *) pNewNsd)->iKeepAliveProbes = iKeepAliveProbes; - ((nsd_ptcp_t *) pNewNsd)->iKeepAliveTime = iKeepAliveTime; CHKiRet(netstrms.CreateStrm(pNS, &pNewStrm)); - pNewStrm->pDrvrData = pNewNsd; + pNewStrm->pDrvrData = (nsd_t*) pNewNsd; pNewNsd = NULL; CHKiRet(fAddLstn(pUsr, pNewStrm)); pNewStrm = NULL; @@ -619,49 +603,10 @@ EnableKeepAlive(nsd_t *pNsd) optlen = sizeof(optval); ret = setsockopt(pThis->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen); if(ret < 0) { - errmsg.LogError(ret, NO_ERRCODE, "cannot enable keepalive mode"); + dbgprintf("EnableKeepAlive socket call returns error %d\n", ret); ABORT_FINALIZE(RS_RET_ERR); } -# if defined(TCP_KEEPCNT) - if(pThis->iKeepAliveProbes > 0) { - optval = pThis->iKeepAliveProbes; - optlen = sizeof(optval); - ret = setsockopt(pThis->sock, SOL_TCP, TCP_KEEPCNT, &optval, optlen); - if(ret < 0) { - errmsg.LogError(errno, NO_ERRCODE, "cannot set keepalive " - "probes to %d - ignored", pThis->iKeepAliveProbes); - } - } - - if(pThis->iKeepAliveTime > 0) { - optval = pThis->iKeepAliveTime; - optlen = sizeof(optval); - ret = setsockopt(pThis->sock, SOL_TCP, TCP_KEEPIDLE, &optval, optlen); - if(ret < 0) { - errmsg.LogError(errno, NO_ERRCODE, "cannot set keepalive " - "time to %d - ignored", pThis->iKeepAliveTime); - } - } - - if(pThis->iKeepAliveIntvl > 0) { - optval = pThis->iKeepAliveIntvl; - optlen = sizeof(optval); - ret = setsockopt(pThis->sock, SOL_TCP, TCP_KEEPINTVL, &optval, optlen); - if(ret < 0) { - errmsg.LogError(errno, NO_ERRCODE, "cannot set keepalive " - "interval to %d - ignored", pThis->iKeepAliveIntvl); - } - } -# else - if(pThis->iKeepAliveIntvl > 0 - || pThis->iKeepAliveTime > 0 - || pThis->iKeepAliveProbes > 0) { - errmsg.LogError(0, NO_ERRCODE, "Setting keepalive parameters is " - "not supported"); - } -# endif - dbgprintf("KEEPALIVE enabled for nsd %p\n", pThis); finalize_it: diff --git a/runtime/nsd_ptcp.h b/runtime/nsd_ptcp.h index 144da8c50..ed6b85652 100644 --- a/runtime/nsd_ptcp.h +++ b/runtime/nsd_ptcp.h @@ -34,11 +34,6 @@ struct nsd_ptcp_s { uchar *pRemHostName; /**< host name of remote peer (currently used in server mode, only) */ struct sockaddr_storage remAddr; /**< remote addr as sockaddr - used for legacy ACL code */ int sock; /**< the socket we use for regular, single-socket, operations */ - /* keep-alive packets settings, see tcp(7) */ - int bKeepAlive; /**< use socket layer KEEPALIVE packets? (see tcp(7)) */ - int iKeepAliveIntvl; /**< tcp_keepalive_intvl (see tcp(7)) */ - int iKeepAliveProbes; /**< tcp_keepalive_probes (see tcp(7)) */ - int iKeepAliveTime; /**< tcp_keepalive_time (see tcp(7)) */ }; /* interface is defined in nsd.h, we just implement it! */ diff --git a/runtime/strmsrv.c b/runtime/strmsrv.c index e65b0bd9e..e8b544b87 100644 --- a/runtime/strmsrv.c +++ b/runtime/strmsrv.c @@ -361,7 +361,7 @@ initSTRMListener(strmsrv_t *pThis, strmLstnPortList_t *pPortEntry) assert(pPortEntry != NULL); /* TODO: add capability to specify local listen address! */ - CHKiRet(netstrm.LstnInit(pThis->pNS, (void*)pPortEntry, addStrmLstn, pPortEntry->pszPort, NULL, pThis->iSessMax, 0, 0, 0, 0)); + CHKiRet(netstrm.LstnInit(pThis->pNS, (void*)pPortEntry, addStrmLstn, pPortEntry->pszPort, NULL, pThis->iSessMax)); finalize_it: RETiRet; diff --git a/tcpsrv.c b/tcpsrv.c index 2736a5261..249795d64 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -138,10 +138,6 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram) pEntry->pSrv = pThis; pEntry->pRuleset = pThis->pRuleset; pEntry->bSuppOctetFram = bSuppOctetFram; - pEntry->bKeepAlive = pThis->bKeepAlive; - pEntry->iKeepAliveIntvl = pThis->iKeepAliveIntvl; - pEntry->iKeepAliveProbes = pThis->iKeepAliveProbes; - pEntry->iKeepAliveTime = pThis->iKeepAliveTime; /* we need to create a property */ CHKiRet(prop.Construct(&pEntry->pInputName)); @@ -366,10 +362,7 @@ initTCPListener(tcpsrv_t *pThis, tcpLstnPortList_t *pPortEntry) TCPLstnPort = pPortEntry->pszPort; /* TODO: add capability to specify local listen address! */ - CHKiRet(netstrm.LstnInit(pThis->pNS, (void*)pPortEntry, addTcpLstn, - TCPLstnPort, NULL, pThis->iSessMax, pPortEntry->bKeepAlive, - pPortEntry->iKeepAliveIntvl, pPortEntry->iKeepAliveProbes, - pPortEntry->iKeepAliveTime)); + CHKiRet(netstrm.LstnInit(pThis->pNS, (void*)pPortEntry, addTcpLstn, TCPLstnPort, NULL, pThis->iSessMax)); finalize_it: RETiRet; @@ -447,6 +440,10 @@ SessAccept(tcpsrv_t *pThis, tcpLstnPortList_t *pLstnInfo, tcps_sess_t **ppSess, ABORT_FINALIZE(RS_RET_MAX_SESS_REACHED); } + if(pThis->bUseKeepAlive) { + CHKiRet(netstrm.EnableKeepAlive(pNewStrm)); + } + /* we found a free spot and can construct our session object */ CHKiRet(tcps_sess.Construct(&pSess)); CHKiRet(tcps_sess.SetTcpsrv(pSess, pThis)); @@ -1079,13 +1076,11 @@ SetUsrP(tcpsrv_t *pThis, void *pUsr) } static rsRetVal -SetKeepAlive(tcpsrv_t *pThis, int bKeepAlive, int iKeepAliveIntvl, int iKeepAliveProbes, int iKeepAliveTime) +SetKeepAlive(tcpsrv_t *pThis, int iVal) { DEFiRet; - pThis->bKeepAlive = bKeepAlive; - pThis->iKeepAliveIntvl = iKeepAliveIntvl; - pThis->iKeepAliveProbes = iKeepAliveProbes; - pThis->iKeepAliveTime = iKeepAliveTime; + DBGPRINTF("tcpsrv: keep-alive set to %d\n", iVal); + pThis->bUseKeepAlive = iVal; RETiRet; } diff --git a/tcpsrv.h b/tcpsrv.h index dd4c2d0b8..a49f6b6c8 100644 --- a/tcpsrv.h +++ b/tcpsrv.h @@ -44,10 +44,6 @@ struct tcpLstnPortList_s { sbool bSuppOctetFram; /**< do we support octect-counted framing? (if no->legay only!)*/ ratelimit_t *ratelimiter; uchar dfltTZ[8]; /**< default TZ if none in timestamp; '\0' =No Default */ - int bKeepAlive; /**< use socket layer KEEPALIVE packets? (see tcp(7)) */ - int iKeepAliveIntvl; /**< tcp_keepalive_intvl (see tcp(7)) */ - int iKeepAliveProbes; /**< tcp_keepalive_probes (see tcp(7)) */ - int iKeepAliveTime; /**< tcp_keepalive_time (see tcp(7)) */ STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit) tcpLstnPortList_t *pNext; /**< next port or NULL */ }; @@ -57,6 +53,7 @@ struct tcpLstnPortList_s { /* the tcpsrv object */ struct tcpsrv_s { BEGINobjInstance; /**< Data to implement generic object - MUST be the first data element! */ + int bUseKeepAlive; /**< use socket layer KEEPALIVE handling? */ netstrms_t *pNS; /**< pointer to network stream subsystem */ int iDrvrMode; /**< mode of the stream driver to use */ uchar *pszDrvrAuthMode; /**< auth mode of the stream driver to use */ @@ -73,10 +70,6 @@ struct tcpsrv_s { int iLstnMax; /**< max number of listeners supported */ int iSessMax; /**< max number of sessions supported */ uchar dfltTZ[8]; /**< default TZ if none in timestamp; '\0' =No Default */ - int bKeepAlive; /**< use socket layer KEEPALIVE packets? (see tcp(7)) */ - int iKeepAliveIntvl; /**< tcp_keepalive_intvl (see tcp(7)) */ - int iKeepAliveProbes; /**< tcp_keepalive_probes (see tcp(7)) */ - int iKeepAliveTime; /**< tcp_keepalive_time (see tcp(7)) */ tcpLstnPortList_t *pLstnPorts; /**< head pointer for listen ports */ int addtlFrameDelim; /**< additional frame delimiter for plain TCP syslog framing (e.g. to handle NetScreen) */ @@ -153,7 +146,7 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */ /* added v10 -- rgerhards, 2011-04-01 */ rsRetVal (*SetUseFlowControl)(tcpsrv_t*, int); /* added v11 -- rgerhards, 2011-05-09 */ - rsRetVal (*SetKeepAlive)(tcpsrv_t*, int, int, int, int); + rsRetVal (*SetKeepAlive)(tcpsrv_t*, int); /* added v13 -- rgerhards, 2012-10-15 */ rsRetVal (*SetLinuxLikeRatelimiters)(tcpsrv_t *pThis, int interval, int burst); /* added v14 -- rgerhards, 2013-07-28 */ @@ -161,13 +154,12 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */ /* added v15 -- rgerhards, 2013-09-17 */ rsRetVal (*SetDrvrName)(tcpsrv_t *pThis, uchar *pszName); ENDinterface(tcpsrv) -#define tcpsrvCURR_IF_VERSION 16 /* increment whenever you change the interface structure! */ +#define tcpsrvCURR_IF_VERSION 15 /* increment whenever you change the interface structure! */ /* change for v4: * - SetAddtlFrameDelim() added -- rgerhards, 2008-12-10 * - SetInputName() added -- rgerhards, 2008-12-10 * change for v5 and up: see above * for v12: param bSuppOctetFram added to configureTCPListen - * for v16: added more options to SetKeepAlive() */