Skip to content
  1. Jul 16, 2022
    • Ed Tanous's avatar
      Use more specific include · 07c8c20d
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Per the coding standard, we should be using the most specific version of
      the boost header we rely on.
      
      Tested: Code compiles
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I76dd5a93c10c17d950b0dbac69183dd622363bce
      07c8c20d
    • Ed Tanous's avatar
      Remove usages of boost::starts/ends_with · 11ba3979
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Per the coding standard, now that C++ supports std::string::starts_with
      and std::string::ends_with, we should be using them over the boost
      alternatives.  This commit goes through and updates all usages.
      
      Arguably some of these are incorrect, and instances of common error 13,
      but because this is mostly a mechanical it intentionally doesn't try to
      handle it.
      
      Tested: Unit tests pass.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: Ic4c6e5d0da90f7442693199dc691a47d2240fa4f
      11ba3979
  2. Jul 15, 2022
    • Jason M. Bills's avatar
      Use nlohmann::json::object_t for dump entries · 433b68b4
      Jason M. Bills authored and Ed Tanous's avatar Ed Tanous committed
      
      
      This is a similar change that was recently made for other entry types,
      so also applying for dump entries.
      
      I don't have a system that uses this resource, so I'm not able to test
      this change.
      
      Change-Id: I74ba2f05658c6c53d7e397e03aad31a44c7c3280
      Signed-off-by: default avatarJason M. Bills <jason.m.bills@intel.com>
      433b68b4
    • Ed Tanous's avatar
      Use more specific include · 02fea7a7
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      boost/urls/urls.hpp pulls in all of boost url, when in this context, we
      only want url_view.hpp.  Per the coding standard (specifically in
      regards to boost) pull in the more specific header
      
      Tested: Code compiles.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I85bc45bdfcc7bc1d8e87be23fe4884b6ec8c4227
      02fea7a7
    • Carson Labrado's avatar
      HTTP Client: Fix handling on connection timeout · 5cab68f3
      Carson Labrado authored and Ed Tanous's avatar Ed Tanous committed
      If a destination is not reachable, then the connection will timeout
      in doConnect().  This causes issues later when the client attempts to
      resend the message.
      
      The error check in doClose() should not exit early since that will
      result in the connection's status not being marked as closed and
      thus it will never get reused.
      
      Similarly, doCloseAndRetry() should not exit early since that will
      cause the retry flow to hang and the connection's callback function
      will not get deleted.
      
      Tested:
      Used Redfish Aggregation patches in the chain through
      https://gerrit.openbmc.org/c/openbmc/bmcweb/+/54896
      
       to verify that
      requests to collections such as /redfish/v1/Chassis no longer hang
      when the specified Satellite BMC does not exist
      
      Signed-off-by: default avatarCarson Labrado <clabrado@google.com>
      Change-Id: Ic8369b0de8efb00ff168bc1ed43f1d7fd6c7366a
      5cab68f3
    • Ed Tanous's avatar
      Fix redundant store · bc20089a
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      mtu = mtu has no effect.  Fix it.
      
      Tested: Syntax only change.  Code compiles.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I8bae9ef83ae9809787f82dd27e95ebdb5e0a0e9c
      bc20089a
    • Sui Chen's avatar
      Manager: add ManagerDiagnosticData handler · a51fc2d2
      Sui Chen authored and Ed Tanous's avatar Ed Tanous committed
      
      
      This change adds a link in the Manager for all BMCs to an empty
      ManagerDiagnosticData resource and a minimum ManagerDiagnosticData
      handler.
      
      This service is backed by phosphor-health-monitor (PHM), which is
      enabled by default through the "obmc-apps" package group. If PHM is
      disabled, the resource will be empty.
      
      $ curl http://${bmc}:10080/redfish/v1/Managers/bmc/ManagerDiagnosticData
      {
        "@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData",
        "@odata.type": "#ManagerDiagnosticData.v1_0_0.ManagerDiagnosticData",
        "Id": "ManagerDiagnosticData",
        "Name": "Manager Diagnostic Data"
      }
      
      Also ran the Redfish Service Validator to make sure no new errors are
      introduced with the introduction of ManagerDiagnosticData.
      
      Signed-off-by: default avatarSui Chen <suichen@google.com>
      Change-Id: Iba242bc3b6ebec851dbd26e149d5c92c19a7992e
      a51fc2d2
    • Nan Zhou's avatar
      lock test: remove unused function · 4f93c20a
      Nan Zhou authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Tested: unit test passed.
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I6f9c6b4648d98f4f035830d8a5da094ba76e7458
      4f93c20a
  3. Jul 14, 2022
    • Ed Tanous's avatar
      Move errant logging statement · 6f2cd97a
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Log statement was after the return, so therefore didn't do anything.
      cppcheck found.
      
      Tested: No way to test without a bug that causes an uncaught exception.
      Code review only.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I5a4ae7d5ac83065040e3c4d9e390b5883fd0f1f9
      6f2cd97a
    • Ed Tanous's avatar
      Simplify logic in router matcher · ef641b65
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      cppcheck takes a little issue with this logic having some redundancies
      in it.  Regardless of that, it's kind of hard to read;  Rearrange the
      logic so it's easier to read and add comments.
      
      Tested: Redfish service validator passes.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I0251ceb511e1bc62260b68c430b272d02b90fcb7
      ef641b65
  4. Jul 12, 2022
  5. Jul 11, 2022
    • Nan Zhou's avatar
      Google RoT: simplify subtree iteration · 5600f024
      Nan Zhou authored
      
      
      Use structured binding declaration to avoid verbose typing of subtree
      response.
      
      Tested:
      1. code compiles
      2. tested on hardware and RoT resources worked as expected.
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I22758c196a097cce8e94208085fd59ce1363cefc
      5600f024
    • Nan Zhou's avatar
      Google RoT: add unit tests for /google/v1 · 322204a4
      Nan Zhou authored
      
      
      Tested: unit test worked.
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I4feb6c9cdf52930617a7011732a5837f06c1adda
      322204a4
    • Nan Zhou's avatar
      Google RoT: remove global constant strings · cd02759b
      Nan Zhou authored
      
      
      These variables are replaced by local string literals, which has
      better readability.
      
      Tested: tested on real hardware.
      
      GET: /google/v1/RootOfTrustCollection
      {
        "@odata.id": "/google/v1/RootOfTrustCollection",
        "@odata.type": "#RootOfTrustCollection.RootOfTrustCollection",
        "Members": [
          {
            "@odata.id": "/google/v1/RootOfTrustCollection/Hoth"
          }
        ],
        "Members@odata.count": 1
      }
      
      GET /google/v1/RootOfTrustCollection/Hoth
      {
        "@odata.id": "/google/v1/RootOfTrustCollection/Hoth",
        "@odata.type": "#RootOfTrust.v1_0_0.RootOfTrust",
        "Actions": {
          "#RootOfTrust.SendCommand": {
            "target": "/google/v1/RootOfTrustCollection/Hoth/Actions/RootOfTrust.SendCommand"
          }
        },
        "Description": "Google Root Of Trust",
        "Id": "Hoth",
        "Location": {
          "PartLocation": {
            "LocationType": "Embedded",
            "ServiceLabel": "Hoth"
          }
        },
        "Name": "Hoth",
        "Status": {
          "State": "Enabled"
        }
      }
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I4c21eeb6a521b657bd9a8eb7394e7748d000ad52
      cd02759b
    • Nan Zhou's avatar
      Google RoT: allign callback style · 30aacdd8
      Nan Zhou authored
      The current convention:
      1. route handler should be named as "handleAbcResouceMethod"
      2. prefer inline functions instead of local lambdas
      
      Tested:
      1. compiles
      2. on Google hardware, the commands in
      https://gerrit.openbmc.org/c/openbmc/bmcweb/+/52222/32
      
       worked
      
      GET: /google/v1/RootOfTrustCollection
      {
        "@odata.id": "/google/v1/RootOfTrustCollection",
        "@odata.type": "#RootOfTrustCollection.RootOfTrustCollection",
        "Members": [
          {
            "@odata.id": "/google/v1/RootOfTrustCollection/Hoth"
          }
        ],
        "Members@odata.count": 1
      }
      
      GET /google/v1/RootOfTrustCollection/Hoth
      {
        "@odata.id": "/google/v1/RootOfTrustCollection/Hoth",
        "@odata.type": "#RootOfTrust.v1_0_0.RootOfTrust",
        "Actions": {
          "#RootOfTrust.SendCommand": {
            "target": "/google/v1/RootOfTrustCollection/Hoth/Actions/RootOfTrust.SendCommand"
          }
        },
        "Description": "Google Root Of Trust",
        "Id": "Hoth",
        "Location": {
          "PartLocation": {
            "LocationType": "Embedded",
            "ServiceLabel": "Hoth"
          }
        },
        "Name": "Hoth",
        "Status": {
          "State": "Enabled"
        }
      }
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I0221b4b183579b33d0848d96a20398aee1a211d4
      30aacdd8
  6. Jul 09, 2022
    • Ed Tanous's avatar
      Remove clang-tidy documentation · c5bb9982
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      clang-tidy is now integrated into CI;  Documenting the "manual" process
      for running tidy doesn't provide value these days.  Point to
      openbmc-build-scripts as the "recommended" mechanism to run static
      analysis.
      
      Tested: Documentation only
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: Idac0d29e8976a168355bfa3b863b8600db916f14
      c5bb9982
    • Ed Tanous's avatar
      Make virtual media use urlFromPieces · fdb20347
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      urlFromPieces is the new way to construct "correct" urls.  It also
      cleans up quite a bit of this code.  Use it.
      
      Tested: Code compiles.  No backend in upstream yet.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: Ic43c257613061708e96a5449e0b3d57f288fbffa
      fdb20347
    • Ed Tanous's avatar
      Fix undefined behavior in timestamp parsing · b2f7609b
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      If this algorithm ever processed a string where the + came before the .,
      then dot - plus would render a negative, and overflow, causing a crash.
      
      In practice, this doesn't happen.
      
      Tested: Inspection only at this time.  Difficult to trigger error.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: Ic7f5153d144ac551118c4f4b2d61f82626ac3779
      b2f7609b
    • Jason M. Bills's avatar
      Update host logger with recent JSON fixes · 6d6574c9
      Jason M. Bills authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Similar changes were recently made for other log entry types to improve
      handling of JSON objects. This applies the same fixes for host logger
      entries.
      
      I don't have a system that uses the host logger, so I'm not able to
      test this change.
      
      Change-Id: If5af976885a321e1077d89d92129f4b87a8e2943
      Signed-off-by: default avatarJason M. Bills <jason.m.bills@intel.com>
      6d6574c9
  7. Jul 08, 2022
    • Ed Tanous's avatar
      Remove magic numbers · c715ec29
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      There's lots of magic numbers in this file that we inherited from crow.
      This commit Adds a TypeCode enum class that can be used in place of the
      magic numbers.  It keeps the same values as were present previously
      (0-6) in case there are places where this abstraction leaked out, but I
      believe this catches all of them.
      
      Tested: Redfish service validator passes.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I063955adb8bf75d9bb6298e29e6e44c210ee9cc3
      c715ec29
  8. Jul 07, 2022
    • Ed Tanous's avatar
      Set UnknownProperty message to be an error · 7b1dd2f9
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      This normally wouldn't be so big of a deal, but the redfish-protocol
      validator tests this case in the REQ_PATCH_BAD_PROP test.
      
      From the specification:
      '''
      If all properties in the update request are read-only, unknown, or
      unsupported, but the resource can be updated, the service shall return
      the HTTP 400 Bad Request status code and an error response with messages
      that show the non-updatable properties.
      '''
      
      We wrote our code almost right for handling this case, but we put the
      response into the per-property responses instead of the error responses.
      
      In terms of backward compatibility, technically this is changing the
      behavior, but considering that it's behavior in an error case, most
      implementations only look at response code, and this is moving to be
      compliant with the specification, it doesn't seem like there would be
      any reason to provide both the old message and the new one, and this has
      a low to zero likelihood of any actual impact.  To hit this condition,
      clients would have to be ignoring the error code response AND using a
      property that's unknown to the BMC.  Clients that make both mistakes
      seems unlikely.
      
      Tested:
      Code now passes the REQ_PATCH_BAD_PROP test.  10 failing test cases down
      to 8.
      
      '''
      curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/AccountService/
      
       -X PATCH -d '{"foo": "bar"}'
      '''
      
      Returns an object with an "error" key in it.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I8a19ed2bcfc91765b63d4544877332038e171c02
      7b1dd2f9
    • Ed Tanous's avatar
      Handle NTPServers list per the specification · b9e15228
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      The Redfish specification for PATCH of arrays defines a number of
      requirements.
      - Setting a value to null, should remove it from the list.
      - Setting a value to empty object "{}" should leave the value unmodified
      - Values at indexes larger than whats included in the PATCH request
        shall be removed.
      
      This commit attempts to fix this behavior for NTPServers and make it
      correct.  It does this by first getting the list of NTP servers, then
      walking the list in parallel with the list given in the patch, and
      either modifying or changing the list as the spec requires before
      setting the setting across the system.
      
      It also turns out that the current behavior of unpacking nlohmann::json
      objects requires an object to be an array, object, or null, which
      doesn't allow unpacking the strings required in this case, so that check
      is removed.  A quick inspection shows that we don't unpack nlohmann
      objects very often, and this should have no impact.
      
      Tested:
      Redfish-protocol-validator tests for NTPServers now pass
      
      '''
      curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/NetworkProtocol
      
       -X PATCH -d '{"NTP": {"NTPServers": []}}'
      '''
      Used to patch values succeeds with various "good" values;
      ["time-a-b.nist.gov", "time-b-b.nist.gov"]
      [{}, {}]
      ["time-a-b.nist.gov", null]
      []
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I23a8febde34817bb0b934e46e2b77ff391b52a57
      b9e15228
    • Ed Tanous's avatar
      Move duplicate reduction · 0225b87b
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      getEthernetIfaceData callback should ideally be returning exactly the
      values the system has, minus duplicates.  In every case this function is
      used, we don't want duplicates, so move where we check for duplicates.
      
      Tested: In conjunction with
      https://gerrit.openbmc.org/c/openbmc/bmcweb/+/54829
      
       test cases pass.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: Ib202db99f70e1a6fdddf18969e15b2382e287848
      0225b87b
    • Xiaochao Ma's avatar
      Add TermalSubsystem schema · 1ec18997
      Xiaochao Ma authored and Ed Tanous's avatar Ed Tanous committed
      
      
      Adds the ThermalSubsystem schema to the list of the supported schemas.
      
      Tested: Code compiles.  Script generated change.
      
      Signed-off-by: default avatarXiaochao Ma <maxiaochao@inspur.com>
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      
      Change-Id: I4540fcaa57455ec95d4c8fff71429309c2eebce3
      1ec18997
    • Nan Zhou's avatar
      dbus_singleton: use stack variable and extern · 6384e323
      Nan Zhou authored and Ed Tanous's avatar Ed Tanous committed
      Currently, the |systemBus| connection is a static variable declared in
      headers. This has a problem that every translation unit will keep its
      own copy. It's not a problem today because there's only one translation
      unit "webserver_main.cpp.o". This issue was brounght up in
      https://gerrit.openbmc.org/c/openbmc/bmcweb/+/54758
      
      Actually, the |systemBus| doesn't need to be a singleton. It can just be
      a stack variable, which is normally more efficient than heap variables.
      
      To keep minimum changes treeside, this commits keeps the existing
      |systemBus| variable as an external variable. It is defined in its own
      translation unit. It is initialized in the main translation unit.
      
      Reference:
      1. Extern
      https://stackoverflow.com/questions/1433204/how-do-i-use-extern-to-share-variables-between-source-files
      
      
      
      Tested:
      1. Romulus QEMU robot Redfish test passed;
      2. Start and restart service on real hardware, no issues;
      3. No new validator failures
      4. Code compies
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I03b387bd5f218a86c9d1765415a46e3c2ad83ff9
      6384e323
    • Nan Zhou's avatar
      Google RoT: avoid potential dangling pointer · 16a5535f
      Nan Zhou authored and Ed Tanous's avatar Ed Tanous committed
      
      
      The struct |ResolvedEntity| stores a pointer which might be dangling in
      the future when interface is not longer a string literal. Given that the
      interface string is small enough, this commits changes the data member
      to a string which is constructed (copied) from the string literal today.
      
      Tested: trivial change. Compiles.
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: I2759635f7fa296cc8aa141735efb3799a1503726
      16a5535f
    • Nan Zhou's avatar
      dbus_utility_test: fix test case names · 623e5336
      Nan Zhou authored and Ed Tanous's avatar Ed Tanous committed
      This commit applies the GTest test case naming convention: Camel case,
      use decriptive Test names.
      
      It also groups test cases according to the name.
      
      Reference:
      https://testing.googleblog.com/2014/10/testing-on-toilet-writing-descriptive.html
      http://google.github.io/googletest/primer.html#simple-tests
      
      
      
      Tested: unit test passes.
      
      Signed-off-by: default avatarNan Zhou <nanzhoumails@gmail.com>
      Change-Id: Ibd1bfcb4456b64e43f437cc2afa7464f03ee634c
      623e5336
  9. Jul 06, 2022
  10. Jul 05, 2022
  11. Jul 01, 2022
    • Ed Tanous's avatar
      Remove unused variable · 768989b1
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      This variable was clearly for the print statement below, but then got
      abandoned at some point.  Clean it up.
      
      cppcheck found this as well.
      
      Tested: Unused code
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I2d143f00dc6956c87ba77d5cbe1b96be631ca795
      768989b1
    • Ed Tanous's avatar
      Fix unused branches in http_client · ca723762
      Ed Tanous authored and Ed Tanous's avatar Ed Tanous committed
      
      
      cppcheck correctly finds that these branches will always be hit, so the
      branch is unneeded.  Let's start by getting the code cleaned up.
      
      Tested: CI only, cpp check.
      
      Signed-off-by: default avatarEd Tanous <edtanous@google.com>
      Change-Id: I7b89337a81e676915243d5bc9d26c24a89c74aef
      ca723762
Loading