[Open-FCoE] [RFC PATCH 10/14] fcoe-utils: Add "--syslog" flag to fcoeplumb

Robert Love robert.w.love at intel.com
Wed Jul 8 22:18:21 UTC 2009


fcoeplumb should not re-read the /etc/fcoe/config file.
Instead have this option and allow the caller (fceomon)
to pass it.

This patch also introduces a config_logging routine that
will be used when either the --debug or --syslog flags are
passed to the script. This makes the order of these flags
irrelevant as it will be called when either flag is received.

Also, modify fcoemon to pass the --syslog flag if use_syslog
is set.

Signed-off-by: Robert Love <robert.w.love at intel.com>
---

 fcoemon.c    |   16 ++++++++++------
 fcoeplumb.in |   30 ++++++++++++++++++++----------
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/fcoemon.c b/fcoemon.c
index 89555a5..465549e 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -1601,7 +1601,7 @@ ignore_event:
  */
 static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 {
-	char *op, *debug = NULL;
+	char *op, *debug, *syslog = NULL;
 	char *qos_arg;
 	char qos[64];
 	u_int32_t mask;
@@ -1653,19 +1653,23 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 			}
 		}
 
+		if (fcoe_config.use_syslog)
+			syslog = "--syslog";
+
 		if (fcm_debug) {
 			debug = "--debug";
 
 			if (!action)
-				FCM_LOG_DEV_DBG(ff, "%s %s\n", fcm_dcbd_cmd,
-						op);
+				FCM_LOG_DEV_DBG(ff, "%s %s %s\n", fcm_dcbd_cmd,
+						op, syslog);
 			else
-				FCM_LOG_DEV_DBG(ff, "%s %s %s %s\n",
-						fcm_dcbd_cmd, op, qos_arg, qos);
+				FCM_LOG_DEV_DBG(ff, "%s %s %s %s %s\n",
+						fcm_dcbd_cmd, op, qos_arg, qos,
+						syslog);
 		}
 
 		execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, ff->ff_name,
-		       op, qos_arg, qos, debug, (char *)NULL);
+		       op, qos_arg, qos, debug, syslog, (char *)NULL);
 
 		FCM_LOG_ERR(errno, "exec '%s' failed", fcm_dcbd_cmd);
 		exit(1);
diff --git a/fcoeplumb.in b/fcoeplumb.in
index f2c0a73..1d09c1d 100755
--- a/fcoeplumb.in
+++ b/fcoeplumb.in
@@ -22,7 +22,7 @@ cmdname=`basename $0`
 usage()
 {
 	echo usage: $cmdname \
-		'<ethX> [--reset | --enable | --disable] [--debug]' \
+		'<ethX> [--reset | --enable | --disable] [--debug] [--syslog]' \
 		'[--qos <pri>[,<pri>]...]]' >&2
 	exit 1
 }
@@ -50,17 +50,10 @@ sysconfdir=@sysconfdir@
 # make sure there's a sane path to find basic commands and system tools (tc)
 PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
 FCOEADM=${sbindir}/fcoeadm	# command to create/destroy FCoE instances
-LOGGER="logger -s -t fcoeplumb"
 CONFIG_DIR=${sysconfdir}/fcoe
+LOGGER=
 DEBUG_LOGGING=
 
-. $CONFIG_DIR/config
-if [ "$USE_SYSLOG" != "yes" ] && [ "$USE_SYSLOG" != "YES" ]; then
-	LOGGER="echo"
-else
-	USE_SYSLOG="yes"
-fi
-
 find_multiq_qdisc()
 {
 	ifname=$1
@@ -229,6 +222,19 @@ create_fcoe_interface()
 	fi
 }
 
+config_logging()
+{
+    if [ $DEBUG_LOGGING ] ; then
+	if [ $USE_SYSLOG ] ; then
+	    LOGGER="logger -s -t fcoeplumb"
+	else
+	    LOGGER="echo"
+	fi
+    else
+	LOGGER=
+    fi
+}
+
 [ "$#" -lt 1 ] && usage
 
 [ ${DEBUG_LOGGING} ] && $LOGGER "fcoeplumb arguments: ($*)"
@@ -249,8 +255,12 @@ do
 		cmd=disable
 		;;
 	    --debug)
-		LOGGER="logger -t fcoeplumb -s"
 		DEBUG_LOGGING=1
+		config_logging
+		;;
+            --syslog)
+		USE_SYSLOG=1
+		config_logging
 		;;
 	    --qos | -q)
 		[ "$#" -lt 2 ] && usage




More information about the devel mailing list