]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.11/tcp-fix-mark-propagation-with-fwmark_reflect-enabled.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.11 / tcp-fix-mark-propagation-with-fwmark_reflect-enabled.patch
CommitLineData
6b06d5d7
GKH
1From bf99b4ded5f8a4767dbb9d180626f06c51f9881f Mon Sep 17 00:00:00 2001
2From: Pau Espin Pedrol <pespin.shar@gmail.com>
3Date: Fri, 6 Jan 2017 20:33:28 +0100
4Subject: tcp: fix mark propagation with fwmark_reflect enabled
5
6From: Pau Espin Pedrol <pespin.shar@gmail.com>
7
8commit bf99b4ded5f8a4767dbb9d180626f06c51f9881f upstream.
9
10Otherwise, RST packets generated by the TCP stack for non-existing
11sockets always have mark 0.
12The mark from the original packet is assigned to the netns_ipv4/6
13socket used to send the response so that it can get copied into the
14response skb when the socket sends it.
15
16Fixes: e110861f8609 ("net: add a sysctl to reflect the fwmark on replies")
17Cc: Lorenzo Colitti <lorenzo@google.com>
18Signed-off-by: Pau Espin Pedrol <pau.espin@tessares.net>
19Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 net/ipv4/ip_output.c | 1 +
24 net/ipv6/tcp_ipv6.c | 1 +
25 2 files changed, 2 insertions(+)
26
27--- a/net/ipv4/ip_output.c
28+++ b/net/ipv4/ip_output.c
29@@ -1606,6 +1606,7 @@ void ip_send_unicast_reply(struct sock *
30 sk->sk_protocol = ip_hdr(skb)->protocol;
31 sk->sk_bound_dev_if = arg->bound_dev_if;
32 sk->sk_sndbuf = sysctl_wmem_default;
33+ sk->sk_mark = fl4.flowi4_mark;
34 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base,
35 len, 0, &ipc, &rt, MSG_DONTWAIT);
36 if (unlikely(err)) {
37--- a/net/ipv6/tcp_ipv6.c
38+++ b/net/ipv6/tcp_ipv6.c
39@@ -837,6 +837,7 @@ static void tcp_v6_send_response(const s
40 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
41 if (!IS_ERR(dst)) {
42 skb_dst_set(buff, dst);
43+ ctl_sk->sk_mark = fl6.flowi6_mark;
44 ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
45 TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
46 if (rst)