summaryrefslogtreecommitdiffstats
path: root/ipmid-new.cpp
Commit message (Collapse)AuthorAgeFilesLines
* ipmid: allow command not found for filtered commandsHEADmasterVernon Mauery2020-02-111-5/+11
| | | | | | | | | | | | | | | | | | | | | | | Filters are executed first and the actual ipmi command handler will not execute if the filter rejects it for any reason. However, if a filter returns a value for a command that is not even implemented, the old logic would return that value instead of command not implemented (C1h). This is incorrect behavior. This fix will run the filter and then check to see if the command is registered. If the command is registered AND the filter has returned some error, only then will the filter error get returned. If the command is registered and the filter returns no error, the command is executed. If the command is not registered, C1h is returned, as per the spec. Tested: 1) Add some bogus command definitions to the whitelist filter 2) Run the bogus command 3) See that C1h is returned, not insufficient privilege Change-Id: I069df8f47a169d6b2961460a561bf9cae6ae285c Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* [ipmid]: Advertise D-Bus signals, only when readyRichard Marian Thomaiyar2020-01-211-8/+8
| | | | | | | | | | | | | | | Requesting the bus name & sending out InterfacesAdded signal earlier causes phosphor-mapper introspect to fail, as ipmi command handler registration & initialization was in progress before hitting io->run(). Hence moved the code to advertise about D-Bus signal, once ipmid is done with init & registration. This fixes phosphor-mapper timeout. Tested: 1. Verified that phosphor-mapper timeout doesn't happen, even when there is delay in cmd handler registrations etc. Change-Id: I3bb565c0e39f2604dde30e21b9539ce88b73cb0e Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
* Provide proper exit code for signalsJames Feist2019-11-271-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently ipmid only exits 0, allow it to exit based on the signal captured. Tested: journalctl -u phosphor-pid-control -o json-pretty { "_SYSTEMD_SLICE" : "-.slice", "_GID" : "0", "_CAP_EFFECTIVE" : "3fffffffff", "MESSAGE" : "phosphor-ipmi-host.service: Main process exited, code=killed, status=9/KILL", "EXIT_STATUS" : "9", "__CURSOR" : "s=cd10fcb9010e4cfdbcdad08709c2265d;i=399;b=2efcc2f735f74bc99588861556589a72;m=7c0ed53;t=592853b62b677;x=1ae3833ab435621e", "__MONOTONIC_TIMESTAMP" : "130084179", "MESSAGE_ID" : "98e322203f7a4ed290d09fe03c09fe15", "_EXE" : "/lib/systemd/systemd", "CODE_LINE" : "5797", "UNIT" : "phosphor-ipmi-host.service", "_SYSTEMD_CGROUP" : "/init.scope", "_SYSTEMD_UNIT" : "init.scope", "SYSLOG_IDENTIFIER" : "systemd", "_COMM" : "systemd", "_UID" : "0", "PRIORITY" : "4", "_HOSTNAME" : "intel-obmc", "SYSLOG_FACILITY" : "3", "CODE_FILE" : "src/core/unit.c", "CODE_FUNC" : "unit_log_process_exit", "_CMDLINE" : "/lib/systemd/systemd", "__REALTIME_TIMESTAMP" : "1568475808183927", "_SOURCE_REALTIME_TIMESTAMP" : "1568475808183827", "COMMAND" : "ExecStart", "INVOCATION_ID" : "67ff87a3ad4b4a4da3fe7e0ff083e2b8", "_TRANSPORT" : "journal", "_MACHINE_ID" : "f7182be05e2147feba2eaceaea0aded3", "_BOOT_ID" : "2efcc2f735f74bc99588861556589a72", "EXIT_CODE" : "killed", "_PID" : "1" } Change-Id: I9f3233546b43a331076d21b73beabbf2aaca9d8b Signed-off-by: James Feist <james.feist@linux.intel.com>
* Added sessionId context in host-ipmid, used by GetSessionInfoRajashekar Gade Reddy2019-11-191-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SessionId is now passed to host-ipmid context along with userid and privilege information. This will enable certain commands to know the current sessionid Added option to get current session info in get session info command. With this change, we can get the current session info by passing sessionIndex as zero in get session info command via lan interface and the same via host interface will return an error, beacuse no session will be created for host interface. Tested: ipmitool -I lanplus -U <user> -P <password> -H <lan1_ip> raw 6 0x3d <Zero> Response : gives currents session info ipmitool -I lanplus -U <user> -P <password> -H <lan2_ip> raw 6 0x3d <Zero> Response : gives currents session info //host interface ipmitool raw 6 0x3d 0 Response: 0xCC // invalid field in the request //This command shows info of all sessions, which includes current session info as well. ipmitool -I lanplus -U <user> -P <password> -H <lan1_ip> session info all session handle : 129 slot count : 45 active sessions : 1 user id : 1 privilege level : ADMINISTRATOR session type : IPMIv1.5 channel number : 0x03 console ip : 0.0.0.0 console mac : 00:00:00:00:00:00 console port : 52670 session handle : 0 slot count : 45 active sessions : 1 //This command shows info of all sessions, which includes current session info as well. ipmitool -I lanplus -U <user> -P <password> -H <lan2_ip> session info all session handle : 0 slot count : 45 active sessions : 1 session handle : 1 slot count : 45 active sessions : 1 user id : 1 privilege level : ADMINISTRATOR session type : IPMIv1.5 channel number : 0x01 console ip : 0.0.0.0 console mac : 00:00:00:00:00:00 console port : 57622 //host interface ipmitool session info all session handle : 0 slot count : 45 active sessions : 0 session handle : 0 slot count : 45 active sessions : 0 Tested other postive and negative test cases for get session info command in Lan1, Lan2 and host interfaces. All are working fine. Signed-off-by: Rajashekar Gade Reddy <raja.sekhar.reddy.gade@linux.intel.com> Change-Id: I9fb1ef12693e4c0da3661ffdf21eec248b48b5b4
* Change yield from ptr to objectJames Feist2019-09-131-2/+2
| | | | | | | | | | | | The ptr makes for ugly code: i.e. *(ctx->yield) all over the place. Change it to copy as it is just 4 pointers. Tested: ipmitool mc info still works Change-Id: I30c5bc395849875cd58925fac99bb23c1804cd5b Signed-off-by: James Feist <james.feist@linux.intel.com>
* Revert "Add system interface as the channel for the legacy interface"Tom Joseph2019-08-201-2/+1
| | | | | | This reverts commit 152e98cd339f3df58d5832af5779eff541f0adc5. Change-Id: Ib36cdbb2d140de749335a3ae9cbb279563c33a1c
* Add system interface as the channel for the legacy interfaceTom Joseph2019-08-181-1/+2
| | | | | | | | | The legacy interface org.openbmc.HostIpmi is used by the btbridge interface and the channel number was set to 0 which implies the IPMB bridge. This is corrected to use the system interface. Change-Id: I870d8fc6c2461b7fc75a90f9576f08599038f211 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
* Add sdbusplus::asio::connection pointer to ipmi::ContextVernon Mauery2019-05-301-6/+7
| | | | | | | | | | | | | | | | | This adds a std::shared_ptr<sdbusplus::asio::connection> to every ipmi::Context in order to facilitate easy transition to yield_method_call over other D-Bus interfaces. This means that a getDbusObjects call could just pass in the ipmi::Context and it will get a yielding call. ipmi::Context is a natural fit because one is created for each of the boost::asio::coroutine contexts. And because a yielding call needs both an async D-Bus connection and a yield_context, this means that we now have one object to rule them all. Tested: Created a handler that uses the new shared_ptr in the context to see the API in action. Change-Id: I429a324180a38bf17845f7fd0544df2226d0300a Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Legacy D-Bus interface must set yield_contextVernon Mauery2019-05-141-23/+36
| | | | | | | | | | | | | | | | The legacy D-Bus interface was not setting the yield_context pointer in the ipmi::Context struct. This means that a command coming in from a legacy D-Bus interface that called a new-provider that uses the yield_method_call function would segfault on a NULL pointer. This change makes the legacy interface behave the same as the new D-Bus interface by creating a new boost::coroutine for each command. Tested-by: running a legacy ipmitool to ensure that the rewritten set chassis power restore policy command worked without a segfault. Change-Id: Ie45fff1fc222b9b949a9d3976bf9d1b2c29bd8f5 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* ipmid: Handler should automatically handle OEM / GroupWilliam A. Kennington III2019-04-291-13/+6
| | | | | | | | We shouldn't require the user to handle these. They are a detail purely at the message layer and weren't provided to handlers in the past. Change-Id: I1796eb887c86dfbd66d9c784a99dbae675ceb774 Signed-off-by: William A. Kennington III <wak@google.com>
* ipmid: Fix group / OEM parsingWilliam A. Kennington III2019-04-291-6/+8
| | | | | | | | | | | | The types of the fields being unpacked are larger than what the spec requires for the sizing. This means our unpacker tries to unpack 4 bytes for the group (which is supposed to be 1 byte) and 4 bytes for the oem (which is only 3 bytes). This breaks oem commands that take no arguments since our parser will reject those commands for being too short. It also breaks the response, since it adds more bytes than needed. Change-Id: I4f4710a6a2720574efb86635827f737be48d296a Signed-off-by: William A. Kennington III <wak@google.com>
* add rqSA ipmb request source addressVernon Mauery2019-04-291-2/+20
| | | | | | | | | | Platform Event Message Command requires that if the message comes in over IPMB, the generator ID is the rqSA of the message. IPMB bridge is now responsible for passing this in via the options map so it can be passed in the context to the command. Change-Id: I52b7c9ef23896a4efcceeebf12559bbdf897d1c2 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* look up channel from D-Bus connectionVernon Mauery2019-04-221-7/+211
| | | | | | | | | | | | | | | | | | | | | | | | | With a single IPMI execution queue and multiple bridges, it is important for the queue to be able to map the incoming D-Bus message to a channel. Each bridge should request a well-known name of the form "xyz.openbmc_project.Ipmi.Channel.<name>" where name is the name field in the /usr/share/ipmi-providers/channel_config.json file. The mapping is done by registering a name change listener on D-Bus and then doing some name lookups via the D-Bus interface to match well-known names to unique names. Then, each incoming messages comes from a unique-named sender and can be resolved to which channel it came from. For now, any unmapped channels will show up as INTRABMC, which is not ideal, but should not break things until the bridges can be converted to the correct name and D-Bus API. Tested-by: run ipmid, start and stop bridges named xyz.openbmc_project.Ipmi.Channel.<NAME> and see the messages show that a new channel has been mapped. Then, with commands that use the ipmi::Context, the correct channel shows up. Change-Id: I3e6bbfbf2e068020e07eeafe64eb09d70c03dc65 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Only include ipmid/api.hpp for the new APIVernon Mauery2019-04-081-1/+0
| | | | | | | | | | | | | | After some feedback from users of the new IPMI API, they wanted to see two things: 1) don't require ipmid/api.hpp and ipmid/registration.hpp to be able to write new handlers 2) only require including ipmid/api.hpp (instead of ipmid/api.h) So now, by simply including ipmid/api.hpp instead of ipmid/api.h (deprecated), handlers incorporating the new IPMI API can be written. Change-Id: I446dcce70cff03d4ecc28c658292d052485f77fc Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* allow legacy handlers to register with groupoem extensionVernon Mauery2019-04-011-1/+14
| | | | | | | | | | | | | DCMI uses the group oem extension 0xdc. The legacy registration allowed for registering with the group extension netfn and did nothing with the actual group extension ID. This change makes the assumption that all legacy group extension registrations are dcmi and registers them as such with the new group handler machinery. Tested-by: Run ipmitool dcmi discover and see it show information Change-Id: I862ba212a7fe2e2dad83d6c9f22e7d1a48b7d406 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* resolve symbolic links to only load each library onceVernon Mauery2019-03-291-0/+6
| | | | | | | | | | Historically, the provider libraries and symlinks to them were installed in the /usr/lib/ipmid-providers directory. This can cause ipmid to attempt to load each one twice. This change will make it so ipmid will not load symlinks, but only real files. Change-Id: I1353f01d509ef495bfa666eed97b034d73a1a90a Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Remove experimental filesystem spliceVernon Mauery2019-03-281-13/+1
| | | | | | | | | | In order to be compatible with older versions of GCC that did not have the experimental filesystem moved over to the standard paths, the code would splice the experimental code into the std namespace. This is no longer necessary with yocto 2.6 and the latest versions of GCC. Change-Id: I2db13c52a91456318795819f2d45c3386b4c56d2 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* move types.hpp to ipmid/types.hpp for exportVernon Mauery2019-03-251-1/+1
| | | | | | | | | | types.hpp is required by utility.hpp, which is exported, so it needs to be exported as well. This moves it to the include/libipmid directory, changes the Makefile to export it, and changes all the files that include it so it can be found in the right place. Change-Id: I30ec365446e4de466c266ec4faa327478460ec05 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* do not use auto and rename handles to providersVernon Mauery2019-03-251-2/+3
| | | | | | | | | handles is a poor name choice for the list of IpmiProviders and being declared as an auto is hard to see what type it really is. This changes the type to be fixed and uses a more appropriate name for the variable. Change-Id: I35f744c491f3810c7381738516b8ff0a6f20f129 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Add user context parameter to legacy ipmi handler registrationVernon Mauery2019-03-211-1/+1
| | | | | | | | | This part was originally omitted, but needed by some external provider libraries. This will more closely mimic the behavior of ipmid prior to the architecture update. Change-Id: I5db35222e268a117480285c700d88206d6505d92 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* make ipmid respond to SIGTERM and SIGINT for clean shutdownVernon Mauery2019-03-201-5/+19
| | | | | | | | | | | | | | | On some systems ipmid was not responding to SIGTERM so systemd could not shut it down in a clean manner, resorting to SIGKILL after a long timeout. This adds code to respond to SIGTERM and SIGINT and safely unwind all the provider libraries on exit. Tested-by: running ipmid; in another shell, and running 'killall -15 ipmid' or 'killall -2 ipmid' to send SIGTERM or SIGINT and watch that ipmid shuts down in a controlled and timely manner. Change-Id: I690846796523bebea1a08845c0d17e1df2a94fee Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Change linkage of ipmid_get_sdbus_plus_handler() to libipmid.soVernon Mauery2019-03-191-17/+13
| | | | | | | | | | | | | | ipmid_get_sdbus_plus_handler() was re-added to be a part of systemintfcmds where it was used. This moves it to libipmid.so because that is where symbols used by both ipmid and the providers should be. Because ipmid_get_sdbus_plus_handler() relies on the io service and the main sdbus::asio::connection is also right there, this moves those symbols to libipmid as well to keep coherent. Change-Id: Ib125a0c217c8bcf47a8a4bd0c557eb69e928245b Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* Use payload interface to unpack group/IANA from messageVernon Mauery2019-03-151-2/+2
| | | | | | | | | | | | Directly calling unpack from the Request interface will attempt to unpack the whole message, resulting in a 0xC7 response if the whole message was not unpacked. Since at this point in the execution, the point is to only extract the group ID or the IANA, the lower-level Payload unpack interface must be used. This allows for partial unpacks and only returns error if there are not enough bytes to unpack. Change-Id: Ie18377597e925eff89c9b7c1a6d2258627d5f240 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* ipmid: Add command filter mechanismVernon Mauery2019-02-251-0/+49
| | | | | | | | | | | | | | | Every ipmi command will pass through a filter prior to execution by the registered handler. The filter consists of all registered filter handlers that all must either return an IPMI error code or allow the command to be executed. If any of the filter handlers return an error code, the remaining handlers will not get a chance to run. Each handler, executed in registered priority order, can be passed the full message, or just the context (metadata describing the command, netfn, cmd, etc.) Change-Id: I3c48f19ebae0d24344b15fbcd2b940a32f8511d7 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* ipmid: Add in Native OEM and Group OEM supportVernon Mauery2019-02-251-1/+124
| | | | | | | | | | Add full support for the IPMI OEM NetFn and the Group OEM support as defined in the IPMI 2.0 specification. For now the legacy OEM router mechanism is still supported. Change-Id: I8cc999489000c6e0daf5aad3579838e6f499ba47 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
* ipmid: Rewrite ipmid to use the new architectureVernon Mauery2019-02-251-0/+459
New architecture highlights: * The new registration detects handler type for argument unpacking. * Upon completion the response is automatically packed. * Handlers can make use of the new async/yield sdbusplus mechanism. * The queue exports a new dbus interface for method-based IPMI calls. * The legacy handler registration is still supported for now. * The legacy dbus interface is still supported for now. Change-Id: Iae8342d9771ccebd3a0834e35597c14be4cc39cf Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
OpenPOWER on IntegriCloud