diff options
author | Mitsuru KANDA <mk@linux-ipv6.org> | 2005-09-18 03:30:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-09-18 03:30:08 -0400 |
commit | 987905ded3d19c196dae25cac46c569cac9594b8 (patch) | |
tree | 2a4b28b00e11ad15386dd9d5559e7be871e83ee2 /net/ipv6 | |
parent | 40abc27066c49b2c13c817154d438431b0303b96 (diff) |
[IPV6]: Check connect(2) status for IPv6 UDP socket (Re: xfrm_lookup)
I think we should cache the per-socket route(dst_entry) only when the
IPv6 UDP socket is connect(2)'ed.
(which is same as IPv4 UDP send behavior)
Signed-off-by: Mitsuru KANDA <mk@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/udp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 2b9bf9bd177f..6001948600f3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -639,6 +639,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
639 | int tclass = -1; | 639 | int tclass = -1; |
640 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; | 640 | int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; |
641 | int err; | 641 | int err; |
642 | int connected = 0; | ||
642 | 643 | ||
643 | /* destination address check */ | 644 | /* destination address check */ |
644 | if (sin6) { | 645 | if (sin6) { |
@@ -748,6 +749,7 @@ do_udp_sendmsg: | |||
748 | fl->fl_ip_dport = inet->dport; | 749 | fl->fl_ip_dport = inet->dport; |
749 | daddr = &np->daddr; | 750 | daddr = &np->daddr; |
750 | fl->fl6_flowlabel = np->flow_label; | 751 | fl->fl6_flowlabel = np->flow_label; |
752 | connected = 1; | ||
751 | } | 753 | } |
752 | 754 | ||
753 | if (!fl->oif) | 755 | if (!fl->oif) |
@@ -770,6 +772,7 @@ do_udp_sendmsg: | |||
770 | } | 772 | } |
771 | if (!(opt->opt_nflen|opt->opt_flen)) | 773 | if (!(opt->opt_nflen|opt->opt_flen)) |
772 | opt = NULL; | 774 | opt = NULL; |
775 | connected = 0; | ||
773 | } | 776 | } |
774 | if (opt == NULL) | 777 | if (opt == NULL) |
775 | opt = np->opt; | 778 | opt = np->opt; |
@@ -787,10 +790,13 @@ do_udp_sendmsg: | |||
787 | ipv6_addr_copy(&final, &fl->fl6_dst); | 790 | ipv6_addr_copy(&final, &fl->fl6_dst); |
788 | ipv6_addr_copy(&fl->fl6_dst, rt0->addr); | 791 | ipv6_addr_copy(&fl->fl6_dst, rt0->addr); |
789 | final_p = &final; | 792 | final_p = &final; |
793 | connected = 0; | ||
790 | } | 794 | } |
791 | 795 | ||
792 | if (!fl->oif && ipv6_addr_is_multicast(&fl->fl6_dst)) | 796 | if (!fl->oif && ipv6_addr_is_multicast(&fl->fl6_dst)) { |
793 | fl->oif = np->mcast_oif; | 797 | fl->oif = np->mcast_oif; |
798 | connected = 0; | ||
799 | } | ||
794 | 800 | ||
795 | err = ip6_dst_lookup(sk, &dst, fl); | 801 | err = ip6_dst_lookup(sk, &dst, fl); |
796 | if (err) | 802 | if (err) |
@@ -846,7 +852,7 @@ do_append_data: | |||
846 | else if (!corkreq) | 852 | else if (!corkreq) |
847 | err = udp_v6_push_pending_frames(sk, up); | 853 | err = udp_v6_push_pending_frames(sk, up); |
848 | 854 | ||
849 | if (dst) | 855 | if (dst && connected) |
850 | ip6_dst_store(sk, dst, | 856 | ip6_dst_store(sk, dst, |
851 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? | 857 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? |
852 | &np->daddr : NULL); | 858 | &np->daddr : NULL); |