diff --git a/core/gate_hooks/tcpdump.cc b/core/gate_hooks/tcpdump.cc index c58a71017..fb01ccf10 100644 --- a/core/gate_hooks/tcpdump.cc +++ b/core/gate_hooks/tcpdump.cc @@ -83,15 +83,17 @@ void Tcpdump::ProcessBatch(const bess::PacketBatch *batch) { for (int i = 0; i < batch->cnt(); i++) { bess::Packet *pkt = batch->pkts()[i]; + size_t snaplen = std::min(pkt->head_len(), 2048); + struct pcap_rec_hdr rec = { .ts_sec = (uint32_t)tv.tv_sec, .ts_usec = (uint32_t)tv.tv_usec, - .incl_len = (uint32_t)pkt->head_len(), + .incl_len = (uint32_t)snaplen, .orig_len = (uint32_t)pkt->total_len(), }; struct iovec vec[2] = {{&rec, sizeof(rec)}, - {pkt->head_data(), (size_t)pkt->head_len()}}; + {pkt->head_data(), snaplen}}; int ret = writev(fd, vec, 2); if (ret < 0) { diff --git a/core/modules/flowgen.h b/core/modules/flowgen.h index 990e3b869..e2833d303 100644 --- a/core/modules/flowgen.h +++ b/core/modules/flowgen.h @@ -40,7 +40,7 @@ #include "../utils/endian.h" #include "../utils/random.h" -#define MAX_TEMPLATE_SIZE 1536 +#define MAX_TEMPLATE_SIZE (SNBUF_DATA - 512) typedef std::pair Event; typedef std::priority_queue, std::greater> diff --git a/core/modules/rewrite.h b/core/modules/rewrite.h index d0a154d91..1aad7c8a5 100644 --- a/core/modules/rewrite.h +++ b/core/modules/rewrite.h @@ -37,7 +37,7 @@ class Rewrite final : public Module { public: static const size_t kNumSlots = bess::PacketBatch::kMaxBurst * 2 - 1; - static const size_t kMaxTemplateSize = 1536; + static const size_t kMaxTemplateSize = (SNBUF_DATA - 512); static const Commands cmds; diff --git a/core/snbuf_layout.h b/core/snbuf_layout.h index 598e406ba..f8431a42b 100644 --- a/core/snbuf_layout.h +++ b/core/snbuf_layout.h @@ -56,7 +56,7 @@ #define SNBUF_SCRATCHPAD 64 #define SNBUF_RESERVE (SNBUF_IMMUTABLE + SNBUF_METADATA + SNBUF_SCRATCHPAD) #define SNBUF_HEADROOM 128 -#define SNBUF_DATA 2048 +#define SNBUF_DATA (12 * 1024 - 512) // total: 12K (HEADROOM + DATA) #define SNBUF_MBUF_OFF 0 #define SNBUF_IMMUTABLE_OFF SNBUF_MBUF