diff options
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r-- | net/ipv6/udp.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 15e5195549cb..ccf2f4d196be 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * UDP over IPv6 | 2 | * UDP over IPv6 |
3 | * Linux INET6 implementation | 3 | * Linux INET6 implementation |
4 | * | 4 | * |
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * Based on linux/ipv4/udp.c | 8 | * Based on linux/ipv4/udp.c |
9 | * | 9 | * |
@@ -67,11 +67,11 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport, | |||
67 | unsigned short hnum = ntohs(dport); | 67 | unsigned short hnum = ntohs(dport); |
68 | int badness = -1; | 68 | int badness = -1; |
69 | 69 | ||
70 | read_lock(&udp_hash_lock); | 70 | read_lock(&udp_hash_lock); |
71 | sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { | 71 | sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { |
72 | struct inet_sock *inet = inet_sk(sk); | 72 | struct inet_sock *inet = inet_sk(sk); |
73 | 73 | ||
74 | if (inet->num == hnum && sk->sk_family == PF_INET6) { | 74 | if (sk->sk_hash == hnum && sk->sk_family == PF_INET6) { |
75 | struct ipv6_pinfo *np = inet6_sk(sk); | 75 | struct ipv6_pinfo *np = inet6_sk(sk); |
76 | int score = 0; | 76 | int score = 0; |
77 | if (inet->dport) { | 77 | if (inet->dport) { |
@@ -105,7 +105,7 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport, | |||
105 | } | 105 | } |
106 | if (result) | 106 | if (result) |
107 | sock_hold(result); | 107 | sock_hold(result); |
108 | read_unlock(&udp_hash_lock); | 108 | read_unlock(&udp_hash_lock); |
109 | return result; | 109 | return result; |
110 | } | 110 | } |
111 | 111 | ||
@@ -120,13 +120,13 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
120 | { | 120 | { |
121 | struct ipv6_pinfo *np = inet6_sk(sk); | 121 | struct ipv6_pinfo *np = inet6_sk(sk); |
122 | struct inet_sock *inet = inet_sk(sk); | 122 | struct inet_sock *inet = inet_sk(sk); |
123 | struct sk_buff *skb; | 123 | struct sk_buff *skb; |
124 | size_t copied; | 124 | size_t copied; |
125 | int err, copy_only, is_udplite = IS_UDPLITE(sk); | 125 | int err, copy_only, is_udplite = IS_UDPLITE(sk); |
126 | 126 | ||
127 | if (addr_len) | 127 | if (addr_len) |
128 | *addr_len=sizeof(struct sockaddr_in6); | 128 | *addr_len=sizeof(struct sockaddr_in6); |
129 | 129 | ||
130 | if (flags & MSG_ERRQUEUE) | 130 | if (flags & MSG_ERRQUEUE) |
131 | return ipv6_recv_error(sk, msg, len); | 131 | return ipv6_recv_error(sk, msg, len); |
132 | 132 | ||
@@ -135,11 +135,11 @@ try_again: | |||
135 | if (!skb) | 135 | if (!skb) |
136 | goto out; | 136 | goto out; |
137 | 137 | ||
138 | copied = skb->len - sizeof(struct udphdr); | 138 | copied = skb->len - sizeof(struct udphdr); |
139 | if (copied > len) { | 139 | if (copied > len) { |
140 | copied = len; | 140 | copied = len; |
141 | msg->msg_flags |= MSG_TRUNC; | 141 | msg->msg_flags |= MSG_TRUNC; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * Decide whether to checksum and/or copy data. | 145 | * Decide whether to checksum and/or copy data. |
@@ -168,7 +168,7 @@ try_again: | |||
168 | /* Copy the address. */ | 168 | /* Copy the address. */ |
169 | if (msg->msg_name) { | 169 | if (msg->msg_name) { |
170 | struct sockaddr_in6 *sin6; | 170 | struct sockaddr_in6 *sin6; |
171 | 171 | ||
172 | sin6 = (struct sockaddr_in6 *) msg->msg_name; | 172 | sin6 = (struct sockaddr_in6 *) msg->msg_name; |
173 | sin6->sin6_family = AF_INET6; | 173 | sin6->sin6_family = AF_INET6; |
174 | sin6->sin6_port = skb->h.uh->source; | 174 | sin6->sin6_port = skb->h.uh->source; |
@@ -191,7 +191,7 @@ try_again: | |||
191 | } else { | 191 | } else { |
192 | if (np->rxopt.all) | 192 | if (np->rxopt.all) |
193 | datagram_recv_ctl(sk, msg, skb); | 193 | datagram_recv_ctl(sk, msg, skb); |
194 | } | 194 | } |
195 | 195 | ||
196 | err = copied; | 196 | err = copied; |
197 | if (flags & MSG_TRUNC) | 197 | if (flags & MSG_TRUNC) |
@@ -309,7 +309,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk, | |||
309 | sk_for_each_from(s, node) { | 309 | sk_for_each_from(s, node) { |
310 | struct inet_sock *inet = inet_sk(s); | 310 | struct inet_sock *inet = inet_sk(s); |
311 | 311 | ||
312 | if (inet->num == num && s->sk_family == PF_INET6) { | 312 | if (s->sk_hash == num && s->sk_family == PF_INET6) { |
313 | struct ipv6_pinfo *np = inet6_sk(s); | 313 | struct ipv6_pinfo *np = inet6_sk(s); |
314 | if (inet->dport) { | 314 | if (inet->dport) { |
315 | if (inet->dport != rmt_port) | 315 | if (inet->dport != rmt_port) |
@@ -339,7 +339,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk, | |||
339 | * so we don't need to lock the hashes. | 339 | * so we don't need to lock the hashes. |
340 | */ | 340 | */ |
341 | static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr, | 341 | static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr, |
342 | struct in6_addr *daddr, struct hlist_head udptable[]) | 342 | struct in6_addr *daddr, struct hlist_head udptable[]) |
343 | { | 343 | { |
344 | struct sock *sk, *sk2; | 344 | struct sock *sk, *sk2; |
345 | const struct udphdr *uh = skb->h.uh; | 345 | const struct udphdr *uh = skb->h.uh; |
@@ -379,7 +379,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh) | |||
379 | } | 379 | } |
380 | if (skb->ip_summed == CHECKSUM_COMPLETE && | 380 | if (skb->ip_summed == CHECKSUM_COMPLETE && |
381 | !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr, | 381 | !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr, |
382 | skb->len, IPPROTO_UDP, skb->csum )) | 382 | skb->len, IPPROTO_UDP, skb->csum )) |
383 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 383 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
384 | 384 | ||
385 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) | 385 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) |
@@ -396,7 +396,7 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[], | |||
396 | { | 396 | { |
397 | struct sk_buff *skb = *pskb; | 397 | struct sk_buff *skb = *pskb; |
398 | struct sock *sk; | 398 | struct sock *sk; |
399 | struct udphdr *uh; | 399 | struct udphdr *uh; |
400 | struct net_device *dev = skb->dev; | 400 | struct net_device *dev = skb->dev; |
401 | struct in6_addr *saddr, *daddr; | 401 | struct in6_addr *saddr, *daddr; |
402 | u32 ulen = 0; | 402 | u32 ulen = 0; |
@@ -437,15 +437,15 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[], | |||
437 | goto discard; | 437 | goto discard; |
438 | } | 438 | } |
439 | 439 | ||
440 | /* | 440 | /* |
441 | * Multicast receive code | 441 | * Multicast receive code |
442 | */ | 442 | */ |
443 | if (ipv6_addr_is_multicast(daddr)) | 443 | if (ipv6_addr_is_multicast(daddr)) |
444 | return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable); | 444 | return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable); |
445 | 445 | ||
446 | /* Unicast */ | 446 | /* Unicast */ |
447 | 447 | ||
448 | /* | 448 | /* |
449 | * check socket cache ... must talk to Alan about his plans | 449 | * check socket cache ... must talk to Alan about his plans |
450 | * for sock caches... i'll skip this for now. | 450 | * for sock caches... i'll skip this for now. |
451 | */ | 451 | */ |
@@ -465,21 +465,21 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[], | |||
465 | kfree_skb(skb); | 465 | kfree_skb(skb); |
466 | return(0); | 466 | return(0); |
467 | } | 467 | } |
468 | 468 | ||
469 | /* deliver */ | 469 | /* deliver */ |
470 | 470 | ||
471 | udpv6_queue_rcv_skb(sk, skb); | 471 | udpv6_queue_rcv_skb(sk, skb); |
472 | sock_put(sk); | 472 | sock_put(sk); |
473 | return(0); | 473 | return(0); |
474 | 474 | ||
475 | short_packet: | 475 | short_packet: |
476 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", | 476 | LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", |
477 | is_udplite? "-Lite" : "", ulen, skb->len); | 477 | is_udplite? "-Lite" : "", ulen, skb->len); |
478 | 478 | ||
479 | discard: | 479 | discard: |
480 | UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite); | 480 | UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite); |
481 | kfree_skb(skb); | 481 | kfree_skb(skb); |
482 | return(0); | 482 | return(0); |
483 | } | 483 | } |
484 | 484 | ||
485 | static __inline__ int udpv6_rcv(struct sk_buff **pskb) | 485 | static __inline__ int udpv6_rcv(struct sk_buff **pskb) |
@@ -498,7 +498,7 @@ static void udp_v6_flush_pending_frames(struct sock *sk) | |||
498 | up->len = 0; | 498 | up->len = 0; |
499 | up->pending = 0; | 499 | up->pending = 0; |
500 | ip6_flush_pending_frames(sk); | 500 | ip6_flush_pending_frames(sk); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | /* | 504 | /* |
@@ -594,7 +594,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
594 | if (sk->sk_state != TCP_ESTABLISHED) | 594 | if (sk->sk_state != TCP_ESTABLISHED) |
595 | return -EDESTADDRREQ; | 595 | return -EDESTADDRREQ; |
596 | daddr = &np->daddr; | 596 | daddr = &np->daddr; |
597 | } else | 597 | } else |
598 | daddr = NULL; | 598 | daddr = NULL; |
599 | 599 | ||
600 | if (daddr) { | 600 | if (daddr) { |
@@ -620,7 +620,7 @@ do_udp_sendmsg: | |||
620 | */ | 620 | */ |
621 | if (len > INT_MAX - sizeof(struct udphdr)) | 621 | if (len > INT_MAX - sizeof(struct udphdr)) |
622 | return -EMSGSIZE; | 622 | return -EMSGSIZE; |
623 | 623 | ||
624 | if (up->pending) { | 624 | if (up->pending) { |
625 | /* | 625 | /* |
626 | * There are pending frames. | 626 | * There are pending frames. |
@@ -713,7 +713,7 @@ do_udp_sendmsg: | |||
713 | if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) | 713 | if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) |
714 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); | 714 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); |
715 | fl.fl_ip_sport = inet->sport; | 715 | fl.fl_ip_sport = inet->sport; |
716 | 716 | ||
717 | /* merge ip6_build_xmit from ip6_output */ | 717 | /* merge ip6_build_xmit from ip6_output */ |
718 | if (opt && opt->srcrt) { | 718 | if (opt && opt->srcrt) { |
719 | struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; | 719 | struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; |
@@ -911,7 +911,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket | |||
911 | src->s6_addr32[2], src->s6_addr32[3], srcp, | 911 | src->s6_addr32[2], src->s6_addr32[3], srcp, |
912 | dest->s6_addr32[0], dest->s6_addr32[1], | 912 | dest->s6_addr32[0], dest->s6_addr32[1], |
913 | dest->s6_addr32[2], dest->s6_addr32[3], destp, | 913 | dest->s6_addr32[2], dest->s6_addr32[3], destp, |
914 | sp->sk_state, | 914 | sp->sk_state, |
915 | atomic_read(&sp->sk_wmem_alloc), | 915 | atomic_read(&sp->sk_wmem_alloc), |
916 | atomic_read(&sp->sk_rmem_alloc), | 916 | atomic_read(&sp->sk_rmem_alloc), |
917 | 0, 0L, 0, | 917 | 0, 0L, 0, |