Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next/508/20240628/v1 #11394

Merged
merged 30 commits into from
Jul 2, 2024
Merged

Commits on Jun 28, 2024

  1. Configuration menu
    Copy the full SHA
    1fa13e4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a81b232 View commit details
    Browse the repository at this point in the history
  3. detect/threshold: implement tracking 'by_flow'

    Add support for 'by_flow' track option. This allows using the various
    threshold options in the context of a single flow.
    
    Example:
    
        alert tcp ... stream-event:pkt_broken_ack; \
            threshold:type limit, track by_flow, count 1, seconds 3600;
    
    The example would limit the number of alerts to once per hour for
    packets triggering the 'pkt_broken_ack' stream event.
    
    Implemented as a special "flowvar" holding the threshold entries. This
    means no synchronization is required, making this a cheaper option
    compared to the other trackers.
    
    Ticket: OISF#6822.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    1552f09 View commit details
    Browse the repository at this point in the history
  4. threshold: add by_flow support for global thresholds

    Allow rate_filter and thresholds from the global config to specify
    tracking "by_flow".
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    cfd55ea View commit details
    Browse the repository at this point in the history
  5. detect: group types used in traffic variables

    Traffic variables (flowvars, flowbits, xbits, etc) use a smaller int for
    their type than detection types. As a workaround make sure the values fit
    in a uint8_t.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    022173d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d0f3f2d View commit details
    Browse the repository at this point in the history
  7. detect/content: fix wrong value for depth check

    Limits propegation checked for DETECT_DEPTH as a content flag,
    which appears to have worked by chance. After reshuffling the
    keyword id's it no longer worked. This patch uses the proper
    flag DETECT_CONTENT_DEPTH.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    f028648 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    3f04af7 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    405491c View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    c963158 View commit details
    Browse the repository at this point in the history
  11. detect/threshold: implement per thread cache

    Thresholding often has 2 stages:
    
    1. recording matches
    2. appling an action, like suppress
    
    E.g. with something like:
    threshold:type limit, count 10, seconds 3600, track by_src;
    the recording state is about counting 10 first hits for an IP,
    then followed by the "suppress" state that might last an hour.
    
    By_src/by_dst are expensive, as they do a host table lookup and lock
    the host. If many threads require this access, lock contention becomes
    a serious problem.
    
    This patch adds a thread local cache to avoid the synchronization
    overhead. When the threshold for a host enters the "apply" stage,
    a thread local hash entry is added. This entry knows the expiry
    time and the action to apply. This way the action can be applied
    w/o the synchronization overhead.
    
    A rbtree is used to handle expiration.
    
    Implemented for IPv4.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    c08c81c View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6622dc7 View commit details
    Browse the repository at this point in the history
  13. detect/threshold: minor code cleanup

    Packet pointer is not used during allocation.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    ab5e045 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    3a7247b View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    114fc37 View commit details
    Browse the repository at this point in the history
  16. thash: add expiration logic

    Add a callback and helper function to handle data expiration.
    
    Update datasets to explicitly not use expiration.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    00e1e89 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    ac400af View commit details
    Browse the repository at this point in the history
  18. thresholds: use dedicated storage

    Instead of a Host and IPPair table thresholding layer, use a dedicated
    THash to store both. This allows hashing on host+sid+tracker or
    ippair+sid+tracker, to create more unique hash keys.
    
    This allows for fewer hash collisions.
    
    The per rule tracking also uses this, so that the single big lock is no
    longer a single point of contention.
    
    Reimplement storage for flow thresholds to reuse as much logic as
    possible from the host/ippair/rule thresholds.
    
    Ticket: OISF#426.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    b8028bf View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    3471c0f View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    2be998f View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    1e9fdc4 View commit details
    Browse the repository at this point in the history
  22. detect/threshold: expand cache support for rule tracking

    Use the same hash key as for the regular threshold storage,
    so include gid, rev, tentant id.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    7bcf364 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    10eaf55 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    7d4fcc3 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    e362a01 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    2abe0df View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    a0d515b View commit details
    Browse the repository at this point in the history
  28. detect/threshold: implement backoff type

    Implement new `type backoff` for thresholding. This allows alerts to be
    limited.
    
    A count of 1 with a multiplier of 10 would generate alerts for matching packets:
    1, 10, 100, 1000, 10000, 100000, etc.
    
    A count of 1 with a multiplier of 2 would generate alerts for matching packets:
    1, 2, 4, 8, 16, 32, etc.
    
    Like with other thresholds, rule actions like drop and setting of
    flowbits will still be performed for each matching packet.
    
    Current implementation is only for the by_flow tracker and for per rule
    threshold statements.
    
    Tracking is done using uint32_t. When it reaches this value, the rest of
    the packets in the tracker will use the silent match.
    
    Ticket: OISF#7120.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    12130df View commit details
    Browse the repository at this point in the history
  29. stream: enable backoff on event rules

    Enable backoff for most rules. The rules looking at the session start up
    use a count of 1 and a multiplier of 2.
    
    Post-3whs rules use a count of 1 and a multiplier of 10.
    victorjulien committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    9e735fd View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    afc3187 View commit details
    Browse the repository at this point in the history