diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-01-11 18:53:04 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-11 19:32:13 -0500 |
commit | ae0f7d5f83236a43c572a744e4bbb30e8702d821 (patch) | |
tree | 3d4ce288b86cb2845d79c6adec9e254054bb0e02 /net/ipv6 | |
parent | a7768097557be91d0d4c37e8f2e38cd126c4cdf9 (diff) |
[IPV6]: Avoid calling ip6_xmit() with NULL sk
The ip6_xmit() function now assumes that its sk argument is non-NULL,
which isn't currently true when TCPv6 code is sending RST or ACK
packets. This fixes that code to use a socket of its own for sending
such packets, as TCPv4 does. (Thanks Andi for the pointer).
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index a25f4e8a8ada..66d04004afda 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -67,6 +67,9 @@ | |||
67 | #include <linux/proc_fs.h> | 67 | #include <linux/proc_fs.h> |
68 | #include <linux/seq_file.h> | 68 | #include <linux/seq_file.h> |
69 | 69 | ||
70 | /* Socket used for sending RSTs and ACKs */ | ||
71 | static struct socket *tcp6_socket; | ||
72 | |||
70 | static void tcp_v6_send_reset(struct sk_buff *skb); | 73 | static void tcp_v6_send_reset(struct sk_buff *skb); |
71 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); | 74 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); |
72 | static void tcp_v6_send_check(struct sock *sk, int len, | 75 | static void tcp_v6_send_check(struct sock *sk, int len, |
@@ -611,7 +614,7 @@ static void tcp_v6_send_reset(struct sk_buff *skb) | |||
611 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 614 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
612 | 615 | ||
613 | if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) { | 616 | if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) { |
614 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 617 | ip6_xmit(tcp6_socket->sk, buff, &fl, NULL, 0); |
615 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 618 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
616 | TCP_INC_STATS_BH(TCP_MIB_OUTRSTS); | 619 | TCP_INC_STATS_BH(TCP_MIB_OUTRSTS); |
617 | return; | 620 | return; |
@@ -675,7 +678,7 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 | |||
675 | 678 | ||
676 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { | 679 | if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) { |
677 | if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) { | 680 | if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) { |
678 | ip6_xmit(NULL, buff, &fl, NULL, 0); | 681 | ip6_xmit(tcp6_socket->sk, buff, &fl, NULL, 0); |
679 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); | 682 | TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); |
680 | return; | 683 | return; |
681 | } | 684 | } |
@@ -1600,8 +1603,21 @@ static struct inet_protosw tcpv6_protosw = { | |||
1600 | 1603 | ||
1601 | void __init tcpv6_init(void) | 1604 | void __init tcpv6_init(void) |
1602 | { | 1605 | { |
1606 | int err; | ||
1607 | |||
1603 | /* register inet6 protocol */ | 1608 | /* register inet6 protocol */ |
1604 | if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0) | 1609 | if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0) |
1605 | printk(KERN_ERR "tcpv6_init: Could not register protocol\n"); | 1610 | printk(KERN_ERR "tcpv6_init: Could not register protocol\n"); |
1606 | inet6_register_protosw(&tcpv6_protosw); | 1611 | inet6_register_protosw(&tcpv6_protosw); |
1612 | |||
1613 | err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_TCP, &tcp6_socket); | ||
1614 | if (err < 0) | ||
1615 | panic("Failed to create the TCPv6 control socket.\n"); | ||
1616 | tcp6_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1617 | |||
1618 | /* Unhash it so that IP input processing does not even | ||
1619 | * see it, we do not wish this socket to see incoming | ||
1620 | * packets. | ||
1621 | */ | ||
1622 | tcp6_socket->sk->sk_prot->unhash(tcp6_socket->sk); | ||
1607 | } | 1623 | } |