]> err.no Git - linux-2.6/blobdiff - net/ipv4/inet_connection_sock.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[linux-2.6] / net / ipv4 / inet_connection_sock.c
index de5a41de191a675e69701fd5416bda497da62aaf..bb81c958b7447ecc1f7cee2b898ab727756cb927 100644 (file)
@@ -55,6 +55,13 @@ int inet_csk_bind_conflict(const struct sock *sk,
        struct hlist_node *node;
        int reuse = sk->sk_reuse;
 
+       /*
+        * Unlike other sk lookup places we do not check
+        * for sk_net here, since _all_ the socks listed
+        * in tb->owners list belong to the same net - the
+        * one this bucket belongs to.
+        */
+
        sk_for_each_bound(sk2, node, &tb->owners) {
                if (sk != sk2 &&
                    !inet_v6_ipv6only(sk2) &&
@@ -78,16 +85,14 @@ EXPORT_SYMBOL_GPL(inet_csk_bind_conflict);
 /* Obtain a reference to a local port for the given sock,
  * if snum is zero it means select any available local port.
  */
-int inet_csk_get_port(struct inet_hashinfo *hashinfo,
-                     struct sock *sk, unsigned short snum,
-                     int (*bind_conflict)(const struct sock *sk,
-                                          const struct inet_bind_bucket *tb))
+int inet_csk_get_port(struct sock *sk, unsigned short snum)
 {
+       struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
        struct inet_bind_hashbucket *head;
        struct hlist_node *node;
        struct inet_bind_bucket *tb;
        int ret;
-       struct net *net = sk->sk_net;
+       struct net *net = sock_net(sk);
 
        local_bh_disable();
        if (!snum) {
@@ -98,7 +103,8 @@ int inet_csk_get_port(struct inet_hashinfo *hashinfo,
                rover = net_random() % remaining + low;
 
                do {
-                       head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
+                       head = &hashinfo->bhash[inet_bhashfn(net, rover,
+                                       hashinfo->bhash_size)];
                        spin_lock(&head->lock);
                        inet_bind_bucket_for_each(tb, node, &head->chain)
                                if (tb->ib_net == net && tb->port == rover)
@@ -125,7 +131,8 @@ int inet_csk_get_port(struct inet_hashinfo *hashinfo,
                 */
                snum = rover;
        } else {
-               head = &hashinfo->bhash[inet_bhashfn(snum, hashinfo->bhash_size)];
+               head = &hashinfo->bhash[inet_bhashfn(net, snum,
+                               hashinfo->bhash_size)];
                spin_lock(&head->lock);
                inet_bind_bucket_for_each(tb, node, &head->chain)
                        if (tb->ib_net == net && tb->port == snum)
@@ -135,14 +142,12 @@ int inet_csk_get_port(struct inet_hashinfo *hashinfo,
        goto tb_not_found;
 tb_found:
        if (!hlist_empty(&tb->owners)) {
-               if (sk->sk_reuse > 1)
-                       goto success;
                if (tb->fastreuse > 0 &&
                    sk->sk_reuse && sk->sk_state != TCP_LISTEN) {
                        goto success;
                } else {
                        ret = 1;
-                       if (bind_conflict(sk, tb))
+                       if (inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb))
                                goto fail_unlock;
                }
        }
@@ -333,15 +338,16 @@ struct dst_entry* inet_csk_route_req(struct sock *sk,
                            .uli_u = { .ports =
                                       { .sport = inet_sk(sk)->sport,
                                         .dport = ireq->rmt_port } } };
+       struct net *net = sock_net(sk);
 
        security_req_classify_flow(req, &fl);
-       if (ip_route_output_flow(&init_net, &rt, &fl, sk, 0)) {
-               IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
+       if (ip_route_output_flow(net, &rt, &fl, sk, 0)) {
+               IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
                return NULL;
        }
        if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) {
                ip_rt_put(rt);
-               IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
+               IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
                return NULL;
        }
        return &rt->u.dst;
@@ -465,7 +471,7 @@ void inet_csk_reqsk_queue_prune(struct sock *parent,
                        if (time_after_eq(now, req->expires)) {
                                if ((req->retrans < thresh ||
                                     (inet_rsk(req)->acked && req->retrans < max_retries))
-                                   && !req->rsk_ops->rtx_syn_ack(parent, req, NULL)) {
+                                   && !req->rsk_ops->rtx_syn_ack(parent, req)) {
                                        unsigned long timeo;
 
                                        if (req->retrans++ == 0)
@@ -658,25 +664,6 @@ void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr)
 
 EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr);
 
-int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family,
-                            unsigned short type, unsigned char protocol)
-{
-       int rc = sock_create_kern(family, type, protocol, sock);
-
-       if (rc == 0) {
-               (*sock)->sk->sk_allocation = GFP_ATOMIC;
-               inet_sk((*sock)->sk)->uc_ttl = -1;
-               /*
-                * Unhash it so that IP input processing does not even see it,
-                * we do not wish this socket to see incoming packets.
-                */
-               (*sock)->sk->sk_prot->unhash((*sock)->sk);
-       }
-       return rc;
-}
-
-EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create);
-
 #ifdef CONFIG_COMPAT
 int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
                               char __user *optval, int __user *optlen)