aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r--net/ipv6/udp.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e51da8c092fa..8b48512ebf6a 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -138,6 +138,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
138 int peeked; 138 int peeked;
139 int err; 139 int err;
140 int is_udplite = IS_UDPLITE(sk); 140 int is_udplite = IS_UDPLITE(sk);
141 int is_udp4;
141 142
142 if (addr_len) 143 if (addr_len)
143 *addr_len=sizeof(struct sockaddr_in6); 144 *addr_len=sizeof(struct sockaddr_in6);
@@ -158,6 +159,8 @@ try_again:
158 else if (copied < ulen) 159 else if (copied < ulen)
159 msg->msg_flags |= MSG_TRUNC; 160 msg->msg_flags |= MSG_TRUNC;
160 161
162 is_udp4 = (skb->protocol == htons(ETH_P_IP));
163
161 /* 164 /*
162 * If checksum is needed at all, try to do it while copying the 165 * If checksum is needed at all, try to do it while copying the
163 * data. If the data is truncated, or if we only want a partial 166 * data. If the data is truncated, or if we only want a partial
@@ -180,9 +183,14 @@ try_again:
180 if (err) 183 if (err)
181 goto out_free; 184 goto out_free;
182 185
183 if (!peeked) 186 if (!peeked) {
184 UDP6_INC_STATS_USER(sock_net(sk), 187 if (is_udp4)
185 UDP_MIB_INDATAGRAMS, is_udplite); 188 UDP_INC_STATS_USER(sock_net(sk),
189 UDP_MIB_INDATAGRAMS, is_udplite);
190 else
191 UDP6_INC_STATS_USER(sock_net(sk),
192 UDP_MIB_INDATAGRAMS, is_udplite);
193 }
186 194
187 sock_recv_timestamp(msg, sk, skb); 195 sock_recv_timestamp(msg, sk, skb);
188 196
@@ -196,7 +204,7 @@ try_again:
196 sin6->sin6_flowinfo = 0; 204 sin6->sin6_flowinfo = 0;
197 sin6->sin6_scope_id = 0; 205 sin6->sin6_scope_id = 0;
198 206
199 if (skb->protocol == htons(ETH_P_IP)) 207 if (is_udp4)
200 ipv6_addr_set(&sin6->sin6_addr, 0, 0, 208 ipv6_addr_set(&sin6->sin6_addr, 0, 0,
201 htonl(0xffff), ip_hdr(skb)->saddr); 209 htonl(0xffff), ip_hdr(skb)->saddr);
202 else { 210 else {
@@ -207,7 +215,7 @@ try_again:
207 } 215 }
208 216
209 } 217 }
210 if (skb->protocol == htons(ETH_P_IP)) { 218 if (is_udp4) {
211 if (inet->cmsg_flags) 219 if (inet->cmsg_flags)
212 ip_cmsg_recv(msg, skb); 220 ip_cmsg_recv(msg, skb);
213 } else { 221 } else {
@@ -228,8 +236,14 @@ out:
228 236
229csum_copy_err: 237csum_copy_err:
230 lock_sock(sk); 238 lock_sock(sk);
231 if (!skb_kill_datagram(sk, skb, flags)) 239 if (!skb_kill_datagram(sk, skb, flags)) {
232 UDP6_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 240 if (is_udp4)
241 UDP_INC_STATS_USER(sock_net(sk),
242 UDP_MIB_INERRORS, is_udplite);
243 else
244 UDP6_INC_STATS_USER(sock_net(sk),
245 UDP_MIB_INERRORS, is_udplite);
246 }
233 release_sock(sk); 247 release_sock(sk);
234 248
235 if (flags & MSG_DONTWAIT) 249 if (flags & MSG_DONTWAIT)
@@ -328,7 +342,7 @@ drop:
328 return -1; 342 return -1;
329} 343}
330 344
331static struct sock *udp_v6_mcast_next(struct sock *sk, 345static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk,
332 __be16 loc_port, struct in6_addr *loc_addr, 346 __be16 loc_port, struct in6_addr *loc_addr,
333 __be16 rmt_port, struct in6_addr *rmt_addr, 347 __be16 rmt_port, struct in6_addr *rmt_addr,
334 int dif) 348 int dif)
@@ -340,7 +354,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
340 sk_for_each_from(s, node) { 354 sk_for_each_from(s, node) {
341 struct inet_sock *inet = inet_sk(s); 355 struct inet_sock *inet = inet_sk(s);
342 356
343 if (sock_net(s) != sock_net(sk)) 357 if (!net_eq(sock_net(s), net))
344 continue; 358 continue;
345 359
346 if (s->sk_hash == num && s->sk_family == PF_INET6) { 360 if (s->sk_hash == num && s->sk_family == PF_INET6) {
@@ -383,14 +397,14 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
383 read_lock(&udp_hash_lock); 397 read_lock(&udp_hash_lock);
384 sk = sk_head(&udptable[udp_hashfn(net, ntohs(uh->dest))]); 398 sk = sk_head(&udptable[udp_hashfn(net, ntohs(uh->dest))]);
385 dif = inet6_iif(skb); 399 dif = inet6_iif(skb);
386 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 400 sk = udp_v6_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif);
387 if (!sk) { 401 if (!sk) {
388 kfree_skb(skb); 402 kfree_skb(skb);
389 goto out; 403 goto out;
390 } 404 }
391 405
392 sk2 = sk; 406 sk2 = sk;
393 while ((sk2 = udp_v6_mcast_next(sk_next(sk2), uh->dest, daddr, 407 while ((sk2 = udp_v6_mcast_next(net, sk_next(sk2), uh->dest, daddr,
394 uh->source, saddr, dif))) { 408 uh->source, saddr, dif))) {
395 struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC); 409 struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC);
396 if (buff) { 410 if (buff) {