From cadf16e7e941c5aa3e5a905df7ce7bf4988fd59b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 26 Mar 2013 11:12:10 +0100 Subject: imudp: support user-selectable inputname --- ChangeLog | 5 +++-- doc/imudp.html | 62 +++++++++++++++++++++++++++++++++++++++++---------- plugins/imudp/imudp.c | 42 +++++++++++++++++++++++++--------- runtime/Makefile.am | 3 +-- 4 files changed, 85 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index d75b79c1..6f258fa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,6 @@ --------------------------------------------------------------------------- Version 7.3.9 [devel] 2013-03-?? -- bugfix: imudp scheduling parameters did affect main thread, not imudp - closes: http://bugzilla.adiscon.com/show_bug.cgi?id=409 +- imudp: now supports user-selectable inputname - omlibdbi: now supports transaction interface if recent enough lbdbi is present - imuxsock: add ability to NOT create/delete sockets during startup and @@ -16,6 +15,8 @@ Version 7.3.9 [devel] 2013-03-?? beginning. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=228 - updated systemd files to match current systemd source +- bugfix: imudp scheduling parameters did affect main thread, not imudp + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=409 - bugfix: build problem on platforms without GLOB_NOMAGIC - bugfix: build problems on non-Linux platforms - bugfix: stdout/stderr were not closed on forking diff --git a/doc/imudp.html b/doc/imudp.html index a86c9939..6c949536 100644 --- a/doc/imudp.html +++ b/doc/imudp.html @@ -18,8 +18,8 @@ multiple input actions.

-

Configuration Directives:

-

Global Directives:

+

Configuration Parameters:

+

Module Parameters:

-

Action Directives:

+

Input Parameters:

Caveats/Known Bugs: -

Sample:

+

Samples:

This sets up an UPD server on port 514:

- +

In the next example, we set up three listners at ports 10514, 10515 and 10516 +and assign a listner name of "udp" to it, followed by the port number: +

+ + +

The next example is almost equal to the previous one, but +now the inputname property will just be set to the port number. +So if a message was received on port 10515, the input name will be +"10515" in this example whereas it was "udp10515" in the previous one. +Note that to do that we set the inputname to the empty string. +

+ + +

Legacy Configuration Directives:

Multiple receivers may be configured by specifying $UDPServerRun multiple times. @@ -88,23 +129,20 @@ equivalent to: SchedulingPolicy

  • $IMUDPSchedulingPriority <number> Available since 4.7.4+, 5.7.3+, 6.1.3+.
    equivalent to: SchedulingPriority -Caveats/Known Bugs: -

    Sample:

    This sets up an UPD server on port 514:

    - +

    [rsyslog.conf overview] [manual index] [rsyslog site]

    This documentation is part of the rsyslog project.
    -Copyright © 2009 by Rainer -Gerhards and +Copyright © 2009-2013 by +Rainer Gerhards and Adiscon. Released under the GNU GPL version 3 or higher.

    diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index 7e11a80e..7bf1473a 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -75,6 +75,7 @@ static struct lstn_s { struct lstn_s *next; int sock; /* socket */ ruleset_t *pRuleset; /* bound ruleset */ + prop_t *pInputName; statsobj_t *stats; /* listener stats */ ratelimit_t *ratelimiter; STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit) @@ -91,7 +92,6 @@ static uchar *pRcvBuf = NULL; /* receive buffer (for a single packet). We use a * it so that we can check available memory in willRun() and request * termination if we can not get it. -- rgerhards, 2007-12-27 */ -static prop_t *pInputName = NULL; /* our inputName currently is always "imudp", and this will hold it */ #define TIME_REQUERY_DFLT 2 #define SCHED_PRIO_UNSET -12345678 /* a value that indicates that the scheduling priority has not been set */ @@ -108,10 +108,12 @@ struct instanceConf_s { uchar *pszBindAddr; /* IP to bind socket to */ uchar *pszBindPort; /* Port to bind socket to */ uchar *pszBindRuleset; /* name of ruleset to bind to */ + uchar *inputname; ruleset_t *pBindRuleset; /* ruleset to bind listener to (use system default if unspecified) */ int ratelimitInterval; int ratelimitBurst; struct instanceConf_s *next; + sbool bAppendPortToInpname; }; struct modConfData_s { @@ -141,6 +143,8 @@ static struct cnfparamblk modpblk = /* input instance parameters */ static struct cnfparamdescr inppdescr[] = { { "port", eCmdHdlrArray, CNFPARAM_REQUIRED }, /* legacy: InputTCPServerRun */ + { "inputname", eCmdHdlrGetWord, 0 }, + { "inputname.appendport", eCmdHdlrBinary, 0 }, { "address", eCmdHdlrString, 0 }, { "ruleset", eCmdHdlrString, 0 }, { "ratelimit.interval", eCmdHdlrInt, 0 }, @@ -169,6 +173,8 @@ createInstance(instanceConf_t **pinst) inst->pszBindPort = NULL; inst->pszBindAddr = NULL; inst->pszBindRuleset = NULL; + inst->inputname = NULL; + inst->bAppendPortToInpname = 0; inst->ratelimitBurst = 10000; /* arbitrary high limit */ inst->ratelimitInterval = 0; /* off */ @@ -229,7 +235,8 @@ addListner(instanceConf_t *inst) struct lstn_s *newlcnfinfo; uchar *bindName; uchar *port; - uchar dispname[64]; + uchar dispname[64], inpnameBuf[128]; + uchar *inputname; /* check which address to bind to. We could do this more compact, but have not * done so in order to make the code more readable. -- rgerhards, 2007-12-27 @@ -257,6 +264,21 @@ addListner(instanceConf_t *inst) snprintf((char*)dispname, sizeof(dispname), "imudp(%s:%s)", bindName, port); dispname[sizeof(dispname)-1] = '\0'; /* just to be on the save side... */ CHKiRet(ratelimitNew(&newlcnfinfo->ratelimiter, (char*)dispname, NULL)); + if(inst->inputname == NULL) { + inputname = (uchar*)"imudp"; + } else { + inputname = inst->inputname; + } + if(inst->bAppendPortToInpname) { + snprintf((char*)inpnameBuf, sizeof(inpnameBuf), "%s%s", + inputname, port); + inpnameBuf[sizeof(inpnameBuf)-1] = '\0'; + inputname = inpnameBuf; + } + CHKiRet(prop.Construct(&newlcnfinfo->pInputName)); + CHKiRet(prop.SetString(newlcnfinfo->pInputName, + inputname, ustrlen(inputname))); + CHKiRet(prop.ConstructFinalize(newlcnfinfo->pInputName)); ratelimitSetLinuxLike(newlcnfinfo->ratelimiter, inst->ratelimitInterval, inst->ratelimitBurst); /* support statistics gathering */ @@ -390,7 +412,7 @@ processSocket(thrdInfo_t *pThrd, struct lstn_s *lstn, struct sockaddr_storage *f /* we now create our own message object and submit it to the queue */ CHKiRet(msgConstructWithTime(&pMsg, &stTime, ttGenTime)); MsgSetRawMsg(pMsg, (char*)pRcvBuf, lenRcvBuf); - MsgSetInputName(pMsg, pInputName); + MsgSetInputName(pMsg, lstn->pInputName); MsgSetRuleset(pMsg, lstn->pRuleset); MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY); pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME | NEEDS_DNSRESOL; @@ -695,6 +717,10 @@ createListner(es_str_t *port, struct cnfparamvals *pvals) continue; if(!strcmp(inppblk.descr[i].name, "port")) { continue; /* array, handled by caller */ + } else if(!strcmp(inppblk.descr[i].name, "inputname")) { + inst->inputname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + } else if(!strcmp(inppblk.descr[i].name, "inputname.appendport")) { + inst->bAppendPortToInpname = (int) pvals[i].val.d.n; } else if(!strcmp(inppblk.descr[i].name, "address")) { inst->pszBindAddr = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); } else if(!strcmp(inppblk.descr[i].name, "ruleset")) { @@ -873,6 +899,7 @@ CODESTARTfreeCnf free(inst->pszBindPort); free(inst->pszBindAddr); free(inst->pBindRuleset); + free(inst->inputname); del = inst; inst = inst->next; free(del); @@ -915,6 +942,7 @@ CODESTARTafterRun statsobj.Destruct(&(lstn->stats)); ratelimitDestruct(lstn->ratelimiter); close(lstn->sock); + prop.Destruct(&lstn->pInputName); lstnDel = lstn; lstn = lstn->next; free(lstnDel); @@ -929,9 +957,6 @@ ENDafterRun BEGINmodExit CODESTARTmodExit - if(pInputName != NULL) - prop.Destruct(&pInputName); - /* release what we no longer need */ objRelease(errmsg, CORE_COMPONENT); objRelease(glbl, CORE_COMPONENT); @@ -986,11 +1011,6 @@ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(ruleset, CORE_COMPONENT)); CHKiRet(objUse(net, LM_NET_FILENAME)); - /* we need to create the inputName property (only once during our lifetime) */ - CHKiRet(prop.Construct(&pInputName)); - CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imudp"), sizeof("imudp") - 1)); - CHKiRet(prop.ConstructFinalize(pInputName)); - /* register config file handlers */ CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputudpserverbindruleset", 0, eCmdHdlrGetWord, NULL, &cs.pszBindRuleset, STD_LOADABLE_MODULE_ID)); diff --git a/runtime/Makefile.am b/runtime/Makefile.am index 8f969512..c05cc773 100644 --- a/runtime/Makefile.am +++ b/runtime/Makefile.am @@ -179,9 +179,8 @@ endif # if ENABLE_GUARDTIME librsgt_la_SOURCES = librsgt.c librsgt_read.c librsgt.h - pkglib_LTLIBRARIES += lmsig_gt.la - lmsig_gt_la_SOURCES = lmsig_gt.c + lmsig_gt_la_SOURCES = lmsig_gt.c lmsig_gt.h lmsig_gt_la_CPPFLAGS = $(RSRT_CFLAGS) $(GUARDTIME_CFLAGS) lmsig_gt_la_LDFLAGS = -module -avoid-version lmsig_gt_la_LIBADD = librsgt.la $(GUARDTIME_LIBS) -- cgit v1.2.3