Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1:Update
open-fcoe
open-fcoe-update-1.0.4.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File open-fcoe-update-1.0.4.diff of Package open-fcoe
Index: open-fcoe/usr/INSTALL =================================================================== --- open-fcoe.orig/usr/INSTALL +++ open-fcoe/usr/INSTALL @@ -3,7 +3,7 @@ The FCoE Management Tools included in this package are - fcoeadm - program to create, destroy, and to display FCoE interfaces + fcoeadm - program to create, reset, destroy, and display FCoE interfaces fcoemon - program to monitor the events from the DCB daemon Requirements: @@ -11,7 +11,8 @@ Requirements: The HBAAPI library and the HBAAPI vendor library source must be build and installed before you can build the management tools. The HBAAPI vendor library, libhbalinux, may be downloaded from www.Open-FCoE.org. The instructions -in the package describes how to download and build the libraries. +in the package describes how to download and build the libraries. See the man +pages for other requirements. Build and Install The Management Tools -------------------------------------- @@ -30,55 +31,25 @@ Build and Install The Management Tools For example, make LIBHBALINUX=/var/work/libhbalinux \ - DCB_SRC=/var/work/dcb/dcbd-0.7.25rt + DCB_SRC=/var/work/dcb/dcbd-0.7.31rt To cleanup, issue make clean make uninstall + Notice that before issuing "make uninstall", make sure the fcoe service is not + running. + 2) The installation adds the following files to the system, /sbin/fcoeadm /sbin/fcoemon - /sbin/fcoeplumb /usr/share/man/man8/fcoeadm.8.gz /usr/share/man/man8/fcoemon.8.gz - /etc/fcoe/open-fcoe.conf - /etc/rc.d/init.d/open-fcoe - -3) Running the tools requires to have the libHBAAPI.so and libhbalinux.so, - and /etc/hba.conf installed on the system. See the INSTALL instructions - of HBAAPI Vendor Libraries. - -4) If you have edited the file /etc/fcoe/open-fcoe.conf to include - one and only one line of - - HBA=<ethX> - - where <ethX> is the ethernet interface you will use to create FCoE - instance, you may start and stop the open-fcoe service with the - following commands: - - # service open-fcoe start - - If DCB daemon is running and the DCB state is set to 'on', - this command will invoke fcoemon. Otherwise it will invoke - fcoeadm to create the FCoE interface. - - # service open-fcoe stop - - This command willinvoke fcoeadm to destroy the FCoE interface. - Additionally, if DCB daemon is running and the DCB state is - set to 'on', this command will also terminate the fcoemon - daemon process. - - # service open-fcoe status - - This command shows if the fcoemon daemon is running or unused. - It will also show the network interfaces currently have FCoE - instances created. + /etc/sysconfig/fcoe/config + /etc/sysconfig/fcoe/cfg-ethX (one file per ethX port) + /etc/sysconfig/fcoe/scripts/fcoeplumb + /etc/init.d/fcoe - # service open-fcoe - Usage: /etc/init.d/open-fcoe {start|stop|reload|restart|status} Index: open-fcoe/usr/Makefile =================================================================== --- open-fcoe.orig/usr/Makefile +++ open-fcoe/usr/Makefile @@ -15,43 +15,14 @@ RM = rm default: all all: - $(foreach i, $(wildcard tools/*), $(MAKE) -C $(i) LIBDIR=$(LIBDIR); ) + $(foreach i, $(wildcard tools/*), $(MAKE) -C $(i) CFLAGS="$(CFLAGS)" LIBDIR="$(LIBDIR)"; ) clean: @$(foreach i, $(wildcard tools/*), $(MAKE) -C $(i) clean ; ) -install: install_initd +install: $(foreach i, $(wildcard tools/*), $(MAKE) -C $(i) install ; ) -uninstall: uninstall_initd +uninstall: @$(foreach i, $(wildcard tools/*), $(MAKE) -C $(i) uninstall ; ) -install_initd: - @$(INSTALL) -d $(DESTDIR)$(ETCDIR)/fcoe - @$(INSTALL) -v -m 644 etc/fcoe.conf \ - $(DESTDIR)$(ETCDIR)/fcoe/open-fcoe.conf - if [ -f /etc/fedora-release ]; then \ - $(MAKE) install_initd_fedora ; \ - elif [ -f /etc/SuSE-release ]; then \ - $(MAKE) install_initd_suse ; \ - fi - @echo - @echo ------------------------------------------------- - @echo Please check INSTALL file for detailed information. - @echo Remember to setup the FCoE config file located at: - @echo -e "\t$(DESTDIR)$(ETCDIR)/fcoe/open-fcoe.conf" - @echo - -install_initd_fedora: - @$(INSTALL) -d $(DESTDIR)$(INITDDIR) - @$(INSTALL) -v -m 755 etc/initd/initd.fcoe \ - $(DESTDIR)$(INITDDIR)/open-fcoe - -install_initd_suse: - @$(INSTALL) -d $(DESTDIR)$(INITDDIR) - @$(INSTALL) -v -m 755 etc/initd/initd.suse \ - $(DESTDIR)$(INITDDIR)/open-fcoe - -uninstall_initd: - @$(RM) -vf $(DESTDIR)$(ETCDIR)/fcoe/open-fcoe.conf - @$(RM) -vf $(DESTDIR)$(INITDDIR)/open-fcoe Index: open-fcoe/usr/doc/fcoeadm.8 =================================================================== --- open-fcoe.orig/usr/doc/fcoeadm.8 +++ open-fcoe/usr/doc/fcoeadm.8 @@ -1,4 +1,4 @@ -.TH FCOEADM 8 "August 21, 2008" "Open-FCoE Applications" "Open-FCoE Tools" +.TH "FCOEADM" "8" "November 4, 2008" "Open-FCoE Applications" "Open-FCoE Tools" .SH "NAME" \fBfcoeadm\fR \- The Fibre Channel over Ethernet (FCoE) administration tool .SH "SYNOPSIS" @@ -16,6 +16,8 @@ .P \fBfcoeadm\fR [\fB\-s\fR|\fB\-\-stats\fR] [\fI<ethX>\fR [\fB\-n\fR \fI<interval>\fR]] .P +\fBfcoeadm\fR [\fB\-v\fR|\fB\-\-version\fR] +.P \fBfcoeadm\fR [\fB\-h\fR|\fB\-\-help\fR] .SH "DESCRIPTION" The \fBfcoeadm\fR command is intended to be the FCoE management tool for the Linux systems. @@ -23,10 +25,10 @@ The \fB\-c\fR, \fB\-d\fR, and \fB\-r\fR an FCoE instance on a given network interface. The other options are used to query the information of the FCoE instance which includes the interface information, target information, LUN information, and port statistics. The \fBfcoeadm\fR command invokes the \fBHBAAPI\fR library -routines to obtain these information. The \fBHBAAPI\fR library routines invoke the vendor-specific +routines to obtain these information. The \fBHBAAPI\fR library routines invoke the vendor\-specific library, \fBlibhbalinux\fR, to grab the information from the /sys file system. In other words, the \fBfcoeadm\fR command requires to have \fBlibHBAAPI\fR and \fBlibhbalinux\fR installed on the system to work. -The \fBlibhbalinux\fR is maintained at \fB\fIwww.Open-FCoE.org\fR. The installation instructions of +The \fBlibhbalinux\fR is maintained at \fB\fIwww.Open\-FCoE.org\fR. The installation instructions of \fBlibhbalinux\fR also instructs how to download the \fBHBAAPI\fR source code, build and install with the \fBlibhbalinux\fR. The last option \fB\-h\fR is used to show a brief usage message of the supported command syntax. @@ -57,7 +59,7 @@ show the information of all the discover .TP \fB\-l\fR, \fB\-\-lun\fR \fI<target_port_id>\fR \fI<lun_id>\fR Show the detailed information of a specific LUN with \fI<lun_id>\fR at the target -with port id \fI<target_port_id>\fR. port id is also known as FC-ID. If \fI<lun_id>\fR +with port id \fI<target_port_id>\fR. port id is also known as FC\-ID. If \fI<lun_id>\fR is not specified, all the LUNs associated with the target will be shown. .TP \fB\-s\fR, \fB\-\-stats\fR \fI<ethX>\fR \fB\-n\fR \fI<interval>\fR @@ -65,82 +67,84 @@ Show the statistics (including FC4 stati The information will be display in one line on the screen per given time interval. \fI<interval>\fR should be specified in whole intergers greater than 0. It specifies the time interval in the unit of second. If \fI<interval>\fR is not specified, the default interval is one second. -.TP -\fB\-h\fR, \fB\-\-help\fR \fI<ethX>\fR -Displays this help information. .TP -\fI<ethX>\fR -The network interface name, such as eth0, eth1, etc. +\fB\-v\fR, \fB\-\-version\fR +Displays the version of the \fBfcoeadm\fR command. +.TP +\fB\-h\fR, \fB\-\-help\fR +Displays the usage message of the \fBfcoeadm\fR command. +.TP +where \fI<ethX>\fR is the network interface name, such as eth0, eth1, etc. .SH "EXAMPLES" Creates an FCoE instance on eth2 .IP -$ \fBfcoeadm\fR -c eth2 +$ \fBfcoeadm\fR \-c eth2 .P Destroys the FCoE instance on eth2 .IP -$ \fBfcoeadm\fR -d eth2 +$ \fBfcoeadm\fR \-d eth2 .P Resets the FCoE instance on eth2 .IP -$ \fBfcoeadm\fR -r eth2 +$ \fBfcoeadm\fR \-r eth2 .P Show the information of all the adapters and their ports having FCoE instances created. .IP -$ \fBfcoeadm\fR -i +$ \fBfcoeadm\fR \-i .P Show the information of a specific interface eth3. If eth3 has no FCoE instances created, the command will show the error "No fc_host found for eth3". .IP -$ \fBfcoeadm\fR -i eth3 +$ \fBfcoeadm\fR \-i eth3 .P Show the information of all the discovered targets from all the ports having FCoE instances created (they may be on different adapter cards). A brief listing of discovered LUNs are listed after the target they are associated with, if any. .IP -$ \fBfcoeadm\fR -t +$ \fBfcoeadm\fR \-t .P Show the information of all the discovered targets from a given port (eth3) having FCoE instance created. A brief listing of discovered LUNs are listed after each target they are associated with, if any. .IP -$ \fBfcoeadm\fR -t eth3 +$ \fBfcoeadm\fR \-t eth3 .P Show the detailed information of all the LUNs associated with a specific target. -The target is identified by its port id (aka FC-ID) 0xD700EF. +The target is identified by its port id (aka FC\-ID) 0xD700EF. .IP -$ \fBfcoeadm\fR -l 0xD700EF +$ \fBfcoeadm\fR \-l 0xD700EF .P .IP -$ \fBfcoeadm\fR -l D700EF +$ \fBfcoeadm\fR \-l D700EF .P .IP -$ \fBfcoeadm\fR -l 0xd700ef +$ \fBfcoeadm\fR \-l 0xd700ef .P .IP -$ \fBfcoeadm\fR -l d700ef +$ \fBfcoeadm\fR \-l d700ef .P Show the detailed information of a LUN associated with a specific target. -The target is identified by its port id (aka FC-ID) 0xD700EF and the LUN +The target is identified by its port id (aka FC\-ID) 0xD700EF and the LUN is identified by its LUN id. .IP -$ \fBfcoeadm\fR -l 0xD700EF 1 +$ \fBfcoeadm\fR \-l 0xD700EF 1 .P Show the statistics information of a specific port eth3 having FCoE instances created. The statistics are displayed one line per time interval. The default interval is one -second if -n option is not specified. +second if \-n option is not specified. .IP -$ \fBfcoeadm\fR -s eth3 +$ \fBfcoeadm\fR \-s eth3 .P .IP -$ \fBfcoeadm\fR -s eth3 -n 3 +$ \fBfcoeadm\fR \-s eth3 \-n 3 .P .IP -$ \fBfcoeadm\fR -s eth3 -n3 +$ \fBfcoeadm\fR \-s eth3 \-n3 .SH "REPORTING BUGS" If you have identified a defect please either file a bug or engage the development mailing list at -<http://www.Open-FCoE.org>. +<http://www.Open\-FCoE.org>. .SH "SUPPORT" -Open-FCoE is maintained at <http://www.Open-FCoE.org>. There are resources +Open\-FCoE is maintained at <http://www.Open\-FCoE.org>. There are resources available for both developers and users at that site. Index: open-fcoe/usr/doc/fcoemon.8 =================================================================== --- open-fcoe.orig/usr/doc/fcoemon.8 +++ open-fcoe/usr/doc/fcoemon.8 @@ -1,31 +1,36 @@ -.TH "FCOEMON" "8" "October 31, 2008" "Open-FCoE Applications" "Open-FCoE Tools" +.TH "FCOEMON" "8" "November 14, 2008" "Open-FCoE Applications" "Open-FCoE Tools" .SH "NAME" \fBfcoemon\fR \- The Fibre Channel over Ethernet (FCoE) administration tool for monitoring and processing events from DCB daemon. .SH "SYNOPSIS" -\fBfcoemon\fR [\fB\-v\fR] [\fB\-d\fR] [\fB\-e\fR \fI<path\-to\-fcoeplumb\-script>\fR] +\fBfcoemon\fR [\fB\-h\fR | \fB\-\-help\fR] +.P +\fBfcoemon\fR [\fB\-v\fR | \fB\-\-version\fR] +.P +\fBfcoemon\fR [\fB\-d\fR | \fB\-\-debug\fR] [\fB\-e\fR | \fB\-\-exec\fR \fI<path\-to\-fcoeplumb\-script>\fR] .SH "DESCRIPTION" -The \fBfcoemon\fR command is an FCoE management tool provided by the Open\-FCoE package. -\fBfcoemon\fR is a daemon which can either be run from the command line or from an -initialization/service\-startup script. When \fBfcoemon\fR starts, it establishes a socket +The \fBfcoemon\fR command is a FCoE management tool provided by the Open\-FCoE package. +\fBfcoemon\fR is the daemon of the \fBfcoe\fR system service. When \fBfcoemon\fR starts, it establishes a socket connection with the \fBDCB\fR daemon. It then sends commands to, and receives responses -and event from the \fBDCB\fR daemon. \fBfcoemon\fR will process the received responses +and event from the \fBDCB\fR daemon. The \fBfcoemon\fR will process the received responses and events and invoke the \fBfcoeplumb\fR script to create and destroy the FCoE interfaces. Since the \fBfcoemon\fR depend on the existence of \fBDCB service\fR, there are settings required for \fBDCB\fR before \fBfcoemon\fR can be started. See the \fIDCB Settings\fR section below. .SH "OPTIONS" -.TP -\fB\-v\fR -Show the build date and time of the \fBfcoeemon\fR command. -.TP -\fB\-d\fR +.TP +\fB\-h | \-\-version\fR +Show the usage message of the \fBfcoeemon\fR command. +.TP +\fB\-v | \-\-version\fR +Show the version of the \fBfcoeemon\fR command. +.TP +\fB\-d | \-\-debug\fR Enable debugging messages. -.TP -\fB\-e\fR \fI<path\-of\-fcoeplumb\-script>\fR +.TP +\fB\-e | \-\-exec\fR \fI<path\-of\-fcoeplumb\-script>\fR Specify the location of the \fBfcoeplumb\fR script. -If this option is not specified, the default location is \fB/sbin/fcoeplumb\fR. -.SH "Terminology" +.SH "TERMINOLOGY" .TP \fBPFC\fR \- The DCB Priority Flow Control feature. .TP @@ -33,13 +38,18 @@ If this option is not specified, the def .TP \fBLLINK\fR \- The DCB Logical Link TLV (or Logical Link) feature. .TP -\fBmultiq\fR \- See linux kernel documentation of networking +\fBmultiq\fR \- See Documentation/networking/multiqueue.txt of linux kernel 2.6.28 or higher. .TP -\fBskbedit\fR \- See linux kernel documentation of networking +\fBskbedit\fR \- See Documentation/networking/multiqueue.txt of linux kernel 2.6.28 or higher. +.SH "INSTALLATION REQUIREMENTS" +The linux kernel must be at version 2.6.27.1\-2 beta4 or higher. The DCB and FCoE kernel +configuration options must be enabled. Both the linux kernel and iproute2 must support multiq +and skbedit. The DCB must be installed with version 0.7.31 and higher. .SH "SUPPORTED DCB EVENTS" -For each supported event from the DCB daemon, the fcoemon collects the current -information of the DCB daemon and decide whether to create, destroy or restart -a FCoE interface, There are three supported events: +In response to each supported event from the DCB daemon, the fcoemon collects the current +settings from the DCB daemon and decide whether to delete and re-add the multiq queue discipline +and skbedit filter. The \fBfcoemon\fR does not destroy, reset, or create FCoE interfaces during +the DCB event processing. .TP \fBFEATURE_APP\fR If an event message is received from dcbd and if the feature code in the event message @@ -58,26 +68,31 @@ If an event message is received from dcb is FEATURE_LLINK (6), and if the subtype field is LLINK_FCOE_STYPE (0), we got a mode or configuration change event of the Logical Link TLV feature. The fcoemon will then issue queries to the DCB daemon to collect the current mode and configuration information. -.SH "CRITERIA OF CREATING AND DESTROYING FCOE INTERFACE" +.SH "CRITERIA OF CREATING, RESETTING AND DESTROYING FCOE INTERFACE" +In this section the \fBdcbtool\fR is used to describe the conditions of the DCB feture status +beccause the meaning is more understandable and precise. Although you may also issue the +commands at run-time, the commands are intended only to be used for description purpose. .TP \fBPFC and App:FCoE\fR DCB is configured correctly if .RS .PD 0 .TP 3 -.BR "1)" " App:FCoE is configured to Enable=TRUE, Advertise=TRUE," +.BR "1)" " The command \fBdcbtool gc ethX dcb\fR shows DCB State: on" +.TP 3 +.BR "2)" " The command \fBdcbtool gc ethX app:0\fR shows Enable:true," .TP 3 -.BR " " " Willing=TRUE locally." +.BR " " " Advertise:true, Willing:true." .TP 3 -.BR "2)" " App:FCoE feature is in Opertional Mode = TRUE," +.BR "3)" " The command \fBdcbtool go ethX app:0\fR shows OperMode:true." .TP 3 -.BR "3)" " PFC feature is in Opertional Mode = TRUE," +.BR "4)" " The command \fBdcbtool go ethX pfc\fR shows OperMode:true and" .TP 3 -.BR "4)" " The priority indicated by the App:FCoE Operational" +.BR " " " the values of pfcup." .TP 3 -.BR " " " Configuration is also enabled in the PFC Operational" +.BR "5)" " The command \fBdcbtool go ethX app:0\fR shows appcfg. The bits" .TP 3 -.BR " " " Configuration." +.BR " " " set to 1 are also set to 1 in pfcup found in (4)." .PD .RE .TP @@ -86,78 +101,107 @@ The Logical Link TLV feature is configur .RS .PD 0 .TP 3 -.BR "1)" " The local configuration of the LLINK feature is configured" +.BR "1)" " The command \fBdcbtool gc ethX ll:0\fR shows" .TP 3 -.BR " " " to Enable=TRUE, Advertise=TRUE, Willing=TRUE." +.BR " " " Enable:true, Advertise:true, Willing:true." .TP 3 -.BR "2)" " The Opertional Mode of the LLINK feature must be TRUE, +.BR "2)" " The command \fBdcbtool go ethX ll:0\fR shows OperMode:true." .TP 3 -.BR "3)" " The Link Status of the LLINK feature must be TRUE (UP). +.BR "3)" " The command \fBdbtool gp ethX ll:0\fR shows Link Status:up." .PD .RE .TP -\fBCriteria to Create FCoE Interface\fR -The DCB and the Logical Link TLV feature are configured correctly. -When the fcoeplumb script creates a FCoE Interface, it also add the multiq qdisc -and the skbedit filter. +\fBCriteria to create FCoE interface\fR +If DCB is required at the Ethernet port, a FCoE interface may be created only if +the DCB and the Logical Link TLV feature are configured correctly. If DCB is not +required at the Ethernet port, the FCoE interface may be created. FCoE interfaces +are normally created by the \fBfcoe\fR system service. .TP \fBCriteria to Destroy FCoE Interface\fR -Either the DCB or the Logical Link TLV feature is configured incorrectly. -When the fcoeplumb script destroys a FCoE Interface, it also delete the multiq qdisc -and the skbedit filter. -.TP -\fBCriteria to Restart FCoE Interface\fR -"Restart" means to destroy the FCoE interface and then create the FCoE interface immediately. -The qdisc and the filter will be deteted and then added accordingly. Restart will be performed -if the PFC priority is changed. -.SH "Linux Kernel Configuration" -The linux kernel must be at version 2.6.27.1\-2 beta4 and higher, and DCB and FCoE kernel -configuration options must be enabled. -.SH "DCB Settings" -Before \fBfcoemon daemon\fR starts, the following commands must be done to set up the -\fBDCB\fR service if they have not been done yet. For further instructions of DCB please -reference \fBDCB\fR documents. -.TP -\fB\ -modprobe dcbnl -\fR -This is to add the module for the Data Center Bridging netlink interface. -.TP -\fB\ -modprobe act_skbedit -\fR -This is to add the module for changing skb priority or queue_mapping settings -.TP -\fB\ -modprobe fcoe -\fR -This is to add the Fibre Channel library module and the Fibre Channel over Ethernet module. -.TP -\fB\ -service dcbx start -\fR -This is to start the DCB service. -.TP -\fB\ -dcbtool sc ethX dcb on -\fR -This is to enable the DCB state of the port ethX. -.TP -\fB\ -dcbtool sc ethX app:0 e:1 a:1 w:1 -\fR -This is to set the DCB configuration of the FCoE application feature of the port ethX to -include enable=ON, advertise=ON, and willing=ON. -.TP -\fB\ -dcbtool sc eth2 ll:0 e:1 a:1 w:1 -\fR -It is assumed that the DCB configuration of the Logical Link TLV feature include -enable=ON, advertise=ON, and willing=ON. Issue this command if the options are set as required. +An FCoE interface will only be destroyed when the \fBfcoe\fR system service is stopped. +.TP +\fBCriteria to reset a FCoE interface\fR +The \fBfcoe\fR system service does not reset any FCoE interfaces. +.TP +\fBChanging DCB Configuration, Qdisc and Filters\fR +Changing the DCB configuration, qdisc, and filter are considered to be administrative actions. +When the \fBfcoe\fR system service starts up, it sets up the default DCB configuration, qdisc, and filter +for reliable FCoE operations. Administrators may alter the configuration while the service is running. +Changing the DCB parameters may cause the fcoemon daemon to delete the existing multiq queue discipline, +skbedit filter and re-add; but the fcoe service will not touch (e.g. destroy or reset) the FCoE interface. +Changing the DCB configuration, qdisc, and filter should be avoided while I/O traffic are in progress. +.SH "FILES" +The Installation of the Open-FCoE management tools include the following files: +.TP +\fB/etc/sysconfig/fcoe/config\fR +This is the common configuration file for the \fBfcoe\fR system service. This file will +be read by the \fI/etc/init.d/fcoe\fR" script, the \fI/etc/sysconfig/fcoe/scripts/fcoeplumb\fR script, +and the \fIfcoemon\fR daemon. The default options in this file are: +\fBDEBUG="yes"\fR and \fBUSE_SYSLOG="yes"\fR. The former is used to enable (select yes) or disable (select no) +debugging messages of fcoemon, the \fIfcoe\fR service script, and the fcoeplumb script. The latter is +to indicate if the log messages of fcoemon, the \fIfcoe\fR service script, and the fcoeplumb script are +to be output to the system log. Use editor to set the desired \fByes/no\fR values. +.TP +\fB/etc/sysconfig/fcoe/cfg-ethX\fR +There is one of this file for each Ethernet interface \fBethX\fR found in the output of +\fBcat /proc/net/dev\fR at the time of installation. This file will be read by the +\fI/etc/init.d/fcoe\fR script and the \fIfcoemon\fR daemon. The default options in this file are: +\fBFCOE_ENABLE="no"\fR and \fBDCB_REQUIRED="yes"\fR. The former is used to enable (select yes) or +disable (select no) the FCoE service at the ethX port. The latter is to indicate if the DCB service +is required (select yes) or not required (select no) at the ethX port. If the former is set to no, the +latter is ignored. The selection of the settings should match the settings of the FCoE switch port connected +to the local Ethernet ethX port. Use editor to set the desired \fByes/no\fR +values for the \fBethX\fR interfaces. +.TP +\fB/etc/init.d/fcoe\fR +This is the \fIfcoe\fR system service shell script. This script is invoked by the \fBinit\fR process +or by the \fBservice\fR command. +.TP +\fB/sbin/fcoemon\fR +This is the \fIfcoemon\fR daemon only invoked by the \fIfcoe\fR system service script. +.TP +\fB/sbin/fcoeadm\fR +This is the program used by the \fIfcoe\fR system service to create or destroy FCoE interfaces. +.TP +\fB/etc/sysconfig/fcoe/scripts/fcoeplumb\fR +This is a script only used by the \fBfcoemon\fR daemon. +.TP +\fB/usr/share/man/man8/fcoemon.8.gz\fR +This is the man page of the \fBfcoemon\fR daemon (This file). +.TP +\fB/usr/share/man/man8/fcoeadm.8.gz\fR +This is the man page of the \fBfcoeadm\fR program. +.SH "FCOE SYSTEM SERVICE" +If the \fIfcoe\fR system service is enabled, it will be started after the +dcb service is started when the Linux system boots up. The following are the +sample commands at system run-time for the \fIfcoe\fR system service. +.TP +\fBchkconfig --list fcoe\fR +To check if the service is enabled. +.TP +\fBchkconfig fcoe off\fR +To disable the \fBfcoe\fR system service. +.TP +\fBchkconfig fcoe on\fR +To enable the \fBfcoe\fR system service. +.TP +\fBservice fcoe stop\fR +To stop the \fBfcoe\fR system service. +.TP +\fBservice fcoe start\fR +To start the stopped \fBfcoe\fR system service. +.TP +\fBservice fcoe restart\fR +To stop and then start the \fBfcoe\fR system service. +.TP +\fBservice fcoe status\fR +To check the status of the \fBfcoe\fR system service. +.TP +\fBservice fcoe\fR +To show the command-line options of the \fBfcoe\fR system service. .SH "REPORTING BUGS" -If you have identified a -defect please either file a bug or engage the development mailing list at -<http://www.Open\-FCoE.org>. +If you have identified a defect please either file a bug or engage the +development mailing list at <http://www.Open\-FCoE.org>. .SH "SUPPORT" Open\-FCoE is maintained at <http://www.Open\-FCoE.org>. There are resources available for both developers and users at that site. Index: open-fcoe/usr/etc/initd/initd.suse =================================================================== --- open-fcoe.orig/usr/etc/initd/initd.suse +++ open-fcoe/usr/etc/initd/initd.suse @@ -1,7 +1,13 @@ #!/bin/sh +################################################################################ # +# Open-FCoE User-Space Software # Copyright(c) 2008 Intel Corporation. All rights reserved. # +# Based on: +# Template LSB system startup script for example service/daemon FOO +# Copyright (C) 1995--2005 Kurt Garloff, SUSE / Novell Inc. +# # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, # version 2, as published by the Free Software Foundation. @@ -17,167 +23,287 @@ # # Maintained at www.Open-FCoE.org # +################################################################################ # -# chkconfig: 2345 92 19 -# description: OpenFC and FCoE: Fibre Channel over Ethernet SAN setup - -SERVICE=open-fcoe -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -HBA= -FCOEADM=/sbin/fcoeadm +# /etc/init.d/fcoe This shell script takes care of starting and stopping +# of the fcoemon daemon +# and its symbolic link +# /sbin/rcfcoe +# +# chkconfig: 345 20 80 +# description: fcoe monitor daemon +# +### BEGIN INIT INFO +# Provides: fcoe +# Required-Start: dcbd +# Required-Stop: +# Default-Start: 3 5 +# Default-Stop: 3 5 +# Description: Open-FCoE SAN Setup +### END INIT INFO + +SERVICE_NAME=fcoe +CONFIG_DIR=/etc/sysconfig/$SERVICE_NAME +CONFIG_SCRIPT=$CONFIG_DIR/scripts/fcoeplumb +PID_FILE="/var/run/fcoemon.pid" +LOG_FILE="/var/log/fcoemon.log" FCOEMON=/sbin/fcoemon -FCOE_CONF=/etc/fcoe/open-fcoe.conf -DCBTOOL=/usr/sbin/dcbtool -DCBX=dcbx +FCOEADM=/sbin/fcoeadm +DCBD=dcbd +LOGGER="logger -t fcoe -s" -# Validates the ifname -fcoe_gethba() -{ - HBA= - if [ ! -e $FCOE_CONF ] - then - echo "Open-fcoe config file $FCOE_CONF not found!" >&2 - return - fi - - # Get HBA= - HBA=`grep -v "#" $FCOE_CONF | grep "HBA=" | cut -f2 -d=` - if ! ifconfig $HBA &> /dev/null - then - echo "HBA $HBA not found in $FCOE_CONF!" >&2 - HBA= +. /etc/rc.status +rc_reset + +test -r $CONFIG_DIR/config || { + $LOGGER "$CONFIG_DIR/config not installed"; + if [ "$1" = "stop" ]; then exit 0; + else + rc_failed + rc_status -v + rc_exit fi } -# Check if DCB is running -if [ `$DCBTOOL gc eth2 dcb | awk '/Status:/{print $2}'` = "Successful" ] && - [ `$DCBTOOL gc eth2 dcb | awk '/DCB State:/{print $3}'` = "on" ] - [ `service $DCBX status | awk '/service dcbd:/{print $5}'` = "..running" ] -then - dcb_exists=1 -else - dcb_exists=0 - echo "DCB is not ready" >&2 +. $CONFIG_DIR/config +if [ "$USE_SYSLOG" != "yes" ] && [ "$USE_SYSLOG" != "YES" ]; then + LOGGER="echo" fi -if [ "$dcb_exists" = "1" ] -then - # Check if fcoemon is installed - which $FCOEMON > /dev/null 2>&1 - if [ $? -ne 0 ] - then - echo "$FCOEMON command not installed" >&2 - exit 1 +test -x $CONFIG_SCRIPT || { + $LOGGER "$CONFIG_SCRIPT not installed"; + if [ "$1" = "stop" ]; then exit 0; + else + rc_failed + rc_status -v + rc_exit fi -fi +} -# Check if fcoeadm is installed -which $FCOEADM > /dev/null 2>&1 -if [ $? -ne 0 ] -then - echo "$FCOEADM command not installed" >&2 - exit 1 -fi +test -x $FCOEADM || { + $LOGGER "$FCOEADM not installed"; + if [ "$1" = "stop" ]; then exit 0; + else + rc_failed + rc_status -v + rc_exit + fi +} -# Switch on start / stop argument -case "$1" in -start) - echo "Starting $SERVICE service ..." +test -x $FCOEMON || { + $LOGGER "$FCOEMON not installed"; + if [ "$1" = "stop" ]; then exit 0; + else + rc_failed + rc_status -v + rc_exit + fi +} - # Check if fcoe.ko and libfc.ko are loaded - lsmod | egrep "fcoe|libfc" &> /dev/null - if [ $? -ne 0 ] - then - modprobe -q fcoe 2> /dev/null - if [ $? -ne 0 ] - then - echo "Failed to load FCoE driver modules!" >&2 - exit 1 +startup_fcoe_modules() +{ + lsmod | egrep "fcoe|libfc" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + modprobe fcoe > /dev/null 2>&1 + if [ $? -ne 0 ]; then + /bin/logger -s "Failed to load FCoE modules!" + return 1 fi fi + return 0 +} - # Get HBA from conf - fcoe_gethba - if [ -z "$HBA" ] - then - echo "Please setup the config file $FCOE_CONF first!" >&2 - exit 1 +startup_dcb_modules() +{ + lsmod | egrep "dcbnl" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + modprobe dcbnl + if [ $? -ne 0 ]; then + $LOGGER "Failed to load dcbnl module!" + return 1 + fi fi - if [ "$dcb_exists" != "1" ] - then - startproc $FCOEMON >&2 - else - $FCOEADM --create $HBA > /dev/null 2>&1 + lsmod | egrep "act_skbedit" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + modprobe act_skbedit + if [ $? -ne 0 ]; then + $LOGGER "Failed to load act_skbedit module!" + return 1 + fi fi - ;; - -stop) - echo "Sutting down $SERVICE service ..." + return 0 +} - # Check if fcoe.ko and libfc.ko are loaded - lsmod | egrep "fcoe|libfc" &> /dev/null - if [ $? -ne 0 ] - then - echo "Open-FCoE driver modules not loaded!" >&2 - exit 1 - fi +configure_dcb_interface() +{ + ifname=$1 - # Get HBA from conf - fcoe_gethba - if [ -n "$HBA" ] - then - $FCOEADM --destroy $HBA > /dev/null 2>&1 - if [ "$dcb_exists" = "1" ] + if [ `service $DCBD status | cut -d" " -f5` != "..running" ]; then + $LOGGER "DCB service is not runnng" + return 1 + fi + + retry_count=3 + while true + do + [ $retry_count -eq 0 ] && return 0 + + if [ `dcbtool gc $ifname dcb | \ + awk '/Status:/{print $2}'` = "Successful" ] && + [ `dcbtool gc $ifname dcb | \ + awk '/DCB State:/{print $3}'` = "on" ] then - killproc $FCOEMON >&2 - rm -f /var/run/$FCOEMON.* + return 0 fi - fi - ;; - -status) - echo "Checking for service $SERVICE status ..." + #ethtool -A $ifname tx on rx on + dcbtool sc $ifname dcb on + dcbtool sc $ifname app:0 e:1 a:1 w:1 + dcbtool sc $ifname ll:0 e:1 a:1 w:1 + sleep 1 + retry_count=$(($retry_count-1)) + done + return 1 +} - # Check if fcoe.ko and libfc.ko are loaded - lsmod | egrep "fcoe|libfc" &> /dev/null - if [ $? -ne 0 ] - then - echo "Open-FCoE driver modules not loaded!" >&2 - exit 1 - fi +case "$1" in + start) + $LOGGER "Starting $SERVICE_NAME ..." - # Get HBA from conf - fcoe_gethba + startup_fcoe_modules + if [ $? -ne 0 ]; then + rc_failed + rc_status -v + else + + HAS_DCB_IF="false" + for ifcfg_file in `ls $CONFIG_DIR/cfg-eth*` + do + ifname=`basename $ifcfg_file | cut -d"-" -f2` + . $ifcfg_file + [ "$FCOE_ENABLE" != "yes" ] && + [ "$FCOE_ENABLE" != "YES" ] && continue + + if [ "$DCB_REQUIRED" != "yes" ] && + [ "$DCB_REQUIRED" != "YES" ]; then + # + # Create the FCoE interface if + # DCB is not required + # + $LOGGER "$FCOEADM --create $ifname ..." + $FCOEADM --create $ifname + else + # + # Configure the DCB for the Ethernet + # port if DCB is required + # + startup_dcb_modules + if [ $? -ne 0 ]; then + rc_failed + break + else + configure_dcb_interface $ifname + if [ $? -ne 0 ]; then + rc_failed + break + else + HAS_DCB_IF="true" + fi + fi + fi + done + + # If DCB-required Ethernet port exists + if [ "$HAS_DCB_IF" = "true" ]; then + checkproc -p ${PID_FILE} ${FCOEMON} + case $? in + 0) echo "Warning: daemon already running." + ;; + 1) echo "Warning: ${PID_FILE} exists." + ;; + esac + startproc -l ${LOG_FILE} -p ${PID_FILE} ${FCOEMON} + #startproc -l ${LOG_FILE} ${FCOEMON} + fi + fi - # Show if fcoemon is running - checkproc $FCOEMON - if [ $? -eq 0 ] - then - echo "fcoemon is RUNNING" - else - echo "fcoemon is UNUSED" - fi - STATUS=`$FCOEADM -interface 2>&1 | awk '/Interface Name:/{print $3}'` - if [ -z "$STATUS" ] - then - echo "No FCoE interfaces exist." - else - echo "Existing FCoE interfaces are:" - echo "$STATUS" - fi - ;; + rc_status -v + ;; + stop) + $LOGGER "Shutting down $SERVICE_NAME ..." + checkproc $FCOEMON + [ $? -eq 0 ] && killproc -TERM $FCOEMON + + for ifcfg_file in `ls $CONFIG_DIR/cfg-eth*` + do + ifname=`basename $ifcfg_file | cut -d"-" -f2` + . $ifcfg_file + [ "$FCOE_ENABLE" != "yes" ] && + [ "$FCOE_ENABLE" != "YES" ] && continue + if [ "$DCB_REQUIRED" == "yes" ] || + [ "$DCB_REQUIRED" == "YES" ]; then + tc qdisc del dev $ifname root > /dev/null 2>&1 + fi + done + + # Check if any FCoE interface still exist. If yes, destroy them. + STATUS=`$FCOEADM -interface 2>&1 | \ + awk '/Interface Name:/{print $3}'` + if [ -n "$STATUS" ]; then + for ifname in $STATUS + do + $FCOEADM --destroy $ifname + done + fi -restart | reload) - $0 stop - $0 start - ;; - -save) - ;; -*) - echo "Usage: $0 {start|stop|reload|restart|status}" >&2 - exit 1 - ;; + rc_status -v + ;; + try-restart|condrestart) + if test "$1" = "condrestart"; then + $LOGGER "${attn} Use try-restart ${done}(LSB)${attn} " \ + "rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi + rc_status + ;; + restart) + $0 stop + $0 start + rc_status + ;; + force-reload) + $0 try-restart + rc_status + ;; + reload) + $LOGGER "Reload service $SERVICE_NAME ..." + rc_failed 3 + rc_status -v + ;; + status) + rc_status -v + checkproc $FCOEMON + if [ $? -eq 0 ]; then + echo "$FCOEMON -- RUNNING" + else + echo "$FCOEMON -- UNUSED" + fi + STATUS=`$FCOEADM -interface 2>&1 | \ + awk '/Interface Name:/{print $3}' | \ + sort | awk '{printf("%s ", $1)}'` + if [ -z "$STATUS" ]; then + echo "No interfaces created." + else + echo "Created interfaces: $STATUS" + fi + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" + exit 1 + ;; esac -exit 0 +rc_exit Index: open-fcoe/usr/tools/fcoeadm/Makefile =================================================================== --- open-fcoe.orig/usr/tools/fcoeadm/Makefile +++ open-fcoe/usr/tools/fcoeadm/Makefile @@ -21,11 +21,11 @@ GZIP = gzip OSNAME = $(shell uname -s) MANPAGES = fcoeadm.8 -CFLAGS += -fPIC -O0 -g -Wall -Werror -CFLAGS += -D$(OSNAME) -CFLAGS += -I. -CFLAGS += -I$(LIBHBALINUX)/include -CFLAGS += -I$(LIBHBALINUX)/hbaapi_src_2.2 +#override CFLAGS += -fPIC -O0 -g -Wall -Werror +override CFLAGS += -D$(OSNAME) -D_GNU_SOURCE +override CFLAGS += -I. +override CFLAGS += -I$(LIBHBALINUX)/include +override CFLAGS += -I$(LIBHBALINUX)/hbaapi_src_2.2 LDFLAGS += -L$(LIBHBALINUX)/hbaapi_src_2.2 PROGRAMS = fcoeadm @@ -35,23 +35,23 @@ default: all all: $(PROGRAMS) clean: - @$(RM) -f *.o version.* $(PROGRAMS) > /dev/null 2>&1 + $(RM) -f *.o version.* $(PROGRAMS) > /dev/null 2>&1 .c.o: @echo ' CC PIC' $< - @$(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< fcoeadm: version.o fcoeadm_display.o fcoeadm.o @echo ' LINK' $@ - $(LD) -o $@ $(LDFLAGS) -Wl,-rpath -Wl,$(LIBDIR) -ldl -lHBAAPI $^ + $(LD) -o $@ $(CFLAGS) $(LDFLAGS) -Wl,-rpath -Wl,$(LIBDIR) -ldl -lHBAAPI $^ install: install_doc - @$(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ + $(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ $(INSTALL) -v -m 775 $(i) $(DESTDIR)$(SBINDIR) ; )) install_doc: - @$(INSTALL) -d $(DESTDIR)$(MANDIR)/man8 - @$(if $(MANPAGES), $(foreach i, $(MANPAGES), \ + $(INSTALL) -d $(DESTDIR)$(MANDIR)/man8 + $(if $(MANPAGES), $(foreach i, $(MANPAGES), \ $(INSTALL) -v -m 644 ../../doc/$(i) $(DESTDIR)$(MANDIR)/man8 ; \ $(RM) -f $(DESTDIR)$(MANDIR)/man8/$(i).gz ; \ $(GZIP) -9 $(DESTDIR)$(MANDIR)/man8/$(i) ; )) @@ -63,11 +63,11 @@ uninstall: $(RM) -vf $(DESTDIR)$(MANDIR)/man8/$(i).gz ; )) version.c: FORCE - @$(if $(LIBHBALINUX),, $(error Error! LIBHBALINUX is not defined,\ + $(if $(LIBHBALINUX),, $(error Error! LIBHBALINUX is not defined,\ Please read the INSTALL file.)) @echo ' BUILD $(@F)' - @$(RM) -f $@ - @echo char tools_version[] = '"'$(BUILD_VERSION) $(shell date)'";' > $@ + $(RM) -f $@ + @echo char build_date[] = '"'$(shell date)'";' > $@ .PHONY: FORCE Index: open-fcoe/usr/tools/fcoeadm/fcoeadm.c =================================================================== --- open-fcoe.orig/usr/tools/fcoeadm/fcoeadm.c +++ open-fcoe/usr/tools/fcoeadm/fcoeadm.c @@ -19,12 +19,18 @@ #include <stdio.h> #include <stdlib.h> +#include <libgen.h> #include <errno.h> #include <getopt.h> #include <dirent.h> #include <string.h> #include "fcoeadm.h" +static char *fcoeadm_version = "\ +fcoeadm v1.0.4\n\ +Copyright (c) 2007-2008, Intel Corporation.\n\ +"; + #define SYSFS_MOUNT "/sys" #define SYSFS_NET SYSFS_MOUNT "/class/net" #define SYSFS_FCHOST SYSFS_MOUNT "/class/fc_host" @@ -32,6 +38,8 @@ #define FCOE_CREATE SYSFS_FCOE "/create" #define FCOE_DESTROY SYSFS_FCOE "/destroy" +#define FCHOSTBUFLEN 64 + static struct option fcoeadm_opts[] = { {"create", 1, 0, 'c'}, {"destroy", 1, 0, 'd'}, @@ -41,16 +49,17 @@ static struct option fcoeadm_opts[] = { {"lun", 1, 0, 'l'}, {"stats", 1, 0, 's'}, {"help", 0, 0, 'h'}, + {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; struct opt_info _opt_info, *opt_info = &_opt_info; -char progname[256]; +char progname[20]; static void fcoeadm_help(void) { - /* printf("Build Date: %s\n", BUILD_DATE); */ + printf("%s\n", fcoeadm_version); printf("Usage: %s\n" "\t [-c|--create] <ethX>\n" "\t [-d|--destroy] <ethX>\n" @@ -59,7 +68,8 @@ fcoeadm_help(void) "\t [-t|--target] [<ethX>]\n" "\t [-l|--lun] [<target port_id> [<lun_id>]]\n" "\t [-s|--stats] <ethX> [-n <interval>]\n" - "\t [-h|--help]\n", progname); + "\t [-v|--version]\n" + "\t [-h|--help]\n\n", progname); } /* @@ -204,7 +214,7 @@ fcoeadm_check_fchost(const char *ifname, static int fcoeadm_find_fchost(char *ifname, char *fchost, int len) { - int n; + int n, dname_len; int found = 0; struct dirent **namelist; @@ -218,18 +228,31 @@ fcoeadm_find_fchost(char *ifname, char * n = scandir(SYSFS_FCHOST, &namelist, 0, alphasort); if (n > 0) { while (n--) { - /* check symboli name */ + /* check symbolic name */ if (!fcoeadm_check_fchost(ifname, namelist[n]->d_name)) { - strncpy(fchost, namelist[n]->d_name, len - 1); - found = 1; + dname_len = strnlen(namelist[n]->d_name, len); + if (dname_len != len) { + /* + * This assumes that d_name is always + * NULL terminated. + */ + strncpy(fchost, namelist[n]->d_name, + dname_len + 1); + found = 1; + } else { + fprintf(stderr, "scsi_host (%s) is " + "too large for a buffer that " + "is only %d bytes large\n", + namelist[n]->d_name, dname_len); + free(namelist[n]); + } } free(namelist[n]); } } free(namelist); - /* check */ return found; } @@ -268,12 +291,12 @@ fcoeadm_destroy(char *ifname) * Validate an existing FCoE instance for an Ethernet interface */ static int -fcoeadm_validate_interface(char *ifname, char *fchost) +fcoeadm_validate_interface(char *ifname, char *fchost, int len) { if (fcoeadm_check(ifname)) return -EINVAL; - if (!fcoeadm_find_fchost(ifname, fchost, sizeof(fchost))) { + if (!fcoeadm_find_fchost(ifname, fchost, len)) { fprintf(stderr, "%s: No fc_host found for %s\n", progname, ifname); return -EINVAL; @@ -288,10 +311,10 @@ fcoeadm_validate_interface(char *ifname, static int fcoeadm_reset(char *ifname) { - char fchost[64]; + char fchost[FCHOSTBUFLEN]; char path[256]; - if (fcoeadm_validate_interface(ifname, fchost)) + if (fcoeadm_validate_interface(ifname, fchost, FCHOSTBUFLEN)) return -EINVAL; sprintf(path, "%s/%s/issue_lip", SYSFS_FCHOST, fchost); @@ -412,7 +435,7 @@ fcoeadm_display_port_stats(struct opt_in int main(int argc, char *argv[]) { - char fchost[64]; + char fchost[FCHOSTBUFLEN]; int opt, rc = -1; if (argc <= 1) { @@ -420,10 +443,10 @@ int main(int argc, char *argv[]) exit(-EINVAL); } - strncpy(progname, argv[0], sizeof(progname)); + strncpy(progname, basename(argv[0]), sizeof(progname)); memset(opt_info, 0, sizeof(*opt_info)); - while ((opt = getopt_long(argc, argv, "c:d:r:itls:n:h", + while ((opt = getopt_long(argc, argv, "c:d:r:itls:n:hv", fcoeadm_opts, NULL)) != -1) { switch (opt) { case 'c': @@ -440,7 +463,8 @@ int main(int argc, char *argv[]) goto error; opt_info->a_flag = 1; if (argv[2]) { - if (fcoeadm_validate_interface(argv[2], fchost)) + if (fcoeadm_validate_interface(argv[2], fchost, + FCHOSTBUFLEN)) goto error; strncpy(opt_info->ifname, argv[2], sizeof(opt_info->ifname)); @@ -452,7 +476,8 @@ int main(int argc, char *argv[]) goto error; opt_info->t_flag = 1; if (argv[2]) { - if (fcoeadm_validate_interface(argv[2], fchost)) + if (fcoeadm_validate_interface(argv[2], fchost, + FCHOSTBUFLEN)) goto error; strncpy(opt_info->ifname, argv[2], sizeof(opt_info->ifname)); @@ -491,7 +516,8 @@ int main(int argc, char *argv[]) opt_info->s_flag = 1; opt_info->n_interval = DEFAULT_STATS_INTERVAL; if (argv[2]) { - if (fcoeadm_validate_interface(argv[2], fchost)) + if (fcoeadm_validate_interface(argv[2], fchost, + FCHOSTBUFLEN)) goto error; strncpy(opt_info->ifname, argv[2], sizeof(opt_info->ifname)); @@ -510,6 +536,9 @@ int main(int argc, char *argv[]) if (!opt_info->s_flag) goto error; goto stats; + case 'v': + printf("%s\n", fcoeadm_version); + goto done; case 'h': default: fcoeadm_help(); @@ -528,5 +557,5 @@ error: exit(-EINVAL); done: - exit(0); + return rc; } Index: open-fcoe/usr/tools/fcoeadm/fcoeadm.h =================================================================== --- open-fcoe.orig/usr/tools/fcoeadm/fcoeadm.h +++ open-fcoe/usr/tools/fcoeadm/fcoeadm.h @@ -60,8 +60,8 @@ struct opt_info { int n_interval; /* seconds */ }; extern struct opt_info *opt_info; +extern char build_date[]; extern void display_adapter_info(struct opt_info *opt_info); extern void display_target_info(struct opt_info *opt_info); extern void display_port_stats(struct opt_info *opt_info); - Index: open-fcoe/usr/tools/fcoemon/Makefile =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/Makefile +++ open-fcoe/usr/tools/fcoemon/Makefile @@ -21,11 +21,11 @@ GZIP = gzip OSNAME = $(shell uname -s) MANPAGES = fcoemon.8 -CFLAGS += -fPIC -O0 -g -Wall -Werror -CFLAGS += -D$(OSNAME) -CFLAGS += -I. -CFLAGS += -I$(LIBHBALINUX)/include -CFLAGS += -I$(DCB_SRC)/include +#CFLAGS += -fPIC -O0 -g -Wall -Werror +override CFLAGS += -D$(OSNAME) -D_GNU_SOURCE +override CFLAGS += -I. +override CFLAGS += -I$(LIBHBALINUX)/include +override CFLAGS += -I$(DCB_SRC)/include PROGRAMS = fcoemon @@ -34,51 +34,51 @@ default: all all: $(PROGRAMS) clean: - @$(RM) -f *.o version.* $(PROGRAMS) > /dev/null 2>&1 + $(RM) -f *.o version.* $(PROGRAMS) > /dev/null 2>&1 .c.o: @echo ' CC PIC' $< - @$(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< fcoemon: version.o fcoemon_utils.o fcoemon.o @echo ' LINK' $@ - @$(LD) -o $@ $(LDFLAGS) -lrt $^ + $(LD) $(CFLAGS) -o $@ $(LDFLAGS) -lrt $^ install_fcoeplumb: - @$(INSTALL) -v -m 775 fcoeplumb.sh $(DESTDIR)$(SBINDIR)/fcoeplumb + $(INSTALL) -v -m 775 fcoeplumb.sh $(DESTDIR)$(SBINDIR)/fcoeplumb install: all install_fcoeplumb install_initd install_doc - @$(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ + $(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ $(INSTALL) -v -m 775 $(i) $(DESTDIR)$(SBINDIR) ; )) install_doc: - @$(INSTALL) -d $(DESTDIR)$(MANDIR)/man8 - @$(if $(MANPAGES), $(foreach i, $(MANPAGES), \ + $(INSTALL) -d $(DESTDIR)$(MANDIR)/man8 + $(if $(MANPAGES), $(foreach i, $(MANPAGES), \ $(INSTALL) -v -m 644 ../../doc/$(i) $(DESTDIR)$(MANDIR)/man8 ; \ $(RM) -f $(DESTDIR)$(MANDIR)/man8/$(i).gz ; \ $(GZIP) -9 $(DESTDIR)$(MANDIR)/man8/$(i) ; )) install_initd: - @$(INSTALL) -d $(DESTDIR)$(ETCDIR)/fcoe - @$(INSTALL) -v -m 644 ../../etc/fcoemon.conf \ + $(INSTALL) -d $(DESTDIR)$(ETCDIR)/fcoe + $(INSTALL) -v -m 644 ../../etc/fcoemon.conf \ $(DESTDIR)$(ETCDIR)/fcoe uninstall: - @$(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ + $(if $(PROGRAMS), $(foreach i, $(PROGRAMS), \ $(RM) -vf $(DESTDIR)$(SBINDIR)/$(i) ; )) - @$(RM) -vf $(DESTDIR)$(SBINDIR)/fcoeplumb - @$(if $(MANPAGES), $(foreach i, $(MANPAGES), \ + $(RM) -vf $(DESTDIR)$(SBINDIR)/fcoeplumb + $(if $(MANPAGES), $(foreach i, $(MANPAGES), \ $(RM) -vf $(DESTDIR)$(MANDIR)/man8/$(i).gz ; )) - @$(RM) -vf $(DESTDIR)$(ETCDIR)/fcoe/fcoemon.conf + $(RM) -vf $(DESTDIR)$(ETCDIR)/fcoe/fcoemon.conf version.c: FORCE - @$(if $(DCB_SRC),, $(error Error! DCB_SRC is not defined. \ + $(if $(DCB_SRC),, $(error Error! DCB_SRC is not defined. \ Please read the INSTALL file.)) - @$(if $(LIBHBALINUX),, $(error Error! LIBHBALINUX is not defined. \ + $(if $(LIBHBALINUX),, $(error Error! LIBHBALINUX is not defined. \ Please read the INSTALL file.)) @echo ' BUILD $(@F)' - @$(RM) -f $@ - @echo char tools_version[] = '"'$(BUILD_VERSION) $(shell date)'";' > $@ + $(RM) -f $@ + @echo char build_date[] = '"'$(shell date)'";' > $@ .PHONY: FORCE Index: open-fcoe/usr/tools/fcoemon/fcoemon.c =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/fcoemon.c +++ open-fcoe/usr/tools/fcoemon/fcoemon.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2008 Intel Corporation. All rights reserved. + * Copyright(c) 2007-2008 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,7 +17,6 @@ * Maintained at www.Open-FCoE.org */ -#define _GNU_SOURCE #include <ctype.h> #include <errno.h> #include <getopt.h> @@ -29,6 +28,7 @@ #include <string.h> #include <strings.h> #include <time.h> +#include <libgen.h> #include <ulimit.h> #include <unistd.h> #include <paths.h> @@ -50,24 +50,47 @@ #include "fcoemon_utils.h" #include "fcoemon.h" +static char *fcoemon_version = "\ +fcoemon v1.0.4\n\ +Copyright (c) 2007-2008, Intel Corporation.\n\ +"; + /* - * Defines for OpenFC config file. + * Defines for FCoE config file. */ -#define OFC_CONF_DIR "/etc/fcoe" -#define OFC_CONF_DEFAULTS "fcoemon.conf" /* file for global settings */ -#define OFC_CONF_FILE "fcconf-" -#define OFC_CONF_LIVE "fclive-" -#define OFC_CONF_WWN_FMT "%16.16llx" /* format for WWN extension */ -#define OFC_CONF_WWN_VLAN_FMT "%16.16llx.%u" /* format for WWN and VLAN */ -#define FCC_FILE_NAME_LEN 256 /* enough for above names */ +#define OFC_CONF_DIR "/etc/sysconfig/fcoe" +#define CONFIG_MIN_VAL_LEN (1 + 2) +#define CONFIG_MAX_VAL_LEN (20 + 2) +#define DCB_APP_0_DEFAULT_ENABLE 1 +#define DCB_APP_0_DEFAULT_WILLING 1 +#define FCM_DEFAULT_QOS_MASK (1 << 3) /* - * The subset of the variable names and values that are used outside of fcconf. + * fcoe service configuration data + * Note: These information are read in from the fcoe service + * files in /etc/sysconfig/fcoe. */ -#define OFC_CONF_DCB_VAR "FCOE_DCB" /* var controlling DCB */ -#define OFC_CONF_DCB_ENABLE "enable" /* use negotiated settings */ -#define OFC_CONF_DCB_LOCAL "local" /* use local parameters */ -#define OFC_CONF_DCB_DISABLE "disable" /* don't use DCB */ +struct fcoe_port_config { + struct fcoe_port_config *next; + char ifname[IFNAMSIZ]; + int fcoe_enable; + int has_fip; + int dcb_required; + int dcb_app_0_enable; + int dcb_app_0_willing; +}; + +struct fcoe_config { + int debug; + int use_syslog; + struct fcoe_port_config *port; +} fcoe_config; + +static u_int8_t fcm_def_qos_mask = FCM_DEFAULT_QOS_MASK; + +#define OFC_CONF_WWN_FMT "%16.16llx" /* format for WWN extension */ +#define OFC_CONF_WWN_VLAN_FMT "%16.16llx.%u" /* format for WWN and VLAN */ +#define FCC_FILE_NAME_LEN 256 /* enough for above names */ /* * Form the config file name for an OpenFC HBA. @@ -92,8 +115,9 @@ struct clif; /* for dcbtool.h only */ #include "clif_cmds.h" #include "common.h" /* for event msg level definitions */ -#define CLIF_PATH "/var/run/dcbd/clif" -#define CLIF_LOCAL_PATH "/var/run/fcoemon.%d" +#define CLIF_NAME_PATH _PATH_VARRUN "dcbd/clif" +#define CLIF_PID_FILE _PATH_VARRUN "fcoemon.pid" +#define CLIF_LOCAL_SUN_PATH _PATH_VARRUN "fcoemon.sun_path.%d" #define FCM_DCBD_TIMEOUT_USEC (30 * 1000 * 1000) /* @@ -121,19 +145,16 @@ static struct fcm_clif fcm_clif_st; static struct fcm_clif *fcm_clif = &fcm_clif_st; static struct sa_timer fcm_dcbd_timer; -char *fcm_dcbd_cmd = "/sbin/fcoeplumb"; +char *fcm_dcbd_cmd = OFC_CONF_DIR "/scripts/fcoeplumb"; int fcm_dcbd_debug; int fcm_link_debug; +int fcm_use_syslog; /* Debugging routine */ -static void print_errors(int errors); -static char *print_status(cmd_status status); +static void print_errors(char *buf, int errors); +static char *get_status_string(cmd_status status); struct fcm_fcoe_head fcm_fcoe_head = TAILQ_HEAD_INITIALIZER(fcm_fcoe_head); -static void fcm_fcoe_read_dcb_settings(FILE *, u_int32_t *, u_int32_t *); - -static u_int32_t fcm_dcbd_def_enable; -static u_int32_t fcm_dcbd_def_will; static int fcm_link_socket; static int fcm_link_seq; @@ -157,13 +178,9 @@ static struct option fcm_options[] = { * - add arg to limit interface list. * - do script to setup traffic classes. */ -char *cmdname; -char cmdbuf[40]; - -#define FCM_DEF_QOS_MASK (1 << 3) /* default QOS mask */ +char progname[20]; -static u_int8_t fcm_def_qos_mask = FCM_DEF_QOS_MASK; -static char fcm_pidfile[] = _PATH_VARRUN "fcmonitor.pid"; +static char fcm_pidfile[] = CLIF_PID_FILE; /* * Issue with buffer size: It isn't clear how to read more than one @@ -214,6 +231,180 @@ fcm_ofc_conf_read(char *val_buf, size_t return 0; } +/* + * A value must be surrounded by quates, e.g. "x". + * The minimum length of a value is 1 excluding the quotes. + * The maximum length of a value is 20 excluding the quotes. + */ +static int +fcm_remove_quotes(char *buf, int len) +{ + char *s = buf; + char *e = buf + len - 1; + char tmp[CONFIG_MAX_VAL_LEN + 1]; + + if (strnlen(buf, len) < CONFIG_MIN_VAL_LEN) + return -1; + if ((*s >= '0' && *s <= '9') || + (*s >= 'a' && *s <= 'z') || + (*s >= 'A' && *s <= 'Z')) + return -1; + if ((*e >= '0' && *e <= '9') || + (*e >= 'a' && *e <= 'z') || + (*e >= 'A' && *e <= 'Z')) + return -1; + s = buf + 1; + *e = '\0'; + strncpy(tmp, s, len - 1); + strncpy(buf, tmp, len - 1); + + return 0; +} + +static int +fcm_read_config_files(void) +{ + char file[80]; + FILE *fp; + char val[CONFIG_MAX_VAL_LEN + 1]; + DIR *dir; + struct dirent *dp; + struct fcoe_port_config *curr; + struct fcoe_port_config *next; + int rc; + + memset(&fcoe_config, 0, sizeof(fcoe_config)); + + strncpy(file, OFC_CONF_DIR "/" "config", sizeof(file)); + fp = fopen(file, "r"); + if (!fp) { + SA_LOG_ERR(errno, "Failed reading %s\n", file); + exit(1); + } + + fcm_ofc_conf_read(val, sizeof(val), fp, "DEBUG"); + rc = fcm_remove_quotes(val, strnlen(val, sizeof(val))); + if (rc < 0) { + SA_LOG_ERR(errno, "Invalid format in config file" + " %s: DEBUG=%s\n", file, val); + fclose(fp); + return -1; + } + if (!strncasecmp(val, "yes", 3)) { + fcoe_config.debug = 1; + fcm_dcbd_debug = 1; + fcm_link_debug = 1; + } + + fcm_ofc_conf_read(val, sizeof(val), fp, "USE_SYSLOG"); + rc = fcm_remove_quotes(val, strnlen(val, sizeof(val))); + if (rc < 0) { + SA_LOG_ERR(errno, "Invalid format in config file" + " %s: USE_SYSLOG=%s\n", file, val); + fclose(fp); + return -1; + } + if (!strncasecmp(val, "yes", 3)) { + fcoe_config.use_syslog = 1; + fcm_use_syslog = 1; + } + + fclose(fp); + + dir = opendir(OFC_CONF_DIR); + if (dir == NULL) { + SA_LOG_ERR(errno, + "Failed reading directory %s\n", OFC_CONF_DIR); + return -1; + } + for (;;) { + dp = readdir(dir); + if (dp == NULL) + break; + if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || + (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) + continue; + rc = strncmp(dp->d_name, "cfg-eth", strlen("cfg-eth")); + if (rc) + continue; + next = (struct fcoe_port_config *) + calloc(1, sizeof(struct fcoe_port_config)); + if (!fcoe_config.port) { + fcoe_config.port = next; + curr = next; + } else { + curr->next = next; + curr = next; + } + strncpy(curr->ifname, dp->d_name + 4, sizeof(curr->ifname)); + strncpy(file, OFC_CONF_DIR "/", sizeof(file)); + strncat(file, dp->d_name, sizeof(file)-1) ; + fp = fopen(file, "r"); + if (!fp) { + SA_LOG_ERR(errno, "Failed reading %s\n", file); + exit(1); + } + + /* FCOE_ENABLE */ + fcm_ofc_conf_read(val, sizeof(val), fp, "FCOE_ENABLE"); + rc = fcm_remove_quotes(val, strnlen(val, sizeof(val))); + if (rc < 0) { + SA_LOG_ERR(errno, "Invalid format in config file" + " %s: FCOE_ENABLE=%s\n", file, val); + fclose(fp); + break; + } + if (!strncasecmp(val, "yes", 3)) + curr->fcoe_enable = 1; + + /* DCB_REQUIRED */ + fcm_ofc_conf_read(val, sizeof(val), fp, "DCB_REQUIRED"); + rc = fcm_remove_quotes(val, strnlen(val, sizeof(val))); + if (rc < 0) { + SA_LOG_ERR(errno, "Invalid format in config file" + " %s: DCB_REQUIRED=%s\n", file, val); + fclose(fp); + break; + } + if (!strncasecmp(val, "yes", 3)) { + curr->dcb_required = 1; + curr->dcb_app_0_enable = DCB_APP_0_DEFAULT_ENABLE; + curr->dcb_app_0_willing = DCB_APP_0_DEFAULT_WILLING; + } + + /* HAS_FIP */ + fcm_ofc_conf_read(val, sizeof(val), fp, "HAS_FIP"); + rc = fcm_remove_quotes(val, strnlen(val, sizeof(val))); + if (rc < 0) { + SA_LOG_ERR(errno, "Invalid format in config file" + " %s: HAS_FIP=%s\n", file, val); + fclose(fp); + break; + } + if (!strncasecmp(val, "yes", 3)) + curr->has_fip = 1; + + fclose(fp); + } + closedir(dir); + return 0; +} + +static struct fcoe_port_config * +fcm_find_port_config(char *ifname) +{ + struct fcoe_port_config *p; + + p = fcoe_config.port; + while (p) { + if (!strncmp(ifname, p->ifname, IFNAMSIZ) && + p->fcoe_enable && p->dcb_required) + return p; + p = p->next; + } + return NULL; +} + static int fcm_link_init(void) { @@ -277,7 +468,7 @@ fcm_link_recv(void *arg) if (hp->nlmsg_type == NLMSG_DONE) break; if (hp->nlmsg_type == NLMSG_ERROR) { - SA_LOG("nlmsg error"); + SA_LOG_ERR(errno, "nlmsg error"); break; } plen = NLMSG_PAYLOAD(hp, 0); @@ -305,10 +496,12 @@ rest: } if (ip->ifi_type != ARPHRD_ETHER) break; + ff = fcm_fcoe_lookup_create_ifindex(ip->ifi_index); if (ff == NULL) break; ff->ff_flags = ip->ifi_flags; + plen -= sizeof(*ip); for (ap = (struct rtattr *)(ip + 1); RTA_OK(ap, plen); ap = RTA_NEXT(ap, plen)) { @@ -395,17 +588,7 @@ fcm_link_buf_check(size_t read_len) static void fcm_fcoe_init(void) { - FILE *fp; - - /* - * Get default settings for DCB if present. - */ - fp = fopen(OFC_CONF_DIR "/" OFC_CONF_DEFAULTS, "r"); - if (fp) { - fcm_fcoe_read_dcb_settings(fp, - &fcm_dcbd_def_enable, &fcm_dcbd_def_will); - fclose(fp); - } + fcm_read_config_files(); } /* @@ -441,7 +624,7 @@ fcm_fcoe_lookup_create_ifindex(u_int32_t ff = fcm_fcoe_alloc(); if (ff != NULL) { ff->ff_ifindex = ifindex; - ff->ff_pfc_info_saved.u.pfcup = 0xffff; + ff->ff_pfc_saved.u.pfcup = 0xffff; } return ff; } @@ -500,35 +683,11 @@ fcm_fcoe_lookup_create_mac(u_int64_t mac #endif static void -fcm_fcoe_read_dcb_settings(FILE *fp, u_int32_t *enp, u_int32_t *willp) -{ - char val[32]; - - fcm_ofc_conf_read(val, sizeof(val), fp, OFC_CONF_DCB_VAR); - if (strcasecmp(val, OFC_CONF_DCB_ENABLE) == 0) { - *willp = 1; - *enp = 1; - } else if (strcasecmp(val, OFC_CONF_DCB_LOCAL) == 0) { - *willp = 0; - *enp = 1; - } else { - if (val[0] != '\0') - SA_LOG("conf value %s=%s not supported.", - OFC_CONF_DCB_VAR, val); - *willp = fcm_dcbd_def_will; - *enp = fcm_dcbd_def_enable; - } -} - -static void fcm_fcoe_get_dcb_settings(struct fcm_fcoe *ff) { - FILE *fp; fc_wwn_t wwpn; - u_int32_t dcb_enable = fcm_dcbd_def_enable; - u_int32_t dcb_willing = fcm_dcbd_def_will; - char conf[FCC_FILE_NAME_LEN]; int vlan = ff->ff_vlan; + struct fcoe_port_config *p; if (ff->ff_mac == 0) return; /* loopback or other non-eligible interface */ @@ -538,25 +697,16 @@ fcm_fcoe_get_dcb_settings(struct fcm_fco */ wwpn = fc_wwn_from_mac(ff->ff_mac, 2, vlan >= 0 ? vlan : 0); - /* try live config */ - fcc_ofc_conf_name(conf, sizeof(conf), - OFC_CONF_DIR "/" OFC_CONF_LIVE, - wwpn, vlan); - - fp = fopen(conf, "r"); - if (fp == NULL) { - /* try startup config */ - fcc_ofc_conf_name(conf, sizeof(conf), - OFC_CONF_DIR "/" OFC_CONF_FILE, - wwpn, vlan); - fp = fopen(conf, "r"); - } - if (fp) { - fcm_fcoe_read_dcb_settings(fp, &dcb_enable, &dcb_willing); - fclose(fp); + p = fcoe_config.port; + while (p) { + if (!strncmp(ff->ff_name, p->ifname, IFNAMSIZ)) { + ff->ff_app_info.enable = p->dcb_app_0_enable; + ff->ff_app_info.willing = p->dcb_app_0_willing; + ff->ff_has_fip = p->has_fip; + break; + } + p = p->next; } - ff->ff_app_info.enable = dcb_enable; - ff->ff_app_info.willing = dcb_willing; } static void @@ -612,7 +762,8 @@ fcm_dcbd_connect(void) lp = &fcm_clif->cl_local; lp->sun_family = PF_UNIX; - snprintf(lp->sun_path, sizeof(lp->sun_path), CLIF_LOCAL_PATH, getpid()); + snprintf(lp->sun_path, sizeof(lp->sun_path), + CLIF_LOCAL_SUN_PATH, getpid()); rc = bind(fd, (struct sockaddr *)lp, sizeof(*lp)); if (rc < 0) { SA_LOG_ERR(errno, "clif bind failed"); @@ -622,7 +773,8 @@ fcm_dcbd_connect(void) memset(&dest, 0, sizeof(dest)); dest.sun_family = PF_UNIX; - snprintf(dest.sun_path, sizeof(dest.sun_path), CLIF_PATH); + snprintf(dest.sun_path, sizeof(dest.sun_path), + CLIF_NAME_PATH); rc = connect(fd, (struct sockaddr *)&dest, sizeof(dest)); if (rc < 0) { if (fcm_dcbd_debug) @@ -669,7 +821,22 @@ fcm_dcbd_disconnect(void) static void fcm_dcbd_shutdown(void) { + struct fcm_fcoe *ff; + struct fcoe_port_config *p; + + p = fcoe_config.port; + while (p) { + if (p->fcoe_enable && p->dcb_required) { + ff = fcm_fcoe_lookup_name(p->ifname); + SA_LOG("Shut down %s\n", p->ifname); + fcm_dcbd_setup(ff, 0); + } + p = p->next; + } fcm_dcbd_disconnect(); + unlink(fcm_clif->cl_local.sun_path); + unlink(fcm_pidfile); + closelog(); } static void @@ -708,13 +875,12 @@ fcm_dcbd_state_set(struct fcm_fcoe *ff, char old[32]; char new[32]; - SA_LOG("%s: %s -> %s (ff=%p)", + SA_LOG("%s: %s -> %s", ff->ff_name, sa_enum_decode(old, sizeof(old), fcm_dcbd_states, ff->ff_dcbd_state), sa_enum_decode(new, sizeof(new), - fcm_dcbd_states, new_state), - ff); + fcm_dcbd_states, new_state)); } ff->ff_dcbd_state = new_state; } @@ -815,8 +981,12 @@ fcm_dcbd_request(char *req) fcm_clif->cl_busy = 0; fcm_dcbd_disconnect(); fcm_dcbd_connect(); - } else if (fcm_dcbd_debug) + return; + } + + if (fcm_dcbd_debug) SA_LOG("sent '%s', rc=%d bytes", req, rc); + return; } /* @@ -891,7 +1061,8 @@ dcb_rsp_parser(struct fcm_fcoe *ff, char dcb_cmd = hex2int(rsp+DCB_CMD_OFF); if (dcb_cmd != CMD_GET_CONFIG && - dcb_cmd != CMD_GET_OPER) + dcb_cmd != CMD_GET_OPER && + dcb_cmd != CMD_GET_PEER) return -1; version = rsp[DCB_VER_OFF] & 0x0f; @@ -931,27 +1102,22 @@ dcb_rsp_parser(struct fcm_fcoe *ff, char f_info->op_mode = (*(rsp+doff+OPER_OPER_MODE) == '1'); f_info->syncd = (*(rsp+doff+OPER_SYNCD) == '1'); doff += OPER_LEN; - break; - } - - switch (feature) { - case FEATURE_PFC: - f_info->u.pfcup = 0; - for (i = 0; i < MAX_USER_PRIORITIES; i++) { - if (*(rsp+doff+PFC_UP(i)) == '1') - f_info->u.pfcup |= 1<<i; + if (feature == FEATURE_PFC) { + f_info->u.pfcup = 0; + for (i = 0; i < MAX_USER_PRIORITIES; i++) { + if (*(rsp+doff+PFC_UP(i)) == '1') + f_info->u.pfcup |= 1<<i; + } } - break; - case FEATURE_APP: - if (subtype == APP_FCOE_STYPE) { + if (feature == FEATURE_APP && subtype == APP_FCOE_STYPE) { n = hex2int(rsp+doff+APP_LEN); snprintf(buf, sizeof(buf), "%*.*s\n", n, n, rsp+doff+APP_DATA); f_info->u.appcfg = hex2int(buf); } break; - case FEATURE_LLINK: - if (subtype == LLINK_FCOE_STYPE) + case CMD_GET_PEER: + if (feature == FEATURE_LLINK && subtype == LLINK_FCOE_STYPE) ff->ff_llink_status = (*(rsp+doff+LLINK_STATUS) == '1'); break; } @@ -977,23 +1143,17 @@ static int validating_app_pfc(struct fcm_fcoe *ff) { if (fcm_dcbd_debug) { - fprintf(stderr, - "\tff_app_info.enable=%d\n", + SA_LOG("\tff_app_info.enable=%d\n", ff->ff_app_info.enable); - fprintf(stderr, - "\tff_app_info.willing=%d\n", + SA_LOG("\tff_app_info.willing=%d\n", ff->ff_app_info.op_mode); - fprintf(stderr, - "\tff_app_info.willing=%d\n", + SA_LOG("\tff_app_info.willing=%d\n", ff->ff_app_info.op_mode); - fprintf(stderr, - "\tff_pfc_info.op_mode=%d\n", + SA_LOG("\tff_pfc_info.op_mode=%d\n", ff->ff_pfc_info.op_mode); - fprintf(stderr, - "\tff_pfc_info.u.pfcup=%d\n", + SA_LOG("\tff_pfc_info.u.pfcup=%d\n", ff->ff_pfc_info.u.pfcup); - fprintf(stderr, - "\tff_app_info.u.appcfg=%d\n", + SA_LOG("\tff_app_info.u.appcfg=%d\n", ff->ff_app_info.u.appcfg); } @@ -1006,11 +1166,11 @@ validating_app_pfc(struct fcm_fcoe *ff) !ff->ff_pfc_info.op_mode) || \ ((ff->ff_pfc_info.u.pfcup & \ ff->ff_app_info.u.appcfg) != ff->ff_app_info.u.appcfg)) { - fprintf(stderr, "DCB is not configured correctly\n"); + SA_LOG("DCB is not configured correctly\n"); return 0; } - fprintf(stderr, "DCB is configured correctly\n"); + SA_LOG("DCB is configured correctly\n"); return 1; } @@ -1030,20 +1190,15 @@ static int validating_llink_tlv(struct fcm_fcoe *ff) { if (fcm_dcbd_debug) { - fprintf(stderr, - "\tff_llink_info.enable=%d\n", + SA_LOG("\tff_llink_info.enable=%d\n", ff->ff_llink_info.enable); - fprintf(stderr, - "\tff_llink_info.advertise=%d\n", + SA_LOG("\tff_llink_info.advertise=%d\n", ff->ff_llink_info.advertise); - fprintf(stderr, - "\tff_llink_info.willing=%d\n", + SA_LOG("\tff_llink_info.willing=%d\n", ff->ff_llink_info.willing); - fprintf(stderr, - "\tff_llink_info.op_mode=%d\n", + SA_LOG("\tff_llink_info.op_mode=%d\n", ff->ff_llink_info.op_mode); - fprintf(stderr, - "\tff_llink_status=%d\n", + SA_LOG("\tff_llink_status=%d\n", ff->ff_llink_status); } @@ -1051,33 +1206,32 @@ validating_llink_tlv(struct fcm_fcoe *ff !ff->ff_llink_info.advertise || !ff->ff_llink_info.willing) || (!ff->ff_llink_info.op_mode)) { - fprintf(stderr, - "FCoE Logical Link is not configured correctly\n"); + SA_LOG("FCoE Logical Link is not configured correctly\n"); return 0; } - fprintf(stderr, "FCoE Logical Link is configured correctly\n"); + SA_LOG("FCoE Logical Link is configured correctly\n"); /* * At this point, this should be the link status * reported by the switch. */ if (!ff->ff_llink_status) { - fprintf(stderr, "Switch Reports FCoE Logical Link is DOWN\n"); + SA_LOG("Switch Reports FCoE Logical Link is DOWN\n"); return 0; } - fprintf(stderr, "Switch Reports FCoE Logical Link is up\n"); + SA_LOG("Switch Reports FCoE Logical Link is up\n"); return 1; } /* - * validating_dcbx_info - Validating DCBX configuration and status + * validating_dcbd_info - Validating DCBD configuration and status * * Returns: 1 if succeeded * 0 if failed */ static int -validating_dcbx_info(struct fcm_fcoe *ff) +validating_dcbd_info(struct fcm_fcoe *ff) { int rc; @@ -1092,14 +1246,19 @@ validating_dcbx_info(struct fcm_fcoe *ff /* * is_pfcup_changed - Check to see if PFC priority is changed * - * Returns: 1 if yes - * 0 if no + * Returns: 0 if no + * 1 if yes, but it is the first time + * 2 if yes */ static int is_pfcup_changed(struct fcm_fcoe *ff) { - if (ff->ff_pfc_info.u.pfcup != ff->ff_pfc_info_saved.u.pfcup) - return 1; + if (ff->ff_pfc_info.u.pfcup != ff->ff_pfc_saved.u.pfcup) { + if (ff->ff_pfc_saved.u.pfcup == 0xffff) + return 1; + else + return 2; + } return 0; } @@ -1112,7 +1271,7 @@ is_pfcup_changed(struct fcm_fcoe *ff) static void update_saved_pfcup(struct fcm_fcoe *ff) { - ff->ff_pfc_info_saved.u.pfcup = ff->ff_pfc_info.u.pfcup; + ff->ff_pfc_saved.u.pfcup = ff->ff_pfc_info.u.pfcup; } /* @@ -1229,8 +1388,8 @@ fcm_dcbd_cmd_resp(char *resp, cmd_status if (val != 0) { SA_LOG("resp:%s\n", orig_resp); if (fcm_dcbd_debug) - print_errors(val); - fcm_dcbd_setup(ff, 0); + print_errors("", val); + /* fcm_dcbd_setup(ff, 0); */ fcm_dcbd_state_set(ff, FCD_DONE); return; } @@ -1295,18 +1454,27 @@ fcm_dcbd_cmd_resp(char *resp, cmd_status } } ff->ff_qos_mask = parm; - enable = validating_dcbx_info(ff); + enable = validating_dcbd_info(ff); if (enable) { - SA_LOG("DCBX parameters of %s qualified" + SA_LOG("DCB settings of %s qualified" " for creating FCoE interface\n", ff->ff_name); - if (is_pfcup_changed(ff)) { - SA_LOG("PFC of %s have changed\n", - ff->ff_name); + rc = is_pfcup_changed(ff); + if (rc == 1) { + SA_LOG("%s: Initial QOS = 0x%x\n", + ff->ff_name, ff->ff_qos_mask); + fcm_dcbd_setup(ff, enable); + } else if (rc == 2) { + SA_LOG("%s: QOS changed to 0x%x\n", + ff->ff_name, ff->ff_qos_mask); fcm_dcbd_setup(ff, ++enable); } - } else - fcm_dcbd_setup(ff, enable); + } else { + SA_LOG("DCB settings of %s not qualified" + " for FCoE operations.", + ff->ff_name); + } + update_saved_pfcup(ff); fcm_dcbd_state_set(ff, FCD_DONE); return; @@ -1327,8 +1495,8 @@ fcm_dcbd_cmd_resp(char *resp, cmd_status if (val != 0) { SA_LOG("resp:%s\n", orig_resp); if (fcm_dcbd_debug) - print_errors(val); - fcm_dcbd_setup(ff, 0); + print_errors("", val); + /* fcm_dcbd_setup(ff, 0); */ fcm_dcbd_state_set(ff, FCD_DONE); return; } @@ -1353,7 +1521,9 @@ fcm_dcbd_cmd_resp(char *resp, cmd_status break; default: - SA_LOG("unknown cmd %x in response: resp %s", cmd, orig_resp); + SA_LOG_ERR(errno, + "unknown cmd %x in response: resp %s", + cmd, orig_resp); break; } } @@ -1374,7 +1544,7 @@ fcm_dcbd_event(char *msg, size_t len) if (msg[EV_LEVEL_OFF] != MSG_DCB + '0' || len <= EV_PORT_ID_OFF) return; if (msg[EV_VERSION_OFF] != CLIF_EV_VERSION + '0') { - SA_LOG("unexpected version in event msg %s", msg); + SA_LOG_ERR(errno, "unexpected version in event msg %s", msg); return; } cp = msg; @@ -1383,19 +1553,36 @@ fcm_dcbd_event(char *msg, size_t len) return; feature = fcm_get_hex(cp + EV_FEATURE_OFF, 2, &ep); if (ep != NULL) { - SA_LOG("invalid feature code in event msg %s", msg); + SA_LOG_ERR(errno, "invalid feature code in event msg %s", msg); return; } - SA_LOG("%s: <Got Event for Feature %d>\n", __func__, feature); - switch (feature) { + case FEATURE_DCB: + SA_LOG("<Got DCB Event>\n"); + goto ignore_event; + case FEATURE_PG: /* 'E5204eth2020001' */ + SA_LOG("<Got PG Event>\n"); + goto ignore_event; + case FEATURE_BCN: /* 'E5204eth2040001' */ + SA_LOG("<Got BCN Event>\n"); + goto ignore_event; + case FEATURE_PG_DESC: + SA_LOG("<Got PG_DESC Event>\n"); + goto ignore_event; case FEATURE_PFC: /* 'E5204eth2030011' */ + SA_LOG("<Got PFC Event>\n"); + goto handle_event; case FEATURE_APP: /* 'E5204eth2050011' */ + SA_LOG("<Got APP Event>\n"); + goto handle_event; case FEATURE_LLINK: + SA_LOG("<Got LLINK Event>\n"); +handle_event: subtype = fcm_get_hex(cp + EV_SUBTYPE_OFF, 2, &ep); if (ep != NULL || subtype != APP_FCOE_STYPE) { - SA_LOG("unknown application subtype in msg %s", msg); + SA_LOG_ERR(errno, + "unknown application subtype in msg %s", msg); break; } if (fcm_dcbd_debug) { @@ -1413,13 +1600,9 @@ fcm_dcbd_event(char *msg, size_t len) fcm_dcbd_port_advance(ff); } break; - case FEATURE_DCB: - case FEATURE_PG: /* 'E5204eth2020001' */ - case FEATURE_BCN: /* 'E5204eth2040001' */ - case FEATURE_PG_DESC: - break; default: - SA_LOG("unknown feature %x in msg %s", feature, msg); +ignore_event: + SA_LOG_ERR(errno, "unknown feature %x in msg %s", feature, msg); break; } } @@ -1429,7 +1612,7 @@ fcm_dcbd_event(char *msg, size_t len) * * Input: enable = 0 Destroy the FCoE interface * enable = 1 Create the FCoE interface - * enable = 2 Destroy and then create the interface + * enable = 2 Reset the interface */ static void fcm_dcbd_setup(struct fcm_fcoe *ff, u_int32_t enable) @@ -1446,7 +1629,7 @@ fcm_dcbd_setup(struct fcm_fcoe *ff, u_in else if (enable == 1) op = "--enable"; else - op = "--restart"; + op = "--reset"; if (enable && !ff->ff_qos_mask) return; if (fcm_dcbd_cmd == NULL) { @@ -1486,13 +1669,13 @@ fcm_dcbd_setup(struct fcm_fcoe *ff, u_in } } if (fcm_dcbd_debug) { - if (enable) + if (!enable) + SA_LOG("%s %s %s\n", + fcm_dcbd_cmd, ff->ff_name, op); + else SA_LOG("%s %s %s %s %s\n", fcm_dcbd_cmd, ff->ff_name, op, qos_arg, qos); - else - SA_LOG("%s %s %s\n", - fcm_dcbd_cmd, ff->ff_name, op); } execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, ff->ff_name, op, qos_arg, qos, (char *)NULL); @@ -1509,9 +1692,15 @@ static void fcm_dcbd_port_advance(struct fcm_fcoe *ff) { char buf[80], params[30]; + struct fcoe_port_config *p; ASSERT(ff); ASSERT(fcm_clif); + + p = fcm_find_port_config(ff->ff_name); + if (!p) + return; + if (ff->ff_dcbd_state != FCD_INIT && !fcm_fcoe_port_ready(ff)) fcm_dcbd_state_set(ff, FCD_INIT); if (fcm_clif->cl_busy) @@ -1527,7 +1716,7 @@ fcm_dcbd_port_advance(struct fcm_fcoe *f fcm_dcbd_state_set(ff, FCD_SEND_CONF); /* Fall through */ case FCD_SEND_CONF: - fcm_fcoe_get_dcb_settings(ff); /* read config file */ + fcm_fcoe_get_dcb_settings(ff); snprintf(params, sizeof(params), "%x1%x02%2.2x", ff->ff_app_info.enable, ff->ff_app_info.willing, @@ -1618,14 +1807,19 @@ fcm_dcbd_next(void) static void fcm_usage(void) { - fprintf(stderr, "usage: %s [--exec <exec>] " - "[--debug] [--version]\n", cmdname); + printf("%s\n", fcoemon_version); + printf("Usage: %s\n" + "\t [-e|--exec <exec>]\n" + "\t [-d|--debug]\n" + "\t [-v|--version]\n" + "\t [-h|--help]\n\n", progname); exit(1); } static void fcm_sig(int sig) { + fcm_dcbd_shutdown(); sa_select_exit(); } @@ -1644,9 +1838,9 @@ fcm_pidfile_create(void) pid = atoi(sp); rc = kill(pid, 0); if (sp && (pid > 0) && !rc) { - fprintf(stderr, "%s: another instance" + SA_LOG("Another instance" " (pid %d) is running - exiting\n", - cmdname, pid); + pid); exit(1); } fclose(fp); @@ -1661,20 +1855,16 @@ fcm_pidfile_create(void) int main(int argc, char **argv) { struct sigaction sig; - char *opt; int rc; int c; - cmdname = argv[0]; - opt = strrchr(cmdname, '/'); - if (opt++ == NULL) - opt = cmdname; - cmdname = opt; - snprintf(cmdbuf, sizeof(cmdbuf), "%s: ", opt); - sa_log_prefix = cmdbuf; + strncpy(progname, basename(argv[0]), sizeof(progname)); + sa_log_prefix = progname; sa_log_flags = 0; + openlog(sa_log_prefix, LOG_CONS, LOG_DAEMON); - while ((c = getopt_long(argc, argv, "de:v", fcm_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "de:hv", + fcm_options, NULL)) != -1) { switch (c) { case 'd': fcm_dcbd_debug = 1; @@ -1683,8 +1873,9 @@ int main(int argc, char **argv) fcm_dcbd_cmd = optarg; break; case 'v': - printf("%s %s\n", cmdname, tools_version); + printf("%s\n", fcoemon_version); return 0; + case 'h': default: fcm_usage(); break; @@ -1708,14 +1899,12 @@ int main(int argc, char **argv) if (rc < 0) SA_LOG_ERR_EXIT(errno, "sigaction failed"); fcm_pidfile_create(); - fcm_fcoe_init(); /* Read /etc/sysconfig/openfc/openfc.conf */ + fcm_fcoe_init(); /* Read /etc/sysconfig/fcoe */ fcm_link_init(); /* NETLINK_ROUTE protocol */ fcm_dcbd_init(); sa_select_loop(); fcm_dcbd_shutdown(); - if (fcm_pidfile[0] != '\0') - unlink(fcm_pidfile); return 0; } @@ -1724,57 +1913,66 @@ int main(int argc, char **argv) *******************************************************/ static void -print_errors(int errors) +print_errors(char *buf, int errors) { + char msg[80]; + int len, j; int flag = 0; - fprintf(stderr, "0x%02x - ", errors); + memset(msg, 0, sizeof(msg)); + len = sprintf(msg, "0x%02x - ", errors); if (!errors) { - fprintf(stderr, "none\n"); + j = sprintf(msg + len, "none\n"); + SA_LOG("%s %s", buf, msg); return; } if (errors & 0x01) { flag++; - fprintf(stderr, "mismatch with peer"); + j = sprintf(msg + len, "mismatch with peer"); } if (errors & 0x02) { + j = len; if (flag++) - fprintf(stderr, ", "); - fprintf(stderr, "local configuration error"); + j = sprintf(msg + len, ", "); + sprintf(msg + j, "local configuration error"); } if (errors & 0x04) { + j = len; if (flag++) - fprintf(stderr, ", "); - fprintf(stderr, "multiple TLV's received"); + j = sprintf(msg + len, ", "); + sprintf(msg + j, "multiple TLV's received"); } if (errors & 0x08) { + j = len; if (flag++) - fprintf(stderr, ", "); - fprintf(stderr, "peer error"); + j = sprintf(msg + len, ", "); + sprintf(msg + j, "peer error"); } if (errors & 0x10) { + j = len; if (flag++) - fprintf(stderr, ", "); - fprintf(stderr, "multiple LLDP neighbors"); + j = sprintf(msg + len, ", "); + sprintf(msg + j, "multiple LLDP neighbors"); } if (errors & 0x20) { + j = len; if (flag++) - fprintf(stderr, ", "); - fprintf(stderr, "peer feature not present"); + j = sprintf(msg + len, ", "); + sprintf(msg + j, "peer feature not present"); } - fprintf(stderr, "\n"); + SA_LOG_ERR(errors, "%s %s\n", buf, msg); } static char * -print_status(cmd_status status) +get_status_string(cmd_status status) { char *str; @@ -1817,11 +2015,13 @@ print_dcb_cmd_response(char *buf, cmd_st int dcb_cmd; int feature; int subtype; - int dcbx_st = dcbx_subtype1; + int dcbd_st = dcbx_subtype1; int plen; int doff; - int i; + int i, j; int n; + char msg[80]; + int len; version = buf[DCB_VER_OFF] & 0x0f; dcb_cmd = hex2int(buf+DCB_CMD_OFF); @@ -1835,86 +2035,86 @@ print_dcb_cmd_response(char *buf, cmd_st } - fprintf(stderr, "\tVersion: \t%d\n", version); + SA_LOG("\tVersion: \t%d\n", version); if (version != CLIF_MSG_VERSION) { - fprintf(stderr, - "Unsupported client interface message version: %d\n", + SA_LOG("Unsupported client interface message version: %d\n", version); return; } - fprintf(stderr, "\tCommand: \t"); + sprintf(msg, "\tCommand: \t"); switch (dcb_cmd) { case CMD_GET_CONFIG: - fprintf(stderr, "Get Config\n"); + SA_LOG("%sGet Config\n", msg); break; case CMD_SET_CONFIG: - fprintf(stderr, "Set Config\n"); + SA_LOG("%sSet Config\n", msg); break; case CMD_GET_OPER: - fprintf(stderr, "Get Oper\n"); + SA_LOG("%sGet Oper\n", msg); break; case CMD_GET_PEER: - fprintf(stderr, "Get Peer\n"); + SA_LOG("%sGet Peer\n", msg); break; default: - fprintf(stderr, "Unknown DCB command: %d:%s\n", dcb_cmd, buf); + SA_LOG("%sUnknown DCB command: %d:%s\n", + msg, dcb_cmd, buf); return; } - fprintf(stderr, "\tFeature: \t"); + sprintf(msg, "\tFeature: \t"); switch (feature) { case FEATURE_DCB: - fprintf(stderr, "DCB State\n"); + SA_LOG("%sDCB State\n", msg); break; case FEATURE_DCBX: - fprintf(stderr, "DCBX Version\n"); + SA_LOG("%sDCBD Version\n", msg); break; case FEATURE_PG: - fprintf(stderr, "Priority Groups\n"); + SA_LOG("%sPriority Groups\n", msg); break; case FEATURE_PFC: - fprintf(stderr, "Priority Flow Control\n"); + SA_LOG("%sPriority Flow Control\n", msg); break; case FEATURE_BCN: - fprintf(stderr, "BCN\n"); + SA_LOG("%sBCN\n", msg); break; case FEATURE_APP: - fprintf(stderr, "Application "); + sprintf(msg, "Application "); switch (subtype) { case APP_FCOE_STYPE: - fprintf(stderr, "FCoE\n"); + SA_LOG("%sFCoE\n", msg); break; default: - fprintf(stderr, "unknown\n"); + SA_LOG("%sunknown\n", msg); break; } break; case FEATURE_LLINK: - fprintf(stderr, "Logical Link "); + sprintf(msg, "Logical Link "); switch (subtype) { case LLINK_FCOE_STYPE: - fprintf(stderr, "FCoE\n"); + SA_LOG("%sFCoE\n", msg); break; default: - fprintf(stderr, "unknown\n"); + SA_LOG("%sunknown\n", msg); break; } break; case FEATURE_PG_DESC: - fprintf(stderr, "BWG Desc\n"); + SA_LOG("BWG Desc\n"); break; default: - fprintf(stderr, "unknown DCB feature: %s\n", buf); + SA_LOG("unknown DCB feature: %s\n", buf); return; } if (feature != FEATURE_DCBX) - fprintf(stderr, "\tPort: \t%*.*s\n", + SA_LOG("\tPort: \t%*.*s\n", plen, plen, buf+DCB_PORT_OFF); - fprintf(stderr, "\tStatus: \t%s\n", print_status(status)); + SA_LOG("\tStatus: \t%s\n", get_status_string(status)); /* print out data */ if (dcb_cmd == CMD_SET_CONFIG) /* set command - we're done */ @@ -1931,13 +2131,13 @@ print_dcb_cmd_response(char *buf, cmd_st case FEATURE_BCN: case FEATURE_APP: case FEATURE_LLINK: - fprintf(stderr, "\tEnable: \t%s\n", + SA_LOG("\tEnable: \t%s\n", (*(buf+doff+CFG_ENABLE) == '1') ? ("true") : ("false")); - fprintf(stderr, "\tAdvertise: \t%s\n", + SA_LOG("\tAdvertise: \t%s\n", (*(buf+doff+CFG_ADVERTISE) == '1') ? ("true") : ("false")); - fprintf(stderr, "\tWilling: \t%s\n", + SA_LOG("\tWilling: \t%s\n", (*(buf+doff+CFG_WILLING) == '1') ? ("true") : ("false")); doff += CFG_LEN; @@ -1950,125 +2150,131 @@ print_dcb_cmd_response(char *buf, cmd_st case CMD_GET_OPER: if (feature == FEATURE_DCBX) break; - fprintf(stderr, "\tOper Version\t%d\n", + SA_LOG("\tOper Version\t%d\n", hex2int(buf+doff+OPER_OPER_VER)); - fprintf(stderr, "\tMax Version\t%d\n", + SA_LOG("\tMax Version\t%d\n", hex2int(buf+doff+OPER_MAX_VER)); - fprintf(stderr, "\tErrors: \t"); - print_errors(hex2int(buf+doff+OPER_ERROR)); - fprintf(stderr, "\tOper Mode: \t%s\n", + sprintf(msg, "\tErrors: \t"); + print_errors(msg, hex2int(buf+doff+OPER_ERROR)); + SA_LOG("\tOper Mode: \t%s\n", (*(buf+doff+OPER_OPER_MODE) == '1') ? ("true") : ("false")); - fprintf(stderr, "\tSyncd: \t%s\n", + SA_LOG("\tSyncd: \t%s\n", (*(buf+doff+OPER_SYNCD) == '1') ? ("true") : ("false")); doff += OPER_LEN; break; case CMD_GET_PEER: - fprintf(stderr, "\tEnable: \t%s\n", + SA_LOG("\tEnable: \t%s\n", (*(buf+doff+PEER_ENABLE) == '1') ? ("true") : ("false")); - fprintf(stderr, "\tWilling: \t%s\n", + SA_LOG("\tWilling: \t%s\n", (*(buf+doff+PEER_WILLING) == '1') ? ("true") : ("false")); - fprintf(stderr, "\tOper Version\t%d\n", + SA_LOG("\tOper Version\t%d\n", hex2int(buf+doff+PEER_OPER_VER)); - fprintf(stderr, "\tMax Version\t%d\n", + SA_LOG("\tMax Version\t%d\n", hex2int(buf+doff+PEER_MAX_VER)); - fprintf(stderr, "\tError: \t%s\n", + SA_LOG("\tError: \t%s\n", (*(buf+doff+PEER_ERROR) == '1') ? ("true") : ("false")); - dcbx_st = (*(buf+doff+PEER_SUBTYPE)) & 0x0f; - fprintf(stderr, "\tDCBX Subtype:\t%d\n", dcbx_st); + dcbd_st = (*(buf+doff+PEER_SUBTYPE)) & 0x0f; + SA_LOG("\tDCBD Subtype:\t%d\n", dcbd_st); doff += PEER_LEN; break; default: - fprintf(stderr, "\tUnknown DCB command: %d:%s\n", + SA_LOG("\tUnknown DCB command: %d:%s\n", dcb_cmd, buf); return; } switch (feature) { case FEATURE_DCB: - fprintf(stderr, "\tDCB State:\t%s\n", + SA_LOG("\tDCB State:\t%s\n", (*(buf+doff+DCB_STATE) == '1') ? ("on") : ("off")); break; case FEATURE_DCBX: - fprintf(stderr, "\tDCBX Version:\t%c\n", + SA_LOG("\tDCBD Version:\t%c\n", *(buf+doff+DCBX_VERSION)); break; case FEATURE_PG_DESC: - fprintf(stderr, "\tPGID: \t%d\n", + SA_LOG("\tPGID: \t%d\n", *(buf+doff+PG_DESC_PGID) & 0x0f); - fprintf(stderr, "\tDescription:\t%*s\n", + SA_LOG("\tDescription:\t%*s\n", hex2int(buf+doff+PG_DESC_LEN), buf+doff+PG_DESC_DATA); break; case FEATURE_PG: - if (dcb_cmd != CMD_GET_PEER) { - fprintf(stderr, "\tup2tc: \t"); - for (i = 0; i < MAX_USER_PRIORITIES; i++) - fprintf(stderr, "%c\t", + len = sprintf(msg, "\tup2tc: \t"); + for (i = 0; i < MAX_USER_PRIORITIES; i++) { + n = sprintf(msg + len, "%c\t", *(buf+doff+PG_UP2TC(i))); - fprintf(stderr, "\n"); + len = n; + } + SA_LOG("%s\n", msg); } - fprintf(stderr, "\tpgpct: \t"); + len = sprintf(msg, "\tpgpct: \t"); for (i = 0; i < MAX_BANDWIDTH_GROUPS; i++) { n = hex2int(buf+doff+PG_PG_PCNT(i)); - fprintf(stderr, "%d%%\t", n); + j = sprintf(msg + len, "%d%%\t", n); + len = j; } - fprintf(stderr, "\n"); - - fprintf(stderr, "\tpgid: \t"); - for (i = 0; i < MAX_USER_PRIORITIES; i++) + SA_LOG("%s\n", msg); - fprintf(stderr, "%c\t", *(buf+doff+PG_UP_PGID(i))); - fprintf(stderr, "\n"); + len = sprintf(msg, "\tpgid: \t"); + for (i = 0; i < MAX_USER_PRIORITIES; i++) { + j = sprintf(msg + len, "%c\t", + *(buf+doff+PG_UP_PGID(i))); + len = j; + } + SA_LOG("%s\n", msg); if ((dcb_cmd != CMD_GET_PEER) || (dcb_cmd == CMD_GET_PEER && - dcbx_st == dcbx_subtype1)) { - fprintf(stderr, "\tuppct: \t"); + dcbd_st == dcbx_subtype1)) { + len = sprintf(msg, "\tuppct: \t"); for (i = 0; i < MAX_USER_PRIORITIES; i++) { n = hex2int(buf+doff+PG_UP_PCNT(i)); - fprintf(stderr, "%d%%\t", n); + j = sprintf(msg + len, "%d%%\t", n); + len = j; } - fprintf(stderr, "\n"); + SA_LOG("%s\n", msg); - fprintf(stderr, "\tpg strict: \t"); - for (i = 0; i < MAX_USER_PRIORITIES; i++) - fprintf(stderr, "%c\t", + len = sprintf(msg, "\tpg strict: \t"); + for (i = 0; i < MAX_USER_PRIORITIES; i++) { + j = sprintf(msg + len, "%c\t", *(buf+doff+PG_UP_STRICT(i))); - - fprintf(stderr, "\n"); + len = j; + } + SA_LOG("%s\n", msg); } if ((dcb_cmd != CMD_GET_PEER) || (dcb_cmd == CMD_GET_PEER && - dcbx_st == dcbx_subtype2)) { - fprintf(stderr, "\tnum TC's: \t%c", + dcbd_st == dcbx_subtype2)) { + SA_LOG("\tnum TC's: \t%c\n", *(buf+doff+PG_UP_NUM_TC)); - fprintf(stderr, "\n"); } break; case FEATURE_PFC: - fprintf(stderr, "\tpfcup: \t"); - for (i = 0; i < MAX_USER_PRIORITIES; i++) - fprintf(stderr, "%c\t", *(buf+doff+PFC_UP(i))); - - fprintf(stderr, "\n"); + len = sprintf(msg, "\tpfcup: \t"); + for (i = 0; i < MAX_USER_PRIORITIES; i++) { + n = sprintf(msg + len, "%c\t", *(buf+doff+PFC_UP(i))); + len = n; + } + SA_LOG("%s\n", msg); if ((dcb_cmd != CMD_GET_PEER) || (dcb_cmd == CMD_GET_PEER && - dcbx_st == dcbx_subtype2)) { - fprintf(stderr, "\tnum TC's: \t%c", + dcbd_st == dcbx_subtype2)) { + SA_LOG("\tnum TC's: \t%c\n", *(buf+doff+PFC_NUM_TC)); - fprintf(stderr, "\n"); } break; +#if 0 case FEATURE_BCN: fprintf(stderr, "\trp admin: \t"); for (i = 0; i < MAX_USER_PRIORITIES; i++) @@ -2183,33 +2389,36 @@ print_dcb_cmd_response(char *buf, cmd_st fprintf(stderr, "%d\n", n); } break; +#endif case FEATURE_APP: switch (subtype) { case APP_FCOE_STYPE: - fprintf(stderr, "\tappcfg: \t"); + len = sprintf(msg, "\tappcfg: \t"); n = hex2int(buf+doff+APP_LEN); - fprintf(stderr, "%*.*s\n", n, n, buf+doff+APP_DATA); + sprintf(msg + len, "%*.*s\n", n, n, buf+doff+APP_DATA); + SA_LOG(msg); break; default: - fprintf(stderr, "\tunknown subtype for "); + SA_LOG("\tunknown subtype for APP\n"); break; } break; case FEATURE_LLINK: switch (subtype) { case LLINK_FCOE_STYPE: - fprintf(stderr, "\tLink status: \t"); - fprintf(stderr, "%s\n", + len = sprintf(msg, "\tLink status: \t"); + sprintf(msg + len, "%s\n", (*(buf+doff+LLINK_STATUS) == '1') ? ("up") : ("down")); + SA_LOG(msg); break; default: - fprintf(stderr, "\tunknown subtype for "); + SA_LOG("\tunknown subtype for LLINK\n"); break; } break; default: - fprintf(stderr, "\tunknown DCB feature: %s\n", buf); + SA_LOG("\tunknown DCB feature: %s\n", buf); return; } } Index: open-fcoe/usr/tools/fcoemon/fcoemon.h =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/fcoemon.h +++ open-fcoe/usr/tools/fcoemon/fcoemon.h @@ -19,8 +19,6 @@ #ifndef _FCOEMON_H_ #define _FCOEMON_H_ -extern char tools_version[]; - /* * States for HBAs relative to the DCB daemon. * States advance sequentially if conditions are right. @@ -81,10 +79,11 @@ struct fcm_fcoe { u_int32_t ff_last_flags; /* previously known flags */ u_int32_t ff_enabled:1; /* operational status */ struct feature_info ff_pfc_info; /* PFC feature info */ - struct feature_info ff_pfc_info_saved;/* saved PFC feature info */ + struct feature_info ff_pfc_saved; /* saved PFC feature info */ struct feature_info ff_app_info; /* App feature info */ struct feature_info ff_llink_info; /* LLink feature info */ u_int32_t ff_llink_status; /* LLink status */ + u_int32_t ff_has_fip; /* FIP is implemented */ u_int64_t ff_mac; /* MAC address */ int ff_vlan; /* VLAN ID or -1 if none */ u_int8_t ff_operstate; /* RFC 2863 operational status */ @@ -96,6 +95,7 @@ struct fcm_fcoe { TAILQ_HEAD(fcm_fcoe_head, fcm_fcoe); struct fcm_fcoe_head fcm_fcoe_head; +extern char build_date[]; static void fcm_dcbd_init(void); static void fcm_dcbd_shutdown(void); Index: open-fcoe/usr/tools/fcoemon/fcoemon_utils.c =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/fcoemon_utils.c +++ open-fcoe/usr/tools/fcoemon/fcoemon_utils.c @@ -176,12 +176,16 @@ sa_log_timestamp(void) fprintf(stderr, "%8s ", ""); } if (sa_log_prefix) - fprintf(stderr, "%s", sa_log_prefix); + fprintf(stderr, "%s: ", sa_log_prefix); } void sa_log_output(const char *buf) { + if (fcm_use_syslog) { + syslog(LOG_INFO, "%s", buf); + return; + } sa_log_timestamp(); fprintf(stderr, "%s", buf); fflush(stderr); Index: open-fcoe/usr/tools/fcoemon/fcoemon_utils.h =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/fcoemon_utils.h +++ open-fcoe/usr/tools/fcoemon/fcoemon_utils.h @@ -35,6 +35,7 @@ #include <unistd.h> #include <signal.h> #include <errno.h> +#include <syslog.h> #include "fc_types.h" @@ -309,5 +310,6 @@ extern fc_wwn_t fc_wwn_from_mac(u_int64_t, u_int32_t scheme, u_int32_t port); extern int hex2int(char *b); +extern int fcm_use_syslog; #endif /* _FCOEMON_UTILS_H_ */ Index: open-fcoe/usr/tools/fcoemon/fcoeplumb.sh =================================================================== --- open-fcoe.orig/usr/tools/fcoemon/fcoeplumb.sh +++ open-fcoe/usr/tools/fcoemon/fcoeplumb.sh @@ -22,7 +22,7 @@ cmdname=`basename $0` usage() { echo usage: $cmdname \ - '<ethX> [--restart | --enable | --disable]' \ + '<ethX> [--reset | --enable | --disable]' \ '[--qos <pri>[,<pri>]...]]' >&2 exit 1 } @@ -36,9 +36,16 @@ FCOE_FILTER=0xfc0e # filter handle (mus # TC_CMD="/usr/sbin/tc" # /sbin/tc or debug command FCOEADM=/sbin/fcoeadm # command to create/destroy FCoE instances -debug_msg=: # no debug message cmd=enable # default command qos_list= +LOGGER="logger -t fcoeplumb -s" +SERVICE_NAME=fcoe +CONFIG_DIR=/etc/sysconfig/$SERVICE_NAME + +. $CONFIG_DIR/config +if [ "$USE_SYSLOG" != "yes" ] && [ "$USE_SYSLOG" != "YES" ]; then + LOGGER="echo" +fi [ "$#" -lt 1 ] && usage @@ -48,8 +55,8 @@ shift while [ "$#" -ge 1 ] do case "$1" in - --restart | -r) - cmd=restart + --reset | -r) + cmd=reset ;; --enable | -e) cmd=enable @@ -58,7 +65,7 @@ do cmd=disable ;; --debug) - debug_msg="echo $cmdname:" + LOGGER="logger -t fcoeplumb -s" ;; --qos | -q) [ "$#" -lt 2 ] && usage @@ -79,21 +86,22 @@ check_fcoe_if() STATUS=`$FCOEADM -i 2>&1 | awk ' BEGIN { - found_ifname = 0 - status = 0 + found = 0 + status = 1 } /Interface Name:/ { - if ($3 = "'$ifname'") - found_ifname++ + if ($3 == ifname) + found++ } /State:/ { - if ((found_ifname == 1) && ($2 == "Online")) - status = 1 + if ((found == 1) && ($2 == "Online")) + status = 0 } END { print status - }'` + }' ifname=$ifname` + $LOGGER "check_fcoe_if: ifname=$ifname, returns $STATUS" return $STATUS } @@ -102,8 +110,8 @@ destroy_interface() ifname=$1 check_fcoe_if $ifname - if [ "$?" = "1" ]; then - $debug_msg "$FCOEADM --destroy $ifname" + if [ $? -eq 0 ]; then + $LOGGER "$FCOEADM --destroy $ifname" $FCOEADM --destroy $ifname fi @@ -122,17 +130,18 @@ destroy_interface() # filter is also removed. # qdisc_id=1: - $debug_msg "$TC_CMD qdisc del dev $ifname ... multiq" + $LOGGER "$TC_CMD qdisc del dev $ifname ... multiq" $TC_CMD qdisc del dev $ifname root handle $qdisc_id multiq fi } -$debug_msg "ifname $ifname cmd $cmd qos_list $qos_list" +$LOGGER "ifname $ifname cmd $cmd qos_list $qos_list" -if [ "$cmd" == "disable" ] || [ "$cmd" == "restart" ]; then +if [ "$cmd" == "disable" ]; then destroy_interface $ifname - [ "$cmd" == "disable" ] && exit 0 + exit 0 fi +## fallthrough for --reset and --enable # # Choose the best QOS to use for FCoE out of the listed choices. @@ -164,7 +173,7 @@ if [ -n "$qos_list" ]; then shift done fi -$debug_msg "choosing FCoE QOS '$QOS_BEST'" +$LOGGER "choosing FCoE QOS '$QOS_BEST'" # # Setup the traffic classifier for FCoE @@ -184,7 +193,7 @@ if [ -n "$QOS_BEST" ]; then # Add the queuing discipline. # qdisc_id=1: - $debug_msg "$TC_CMD qdisc add dev $ifname ... multiq" + $LOGGER "$TC_CMD qdisc add dev $ifname ... multiq" $TC_CMD qdisc add dev $ifname root handle $qdisc_id multiq fi @@ -212,13 +221,13 @@ if [ -n "$QOS_BEST" ]; then print found_filter } '` - $debug_msg "found filter $found_filter" + $LOGGER "found filter $found_filter" # # Add the filter for FCoE # if [ "$found_filter" -eq 0 ]; then - $debug_msg "tc filter add dev $ifname ... skbedit queue_mapping 3" + $LOGGER "tc filter add dev $ifname ... skbedit queue_mapping 3" $TC_CMD filter add dev $ifname parent $qdisc_id protocol 802_3 \ handle $FCOE_FILTER basic match 'cmp(u16' at 12 \ layer 1 mask 0xffff eq $FCOE_ETHERTYPE')' \ @@ -229,7 +238,17 @@ fi # # Start FCoE # -$debug_msg "fcoeadm --create $ifname" -$FCOEADM --create $ifname + +## For --reset we only change the qdisc and filter when necessary. +## The kernel code should be doing reset. No need to reset here. +if [ "$cmd" == "enable" ]; then + check_fcoe_if $ifname + if [ $? -ne 0 ]; then + $LOGGER "fcoeadm --create $ifname" + $FCOEADM --create $ifname + else + $LOGGER "FCoE interface $ifname exists" + fi +fi exit 0 Index: open-fcoe/usr/etc/initd/cfg-ethx =================================================================== --- /dev/null +++ open-fcoe/usr/etc/initd/cfg-ethx @@ -0,0 +1,3 @@ +FCOE_ENABLE="no" +DCB_REQUIRED="yes" + Index: open-fcoe/libhbalinux/Makefile.hbaapi =================================================================== --- open-fcoe.orig/libhbalinux/Makefile.hbaapi +++ open-fcoe/libhbalinux/Makefile.hbaapi @@ -13,8 +13,8 @@ INSTALL = install LIB = libHBAAPI.so.1.0.0 DATE=`date "+%D-%T"` -CFLAGS += -DBUILD_DATE="\"${DATE}\"" -CFLAGS += -fPIC -DVENDOR='"Intel Corporation"' \ +override CFLAGS += -DBUILD_DATE="\"${DATE}\"" +override CFLAGS += -fPIC -DVENDOR='"Intel Corporation"' \ -DREVISION='"Rev 2.2"' -DREVNUM=2 -DMINREVNUM=2 \ -DLICENSE='"Subject to SNIA Public License"' #LDFLAGS += -G @@ -32,7 +32,7 @@ libHBAAPI.so.1.0.0: HBAAPILIB.c hbaapi.h @echo ' CC PIC' $< $(CC) $(CFLAGS) -c HBAAPILIB.c @echo ' LINK' $< - $(CC) $(LDFLAGS) -shared HBAAPILIB.o -Wl,-soname=libHBAAPI.so.1 -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) -shared HBAAPILIB.o -Wl,-soname=libHBAAPI.so.1 -o $@ ln -s $@ libHBAAPI.so ln -s $@ libHBAAPI.so.1 @@ -41,11 +41,11 @@ clean: install: @echo ' INSTALL' $< - @$(INSTALL) -D $(LIB) $(DESTDIR)$(LIBDIR) - $(INSTALL) *.so.1 $(DESTDIR)$(LIBDIR) - @echo $(HBA_ID) $(LIBDIR)$(LIB) > $(DESTDIR)/etc/hba.conf - @$(CHMOD) 644 $(DESTDIR)/etc/hba.conf + $(INSTALL) -D $(LIB) $(DESTDIR)$(LIBDIR) +# $(INSTALL) *.so.1 $(DESTDIR)$(LIBDIR) + echo $(HBA_ID) $(LIBDIR)$(LIB) > $(DESTDIR)/etc/hba.conf + $(CHMOD) 644 $(DESTDIR)/etc/hba.conf uninstall: - @$(RM) -f $(LIBDIR)$(LIB) > /dev/null 2>&1 - @$(RM) -f $(DESTDIR)/etc/hba.conf > /dev/null 2>&1 + $(RM) -f $(LIBDIR)$(LIB) > /dev/null 2>&1 + $(RM) -f $(DESTDIR)/etc/hba.conf > /dev/null 2>&1 Index: open-fcoe/libhbalinux/Makefile =================================================================== --- open-fcoe.orig/libhbalinux/Makefile +++ open-fcoe/libhbalinux/Makefile @@ -7,8 +7,8 @@ MAKE = make HBAAPI=$(shell (cd hbaapi_src_2.2; pwd)) all: - (cd $(HBAAPI); $(MAKE) -f ../Makefile.hbaapi) - $(MAKE) HBAAPI=$(HBAAPI) -C src + (cd $(HBAAPI); $(MAKE) -f ../Makefile.hbaapi CFLAGS="$(CFLAGS)") + $(MAKE) HBAAPI=$(HBAAPI) -C src CFLAGS="$(CFLAGS)" install: (cd $(HBAAPI); $(MAKE) -f ../Makefile.hbaapi install) Index: open-fcoe/Makefile =================================================================== --- open-fcoe.orig/Makefile +++ open-fcoe/Makefile @@ -4,7 +4,7 @@ # set the following corresepondingly to your preferred locations DESTDIR ?= -LIBDIR = $(libdir)/open-fcoe-1.0.3 +LIBDIR = $(libdir)/open-fcoe-1.0.4 prefix = /usr exec_prefix = / @@ -23,8 +23,8 @@ INSTALL = install default: all all: - $(MAKE) -C libhbalinux - $(MAKE) -C usr LIBDIR=$(LIBDIR) + $(MAKE) -C libhbalinux CFLAGS="$(CFLAGS)" + $(MAKE) -C usr LIBDIR=$(LIBDIR) CFLAGS="$(CFLAGS)" clean: $(MAKE) -C usr clean Index: open-fcoe/libhbalinux/src/Makefile =================================================================== --- open-fcoe.orig/libhbalinux/src/Makefile +++ open-fcoe/libhbalinux/src/Makefile @@ -28,11 +28,11 @@ LIBRARIES = -lrt -lpciaccess # #DATE=`date "+%D-%T"` DATE=`date "+%Y/%m/%d %T %Z"` -CFLAGS += -DBUILD_DATE="\"${DATE}\"" -CFLAGS += -fPIC -O0 -g -Wall -Werror -CFLAGS += -I. -CFLAGS += -I../include -CFLAGS += -I../hbaapi_src_2.2 +override CFLAGS += -DBUILD_DATE="\"${DATE}\"" +#override CFLAGS += -fPIC -O0 -g -Wall -Werror +override CFLAGS += -I. +override CFLAGS += -I../include +override CFLAGS += -I../hbaapi_src_2.2 # # C files to be compiled @@ -64,8 +64,8 @@ $(LIB_SO): $(PICS) $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname=libhbalinux.so.1 -shared -o $@ $^ $(LIBRARIES) $(BUILD_DIR)/%.o: %.c - @echo ' CC PIC' $<; \ - $(CC) -MM $(CFLAGS) -fpic $< | \ + @echo ' CC PIC' $<; + $(CC) -c $(CFLAGS) -fpic $< | \ ( $(SED) 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/$*.d || \ $(RM) -f $(BUILD_DIR)/$*.d ); \ $(CC) -c $(CFLAGS) -fpic -o $@ $< @@ -75,7 +75,7 @@ clean: install: $(LIB) @echo ' INSTALL' $< - @$(INSTALL) $(LIB) $(INSTALL_DIR) + $(INSTALL) $(LIB) $(INSTALL_DIR) uninstall: @$(RM) -f $(INSTALL_DIR)/$(LIB) > /dev/null 2>&1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor