Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300750
b: refs/heads/master
c: aacd928
h: refs/heads/master
v: v3
  • Loading branch information
Alex Copot authored and David S. Miller committed Apr 14, 2012
1 parent cd4c40d commit 396603b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c72e118334a2590f4f07d9e51490b902c33f5280
refs/heads/master: aacd9289af8b82f5fb01bcdd53d0e3406d1333c7
2 changes: 1 addition & 1 deletion trunk/include/net/inet6_connection_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct sock;
struct sockaddr;

extern int inet6_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb);
const struct inet_bind_bucket *tb, bool relax);

extern struct dst_entry* inet6_csk_route_req(struct sock *sk,
const struct request_sock *req);
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/net/inet_connection_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct inet_connection_sock_af_ops {
#endif
void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
int (*bind_conflict)(const struct sock *sk,
const struct inet_bind_bucket *tb);
const struct inet_bind_bucket *tb, bool relax);
};

/** inet_connection_sock - INET connection oriented sock
Expand Down Expand Up @@ -245,7 +245,7 @@ extern struct request_sock *inet_csk_search_req(const struct sock *sk,
const __be32 raddr,
const __be32 laddr);
extern int inet_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb);
const struct inet_bind_bucket *tb, bool relax);
extern int inet_csk_get_port(struct sock *sk, unsigned short snum);

extern struct dst_entry* inet_csk_route_req(struct sock *sk,
Expand Down
18 changes: 14 additions & 4 deletions trunk/net/ipv4/inet_connection_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void inet_get_local_port_range(int *low, int *high)
EXPORT_SYMBOL(inet_get_local_port_range);

int inet_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb)
const struct inet_bind_bucket *tb, bool relax)
{
struct sock *sk2;
struct hlist_node *node;
Expand All @@ -79,6 +79,14 @@ int inet_csk_bind_conflict(const struct sock *sk,
sk2_rcv_saddr == sk_rcv_saddr(sk))
break;
}
if (!relax && reuse && sk2->sk_reuse &&
sk2->sk_state != TCP_LISTEN) {
const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);

if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
sk2_rcv_saddr == sk_rcv_saddr(sk))
break;
}
}
}
return node != NULL;
Expand Down Expand Up @@ -122,12 +130,13 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
(tb->num_owners < smallest_size || smallest_size == -1)) {
smallest_size = tb->num_owners;
smallest_rover = rover;
if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) {
if (atomic_read(&hashinfo->bsockets) > (high - low) + 1 &&
!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, false)) {
snum = smallest_rover;
goto tb_found;
}
}
if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, false)) {
snum = rover;
goto tb_found;
}
Expand Down Expand Up @@ -178,12 +187,13 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
goto success;
} else {
ret = 1;
if (inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
if (inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb, true)) {
if (sk->sk_reuse && sk->sk_state != TCP_LISTEN &&
smallest_size != -1 && --attempts >= 0) {
spin_unlock(&head->lock);
goto again;
}

goto fail_unlock;
}
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv6/inet6_connection_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <net/inet6_connection_sock.h>

int inet6_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb)
const struct inet_bind_bucket *tb, bool relax)
{
const struct sock *sk2;
const struct hlist_node *node;
Expand Down

0 comments on commit 396603b

Please sign in to comment.