Commit graph

92 commits

Author SHA1 Message Date
Tim Wojtulewicz
4c58fb26c4 Fix uninitialized class member Coverity findings 2025-07-23 15:17:53 -07:00
Tim Wojtulewicz
e84c99fb14 Fix clang-tidy cppcoreguidelines-macro-usage warnings in headers 2025-06-23 08:35:24 -07:00
Tim Wojtulewicz
74bf987b82 Fix clang-tidy modernize-use-using warnings in headers 2025-06-23 08:35:24 -07:00
Tim Wojtulewicz
f386deba94 Fix clang-tidy performance-enum-size warnings in headers 2025-06-23 08:35:24 -07:00
Tim Wojtulewicz
896e41c794 Remove unnecessary #includes in base files in repo 2025-05-19 09:50:23 -07:00
Benjamin Bannier
db42b2cfe5 Bump clang-format
This patch contains a bump of the configured clang-format version from
17.0.3 to 18.1.8 and automatically generated C++ source updates. The
main difference we are seeing from this is fixes for previously
incomplete reformats.
2024-09-02 16:46:59 +02:00
Tim Wojtulewicz
d1f7999f61 Move dns_mgr stats to telemetry instruments 2024-08-02 21:27:26 -07:00
Tim Wojtulewicz
3295c8f1c1 Change function return types to more concise types where possible
This helps avoid needing to call std::move on return values when we know the
type of value is fixed.
2023-11-28 13:40:28 -07:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Arne Welzel
a57c45428f DNS_Mgr: Use Process() for timeout expiration
DNS_Mgr has a GetNextTimeout() implementation that may return 0.0. When
that is the case, its IO source is enqueued as ready with an fd of -1.
This in turn results in Process() being called instead of ProcessFd()
in RunState.cc.

Ensure timeouts behavior is properly handled by actually forwarding
timeout indications to c-ares via DNS_Mgr::Process(). This results
in pending DNS queries for which a timeout happened to actually
timeout (when there's no other connectivity).
2023-09-04 18:09:40 +02:00
Arne Welzel
2251c67e56 get_dns_stats: Expose total cache size and cached text entries
It wasn't possible from script land to determine the total size
of the cache table held by the DNS_Mgr. Add the total and also
also the TEXT entries count.
2023-03-10 09:22:45 +01:00
Tim Wojtulewicz
82576f8de2 GH-2136: Clean up DNS_Mgr before shutting down 2022-06-01 09:22:29 -07:00
Tim Wojtulewicz
6f2bedaa56 Pre-initialize c-ares channel object. Fixes Coverity 1488318 2022-04-27 17:42:15 +00:00
Tim Wojtulewicz
75d07c021e Remove obsolete DNS_Mgr::asyncs_timeouts 2022-04-27 17:42:15 +00:00
Tim Wojtulewicz
f9f37b11c6 Add new features to IOSource::Manager, used by DNS_Mgr
- iosource_mgr can now track write events to file descriptors as well
  as read events. This adds an argument to both RegisterFd() and
  UnregisterFd() for setting the mode, defaulting to read.
- IOSources can now implement a ProcessFd() method that allows them to
  handle events to single file descriptors instead of of having to
  loop through/track sets of them at processing time.
2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
c4cac72fd7 Use shared_ptrs for DNS_Mapping objects 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
b531ec97ef Similar map changes for async requests 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
e8f833b8a6 Store all mappings in a single map instead of split by type
This opens up the possibility of storing other request types outside
of T_A, T_PTR and T_TXT without requiring redoing the caching. It
also fixes the caching code in DNS_Mapping, adding a version number
to the start of the cache file so the cache structure can be modified
and old caches invalidated more easily.
2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
fb59239f41 Don't split ipv4/ipv6 mappings into separate pointers 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
3bdc744b14 Add merging to DNS_Mgr::AddResult() to support both ipv4 and ipv6 responses simultaneously 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
9f197aa458 Rework DNS_Mgr API to be more consistent and to support more request types 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
336c6ae5c2 Replace nb_dns library with C-Ares 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
e6e9144da6 Add unit testing for DNS_Mgr and related classes 2022-04-22 13:10:37 -07:00
Tim Wojtulewicz
64748edab1 Replace most uses of typedef with using for type aliasing 2021-10-11 14:51:10 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Tim Wojtulewicz
9b15db25f6 Reorder fields in some classes for more compact memory layout 2021-07-14 14:59:49 -07:00
Tim Wojtulewicz
4ad08172d0 Remove obsolete ZEEK_FORWARD_DECLARE_NAMESPACED macros 2021-02-24 14:35:44 -07:00
Tim Wojtulewicz
0618be792f Remove all of the random single-file deprecations
These are the changes that don't require a ton of changes to other files outside
of the original removal.
2021-01-27 10:52:40 -07:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
8d2d867a65 Move everything in util.h to zeek::util namespace.
This commit includes renaming a number of methods prefixed with bro_ to be prefixed with zeek_.
2020-08-20 16:00:33 -07:00
Tim Wojtulewicz
be92bd536f Move iosource code to zeek namespaces 2020-08-20 15:55:17 -07:00
Tim Wojtulewicz
45b5a98420 Move EventMgr, EventHandler, and EventRegistry code to zeek namespace. Rename mgr to event_mgr. 2020-07-31 16:23:32 -04:00
Tim Wojtulewicz
7cedd94ee7 Move DNS_Mgr to zeek::detail namespace 2020-07-31 16:22:41 -04:00
Tim Wojtulewicz
25c0fc7ab2 Move IP Addr/Prefix/Header classes into namespaces 2020-07-31 16:22:04 -04:00
Tim Wojtulewicz
a2bc42dd93 Move Func up to zeek namespace, rename BroFunc to ScriptFunc 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
464efbe66a Move Dictionary/PDict, List/PList, and Queue/PQueue to zeek namespace 2020-06-30 21:12:26 -07:00
Tim Wojtulewicz
d6f1ea16ac Move Func and associated classes into zeek::detail namespace 2020-06-30 20:51:58 -07:00
Tim Wojtulewicz
64332ca22c Move all Val classes to the zeek namespaces 2020-06-30 20:48:09 -07:00
Tim Wojtulewicz
ec9eff0bd5 Use type aliases for IntrusivePtr definitions 2020-06-30 20:37:30 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Jon Siwek
d4f3cad7d1 Merge remote-tracking branch 'origin/topic/timw/266-namespaces'
Merge adjustments:

- Preserved original `base_type_no_ref` argument type as ::TypeTag
- Removed superfluous #pragma guard around deprecated TableVal ctor
- Clarify NEWS regarding MetaHook{Pre,Post} deprecations
- Simplify some `::zeek::` qualifications to just `zeek::`
- Prefixed FORWARD_DECLARE_NAMESPACED macro with ZEEK_

* origin/topic/timw/266-namespaces:
  Disable some deprecation diagnostics for GCC
  Rename BroType to Type
  Update NEWS
  Review cleanup
  Move Type types to zeek namespace
  Move Flare/Pipe from the bro namespace to zeek::detail
  Move Attr to the zeek::detail namespace
  Move Trigger into the zeek::detail namespace
  Move ID to the zeek::detail namespace
  Move Anon.h into zeek::detail namespace
  Mark all of the aliased classes in plugin/Plugin.h deprecated, and fix all of the plugins that were using them
  Move all of the base plugin classes into the zeek::plugin namespace
  Expr: move all classes into zeek::detail
  Stmt: move Stmt classes into zeek::detail namespace
  Add utility macro for creating namespaced aliases for classes
2020-06-11 23:20:51 -07:00
Tim Wojtulewicz
ed13972924 Move Type types to zeek namespace 2020-06-09 17:20:45 -07:00
Jon Siwek
440b0623ac Deprecate RecordVal(RecordType*) ctor
Replaced with one that takes IntrusivePtr
2020-05-14 19:31:43 -07:00
Jon Siwek
78e3267c44 Deprecate internal_handler(), replace with EventRegistry::Register()
Added a couple explicit event declarations that were missing: "net_done"
and "dns_mapping_name_changed".
2020-05-14 17:25:02 -07:00
Johanna Amann
876c803d75 Merge remote-tracking branch 'origin/topic/timw/776-using-statements'
* origin/topic/timw/776-using-statements:
  Remove 'using namespace std' from SerialTypes.h
  Remove other using statements from headers
  GH-776: Remove using statements added by PR 770

Includes small fixes in files that changed since the merge request was
made.

Also includes a few small indentation fixes.
2020-04-09 13:31:07 -07:00
Jon Siwek
5fe2a57356 Merge remote-tracking branch 'origin/topic/timw/structure-packing'
During merge, changed a bit of how Frame OffsetMap
assignments/contruction were handled to keep parity with old version.

* origin/topic/timw/structure-packing:
  Lazy-initalize some of the fields in Frame to reduce the size of all Frames when they're not used
  Set InternalHashTag to a uint16_t so CompositeHash doesn't have a gap in it.
  Mark constants in List constexpr so they don't actually take up space in created objects
  Reorder some class variables to fill in gaps in structure packing
2020-04-08 13:57:44 -07:00
Tim Wojtulewicz
d53c1454c0 Remove 'using namespace std' from SerialTypes.h
This unfortunately cuases a ton of flow-down changes because a lot of other
code was depending on that definition existing. This has a fairly large chance
to break builds of external plugins, considering how many internal ones it broke.
2020-04-07 15:59:59 -07:00
Tim Wojtulewicz
2964093e5d Reorder some class variables to fill in gaps in structure packing
The big hitters:
Dict: Fills in four 4-byte holes in the structure. This shrinks Dictionary from 136 bytes to 114 bytes.
Desc: Fills in a 6-byte hole in the structure. This shrinks ODesc from 152 bytes to 144 bytes.
Frame: Moves and combines 4 bool variables from a few places into one single 4-byte block. This resolves all of the holes at once. This shrinks Frame from 216 bytes to 192 bytes and removes one cache line.
Func: Moves one int32_t variable to fill in a 4-byte hole. This shrinks Func from 112 bytes to 104 bytes.
ID: Moves two bool variables to fill in a 3-byte hole. This leaves behind a 1-byte hole, but removes a 6-byte pad from the end of the structure. This shrinks ID from 144 bytes to 136 bytes.

Other changes:
RuleHdrTest: Fills in one 4-byte hole in the structure. This shrinks RuleHdrTest from 248 bytes to 240 bytes.
RuleEndpointState: Moves one bool variable down in the structure to reduce a 7-byte hole. This unfortunately causes a 3-byte hole later in the structure but there’s no easy way to filll it in. This does shrink RuleEndpointState from 128 bytes to 120 bytes though.
ScannedFile: Moves two bool values to reduce a 4-byte hole by 2 bytes. This shrinks ScannedFile from 64 bytes to 56 bytes.
Brofiler: Moves one char value to reduce a 4-byte hole by 1 byte. This shrinks Brofiler from 96 bytes to 88 bytes and removes one cache line.
DbgBreakpoint: Moves some values around to fill in a 4-byte hole and reduce a second. A 2-byte hole still exists, but the structure shrinks from 632 bytes to 624 bytes. It’s possible on this one that one of the int32_t values could be an int16_t and remove the last 2-byte gap.
ParseLocationRec: Moves one int to fill in a 4-byte hole. This shrinks ParseLocationRec from 32 bytes to 24 bytes.
DebugCmdInfo: Moves one bool variable to shift a few others up. This results in a 6-byte pad at the end of the structure but removes a 7-byte hole in the middle. This shrinks DebugCmdInfo from 56 bytes to 48 bytes.
FragReassembler: Moves one variable down to fill in a 4-byte hole. This shrinks FragReassembler from 272 bytes to 264 bytes.
nb_dns_result: Moves ones uint32_t variable to fill in a 4-byte hole, also removing a 4-byte pad from the end of the structure. This shrinks nb_dns_result from 32 bytes to 24 bytes.
nb_dns_entry: Moves one short value to fill in a 2-byte hole, also removing a 6-byte hole. This shrinks nb_dns_entry from 1064 bytes to 1056 bytes.
2020-04-06 14:07:29 -07:00
Tim Wojtulewicz
4035ec7760 More final markings.
These classes were recommended by gcc's -Wsugggest-final-types as places where
large numbers of virtual functions could be optimized away.
2020-04-03 18:35:24 -04:00