aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorKonstantin Khorenko <khorenko@virtuozzo.com>2018-08-10 13:11:43 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-11 15:25:15 -0400
commit0d493b4d0be352b5e361e4fa0bc3efe952d8b10e (patch)
treedeb3bba890d034e4bbf323e99060f7c5fe934e6e /include/net
parent05364ca03cfd419caecb292fede20eb39667eaae (diff)
net/sctp: Replace in/out stream arrays with flex_array
This path replaces physically contiguous memory arrays allocated using kmalloc_array() with flexible arrays. This enables to avoid memory allocation failures on the systems under a memory stress. Signed-off-by: Oleg Babin <obabin@virtuozzo.com> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sctp/structs.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 6b2b8df8a1d2..28a7c8e44636 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -57,6 +57,7 @@
57#include <linux/atomic.h> /* This gets us atomic counters. */ 57#include <linux/atomic.h> /* This gets us atomic counters. */
58#include <linux/skbuff.h> /* We need sk_buff_head. */ 58#include <linux/skbuff.h> /* We need sk_buff_head. */
59#include <linux/workqueue.h> /* We need tq_struct. */ 59#include <linux/workqueue.h> /* We need tq_struct. */
60#include <linux/flex_array.h> /* We need flex_array. */
60#include <linux/sctp.h> /* We need sctp* header structs. */ 61#include <linux/sctp.h> /* We need sctp* header structs. */
61#include <net/sctp/auth.h> /* We need auth specific structs */ 62#include <net/sctp/auth.h> /* We need auth specific structs */
62#include <net/ip.h> /* For inet_skb_parm */ 63#include <net/ip.h> /* For inet_skb_parm */
@@ -1438,8 +1439,8 @@ struct sctp_stream_in {
1438}; 1439};
1439 1440
1440struct sctp_stream { 1441struct sctp_stream {
1441 struct sctp_stream_out *out; 1442 struct flex_array *out;
1442 struct sctp_stream_in *in; 1443 struct flex_array *in;
1443 __u16 outcnt; 1444 __u16 outcnt;
1444 __u16 incnt; 1445 __u16 incnt;
1445 /* Current stream being sent, if any */ 1446 /* Current stream being sent, if any */
@@ -1465,14 +1466,14 @@ static inline struct sctp_stream_out *sctp_stream_out(
1465 const struct sctp_stream *stream, 1466 const struct sctp_stream *stream,
1466 __u16 sid) 1467 __u16 sid)
1467{ 1468{
1468 return ((struct sctp_stream_out *)(stream->out)) + sid; 1469 return flex_array_get(stream->out, sid);
1469} 1470}
1470 1471
1471static inline struct sctp_stream_in *sctp_stream_in( 1472static inline struct sctp_stream_in *sctp_stream_in(
1472 const struct sctp_stream *stream, 1473 const struct sctp_stream *stream,
1473 __u16 sid) 1474 __u16 sid)
1474{ 1475{
1475 return ((struct sctp_stream_in *)(stream->in)) + sid; 1476 return flex_array_get(stream->in, sid);
1476} 1477}
1477 1478
1478#define SCTP_SO(s, i) sctp_stream_out((s), (i)) 1479#define SCTP_SO(s, i) sctp_stream_out((s), (i))