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

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