Skip to content

Commit 0d4c19e

Browse files
ummakynesgregkh
authored andcommitted
tcp: don't annotate mark on control socket from tcp_v6_send_response()
commit 92e55f4 upstream. Unlike ipv4, this control socket is shared by all cpus so we cannot use it as scratchpad area to annotate the mark that we pass to ip6_xmit(). Add a new parameter to ip6_xmit() to indicate the mark. The SCTP socket family caches the flowi6 structure in the sctp_transport structure, so we cannot use to carry the mark unless we later on reset it back, which I discarded since it looks ugly to me. Fixes: bf99b4d ("tcp: fix mark propagation with fwmark_reflect enabled") Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0e0751c commit 0d4c19e

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎include/net/ipv6.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
871871
* upper-layer output functions
872872
*/
873873
int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
874-
struct ipv6_txoptions *opt, int tclass);
874+
__u32 mark, struct ipv6_txoptions *opt, int tclass);
875875

876876
int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
877877

‎net/dccp/ipv6.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req
227227
opt = ireq->ipv6_opt;
228228
if (!opt)
229229
opt = rcu_dereference(np->opt);
230-
err = ip6_xmit(sk, skb, &fl6, opt, np->tclass);
230+
err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);
231231
rcu_read_unlock();
232232
err = net_xmit_eval(err);
233233
}
@@ -281,7 +281,7 @@ static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)
281281
dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
282282
if (!IS_ERR(dst)) {
283283
skb_dst_set(skb, dst);
284-
ip6_xmit(ctl_sk, skb, &fl6, NULL, 0);
284+
ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);
285285
DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
286286
DCCP_INC_STATS(DCCP_MIB_OUTRSTS);
287287
return;

‎net/ipv6/inet6_connection_sock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl_unused
173173
/* Restore final destination back after routing done */
174174
fl6.daddr = sk->sk_v6_daddr;
175175

176-
res = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt),
176+
res = ip6_xmit(sk, skb, &fl6, sk->sk_mark, rcu_dereference(np->opt),
177177
np->tclass);
178178
rcu_read_unlock();
179179
return res;

‎net/ipv6/ip6_output.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
163163
* which are using proper atomic operations or spinlocks.
164164
*/
165165
int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
166-
struct ipv6_txoptions *opt, int tclass)
166+
__u32 mark, struct ipv6_txoptions *opt, int tclass)
167167
{
168168
struct net *net = sock_net(sk);
169169
const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -230,7 +230,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
230230

231231
skb->protocol = htons(ETH_P_IPV6);
232232
skb->priority = sk->sk_priority;
233-
skb->mark = sk->sk_mark;
233+
skb->mark = mark;
234234

235235
mtu = dst_mtu(dst);
236236
if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) {

‎net/ipv6/tcp_ipv6.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
467467
opt = ireq->ipv6_opt;
468468
if (!opt)
469469
opt = rcu_dereference(np->opt);
470-
err = ip6_xmit(sk, skb, fl6, opt, np->tclass);
470+
err = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);
471471
rcu_read_unlock();
472472
err = net_xmit_eval(err);
473473
}
@@ -837,8 +837,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
837837
dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
838838
if (!IS_ERR(dst)) {
839839
skb_dst_set(buff, dst);
840-
ctl_sk->sk_mark = fl6.flowi6_mark;
841-
ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
840+
ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);
842841
TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
843842
if (rst)
844843
TCP_INC_STATS(net, TCP_MIB_OUTRSTS);

‎net/sctp/ipv6.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
222222
SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
223223

224224
rcu_read_lock();
225-
res = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), np->tclass);
225+
res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt),
226+
np->tclass);
226227
rcu_read_unlock();
227228
return res;
228229
}

0 commit comments

Comments
 (0)