From: Sasha Levin Date: Tue, 23 Apr 2019 23:39:24 +0000 (-0400) Subject: replace ipv6 patches on 4.19 X-Git-Tag: v3.18.139~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=803f9fa6f616ed88f1d98e673ad00bf59ceab9dc;p=thirdparty%2Fkernel%2Fstable-queue.git replace ipv6 patches on 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/net-ip-defrag-encapsulate-rbtree-defrag-code-into-ca.patch b/queue-4.19/net-ip-defrag-encapsulate-rbtree-defrag-code-into-ca.patch index fa8cc3e375a..6735805b6ca 100644 --- a/queue-4.19/net-ip-defrag-encapsulate-rbtree-defrag-code-into-ca.patch +++ b/queue-4.19/net-ip-defrag-encapsulate-rbtree-defrag-code-into-ca.patch @@ -1,6 +1,6 @@ -From 7905dc07a3d1aac701694adcb0c0cb4439a47117 Mon Sep 17 00:00:00 2001 +From 55bd1742ee0cf2320e6fd058090b3d46c0eef1cf Mon Sep 17 00:00:00 2001 From: Peter Oskolkov -Date: Mon, 8 Apr 2019 17:10:03 -0700 +Date: Tue, 23 Apr 2019 10:25:31 -0700 Subject: net: IP defrag: encapsulate rbtree defrag code into callable functions @@ -10,18 +10,19 @@ This is a refactoring patch: without changing runtime behavior, it moves rbtree-related code from IPv4-specific files/functions into .h/.c defrag files shared with IPv6 defragmentation code. +v2: make handling of overlapping packets match upstream. + Signed-off-by: Peter Oskolkov Cc: Eric Dumazet Cc: Florian Westphal Cc: Tom Herbert Signed-off-by: David S. Miller -Acked-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/inet_frag.h | 16 ++- - net/ipv4/inet_fragment.c | 293 +++++++++++++++++++++++++++++++++++++++ - net/ipv4/ip_fragment.c | 290 ++++---------------------------------- - 3 files changed, 335 insertions(+), 264 deletions(-) + net/ipv4/inet_fragment.c | 293 +++++++++++++++++++++++++++++++++++++ + net/ipv4/ip_fragment.c | 302 +++++---------------------------------- + 3 files changed, 342 insertions(+), 269 deletions(-) diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 1662cbc0b46b..b02bf737d019 100644 @@ -371,7 +372,7 @@ index 760a9e52e02b..9f69411251d0 100644 +} +EXPORT_SYMBOL(inet_frag_pull_head); diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c -index d95b32af4a0e..15c609e6f12e 100644 +index d95b32af4a0e..5a1d39e32196 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -57,57 +57,6 @@ @@ -478,7 +479,40 @@ index d95b32af4a0e..15c609e6f12e 100644 int err = -ENOENT; u8 ecn; -@@ -414,62 +343,13 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) +@@ -382,7 +311,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) + */ + if (end < qp->q.len || + ((qp->q.flags & INET_FRAG_LAST_IN) && end != qp->q.len)) +- goto err; ++ goto discard_qp; + qp->q.flags |= INET_FRAG_LAST_IN; + qp->q.len = end; + } else { +@@ -394,82 +323,33 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) + if (end > qp->q.len) { + /* Some bits beyond end -> corruption. */ + if (qp->q.flags & INET_FRAG_LAST_IN) +- goto err; ++ goto discard_qp; + qp->q.len = end; + } + } + if (end == offset) +- goto err; ++ goto discard_qp; + + err = -ENOMEM; + if (!pskb_pull(skb, skb_network_offset(skb) + ihl)) +- goto err; ++ goto discard_qp; + + err = pskb_trim_rcsum(skb, end - offset); + if (err) +- goto err; ++ goto discard_qp; + + /* Note : skb->rbnode and skb->dev share the same location. */ + dev = skb->dev; /* Makes sure compiler wont do silly aliasing games */ barrier(); @@ -544,7 +578,15 @@ index d95b32af4a0e..15c609e6f12e 100644 qp->q.stamp = skb->tstamp; qp->q.meat += skb->len; -@@ -500,9 +380,16 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) +@@ -494,15 +374,24 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) + skb->_skb_refdst = 0UL; + err = ip_frag_reasm(qp, skb, prev_tail, dev); + skb->_skb_refdst = orefdst; ++ if (err) ++ inet_frag_kill(&qp->q); + return err; + } + skb_dst_drop(skb); return -EINPROGRESS; @@ -562,7 +604,7 @@ index d95b32af4a0e..15c609e6f12e 100644 err: kfree_skb(skb); return err; -@@ -514,13 +401,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, +@@ -514,13 +403,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, { struct net *net = container_of(qp->q.net, struct net, ipv4.frags); struct iphdr *iph; @@ -578,7 +620,7 @@ index d95b32af4a0e..15c609e6f12e 100644 u8 ecn; ipq_kill(qp); -@@ -530,117 +412,23 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, +@@ -530,117 +414,23 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, err = -EINVAL; goto out_fail; } @@ -602,9 +644,9 @@ index d95b32af4a0e..15c609e6f12e 100644 - consume_skb(head); - head = skb; - } -- -- WARN_ON(head->ip_defrag_offset != 0); +- WARN_ON(head->ip_defrag_offset != 0); +- - /* Allocate a new buffer for the datagram. */ - ihlen = ip_hdrlen(head); - len = ihlen + qp->q.len; @@ -705,7 +747,7 @@ index d95b32af4a0e..15c609e6f12e 100644 iph->tot_len = htons(len); iph->tos |= ecn; -@@ -653,7 +441,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, +@@ -653,7 +443,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, * from one very small df-fragment and one large non-df frag. */ if (qp->max_df_size == qp->q.max_size) { @@ -714,7 +756,7 @@ index d95b32af4a0e..15c609e6f12e 100644 iph->frag_off = htons(IP_DF); } else { iph->frag_off = 0; -@@ -751,28 +539,6 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user) +@@ -751,28 +541,6 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user) } EXPORT_SYMBOL(ip_check_defrag); diff --git a/queue-4.19/net-ip6-defrag-use-rbtrees-for-ipv6-defrag.patch b/queue-4.19/net-ip6-defrag-use-rbtrees-for-ipv6-defrag.patch index 0d802c4bda2..8b8a871c5b2 100644 --- a/queue-4.19/net-ip6-defrag-use-rbtrees-for-ipv6-defrag.patch +++ b/queue-4.19/net-ip6-defrag-use-rbtrees-for-ipv6-defrag.patch @@ -1,6 +1,6 @@ -From a4875906060ceefdd345989aed28133d070053d3 Mon Sep 17 00:00:00 2001 +From 203ae2b2db098f24e3e8f82c1bd3657e58b1400b Mon Sep 17 00:00:00 2001 From: Peter Oskolkov -Date: Mon, 8 Apr 2019 17:10:04 -0700 +Date: Tue, 23 Apr 2019 10:25:32 -0700 Subject: net: IP6 defrag: use rbtrees for IPv6 defrag [ Upstream commit d4289fcc9b16b89619ee1c54f829e05e56de8b9a ] @@ -16,17 +16,18 @@ https://www.spinics.net/lists/netdev/msg543846.html This patch re-uses common IP defragmentation queueing and reassembly code in IPv6, removing the 1280 byte restriction. +v2: change handling of overlaps to match that of upstream. + Signed-off-by: Peter Oskolkov Reported-by: Tom Herbert Cc: Eric Dumazet Cc: Florian Westphal Signed-off-by: David S. Miller -Acked-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/ipv6_frag.h | 11 +- - net/ipv6/reassembly.c | 233 +++++++++++----------------------------- - 2 files changed, 71 insertions(+), 173 deletions(-) + net/ipv6/reassembly.c | 240 +++++++++++----------------------------- + 2 files changed, 75 insertions(+), 176 deletions(-) diff --git a/include/net/ipv6_frag.h b/include/net/ipv6_frag.h index 6ced1e6899b6..28aa9b30aece 100644 @@ -51,7 +52,7 @@ index 6ced1e6899b6..28aa9b30aece 100644 head->dev = dev; diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c -index 7c943392c128..642f9f53b01d 100644 +index 7c943392c128..095825f964e2 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -69,8 +69,8 @@ static u8 ip6_frag_ecn(const struct ipv6hdr *ipv6h) @@ -95,15 +96,34 @@ index 7c943392c128..642f9f53b01d 100644 return -1; } -@@ -170,62 +175,27 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, +@@ -145,7 +150,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, + */ + if (end < fq->q.len || + ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len)) +- goto err; ++ goto discard_fq; + fq->q.flags |= INET_FRAG_LAST_IN; + fq->q.len = end; + } else { +@@ -162,70 +167,35 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, + if (end > fq->q.len) { + /* Some bits beyond end -> corruption. */ + if (fq->q.flags & INET_FRAG_LAST_IN) +- goto err; ++ goto discard_fq; + fq->q.len = end; + } + } + if (end == offset) - goto err; +- goto err; ++ goto discard_fq; + err = -ENOMEM; /* Point into the IP datagram 'data' part. */ if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) - goto err; - +- goto err; +- - if (pskb_trim_rcsum(skb, end - offset)) - goto err; - @@ -134,8 +154,8 @@ index 7c943392c128..642f9f53b01d 100644 - /* Check for overlap with preceding fragment. */ - if (prev && - (prev->ip_defrag_offset + prev->len) > offset) -- goto discard_fq; -- + goto discard_fq; + - /* Look for overlap with succeeding segment. */ - if (next && next->ip_defrag_offset < end) + err = pskb_trim_rcsum(skb, end - offset); @@ -383,7 +403,15 @@ index 7c943392c128..642f9f53b01d 100644 return 1; out_oversize: -@@ -463,10 +357,6 @@ static int ipv6_frag_rcv(struct sk_buff *skb) +@@ -425,6 +319,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, + rcu_read_lock(); + __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); + rcu_read_unlock(); ++ inet_frag_kill(&fq->q); + return -1; + } + +@@ -463,10 +358,6 @@ static int ipv6_frag_rcv(struct sk_buff *skb) return 1; } @@ -394,7 +422,7 @@ index 7c943392c128..642f9f53b01d 100644 iif = skb->dev ? skb->dev->ifindex : 0; fq = fq_find(net, fhdr->identification, hdr, iif); if (fq) { -@@ -484,6 +374,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb) +@@ -484,6 +375,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb) if (prob_offset) { __IP6_INC_STATS(net, __in6_dev_get_safely(skb->dev), IPSTATS_MIB_INHDRERRORS); diff --git a/queue-4.19/net-ip6-defrag-use-rbtrees-in-nf_conntrack_reasm.c.patch b/queue-4.19/net-ip6-defrag-use-rbtrees-in-nf_conntrack_reasm.c.patch index 937e39eec5f..79cbf403b18 100644 --- a/queue-4.19/net-ip6-defrag-use-rbtrees-in-nf_conntrack_reasm.c.patch +++ b/queue-4.19/net-ip6-defrag-use-rbtrees-in-nf_conntrack_reasm.c.patch @@ -1,6 +1,6 @@ -From d1647fd4aa1024ca0c3361080279a663334751b9 Mon Sep 17 00:00:00 2001 +From 15cfb7982a39ac843dbe81ee7ec2ef1a447b24b0 Mon Sep 17 00:00:00 2001 From: Peter Oskolkov -Date: Mon, 8 Apr 2019 17:10:05 -0700 +Date: Tue, 23 Apr 2019 10:25:33 -0700 Subject: net: IP6 defrag: use rbtrees in nf_conntrack_reasm.c [ Upstream commit 997dd96471641e147cb2c33ad54284000d0f5e35 ] @@ -22,7 +22,6 @@ Reported-by: Tom Herbert Cc: Eric Dumazet Cc: Florian Westphal Signed-off-by: David S. Miller -Acked-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nf_conntrack_reasm.c | 260 +++++++-----------------