Menu ▾ ▴

#408 ipmitool sel list last X handling is broken in various ways

version-1.8.18
closed-fixed
None
5
2016-05-03
2016-01-11
Boris Ranto
No

Hi,

I've encountered several issues in code, here:

1) the way we compute delta for a negative count (last X), we get the ID of the first entry, the id of the next entry and we simply divide it, this breaks if we e.g. remove the second entry from the sel log as it will always request ~double the entries

2) the way we compute first next_id for a negative count
a) if your last entry id is X and you request X+1 entries (assuming delta is 1), nothing gets printed out because we get next_id 0xffff and we won't even enter the while loop
b) if your last entry id is X and you request X entries, you get next_id 0 and hence, you print all the events in the SEL log not just last X events
c) if you delete an event and last - X equals to the ID of the event, you get errors since there is no such entry
d) if the highest entry the sel log achieved is << 0xfffe (e.g. it is 0x01ff) and we request more entries than is the ID of the latest one, we try to access events with IDs like 0xffXY which obviously do not exist

We could try to lower the impact, here but we can't solve 2c) and 2d) (and maybe even 1) that way, properly. I'm attaching a scratch patch (Improve-sel-list-last-handling.patch) that tries to do exactly that.

However, the proper solution would unfortunately involve traversing the full SEL log skipping first 'NR_ENTRIES - count' entries and showing only the last 'count' entries (Fix-sel-list-last-X-listing.patch).

2 Attachments

Discussion

  • Zdenek Styblik

    Zdenek Styblik - 2016-03-10

    Argh. I thought this is related to SDR and didn't dare to touch it.

     
  • Boris Ranto

    Boris Ranto - 2016-03-15

    Hi Zdenek,

    any comments on the patches/preferred way to go about fixing this?

     
    • Zdenek Styblik

      Zdenek Styblik - 2016-03-16

      Hello Boris,

      I've given read to what you've written, IPMI spec and IPMI tool code in SEL. I haven't read the patches yet.
      What I don't understand is why is delta being calculated? Why can't we read until we either hit "the end" or count of entries have been successfully read from SEL?

      Thank you.

      Z.

       
      • Zdenek Styblik

        Zdenek Styblik - 2016-03-16

        ... because we have to start reading "in the middle" of the list, right?

         
  • Boris Ranto

    Boris Ranto - 2016-03-16

    Yes, the delta is computed so that it could jump to the position described by something like

    first + delta*(nr_items-count)

    but that position is simply not correct; not to mention that it might not even exist -- could have been deleted, etc.

    I really don't see a way to fix this completely without traversing the full SEL log.

     
  • Zdenek Styblik

    Zdenek Styblik - 2016-03-17

    Hm. I've been thinking about this, however, and correct me if I'm wrong, but to trully fix this, you'd have to create "map" of SEL IDs, at least, or put everything into memory, at most.
    Given the fact that BMC and communication with BMC is slow, it doesn't really look like a perspective solution, does it? This includes traversing the full SEL log :\

     
  • Boris Ranto

    Boris Ranto - 2016-03-17

    You don't need to create the map, you just iterate over the items one-by-one until you traverse nr_items + count (count is negative in that case) items. Also, you don't store them all, you can store them one by one so memory footprint should be ok. See the 0001-Fix... patch for details.

    I agree that it is not the fastest solution but I don't see any faster that would fix it completely (code-wise, it is even quite simple).

    Anyway, we should probably be good to go if we at least tried to fix-up the code a bit and handle few of the corner cases better. That is why I attached the second 0001-Improve... patch that tries to do a best effort compution of the position and fixes up few bugs in the code. I removed the delta compution altogether as in most machines it just caused problems. I understand that step might be questionable but I have yet to see a SEL log with delta /= 1.

     
    • Zdenek Styblik

      Zdenek Styblik - 2016-03-17

      I didn't say no. I've expressed my concerns. However, I feel like I'm missing something. SEL is a list with begining, end and pointer to the next entry, correct? Say:

      [0, 1, 2, 3, 4]

      Now, the way I understood it. If we delete number 2 from the list:

      [0, 1, x, 3, 4]

      then there is a hole in the list, but we don't know about it and we have no way to find out about it, unless we will go through the whole SEL.
      Hence, that's why I've said we would have to create map(list) of SEL IDs. Then, and only then(?), you can calculate any kind of delta or where to begin.
      So, I kind of don't understand how going through SEL, counting entries that have been passed already, would fix the issue at hand.
      Now, if I understand the issue correctly, if you want to print last 4 entries from:

      [0, 1, x, 3, 4]

      then only 3 entries would be printed out instead of 4, because there is a hole in the list, correct?

       
  • Boris Ranto

    Boris Ranto - 2016-03-17

    You are also aware of the number of entries in the SEL log. It is part of the response to IPMI_CMD_GET_SEL_INFO cmd that pretty much initiates this.

    My idea was as simple as that if you know the number of entries, you can simply traverse the first 'nr_entries - nr_to_show' entries without actually printing anything and then continue to traverse the last 'nr_to_show' entries printing their content. I did not have to construct any map or anything. Of course, if nr_entries <= nr_to_show, I just skipped the first part and printed out the full SEL log.

    btw: The id 0 is a reserved entry id. It should denote the end of SEL log.
    btw2: In the code nr_entries is 'entries' and nr_to_show is '-count'.

     
    • Zdenek Styblik

      Zdenek Styblik - 2016-03-18

      I see. I have overlooked that in the spec. Any thoughts or experiments on partial reads? I mean, it could, should and probably would speed up things, imho.

       
  • Boris Ranto

    Boris Ranto - 2016-03-23

    I'm not that familiar with the code so I mostly just followed what I saw in the code and used the regular reads.

    I tried to look it up in the code but the best I could find was a partial write (IPMI_CMD_PARTIAL_ADD_SEL_ENTRY). The only get functions listed in include/ipmitool/ipmi_sel.h are:

    IPMI_CMD_GET_SEL_INFO
    IPMI_CMD_GET_SEL_ALLOC_INFO
    IPMI_CMD_GET_SEL_ENTRY
    IPMI_CMD_GET_SEL_TIME
    IPMI_CMD_GET_AUX_LOG_STATUS

    Any pointers on where to look at?

     
    • Zdenek Styblik

      Zdenek Styblik - 2016-03-24

      I don't think any of the current code uses this option. I've seen it in IPMI specification and one reference in the code. For some reason, partial read requires reservation ID and thus the remark in the code.

       
  • Boris Ranto

    Boris Ranto - 2016-04-19

    I've seen something about the partial SDR in the IPMI spec the last I looked but I'm not very familiar with them.

    Any idea on how you would like to proceed on this matter?

     
    • Zdenek Styblik

      Zdenek Styblik - 2016-04-22

      Hello,

      first of all, I'm sorry about moving this to v1.8.18.
      On the bright side, I'm almost done with my naive implementation of SEL, so I should be able to test. Although, I'm missing SDR which is somewhat required by IPMItool for the lookups.
      What I had in mind is on page 450 in PDF(~424 in "printed version"). Get SEL Event supports "bytes to read" attribute. So, I thought this could be set to 0(zero bytes to read) and save some bandwidth and speed up things. However, I'm worried that some BMCs could interpret this as an invalid request. Also, it's not actually guarantee it will be faster, because BMC will most likely fetch the whole record anyway. Last, but not least, in my SEL implementation, doing partial reads proven to be, well, next to impossible, because I've used a structure(wrong approach, really).
      May be I've asked already, but which patch should I give a look and try then?

      Thanks,
      Z.

       
      • Boris Ranto

        Boris Ranto - 2016-04-22

        I'd recommend the '0001-Fix-sel-list-last-X-listing.patch' patch. It's a bit slower but a lot less hacky and it fixed the behaviour in all the cases I've tried. It is also quite non-invasive:

        1. remove the old heuristic that computes and jumpts to the first sel log entry to be shown
        2. replace it with algorithm that traverses the first NR_ENTRIES - NR_TO_SHOW entries without printing anything
         

        Last edit: Boris Ranto 2016-04-22
  • Zdenek Styblik

    Zdenek Styblik - 2016-04-22
    • Group: version-1.8.17 --> version-1.8.18
     
  • Zdenek Styblik

    Zdenek Styblik - 2016-05-01

    Hello Boris,

    please ...

    for(i = 0;i < entries + count;i++) {
    

    put spaces after ; and remove redundant empty lines from that for() cycle, resp. the first and the last inner empty new-line.

    if (next_id == 0)
        break
    

    put { and } here.

    Once these are addresses, patch can be merged.

    Thank you,
    Z.

     
  • Boris Ranto

    Boris Ranto - 2016-05-02

    Hi Zdenek,

    I've made the changes you requested (+ I've rebased this on top of the latest master and amended the commit message to include this bug ID).

     
  • Zdenek Styblik

    Zdenek Styblik - 2016-05-03
    • status: open --> closed-fixed
    • assigned_to: Zdenek Styblik
     
  • Zdenek Styblik

    Zdenek Styblik - 2016-05-03

    It is in. Thanks.

     

Log in to post a comment.