Skip to content

Commit ea94ff3

Browse files
krkumardavem330
authored andcommitted
net: Fix for dst_negative_advice
dst_negative_advice() should check for changed dst and reset sk_tx_queue_mapping accordingly. Pass sock to the callers of dst_negative_advice. (sk_reset_txq is defined just for use by dst_negative_advice. The only way I could find to get around this is to move dst_negative_() from dst.h to dst.c, include sock.h in dst.c, etc) Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f04c827 commit ea94ff3

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

include/net/dst.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,19 @@ static inline void dst_confirm(struct dst_entry *dst)
222222
neigh_confirm(dst->neighbour);
223223
}
224224

225-
static inline void dst_negative_advice(struct dst_entry **dst_p)
225+
static inline void dst_negative_advice(struct dst_entry **dst_p,
226+
struct sock *sk)
226227
{
227228
struct dst_entry * dst = *dst_p;
228-
if (dst && dst->ops->negative_advice)
229+
if (dst && dst->ops->negative_advice) {
229230
*dst_p = dst->ops->negative_advice(dst);
231+
232+
if (dst != *dst_p) {
233+
extern void sk_reset_txq(struct sock *sk);
234+
235+
sk_reset_txq(sk);
236+
}
237+
}
230238
}
231239

232240
static inline void dst_link_failure(struct sk_buff *skb)

net/core/sock.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
352352
}
353353
EXPORT_SYMBOL(sk_receive_skb);
354354

355+
void sk_reset_txq(struct sock *sk)
356+
{
357+
sk_tx_queue_clear(sk);
358+
}
359+
EXPORT_SYMBOL(sk_reset_txq);
360+
355361
struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie)
356362
{
357363
struct dst_entry *dst = sk->sk_dst_cache;

net/dccp/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int dccp_write_timeout(struct sock *sk)
3838

3939
if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) {
4040
if (icsk->icsk_retransmits != 0)
41-
dst_negative_advice(&sk->sk_dst_cache);
41+
dst_negative_advice(&sk->sk_dst_cache, sk);
4242
retry_until = icsk->icsk_syn_retries ?
4343
: sysctl_dccp_request_retries;
4444
} else {
@@ -63,7 +63,7 @@ static int dccp_write_timeout(struct sock *sk)
6363
Golden words :-).
6464
*/
6565

66-
dst_negative_advice(&sk->sk_dst_cache);
66+
dst_negative_advice(&sk->sk_dst_cache, sk);
6767
}
6868

6969
retry_until = sysctl_dccp_retries2;

net/decnet/af_decnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
19551955
}
19561956

19571957
if ((flags & MSG_TRYHARD) && sk->sk_dst_cache)
1958-
dst_negative_advice(&sk->sk_dst_cache);
1958+
dst_negative_advice(&sk->sk_dst_cache, sk);
19591959

19601960
mss = scp->segsize_rem;
19611961
fctype = scp->services_rem & NSP_FC_MASK;

net/ipv4/tcp_timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ static int tcp_write_timeout(struct sock *sk)
141141

142142
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
143143
if (icsk->icsk_retransmits)
144-
dst_negative_advice(&sk->sk_dst_cache);
144+
dst_negative_advice(&sk->sk_dst_cache, sk);
145145
retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
146146
} else {
147147
if (retransmits_timed_out(sk, sysctl_tcp_retries1)) {
148148
/* Black hole detection */
149149
tcp_mtu_probing(icsk, sk);
150150

151-
dst_negative_advice(&sk->sk_dst_cache);
151+
dst_negative_advice(&sk->sk_dst_cache, sk);
152152
}
153153

154154
retry_until = sysctl_tcp_retries2;

0 commit comments

Comments
 (0)