All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: [PATCH 7/7] eal: add ability to override DPDK syslog parameters
Date: Thu, 30 May 2013 10:12:41 -0700	[thread overview]
Message-ID: <20130530171627.135792331@vyatta.com> (raw)
In-Reply-To: 20130530171234.301927271@vyatta.com

[-- Attachment #1: syslog.patch --]
[-- Type: text/plain, Size: 5945 bytes --]

By default, DPDK based applications would only allow logging
to syslog as "rte", DAEMON; but for any production application more
control is desired to allow using actual application name and
overriding the facility.

Signed-off-by: Stephen Hemminger <shemminger-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>

---
 lib/librte_eal/common/include/eal_private.h            |    2 
 lib/librte_eal/linuxapp/eal/eal.c                      |   58 ++++++++++++++++-
 lib/librte_eal/linuxapp/eal/eal_log.c                  |    4 -
 lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h |    1 
 4 files changed, 61 insertions(+), 4 deletions(-)

--- a/lib/librte_eal/common/include/eal_private.h	2013-05-29 17:03:20.167850142 -0700
+++ b/lib/librte_eal/common/include/eal_private.h	2013-05-29 17:05:15.066310021 -0700
@@ -115,7 +115,7 @@ int rte_eal_log_early_init(void);
  * @return
  *   0 on success, negative on error
  */
-int rte_eal_log_init(void);
+int rte_eal_log_init(const char *id, int facility);
 
 /**
  * Init the default log stream
--- a/lib/librte_eal/linuxapp/eal/eal.c	2013-05-29 17:03:20.167850142 -0700
+++ b/lib/librte_eal/linuxapp/eal/eal.c	2013-05-29 17:12:09.317086933 -0700
@@ -40,6 +40,7 @@
 #include <stdarg.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <syslog.h>
 #include <getopt.h>
 #include <fcntl.h>
 #include <stddef.h>
@@ -82,6 +83,7 @@
 #define OPT_NO_PCI      "no-pci"
 #define OPT_NO_HUGE     "no-huge"
 #define OPT_FILE_PREFIX "file-prefix"
+#define OPT_SYSLOG      "syslog"
 
 #define RTE_EAL_BLACKLIST_SIZE	0x100
 
@@ -265,6 +267,7 @@ eal_usage(const char *prgname)
 	       "               (multiple -b options are alowed)\n"
 	       "  -m MB      : memory to allocate (default = size of hugemem)\n"
 	       "  -r NUM     : force number of memory ranks (don't detect)\n"
+	       "  --"OPT_SYSLOG"   : set syslog facility\n"
 	       "  --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
 	       "  --"OPT_PROC_TYPE": type of this process\n"
 	       "  --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
@@ -369,6 +372,45 @@ eal_parse_blacklist_opt(const char *opta
 	return (idx);
 }
 
+static int
+eal_parse_syslog(const char *facility)
+{
+	int i;
+	static struct {
+		const char *name;
+		int value;
+	} map[] = {
+		{ "auth", LOG_AUTH },
+		{ "cron", LOG_CRON },
+		{ "daemon", LOG_DAEMON },
+		{ "ftp", LOG_FTP },
+		{ "kern", LOG_KERN },
+		{ "lpr", LOG_LPR },
+		{ "mail", LOG_MAIL },
+		{ "news", LOG_NEWS },
+		{ "syslog", LOG_SYSLOG },
+		{ "user", LOG_USER },
+		{ "uucp", LOG_UUCP },
+		{ "local0", LOG_LOCAL0 },
+		{ "local1", LOG_LOCAL1 },
+		{ "local2", LOG_LOCAL2 },
+		{ "local3", LOG_LOCAL3 },
+		{ "local4", LOG_LOCAL4 },
+		{ "local5", LOG_LOCAL5 },
+		{ "local6", LOG_LOCAL6 },
+		{ "local7", LOG_LOCAL7 },
+		{ NULL, 0 }
+	};
+
+	for (i = 0; map[i].name; i++) {
+		if (!strcmp(facility, map[i].name)) {
+			internal_config.syslog_facility = map[i].value;
+			return 0;
+		}
+	}
+	return -1;
+}
+
 
 /* Parse the argument given in the command line of the application */
 static int
@@ -389,6 +431,7 @@ eal_parse_args(int argc, char **argv)
 		{OPT_NO_SHCONF, 0, 0, 0},
 		{OPT_PROC_TYPE, 1, 0, 0},
 		{OPT_FILE_PREFIX, 1, 0, 0},
+		{OPT_SYSLOG, 1, 0, 0},
 		{0, 0, 0, 0}
 	};
 
@@ -399,6 +442,7 @@ eal_parse_args(int argc, char **argv)
 	internal_config.force_nchannel = 0;
 	internal_config.hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
 	internal_config.hugepage_dir = NULL;
+	internal_config.syslog_facility = LOG_DAEMON;
 #ifdef RTE_LIBEAL_USE_HPET
 	internal_config.no_hpet = 0;
 #else
@@ -487,6 +531,14 @@ eal_parse_args(int argc, char **argv)
 			else if (!strcmp(lgopts[option_index].name, OPT_FILE_PREFIX)) {
 				internal_config.hugefile_prefix = optarg;
 			}
+			else if (!strcmp(lgopts[option_index].name, OPT_SYSLOG)) {
+				if (eal_parse_syslog(optarg) < 0) {
+					RTE_LOG(ERR, EAL, "invalid parameters for --"
+							OPT_SYSLOG "\n");
+					eal_usage(prgname);
+					return -1;
+				}
+			}
 			break;
 
 		default:
@@ -538,6 +590,10 @@ rte_eal_init(int argc, char **argv)
 {
 	int i, fctret, ret;
 	pthread_t thread_id;
+	const char *logid;
+
+	logid = strrchr(argv[0], '/');
+	logid = strdup(logid ? logid + 1: argv[0]);
 
 	thread_id = pthread_self();
 
@@ -585,7 +641,7 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_tailqs_init() < 0)
 		rte_panic("Cannot init tail queues for objects\n");
 
-	if (rte_eal_log_init() < 0)
+	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
 		rte_panic("Cannot init logs\n");
 
 	if (rte_eal_alarm_init() < 0)
--- a/lib/librte_eal/linuxapp/eal/eal_log.c	2013-05-29 17:03:20.167850142 -0700
+++ b/lib/librte_eal/linuxapp/eal/eal_log.c	2013-05-29 17:05:15.066310021 -0700
@@ -119,7 +119,7 @@ static cookie_io_functions_t console_log
  * once memzones are available.
  */
 int
-rte_eal_log_init(void)
+rte_eal_log_init(const char *id, int facility)
 {
 	FILE *log_stream;
 
@@ -127,7 +127,7 @@ rte_eal_log_init(void)
 	if (log_stream == NULL)
 		return -1;
 
-	openlog("rte", LOG_NDELAY | LOG_PID, LOG_DAEMON);
+	openlog(id, LOG_NDELAY | LOG_PID, facility);
 
 	if (rte_eal_common_log_init(log_stream) < 0)
 		return -1;
--- a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h	2013-05-29 17:03:20.167850142 -0700
+++ b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h	2013-05-29 17:05:15.066310021 -0700
@@ -65,6 +65,7 @@ struct internal_config {
 	volatile unsigned no_hpet;        /* true to disable HPET */
 	volatile unsigned vmware_tsc_map; /* true to use VMware TSC mapping instead of native TSC */
 	volatile unsigned no_shconf;      /* true if there is no shared config */
+	volatile int syslog_facility;	  /* facility passed to openlog() */
 	volatile enum rte_proc_type_t process_type; /* multi-process proc type */
 	const char *hugefile_prefix;      /* the base filename of hugetlbfs files */
 	const char *hugepage_dir;         /* specific hugetlbfs directory to use */

  parent reply	other threads:[~2013-05-30 17:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 17:12 [PATCH 0/7] Vyatta patches Stephen Hemminger
2013-05-30 17:12 ` [PATCH 1/7] [PATCH 4/8] igb: workaround errata with wthresh on 82576 Stephen Hemminger
     [not found]   ` <20130530171626.764056062-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-05 14:22     ` Vincent JARDIN
     [not found]       ` <51AF499B.8020903-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 10:06         ` [PATCH 1/7] " Thomas Monjalon
2013-05-30 17:12 ` [PATCH 2/7] rte_timer: optimize for empty case Stephen Hemminger
     [not found]   ` <20130530171626.825256039-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-05 14:25     ` Vincent JARDIN
     [not found]       ` <51AF4A42.4000005-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 10:07         ` Thomas Monjalon
2013-05-30 17:12 ` [PATCH 3/7] optimize log/panic Stephen Hemminger
     [not found]   ` <20130530171626.884622340-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-05 14:34     ` Vincent JARDIN
     [not found]       ` <51AF4C82.2010603-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 10:09         ` Thomas Monjalon
2013-05-30 17:12 ` [PATCH 4/7] eal: support different modules Stephen Hemminger
     [not found]   ` <20130530171626.948387515-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-03  8:58     ` Damien Millescamps
     [not found]       ` <51AC5A99.1050207-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-03 15:41         ` Stephen Hemminger
     [not found]           ` <20130603084154.70219c8f-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2013-06-03 16:36             ` Thomas Monjalon
     [not found]               ` <201306031836.52362.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-03 17:26                 ` Stephen Hemminger
     [not found]                   ` <20130603102629.713d917c-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2013-06-04  9:17                     ` Damien Millescamps
2013-06-03 16:08         ` Antti Kantee
     [not found]           ` <51ACBF95.1030109-X3B1VOXEql0@public.gmane.org>
2013-06-03 16:29             ` Thomas Monjalon
     [not found]               ` <201306031829.02984.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-03 17:25                 ` Stephen Hemminger
2013-06-03 18:40                 ` Antti Kantee
2013-05-30 17:12 ` [PATCH 5/7] pci: support multiple PCI regions per device Stephen Hemminger
     [not found]   ` <20130530171627.005239011-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-03 16:41     ` Thomas Monjalon
2013-06-05 14:50     ` Damien Millescamps
     [not found]       ` <51AF501B.5060306-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-05 15:49         ` Stephen Hemminger
     [not found]           ` <20130605084927.34f138c1-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2013-06-05 18:05             ` Damien Millescamps
     [not found]               ` <51AF7DDB.1070005-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-05 21:33                 ` Stephen Hemminger
     [not found]                   ` <20130605143337.76af91ff-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2013-06-18  1:28                     ` somnath kotur
     [not found]                       ` <CAMXF-eXYRFfSvA_RhHa6tz27_JaLnkAvDN=hBZYEJB=9xg3NrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-16  8:53                         ` Thomas Monjalon
     [not found]                           ` <201307161053.19175.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-07-19 16:44                             ` Stephen Hemminger
2013-05-30 17:12 ` [PATCH 6/7] igb_uio: pci_block_user_cfg_access is unsafe, remove it Stephen Hemminger
2013-05-30 17:12 ` Stephen Hemminger [this message]
     [not found]   ` <20130530171627.135792331-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-06-05 14:36     ` [PATCH 7/7] eal: add ability to override DPDK syslog parameters Vincent JARDIN
     [not found]       ` <51AF4CFF.80906-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 10:18         ` Thomas Monjalon
     [not found] ` <20130530171234.301927271-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2013-05-30 22:20   ` [PATCH 0/7] Vyatta patches Thomas Monjalon
2013-05-31  9:29   ` Damien Millescamps
     [not found]     ` <51A86D65.2090003-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-05-31 15:45       ` Stephen Hemminger
     [not found]         ` <20130531084529.5c63d4c0-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2013-05-31 16:44           ` Damien Millescamps
     [not found]             ` <51A8D353.50101-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-05-31 17:00               ` Stephen Hemminger
2013-06-03 15:22   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130530171627.135792331@vyatta.com \
    --to=shemminger-ztmgi6mnkb3qt0dzr+alfa@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.