Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[TCP]: Honour sk_bound_dev_if in tcp_v4_send_ack

A time_wait socket inherits sk_bound_dev_if from the original socket,
but it is not used when sending ACK packets using ip_send_reply.

Fix by passing the oif to ip_send_reply in struct ip_reply_arg and
use it for output routing.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Patrick McHardy and committed by
David S. Miller
f0e48dbf b91b9fd1

+6 -1
+1
include/net/ip.h
··· 143 143 __wsum csum; 144 144 int csumoffset; /* u16 offset of csum in iov[0].iov_base */ 145 145 /* -1 if not needed */ 146 + int bound_dev_if; 146 147 }; 147 148 148 149 void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg,
+3 -1
net/ipv4/ip_output.c
··· 1352 1352 } 1353 1353 1354 1354 { 1355 - struct flowi fl = { .nl_u = { .ip4_u = 1355 + struct flowi fl = { .oif = arg->bound_dev_if, 1356 + .nl_u = { .ip4_u = 1356 1357 { .daddr = daddr, 1357 1358 .saddr = rt->rt_spec_dst, 1358 1359 .tos = RT_TOS(ip_hdr(skb)->tos) } }, ··· 1377 1376 inet->tos = ip_hdr(skb)->tos; 1378 1377 sk->sk_priority = skb->priority; 1379 1378 sk->sk_protocol = ip_hdr(skb)->protocol; 1379 + sk->sk_bound_dev_if = arg->bound_dev_if; 1380 1380 ip_append_data(sk, ip_reply_glue_bits, arg->iov->iov_base, len, 0, 1381 1381 &ipc, rt, MSG_DONTWAIT); 1382 1382 if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
+2
net/ipv4/tcp_ipv4.c
··· 705 705 ip_hdr(skb)->saddr, /* XXX */ 706 706 arg.iov[0].iov_len, IPPROTO_TCP, 0); 707 707 arg.csumoffset = offsetof(struct tcphdr, check) / 2; 708 + if (twsk) 709 + arg.bound_dev_if = twsk->tw_sk.tw_bound_dev_if; 708 710 709 711 ip_send_reply(tcp_socket->sk, skb, &arg, arg.iov[0].iov_len); 710 712