aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 666b963496ff..4560b291180b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -307,13 +307,13 @@ static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
307static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr, 307static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
308 unsigned int port) 308 unsigned int port)
309{ 309{
310 return jhash_1word(saddr, net_hash_mix(net)) ^ port; 310 return jhash_1word((__force u32)saddr, net_hash_mix(net)) ^ port;
311} 311}
312 312
313int udp_v4_get_port(struct sock *sk, unsigned short snum) 313int udp_v4_get_port(struct sock *sk, unsigned short snum)
314{ 314{
315 unsigned int hash2_nulladdr = 315 unsigned int hash2_nulladdr =
316 udp4_portaddr_hash(sock_net(sk), INADDR_ANY, snum); 316 udp4_portaddr_hash(sock_net(sk), htonl(INADDR_ANY), snum);
317 unsigned int hash2_partial = 317 unsigned int hash2_partial =
318 udp4_portaddr_hash(sock_net(sk), inet_sk(sk)->inet_rcv_saddr, 0); 318 udp4_portaddr_hash(sock_net(sk), inet_sk(sk)->inet_rcv_saddr, 0);
319 319
@@ -466,14 +466,14 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
466 daddr, hnum, dif, 466 daddr, hnum, dif,
467 hslot2, slot2); 467 hslot2, slot2);
468 if (!result) { 468 if (!result) {
469 hash2 = udp4_portaddr_hash(net, INADDR_ANY, hnum); 469 hash2 = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum);
470 slot2 = hash2 & udptable->mask; 470 slot2 = hash2 & udptable->mask;
471 hslot2 = &udptable->hash2[slot2]; 471 hslot2 = &udptable->hash2[slot2];
472 if (hslot->count < hslot2->count) 472 if (hslot->count < hslot2->count)
473 goto begin; 473 goto begin;
474 474
475 result = udp4_lib_lookup2(net, saddr, sport, 475 result = udp4_lib_lookup2(net, saddr, sport,
476 INADDR_ANY, hnum, dif, 476 htonl(INADDR_ANY), hnum, dif,
477 hslot2, slot2); 477 hslot2, slot2);
478 } 478 }
479 rcu_read_unlock(); 479 rcu_read_unlock();
@@ -1062,10 +1062,10 @@ static unsigned int first_packet_length(struct sock *sk)
1062 spin_unlock_bh(&rcvq->lock); 1062 spin_unlock_bh(&rcvq->lock);
1063 1063
1064 if (!skb_queue_empty(&list_kill)) { 1064 if (!skb_queue_empty(&list_kill)) {
1065 lock_sock(sk); 1065 lock_sock_bh(sk);
1066 __skb_queue_purge(&list_kill); 1066 __skb_queue_purge(&list_kill);
1067 sk_mem_reclaim_partial(sk); 1067 sk_mem_reclaim_partial(sk);
1068 release_sock(sk); 1068 unlock_sock_bh(sk);
1069 } 1069 }
1070 return res; 1070 return res;
1071} 1071}
@@ -1196,10 +1196,10 @@ out:
1196 return err; 1196 return err;
1197 1197
1198csum_copy_err: 1198csum_copy_err:
1199 lock_sock(sk); 1199 lock_sock_bh(sk);
1200 if (!skb_kill_datagram(sk, skb, flags)) 1200 if (!skb_kill_datagram(sk, skb, flags))
1201 UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 1201 UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
1202 release_sock(sk); 1202 unlock_sock_bh(sk);
1203 1203
1204 if (noblock) 1204 if (noblock)
1205 return -EAGAIN; 1205 return -EAGAIN;
@@ -1217,7 +1217,7 @@ int udp_disconnect(struct sock *sk, int flags)
1217 sk->sk_state = TCP_CLOSE; 1217 sk->sk_state = TCP_CLOSE;
1218 inet->inet_daddr = 0; 1218 inet->inet_daddr = 0;
1219 inet->inet_dport = 0; 1219 inet->inet_dport = 0;
1220 inet_rps_save_rxhash(sk, 0); 1220 sock_rps_save_rxhash(sk, 0);
1221 sk->sk_bound_dev_if = 0; 1221 sk->sk_bound_dev_if = 0;
1222 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) 1222 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
1223 inet_reset_saddr(sk); 1223 inet_reset_saddr(sk);
@@ -1262,9 +1262,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1262 int rc; 1262 int rc;
1263 1263
1264 if (inet_sk(sk)->inet_daddr) 1264 if (inet_sk(sk)->inet_daddr)
1265 inet_rps_save_rxhash(sk, skb->rxhash); 1265 sock_rps_save_rxhash(sk, skb->rxhash);
1266 1266
1267 rc = sock_queue_rcv_skb(sk, skb); 1267 rc = ip_queue_rcv_skb(sk, skb);
1268 if (rc < 0) { 1268 if (rc < 0) {
1269 int is_udplite = IS_UDPLITE(sk); 1269 int is_udplite = IS_UDPLITE(sk);
1270 1270
@@ -1372,6 +1372,10 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1372 goto drop; 1372 goto drop;
1373 } 1373 }
1374 1374
1375
1376 if (sk_rcvqueues_full(sk, skb))
1377 goto drop;
1378
1375 rc = 0; 1379 rc = 0;
1376 1380
1377 bh_lock_sock(sk); 1381 bh_lock_sock(sk);
@@ -1620,9 +1624,9 @@ int udp_rcv(struct sk_buff *skb)
1620 1624
1621void udp_destroy_sock(struct sock *sk) 1625void udp_destroy_sock(struct sock *sk)
1622{ 1626{
1623 lock_sock(sk); 1627 lock_sock_bh(sk);
1624 udp_flush_pending_frames(sk); 1628 udp_flush_pending_frames(sk);
1625 release_sock(sk); 1629 unlock_sock_bh(sk);
1626} 1630}
1627 1631
1628/* 1632/*