aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Westgaard Ry <hans.westgaard.ry@oracle.com>2016-02-03 03:26:57 -0500
committerDavid S. Miller <davem@davemloft.net>2016-02-09 04:28:06 -0500
commit5f74f82ea34c0da80ea0b49192bb5ea06e063593 (patch)
treed0c5e30a637a99cb780e47193167c3a8aa655659
parent9cf7490360bf2c46a16b7525f899e4970c5fc144 (diff)
net:Add sysctl_max_skb_frags
Devices may have limits on the number of fragments in an skb they support. Current codebase uses a constant as maximum for number of fragments one skb can hold and use. When enabling scatter/gather and running traffic with many small messages the codebase uses the maximum number of fragments and may thereby violate the max for certain devices. The patch introduces a global variable as max number of fragments. Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com> Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/skbuff.h1
-rw-r--r--net/core/skbuff.c2
-rw-r--r--net/core/sysctl_net_core.c10
-rw-r--r--net/ipv4/tcp.c4
4 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 11f935c1a090..4ce9ff7086f4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -299,6 +299,7 @@ struct sk_buff;
299#else 299#else
300#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1) 300#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1)
301#endif 301#endif
302extern int sysctl_max_skb_frags;
302 303
303typedef struct skb_frag_struct skb_frag_t; 304typedef struct skb_frag_struct skb_frag_t;
304 305
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b2df375ec9c2..5bf88f58bee7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -79,6 +79,8 @@
79 79
80struct kmem_cache *skbuff_head_cache __read_mostly; 80struct kmem_cache *skbuff_head_cache __read_mostly;
81static struct kmem_cache *skbuff_fclone_cache __read_mostly; 81static struct kmem_cache *skbuff_fclone_cache __read_mostly;
82int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
83EXPORT_SYMBOL(sysctl_max_skb_frags);
82 84
83/** 85/**
84 * skb_panic - private function for out-of-line support 86 * skb_panic - private function for out-of-line support
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 95b6139d710c..a6beb7b6ae55 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -26,6 +26,7 @@ static int zero = 0;
26static int one = 1; 26static int one = 1;
27static int min_sndbuf = SOCK_MIN_SNDBUF; 27static int min_sndbuf = SOCK_MIN_SNDBUF;
28static int min_rcvbuf = SOCK_MIN_RCVBUF; 28static int min_rcvbuf = SOCK_MIN_RCVBUF;
29static int max_skb_frags = MAX_SKB_FRAGS;
29 30
30static int net_msg_warn; /* Unused, but still a sysctl */ 31static int net_msg_warn; /* Unused, but still a sysctl */
31 32
@@ -392,6 +393,15 @@ static struct ctl_table net_core_table[] = {
392 .mode = 0644, 393 .mode = 0644,
393 .proc_handler = proc_dointvec 394 .proc_handler = proc_dointvec
394 }, 395 },
396 {
397 .procname = "max_skb_frags",
398 .data = &sysctl_max_skb_frags,
399 .maxlen = sizeof(int),
400 .mode = 0644,
401 .proc_handler = proc_dointvec_minmax,
402 .extra1 = &one,
403 .extra2 = &max_skb_frags,
404 },
395 { } 405 { }
396}; 406};
397 407
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 19746b3fcbbe..0c36ef4a3f86 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -940,7 +940,7 @@ new_segment:
940 940
941 i = skb_shinfo(skb)->nr_frags; 941 i = skb_shinfo(skb)->nr_frags;
942 can_coalesce = skb_can_coalesce(skb, i, page, offset); 942 can_coalesce = skb_can_coalesce(skb, i, page, offset);
943 if (!can_coalesce && i >= MAX_SKB_FRAGS) { 943 if (!can_coalesce && i >= sysctl_max_skb_frags) {
944 tcp_mark_push(tp, skb); 944 tcp_mark_push(tp, skb);
945 goto new_segment; 945 goto new_segment;
946 } 946 }
@@ -1213,7 +1213,7 @@ new_segment:
1213 1213
1214 if (!skb_can_coalesce(skb, i, pfrag->page, 1214 if (!skb_can_coalesce(skb, i, pfrag->page,
1215 pfrag->offset)) { 1215 pfrag->offset)) {
1216 if (i == MAX_SKB_FRAGS || !sg) { 1216 if (i == sysctl_max_skb_frags || !sg) {
1217 tcp_mark_push(tp, skb); 1217 tcp_mark_push(tp, skb);
1218 goto new_segment; 1218 goto new_segment;
1219 } 1219 }