]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: use max packet size as snaplen 1473/head
authorEric Leblond <eric@regit.org>
Sun, 25 Jan 2015 19:49:28 +0000 (20:49 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 8 May 2015 09:37:12 +0000 (11:37 +0200)
If default_packet_size is set to 0, then we use the maximum packet
size as snaplen.

src/source-af-packet.c

index 813987959a77ab7fe525c16cccff7a343eb87d9a..718cdbf65456065e7300b01d45f929507a9c7d21 100644 (file)
@@ -1340,6 +1340,15 @@ frame size: TPACKET_ALIGN(snaplen + TPACKET_ALIGN(TPACKET_ALIGN(tp_hdrlen) + siz
     int tp_hdrlen = sizeof(struct tpacket_hdr);
     int snaplen = default_packet_size;
 
+    if (snaplen == 0) {
+        snaplen = GetIfaceMaxPacketSize(ptv->iface);
+        if (snaplen <= 0) {
+            SCLogWarning(SC_ERR_INVALID_VALUE,
+                         "Unable to get MTU, setting snaplen to sane default of 1514");
+            snaplen = 1514;
+        }
+    }
+
     ptv->req.tp_frame_size = TPACKET_ALIGN(snaplen +TPACKET_ALIGN(TPACKET_ALIGN(tp_hdrlen) + sizeof(struct sockaddr_ll) + ETH_HLEN) - ETH_HLEN);
     ptv->req.tp_block_size = getpagesize() << order;
     int frames_per_block = ptv->req.tp_block_size / ptv->req.tp_frame_size;