Skip to content

Commit 92e55f4

Browse files
ummakynesdavem330
authored andcommitted
tcp: don't annotate mark on control socket from tcp_v6_send_response()
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>
1 parent a47b70e commit 92e55f4

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
@@ -176,7 +176,7 @@ int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl_unused
176176
/* Restore final destination back after routing done */
177177
fl6.daddr = sk->sk_v6_daddr;
178178

179-
res = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt),
179+
res = ip6_xmit(sk, skb, &fl6, sk->sk_mark, rcu_dereference(np->opt),
180180
np->tclass);
181181
rcu_read_unlock();
182182
return res;

‎net/ipv6/ip6_output.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
172172
* which are using proper atomic operations or spinlocks.
173173
*/
174174
int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
175-
struct ipv6_txoptions *opt, int tclass)
175+
__u32 mark, struct ipv6_txoptions *opt, int tclass)
176176
{
177177
struct net *net = sock_net(sk);
178178
const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -240,7 +240,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
240240

241241
skb->protocol = htons(ETH_P_IPV6);
242242
skb->priority = sk->sk_priority;
243-
skb->mark = sk->sk_mark;
243+
skb->mark = mark;
244244

245245
mtu = dst_mtu(dst);
246246
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
@@ -469,7 +469,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
469469
opt = ireq->ipv6_opt;
470470
if (!opt)
471471
opt = rcu_dereference(np->opt);
472-
err = ip6_xmit(sk, skb, fl6, opt, np->tclass);
472+
err = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);
473473
rcu_read_unlock();
474474
err = net_xmit_eval(err);
475475
}
@@ -840,8 +840,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
840840
dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
841841
if (!IS_ERR(dst)) {
842842
skb_dst_set(buff, dst);
843-
ctl_sk->sk_mark = fl6.flowi6_mark;
844-
ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
843+
ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);
845844
TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
846845
if (rst)
847846
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)