mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
build_inner_connection: Avoid one extra Init()
Packet::Init() is not so cheap as one might think: It computes a timestamp from { 0, 0 } using double division. Just avoid this by not initializing an empty Packet.
This commit is contained in:
parent
ec4ad2e80d
commit
d08e347e5e
1 changed files with 2 additions and 3 deletions
|
@ -152,8 +152,6 @@ std::unique_ptr<Packet> build_inner_packet(Packet* outer_pkt, int* encap_index,
|
||||||
std::shared_ptr<EncapsulationStack> encap_stack, uint32_t inner_cap_len,
|
std::shared_ptr<EncapsulationStack> encap_stack, uint32_t inner_cap_len,
|
||||||
const u_char* data, int link_type, BifEnum::Tunnel::Type tunnel_type,
|
const u_char* data, int link_type, BifEnum::Tunnel::Type tunnel_type,
|
||||||
const Tag& analyzer_tag) {
|
const Tag& analyzer_tag) {
|
||||||
auto inner_pkt = std::make_unique<Packet>();
|
|
||||||
|
|
||||||
assert(outer_pkt->cap_len >= inner_cap_len);
|
assert(outer_pkt->cap_len >= inner_cap_len);
|
||||||
assert(outer_pkt->len >= outer_pkt->cap_len - inner_cap_len);
|
assert(outer_pkt->len >= outer_pkt->cap_len - inner_cap_len);
|
||||||
|
|
||||||
|
@ -169,7 +167,8 @@ std::unique_ptr<Packet> build_inner_packet(Packet* outer_pkt, int* encap_index,
|
||||||
pkt_timeval ts;
|
pkt_timeval ts;
|
||||||
ts.tv_sec = static_cast<time_t>(run_state::current_timestamp);
|
ts.tv_sec = static_cast<time_t>(run_state::current_timestamp);
|
||||||
ts.tv_usec = static_cast<suseconds_t>((run_state::current_timestamp - static_cast<double>(ts.tv_sec)) * 1000000);
|
ts.tv_usec = static_cast<suseconds_t>((run_state::current_timestamp - static_cast<double>(ts.tv_sec)) * 1000000);
|
||||||
inner_pkt->Init(link_type, &ts, inner_cap_len, inner_wire_len, data);
|
|
||||||
|
auto inner_pkt = std::make_unique<Packet>(link_type, &ts, inner_cap_len, inner_wire_len, data);
|
||||||
|
|
||||||
*encap_index = 0;
|
*encap_index = 0;
|
||||||
if ( outer_pkt->session ) {
|
if ( outer_pkt->session ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue