arcbox-net 0.1.4

High-performance network stack for ArcBox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
//! Zero-copy packet representation.
//!
//! This module provides packet structures that reference shared memory directly
//! without copying data, enabling high-performance packet processing.

use std::net::{Ipv4Addr, Ipv6Addr};
use std::sync::atomic::{AtomicU32, Ordering};

/// Network protocol identifier.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[repr(u8)]
pub enum Protocol {
    /// Unknown or unsupported protocol.
    #[default]
    Unknown = 0,
    /// Internet Control Message Protocol.
    Icmp = 1,
    /// Transmission Control Protocol.
    Tcp = 6,
    /// User Datagram Protocol.
    Udp = 17,
    /// ICMPv6.
    Icmpv6 = 58,
}

impl From<u8> for Protocol {
    fn from(value: u8) -> Self {
        match value {
            1 => Self::Icmp,
            6 => Self::Tcp,
            17 => Self::Udp,
            58 => Self::Icmpv6,
            _ => Self::Unknown,
        }
    }
}

/// IP version.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum IpVersion {
    /// Unknown version.
    #[default]
    Unknown = 0,
    /// IPv4.
    V4 = 4,
    /// IPv6.
    V6 = 6,
}

/// Pre-parsed packet metadata for fast path processing.
///
/// Storing parsed header offsets and protocol information avoids
/// repeated parsing in the hot path.
#[repr(C)]
#[derive(Debug, Clone, Copy, Default)]
pub struct PacketMetadata {
    /// Offset to L2 (Ethernet) header from packet start.
    pub l2_offset: u16,
    /// Offset to L3 (IP) header from packet start.
    pub l3_offset: u16,
    /// Offset to L4 (TCP/UDP) header from packet start.
    pub l4_offset: u16,
    /// L4 protocol type.
    pub protocol: Protocol,
    /// IP version.
    pub ip_version: IpVersion,
    /// Cached flow hash for connection tracking lookups.
    pub flow_hash: u64,
    /// Source port (for TCP/UDP).
    pub src_port: u16,
    /// Destination port (for TCP/UDP).
    pub dst_port: u16,
    /// Packet flags (e.g., TCP flags).
    pub flags: u8,
    /// Padding for alignment.
    _padding: [u8; 3],
}

impl PacketMetadata {
    /// Creates empty metadata.
    #[inline]
    #[must_use]
    pub const fn new() -> Self {
        Self {
            l2_offset: 0,
            l3_offset: 0,
            l4_offset: 0,
            protocol: Protocol::Unknown,
            ip_version: IpVersion::Unknown,
            flow_hash: 0,
            src_port: 0,
            dst_port: 0,
            flags: 0,
            _padding: [0; 3],
        }
    }

    /// Returns true if this is a TCP packet.
    #[inline]
    #[must_use]
    pub const fn is_tcp(&self) -> bool {
        matches!(self.protocol, Protocol::Tcp)
    }

    /// Returns true if this is a UDP packet.
    #[inline]
    #[must_use]
    pub const fn is_udp(&self) -> bool {
        matches!(self.protocol, Protocol::Udp)
    }

    /// Returns true if this is an ICMP packet.
    #[inline]
    #[must_use]
    pub const fn is_icmp(&self) -> bool {
        matches!(self.protocol, Protocol::Icmp | Protocol::Icmpv6)
    }
}

/// Zero-copy packet referencing shared memory directly.
///
/// This structure holds a pointer to packet data in guest memory
/// without copying the actual data. The reference count enables
/// safe deferred release after processing.
///
/// # Safety
///
/// The data pointer must remain valid for the lifetime of this packet.
/// The caller is responsible for ensuring the underlying memory is not
/// deallocated or modified while the packet is in use.
///
/// # Cache Line Alignment
///
/// The structure is aligned to 64 bytes to prevent false sharing
/// when packets are processed in parallel.
#[repr(C, align(64))]
pub struct ZeroCopyPacket {
    /// Pointer to packet data in shared memory.
    data: *const u8,
    /// Packet data length in bytes.
    len: u32,
    /// Pre-parsed packet metadata.
    metadata: PacketMetadata,
    /// Reference count for deferred release.
    refcount: AtomicU32,
    /// VirtIO descriptor index for completion.
    desc_idx: u16,
    /// Flags.
    flags: u16,
    /// Timestamp when packet was received (microseconds).
    timestamp: u64,
}

// Safety: The packet data pointer is read-only and can be shared.
unsafe impl Send for ZeroCopyPacket {}
unsafe impl Sync for ZeroCopyPacket {}

impl Default for ZeroCopyPacket {
    fn default() -> Self {
        Self::empty()
    }
}

impl ZeroCopyPacket {
    /// Packet flag: needs checksum calculation.
    pub const FLAG_NEEDS_CSUM: u16 = 1 << 0;
    /// Packet flag: is a GSO packet.
    pub const FLAG_GSO: u16 = 1 << 1;
    /// Packet flag: from guest (TX direction).
    pub const FLAG_FROM_GUEST: u16 = 1 << 2;
    /// Packet flag: to guest (RX direction).
    pub const FLAG_TO_GUEST: u16 = 1 << 3;

    /// Creates an empty packet.
    #[inline]
    #[must_use]
    pub const fn empty() -> Self {
        Self {
            data: std::ptr::null(),
            len: 0,
            metadata: PacketMetadata::new(),
            refcount: AtomicU32::new(0),
            desc_idx: 0,
            flags: 0,
            timestamp: 0,
        }
    }

    /// Creates a new zero-copy packet from raw parts.
    ///
    /// # Safety
    ///
    /// The caller must ensure that:
    /// - `data` points to valid memory for at least `len` bytes.
    /// - The memory remains valid for the lifetime of the packet.
    /// - The memory is not modified while the packet is in use.
    #[inline]
    #[must_use]
    pub const unsafe fn from_raw_parts(data: *const u8, len: u32, desc_idx: u16) -> Self {
        Self {
            data,
            len,
            metadata: PacketMetadata::new(),
            refcount: AtomicU32::new(1),
            desc_idx,
            flags: 0,
            timestamp: 0,
        }
    }

    /// Creates a packet from a slice (for testing/non-zero-copy paths).
    ///
    /// # Safety
    ///
    /// The slice must remain valid for the lifetime of the packet.
    #[inline]
    #[must_use]
    pub const unsafe fn from_slice(data: &[u8], desc_idx: u16) -> Self {
        Self {
            data: data.as_ptr(),
            len: data.len() as u32,
            metadata: PacketMetadata::new(),
            refcount: AtomicU32::new(1),
            desc_idx,
            flags: 0,
            timestamp: 0,
        }
    }

    /// Returns true if this packet is empty.
    #[inline]
    #[must_use]
    pub const fn is_empty(&self) -> bool {
        self.len == 0 || self.data.is_null()
    }

    /// Returns the packet data length.
    #[inline]
    #[must_use]
    pub const fn len(&self) -> usize {
        self.len as usize
    }

    /// Returns the packet data as a slice.
    ///
    /// # Safety
    ///
    /// The caller must ensure the underlying memory is still valid.
    #[inline]
    #[must_use]
    pub unsafe fn as_slice(&self) -> &[u8] {
        if self.data.is_null() {
            &[]
        } else {
            // Safety: caller guarantees memory validity per function contract.
            unsafe { std::slice::from_raw_parts(self.data, self.len as usize) }
        }
    }

    /// Returns the raw data pointer.
    #[inline]
    #[must_use]
    pub const fn data_ptr(&self) -> *const u8 {
        self.data
    }

    /// Returns the descriptor index.
    #[inline]
    #[must_use]
    pub const fn desc_idx(&self) -> u16 {
        self.desc_idx
    }

    /// Returns a reference to the packet metadata.
    #[inline]
    #[must_use]
    pub const fn metadata(&self) -> &PacketMetadata {
        &self.metadata
    }

    /// Returns a mutable reference to the packet metadata.
    #[inline]
    #[must_use]
    pub fn metadata_mut(&mut self) -> &mut PacketMetadata {
        &mut self.metadata
    }

    /// Sets the packet metadata.
    #[inline]
    pub fn set_metadata(&mut self, metadata: PacketMetadata) {
        self.metadata = metadata;
    }

    /// Returns the packet flags.
    #[inline]
    #[must_use]
    pub const fn flags(&self) -> u16 {
        self.flags
    }

    /// Sets packet flags.
    #[inline]
    pub fn set_flags(&mut self, flags: u16) {
        self.flags = flags;
    }

    /// Adds a flag.
    #[inline]
    pub fn add_flag(&mut self, flag: u16) {
        self.flags |= flag;
    }

    /// Checks if a flag is set.
    #[inline]
    #[must_use]
    pub const fn has_flag(&self, flag: u16) -> bool {
        self.flags & flag != 0
    }

    /// Returns the timestamp.
    #[inline]
    #[must_use]
    pub const fn timestamp(&self) -> u64 {
        self.timestamp
    }

    /// Sets the timestamp.
    #[inline]
    pub fn set_timestamp(&mut self, timestamp: u64) {
        self.timestamp = timestamp;
    }

    /// Increments the reference count.
    #[inline]
    pub fn add_ref(&self) {
        self.refcount.fetch_add(1, Ordering::AcqRel);
    }

    /// Decrements the reference count and returns true if it reached zero.
    #[inline]
    pub fn release(&self) -> bool {
        self.refcount.fetch_sub(1, Ordering::AcqRel) == 1
    }

    /// Returns the current reference count.
    #[inline]
    #[must_use]
    pub fn refcount(&self) -> u32 {
        self.refcount.load(Ordering::Acquire)
    }

    /// Parses packet headers and populates metadata.
    ///
    /// # Safety
    ///
    /// The packet data must be valid and accessible.
    pub unsafe fn parse_headers(&mut self) {
        if self.len < 14 {
            return; // Too short for Ethernet header
        }

        // Use raw pointer to avoid borrow conflict with metadata mutation.
        // Safety: caller guarantees data validity per function contract.
        let data = unsafe { std::slice::from_raw_parts(self.data, self.len as usize) };

        // Ethernet header is 14 bytes
        self.metadata.l2_offset = 0;
        self.metadata.l3_offset = 14;

        // Check EtherType
        let ethertype = u16::from_be_bytes([data[12], data[13]]);

        match ethertype {
            0x0800 => {
                // IPv4
                self.metadata.ip_version = IpVersion::V4;
                self.parse_ipv4(data, 14);
            }
            0x86DD => {
                // IPv6
                self.metadata.ip_version = IpVersion::V6;
                self.parse_ipv6(data, 14);
            }
            0x8100 => {
                // VLAN tagged - skip 4 bytes
                self.metadata.l3_offset = 18;
                if self.len >= 18 {
                    let inner_ethertype = u16::from_be_bytes([data[16], data[17]]);
                    match inner_ethertype {
                        0x0800 => {
                            self.metadata.ip_version = IpVersion::V4;
                            self.parse_ipv4(data, 18);
                        }
                        0x86DD => {
                            self.metadata.ip_version = IpVersion::V6;
                            self.parse_ipv6(data, 18);
                        }
                        _ => {}
                    }
                }
            }
            _ => {}
        }

        // Calculate flow hash
        self.metadata.flow_hash = self.calculate_flow_hash();
    }

    /// Parses IPv4 header.
    fn parse_ipv4(&mut self, data: &[u8], offset: usize) {
        if data.len() < offset + 20 {
            return; // Too short for IPv4 header
        }

        let ihl = (data[offset] & 0x0F) as usize * 4;
        self.metadata.l4_offset = (offset + ihl) as u16;
        self.metadata.protocol = Protocol::from(data[offset + 9]);

        // Parse L4 ports for TCP/UDP
        let l4_offset = self.metadata.l4_offset as usize;
        if data.len() >= l4_offset + 4 {
            match self.metadata.protocol {
                Protocol::Tcp | Protocol::Udp => {
                    self.metadata.src_port =
                        u16::from_be_bytes([data[l4_offset], data[l4_offset + 1]]);
                    self.metadata.dst_port =
                        u16::from_be_bytes([data[l4_offset + 2], data[l4_offset + 3]]);

                    // TCP flags
                    if self.metadata.protocol == Protocol::Tcp && data.len() >= l4_offset + 14 {
                        self.metadata.flags = data[l4_offset + 13];
                    }
                }
                _ => {}
            }
        }
    }

    /// Parses IPv6 header.
    fn parse_ipv6(&mut self, data: &[u8], offset: usize) {
        if data.len() < offset + 40 {
            return; // Too short for IPv6 header
        }

        self.metadata.l4_offset = (offset + 40) as u16;
        self.metadata.protocol = Protocol::from(data[offset + 6]); // Next Header

        // Parse L4 ports for TCP/UDP
        let l4_offset = self.metadata.l4_offset as usize;
        if data.len() >= l4_offset + 4 {
            match self.metadata.protocol {
                Protocol::Tcp | Protocol::Udp => {
                    self.metadata.src_port =
                        u16::from_be_bytes([data[l4_offset], data[l4_offset + 1]]);
                    self.metadata.dst_port =
                        u16::from_be_bytes([data[l4_offset + 2], data[l4_offset + 3]]);

                    // TCP flags
                    if self.metadata.protocol == Protocol::Tcp && data.len() >= l4_offset + 14 {
                        self.metadata.flags = data[l4_offset + 13];
                    }
                }
                _ => {}
            }
        }
    }

    /// Calculates a flow hash for connection tracking.
    fn calculate_flow_hash(&self) -> u64 {
        // Simple FNV-1a hash of the 5-tuple
        let mut hash: u64 = 0xcbf2_9ce4_8422_2325;

        hash ^= self.metadata.protocol as u64;
        hash = hash.wrapping_mul(0x0100_0000_01b3);

        hash ^= self.metadata.src_port as u64;
        hash = hash.wrapping_mul(0x0100_0000_01b3);

        hash ^= self.metadata.dst_port as u64;
        hash = hash.wrapping_mul(0x0100_0000_01b3);

        // Include IP addresses if we have them
        unsafe {
            let data = self.as_slice();
            if self.metadata.ip_version == IpVersion::V4 {
                let l3 = self.metadata.l3_offset as usize;
                if data.len() >= l3 + 20 {
                    // Source IP
                    for i in 0..4 {
                        hash ^= data[l3 + 12 + i] as u64;
                        hash = hash.wrapping_mul(0x0100_0000_01b3);
                    }
                    // Dest IP
                    for i in 0..4 {
                        hash ^= data[l3 + 16 + i] as u64;
                        hash = hash.wrapping_mul(0x0100_0000_01b3);
                    }
                }
            } else if self.metadata.ip_version == IpVersion::V6 {
                let l3 = self.metadata.l3_offset as usize;
                if data.len() >= l3 + 40 {
                    // Source IP (16 bytes)
                    for i in 0..16 {
                        hash ^= data[l3 + 8 + i] as u64;
                        hash = hash.wrapping_mul(0x0100_0000_01b3);
                    }
                    // Dest IP (16 bytes)
                    for i in 0..16 {
                        hash ^= data[l3 + 24 + i] as u64;
                        hash = hash.wrapping_mul(0x0100_0000_01b3);
                    }
                }
            }
        }

        hash
    }

    /// Returns the source IPv4 address, if this is an IPv4 packet.
    ///
    /// # Safety
    ///
    /// The packet data must be valid.
    #[must_use]
    pub unsafe fn src_ipv4(&self) -> Option<Ipv4Addr> {
        if self.metadata.ip_version != IpVersion::V4 {
            return None;
        }
        // Safety: caller guarantees data validity per function contract.
        let data = unsafe { self.as_slice() };
        let l3 = self.metadata.l3_offset as usize;
        if data.len() >= l3 + 20 {
            Some(Ipv4Addr::new(
                data[l3 + 12],
                data[l3 + 13],
                data[l3 + 14],
                data[l3 + 15],
            ))
        } else {
            None
        }
    }

    /// Returns the destination IPv4 address, if this is an IPv4 packet.
    ///
    /// # Safety
    ///
    /// The packet data must be valid.
    #[must_use]
    pub unsafe fn dst_ipv4(&self) -> Option<Ipv4Addr> {
        if self.metadata.ip_version != IpVersion::V4 {
            return None;
        }
        // Safety: caller guarantees data validity per function contract.
        let data = unsafe { self.as_slice() };
        let l3 = self.metadata.l3_offset as usize;
        if data.len() >= l3 + 20 {
            Some(Ipv4Addr::new(
                data[l3 + 16],
                data[l3 + 17],
                data[l3 + 18],
                data[l3 + 19],
            ))
        } else {
            None
        }
    }

    /// Returns the source IPv6 address, if this is an IPv6 packet.
    ///
    /// # Safety
    ///
    /// The packet data must be valid.
    #[must_use]
    pub unsafe fn src_ipv6(&self) -> Option<Ipv6Addr> {
        if self.metadata.ip_version != IpVersion::V6 {
            return None;
        }
        // Safety: caller guarantees data validity per function contract.
        let data = unsafe { self.as_slice() };
        let l3 = self.metadata.l3_offset as usize;
        if data.len() >= l3 + 40 {
            let mut octets = [0u8; 16];
            octets.copy_from_slice(&data[l3 + 8..l3 + 24]);
            Some(Ipv6Addr::from(octets))
        } else {
            None
        }
    }

    /// Returns the destination IPv6 address, if this is an IPv6 packet.
    ///
    /// # Safety
    ///
    /// The packet data must be valid.
    #[must_use]
    pub unsafe fn dst_ipv6(&self) -> Option<Ipv6Addr> {
        if self.metadata.ip_version != IpVersion::V6 {
            return None;
        }
        // Safety: caller guarantees data validity per function contract.
        let data = unsafe { self.as_slice() };
        let l3 = self.metadata.l3_offset as usize;
        if data.len() >= l3 + 40 {
            let mut octets = [0u8; 16];
            octets.copy_from_slice(&data[l3 + 24..l3 + 40]);
            Some(Ipv6Addr::from(octets))
        } else {
            None
        }
    }
}

impl std::fmt::Debug for ZeroCopyPacket {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("ZeroCopyPacket")
            .field("data", &self.data)
            .field("len", &self.len)
            .field("metadata", &self.metadata)
            .field("refcount", &self.refcount.load(Ordering::Relaxed))
            .field("desc_idx", &self.desc_idx)
            .field("flags", &self.flags)
            .field("timestamp", &self.timestamp)
            .finish()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_packet_size() {
        // Ensure packet fits in a cache line
        assert!(std::mem::size_of::<ZeroCopyPacket>() <= 128);
        // Ensure alignment
        assert_eq!(std::mem::align_of::<ZeroCopyPacket>(), 64);
    }

    #[test]
    fn test_empty_packet() {
        let pkt = ZeroCopyPacket::empty();
        assert!(pkt.is_empty());
        assert_eq!(pkt.len(), 0);
        assert_eq!(pkt.refcount(), 0);
    }

    #[test]
    fn test_protocol_from() {
        assert_eq!(Protocol::from(1), Protocol::Icmp);
        assert_eq!(Protocol::from(6), Protocol::Tcp);
        assert_eq!(Protocol::from(17), Protocol::Udp);
        assert_eq!(Protocol::from(58), Protocol::Icmpv6);
        assert_eq!(Protocol::from(255), Protocol::Unknown);
    }

    #[test]
    fn test_metadata() {
        let mut meta = PacketMetadata::new();
        meta.protocol = Protocol::Tcp;
        meta.src_port = 12345;
        meta.dst_port = 80;

        assert!(meta.is_tcp());
        assert!(!meta.is_udp());
        assert!(!meta.is_icmp());
    }

    #[test]
    fn test_packet_from_slice() {
        let data = [0u8; 64];
        let pkt = unsafe { ZeroCopyPacket::from_slice(&data, 42) };

        assert!(!pkt.is_empty());
        assert_eq!(pkt.len(), 64);
        assert_eq!(pkt.desc_idx(), 42);
        assert_eq!(pkt.refcount(), 1);
    }

    #[test]
    fn test_refcount() {
        let data = [0u8; 64];
        let pkt = unsafe { ZeroCopyPacket::from_slice(&data, 0) };

        assert_eq!(pkt.refcount(), 1);

        pkt.add_ref();
        assert_eq!(pkt.refcount(), 2);

        assert!(!pkt.release());
        assert_eq!(pkt.refcount(), 1);

        assert!(pkt.release());
        assert_eq!(pkt.refcount(), 0);
    }

    #[test]
    fn test_flags() {
        let mut pkt = ZeroCopyPacket::empty();

        assert_eq!(pkt.flags(), 0);
        assert!(!pkt.has_flag(ZeroCopyPacket::FLAG_NEEDS_CSUM));

        pkt.add_flag(ZeroCopyPacket::FLAG_NEEDS_CSUM);
        assert!(pkt.has_flag(ZeroCopyPacket::FLAG_NEEDS_CSUM));
        assert!(!pkt.has_flag(ZeroCopyPacket::FLAG_GSO));

        pkt.add_flag(ZeroCopyPacket::FLAG_GSO);
        assert!(pkt.has_flag(ZeroCopyPacket::FLAG_NEEDS_CSUM));
        assert!(pkt.has_flag(ZeroCopyPacket::FLAG_GSO));
    }
}