Blame SOURCES/0006-Bound-tpacketv2-to-64k.patch

6730c1
From d8aade59b5787f5d3517fededcd684fe85367afa Mon Sep 17 00:00:00 2001
6730c1
From: rpm-build <rpm-build>
6730c1
Date: Mon, 29 May 2017 11:54:43 +0200
6730c1
Subject: [PATCH] Backport patch to bound tpacketv2 to 64k
6730c1
6730c1
---
6730c1
 pcap-linux.c | 29 ++++++++++++++++++-----------
6730c1
 1 file changed, 18 insertions(+), 11 deletions(-)
6730c1
6730c1
diff --git a/pcap-linux.c b/pcap-linux.c
6730c1
index f7f2aae..d7149d5 100644
6730c1
--- a/pcap-linux.c
6730c1
+++ b/pcap-linux.c
6730c1
@@ -3600,6 +3600,8 @@ prepare_tpacket_socket(pcap_t *handle)
6730c1
 	return 1;
6730c1
 }
6730c1
 
6730c1
+#define MAX(a,b) ((a)>(b)?(a):(b))
6730c1
+
6730c1
 /*
6730c1
  * Attempt to set up memory-mapped access.
6730c1
  *
6730c1
@@ -3674,25 +3676,30 @@ create_ring(pcap_t *handle, int *status)
6730c1
 		 * "packets" bigger than the MTU. */
6730c1
 		frame_size = handle->snapshot;
6730c1
 		if (handle->linktype == DLT_EN10MB) {
6730c1
+                        unsigned int max_frame_len;
6730c1
 			int mtu;
6730c1
 			int offload;
6730c1
 
6730c1
+                        mtu = iface_get_mtu(handle->fd, handle->opt.source,
6730c1
+                                handle->errbuf);
6730c1
+                        if (mtu == -1) {
6730c1
+                            *status = PCAP_ERROR;
6730c1
+                            return -1;
6730c1
+                        }
6730c1
 			offload = iface_get_offload(handle);
6730c1
 			if (offload == -1) {
6730c1
 				*status = PCAP_ERROR;
6730c1
 				return -1;
6730c1
 			}
6730c1
-			if (!offload) {
6730c1
-				mtu = iface_get_mtu(handle->fd, handle->opt.source,
6730c1
-				    handle->errbuf);
6730c1
-				if (mtu == -1) {
6730c1
-					*status = PCAP_ERROR;
6730c1
-					return -1;
6730c1
-				}
6730c1
-				if (frame_size > mtu + 18)
6730c1
-					frame_size = mtu + 18;
6730c1
-			}
6730c1
-		}
6730c1
+                        if (offload)
6730c1
+                            max_frame_len = MAX(mtu, 65535);
6730c1
+                        else
6730c1
+                            max_frame_len = mtu;
6730c1
+                        max_frame_len += 18;
6730c1
+
6730c1
+                        if (frame_size > max_frame_len)
6730c1
+                            frame_size = max_frame_len;
6730c1
+                }
6730c1
 
6730c1
 		/* NOTE: calculus matching those in tpacket_rcv()
6730c1
 		 * in linux-2.6/net/packet/af_packet.c
6730c1
-- 
6730c1
2.13.0
6730c1