Skip to contentSkip to conversation

TCP minisock tcp_create_openreq_child() typo?

DISCUSSION Applied KOVACS Krisztian 3 participants 3 messages Feb 28, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

While reading TCP minisock code I've found this suspiciously looking
code fragment:

- 8< -
struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb)

{
	struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);

	if (newsk != NULL) {
		const struct inet_request_sock *ireq = inet_rsk(req);
		struct tcp_request_sock *treq = tcp_rsk(req);
		struct inet_connection_sock *newicsk = inet_csk(sk);
		struct tcp_sock *newtp;

- 8< -

The above code initializes newicsk to inet_csk(sk), isn't that supposed
to be inet_csk(newsk)? As far as I can tell this might leave icsk_ack.last_seg_size zero even if we do have received data.

Signature · 2 lines
 Regards,
  Krisztian Kovacs
#1 lore raw
Quoted 16 lines · KOVACS Krisztian

Hi,

While reading TCP minisock code I've found this suspiciously looking
code fragment:

- 8< -
struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb)

{
        struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);

        if (newsk != NULL) {
                const struct inet_request_sock *ireq = inet_rsk(req);
                struct tcp_request_sock *treq = tcp_rsk(req);
                struct inet_connection_sock *newicsk = inet_csk(sk);
                struct tcp_sock *newtp;
Quoted 5 lines

- 8< -

The above code initializes newicsk to inet_csk(sk), isn't that supposed
to be inet_csk(newsk)? As far as I can tell this might leave icsk_ack.last_seg_size zero even if we do have received data.

Good catch!

David, please apply the attached patch.

Thanks Krisztian!

- Arnaldo

net/ipv4/tcp_minisocks.c +1 -1
index 30b1e52..6b5c64f 100644
@@ -381,7 +381,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
 	if (newsk != NULL) {
 		const struct inet_request_sock *ireq = inet_rsk(req);
 		struct tcp_request_sock *treq = tcp_rsk(req);
-		struct inet_connection_sock *newicsk = inet_csk(sk);
+		struct inet_connection_sock *newicsk = inet_csk(newsk);
 		struct tcp_sock *newtp;
 
 		/* Now setup tcp_sock */
maintainer Applied
#2 lore raw

From: "Arnaldo Carvalho de Melo" <[email protected]>
Date: Wed, 28 Feb 2007 09:10:10 -0300

Quoted 23 lines · KOVACS Krisztian
Quoted 16 lines

Hi,

While reading TCP minisock code I've found this suspiciously looking
code fragment:

- 8< -
struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb)

{
        struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);

        if (newsk != NULL) {
                const struct inet_request_sock *ireq = inet_rsk(req);
                struct tcp_request_sock *treq = tcp_rsk(req);
                struct inet_connection_sock *newicsk = inet_csk(sk);
                struct tcp_sock *newtp;
Quoted 5 lines

- 8< -

The above code initializes newicsk to inet_csk(sk), isn't that supposed
to be inet_csk(newsk)? As far as I can tell this might leave icsk_ack.last_seg_size zero even if we do have received data.

Quoted 5 lines

Good catch!

David, please apply the attached patch.

Applied, thanks everyone.