Skip to contentSkip to conversation

tcp_v4_send_reset: binding oif to iif in no sock case

PATCH In review Shawn Lu 4 participants 9 messages Feb 4, 2012 – Feb 5, 2012 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): RE: [PATCH] tcp: RST: binding oif to iif for tcp v4

Shawn Lu

author
#1 lore raw

PATCH 1/1 tcp_v4_send_reset: binding oif to iif in no sock case

Binding RST packet outgoing interface to incomming interface for tcp v4 when there is no socket associate with it. This has few benefits:
1. tcp_v6_send_reset already did that.

2. This helps tcp connect with SO_BINDTODEVICE set. When connection is lost, we still able to sending out RST using same interface.

3. we are send reply, it is most likely to be succeed if iif is used

---
V2: amend as Eric Dumazet suggested

 net/ipv4/tcp_ipv4.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
net/ipv4/tcp_ipv4.c +6 -0
index 90e4793..f2fde8d 100644
@@ -676,6 +676,12 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
 				      arg.iov[0].iov_len, IPPROTO_TCP, 0);
 	arg.csumoffset = offsetof(struct tcphdr, check) / 2;
 	arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK : 0;
+	/*
+	 * When socket is gone, all binding information is lost.
+	 * routing might fail in this case. using iif for oif to
+	 * make sure we can deliver it
+	 */
+	arg.bound_dev_if = sk ? sk->sk_bound_dev_if : inet_iif(skb);
 
 	net = dev_net(skb_dst(skb)->dev);
 	arg.tos = ip_hdr(skb)->tos;
Signature · 1 line
1.7.0.4
maintainer
#2 lore raw

From: Shawn Lu <[email protected]>
Date: Sat, 4 Feb 2012 13:22:36 -0800

net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) · line 683

Quoted 5 lines
net/ipv4/tcp_ipv4.c +5 -0
+	/*
+	 * When socket is gone, all binding information is lost.
+	 * routing might fail in this case. using iif for oif to
+	 * make sure we can deliver it
+	 */

Comment is poorly formatted, and I'm getting tired of teaching people

	/* That comments are formatted like
	 * this.
	 */

	/*
	 * Not like this.
	 */

or do you have infinite vertical lines on your monitor so that this empty "/*" line has no impact on your screen real estate like it does for the rest of us?

author
#3 lore raw

Sorry, will resubmit with right format.

Quoted 31 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Saturday, February 04, 2012 1:26 PM
To: Shawn Lu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tcp_v4_send_reset: binding oif to iif in no sock case

From: Shawn Lu <[email protected]>
Date: Sat, 4 Feb 2012 13:22:36 -0800

net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) · line 683

Quoted 5 lines
net/ipv4/tcp_ipv4.c +5 -0
+	/*
+	 * When socket is gone, all binding information is lost.
+	 * routing might fail in this case. using iif for oif to
+	 * make sure we can deliver it
+	 */

Comment is poorly formatted, and I'm getting tired of teaching people

	/* That comments are formatted like
	 * this.
	 */

	/*
	 * Not like this.
	 */

or do you have infinite vertical lines on your monitor so that this empty "/*" line has no impact on your screen real estate like it does for the rest of us?

#4 lore raw

PATCH 1/1 CodingStyle: Add net and drivers/net preferred commenting style

In reply to David Miller

Perhaps adding something to CodingStyle is useful?

---

 Documentation/CodingStyle |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
Documentation/CodingStyle +8 -0
index 2b90d32..65e82e4 100644
@@ -454,6 +454,14 @@ The preferred style for long (multi-line) comments is:
 	 * with beginning and ending almost-blank lines.
 	 */
 
+Unless the files are in net or drivers/net where David Miller
+prefers the vertically shorter:
+
+	 /* This is the preferred style for multi-line
+	  * comments in the net and drivers/net directories.
+	  * Please use it consistently.
+	  */
+
 It's also important to comment data, whether they are basic types or derived
 types.  To this end, use just one data declaration per line (no commas for
 multiple data declarations).  This leaves you room for a small comment on each
maintainer
#5 lore raw

Re: [PATCH] CodingStyle: Add net and drivers/net preferred commenting style

From: Joe Perches <[email protected]>
Date: Sat, 04 Feb 2012 13:34:43 -0800

Quoted 1 line

Perhaps adding something to CodingStyle is useful?

Come on, get real.

#6 lore raw

Re: [PATCH] CodingStyle: Add net and drivers/net preferred commenting style

Quoted 4 lines · David Miller

From: Joe Perches <[email protected]>
Date: Sat, 04 Feb 2012 13:34:43 -0800

Quoted 1 line

Perhaps adding something to CodingStyle is useful?

Come on, get real.

;)

I'm trying to get you to understand that your commenting style is not what's in CodingStyle and that you are a bit of an outlier for using it.

You can repeat it again and again on the list, but not everyone reads it.

Notice I didn't sign it either, but I suppose checkpatch could always add something instead...

cheers, Joe

maintainer
#7 lore raw

Re: [PATCH] CodingStyle: Add net and drivers/net preferred commenting style

From: Joe Perches <[email protected]>
Date: Sat, 04 Feb 2012 13:50:59 -0800

Quoted 12 lines · David Miller
Quoted 4 lines

From: Joe Perches <[email protected]>
Date: Sat, 04 Feb 2012 13:34:43 -0800

Quoted 1 line

Perhaps adding something to CodingStyle is useful?

Come on, get real.

;)

I'm trying to get you to understand that your
commenting style is not what's in CodingStyle
and that you are a bit of an outlier for using
it.

So do you think my way is superior or inferior to the CodingStyle suggestion?

Explain.

If you think my way is better, then submit a patch to change it for everyone, not just networking.

#8 lore raw

Re: [PATCH] CodingStyle: Add net and drivers/net preferred commenting style

Quoted 7 lines · David Miller

From: Joe Perches <[email protected]>

Quoted 4 lines

I'm trying to get you to understand that your
commenting style is not what's in CodingStyle
and that you are a bit of an outlier for using
it.

So do you think my way is superior or inferior to the CodingStyle suggestion?

I think it doesn't matter enough to care about it
and I generally use relatively height limited
screens (100x 50y or so).

cheers, Joe

#9 lore raw
In reply to David Miller
Quoted 12 lines · David Miller

From: Shawn Lu<[email protected]>
Date: Sat, 4 Feb 2012 13:22:36 -0800

net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) · line 683

Quoted 5 lines
net/ipv4/tcp_ipv4.c +5 -0
+	/*
+	 * When socket is gone, all binding information is lost.
+	 * routing might fail in this case. using iif for oif to
+	 * make sure we can deliver it
+	 */

Comment is poorly formatted, and I'm getting tired of teaching people

Quoted 7 lines
	/* That comments are formatted like
	 * this.
	 */

	/*
	 * Not like this.
	 */

I agree with your taste in comments, but the linux style guide says basically the opposite. Maybe see if you can sneak a patch into the style guide? :)

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com