summaryrefslogtreecommitdiffstats
path: root/ring.c
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-09-26 01:27:34 +0900
committerSteve Kondik <steve@cyngn.com>2016-06-08 21:15:23 -0700
commitbee83f8d7edb48a1d8b8f2333a1b259854c44b95 (patch)
tree4b32117a26b25295f155ac185b3eca0ec26396c2 /ring.c
parent4f99df509e1e6626967aa8bb394045932e75576b (diff)
downloadandroid_external_android-clat-cm-13.0.tar.gz
android_external_android-clat-cm-13.0.tar.bz2
android_external_android-clat-cm-13.0.zip
Add a "packet_burst" config option that will cause clatd to read (and write) in bursts of up to that number of packets, instead of always only reading one packet at a time. This reduces poll overhead and improves performance. The variable is initially set to 10. Bug: 24113287 Change-Id: I7feba4127538c5a89f92e0ebea1fb75971d6b901
Diffstat (limited to 'ring.c')
-rw-r--r--ring.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ring.c b/ring.c
index 17f8026..dcf4310 100644
--- a/ring.c
+++ b/ring.c
@@ -24,6 +24,7 @@
#include <linux/if.h>
#include <linux/if_packet.h>
+#include "config.h"
#include "logging.h"
#include "ring.h"
#include "translate.h"
@@ -116,9 +117,10 @@ static struct tpacket2_hdr* ring_advance(struct packet_ring *ring) {
* to_ipv6 - whether the packet is to be translated to ipv6 or ipv4
*/
void ring_read(struct packet_ring *ring, int write_fd, int to_ipv6) {
+ int numread = 0;
struct tpacket2_hdr *tp = ring->next;
uint16_t val = TP_CSUM_NONE;
- if (tp->tp_status & TP_STATUS_USER) {
+ while (tp->tp_status & TP_STATUS_USER && numread++ < Global_Clatd_Config.packet_burst) {
//We expect only GRO coalesced packets to have TP_STATUS_CSUMNOTREADY
//(ip_summed = CHECKSUM_PARTIAL) in this path. Note that these packets have already gone
//through checksum validation in GRO engine. CHECKSUM_PARTIAL is defined to be 3 while