Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / net / rxrpc / connection.c
index 2ba14a75dbbeb94c37d196b4501bbe6025c1ac69..a7c929a9fdca89070c1fa70d4dc9a0b4a4275664 100644 (file)
@@ -58,13 +58,12 @@ static inline int __rxrpc_create_connection(struct rxrpc_peer *peer,
        _enter("%p",peer);
 
        /* allocate and initialise a connection record */
-       conn = kmalloc(sizeof(struct rxrpc_connection), GFP_KERNEL);
+       conn = kzalloc(sizeof(struct rxrpc_connection), GFP_KERNEL);
        if (!conn) {
                _leave(" = -ENOMEM");
                return -ENOMEM;
        }
 
-       memset(conn, 0, sizeof(struct rxrpc_connection));
        atomic_set(&conn->usage, 1);
 
        INIT_LIST_HEAD(&conn->link);
@@ -164,7 +163,7 @@ int rxrpc_create_connection(struct rxrpc_transport *trans,
                conn = list_entry(_p, struct rxrpc_connection, link);
                if (conn->addr.sin_port == candidate->addr.sin_port     &&
                    conn->security_ix   == candidate->security_ix       &&
-                   conn->service_id    == candidate->service_id        && 
+                   conn->service_id    == candidate->service_id        &&
                    conn->in_clientflag == 0)
                        goto found_in_graveyard;
        }
@@ -220,6 +219,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
 {
        struct rxrpc_connection *conn, *candidate = NULL;
        struct list_head *_p;
+       struct sk_buff *pkt = msg->pkt;
        int ret, fresh = 0;
        __be32 x_epoch, x_connid;
        __be16 x_port, x_servid;
@@ -229,10 +229,10 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
        _enter("%p{{%hu}},%u,%hu",
               peer,
               peer->trans->port,
-              ntohs(msg->pkt->h.uh->source),
+              ntohs(pkt->h.uh->source),
               ntohs(msg->hdr.serviceId));
 
-       x_port          = msg->pkt->h.uh->source;
+       x_port          = pkt->h.uh->source;
        x_epoch         = msg->hdr.epoch;
        x_clflag        = msg->hdr.flags & RXRPC_CLIENT_INITIATED;
        x_connid        = htonl(ntohl(msg->hdr.cid) & RXRPC_CIDMASK);
@@ -247,13 +247,13 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_active;
        }
        read_unlock(&peer->conn_lock);
 
-       /* [uncommon case] not active 
+       /* [uncommon case] not active
         * - create a candidate for a new record if an inbound connection
         * - only examine the graveyard for an outbound connection
         */
@@ -267,7 +267,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                /* fill in the specifics */
                candidate->addr.sin_family      = AF_INET;
                candidate->addr.sin_port        = x_port;
-               candidate->addr.sin_addr.s_addr = msg->pkt->nh.iph->saddr;
+               candidate->addr.sin_addr.s_addr = pkt->nh.iph->saddr;
                candidate->in_epoch             = x_epoch;
                candidate->out_epoch            = x_epoch;
                candidate->in_clientflag        = RXRPC_CLIENT_INITIATED;
@@ -286,7 +286,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_active_second_chance;
        }
@@ -299,7 +299,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                    conn->in_epoch              == x_epoch      &&
                    conn->conn_id               == x_connid     &&
                    conn->security_ix           == x_secix      &&
-                   conn->service_id            == x_servid     && 
+                   conn->service_id            == x_servid     &&
                    conn->in_clientflag         == x_clflag)
                        goto found_in_graveyard;
        }
@@ -401,8 +401,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
 
        /* move to graveyard queue */
        _debug("burying connection: {%08x}", ntohl(conn->conn_id));
-       list_del(&conn->link);
-       list_add_tail(&conn->link, &peer->conn_graveyard);
+       list_move_tail(&conn->link, &peer->conn_graveyard);
 
        rxrpc_krxtimod_add_timer(&conn->timeout, rxrpc_conn_timeout * HZ);
 
@@ -535,13 +534,12 @@ int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
                return -EINVAL;
        }
 
-       msg = kmalloc(sizeof(struct rxrpc_message), alloc_flags);
+       msg = kzalloc(sizeof(struct rxrpc_message), alloc_flags);
        if (!msg) {
                _leave(" = -ENOMEM");
                return -ENOMEM;
        }
 
-       memset(msg, 0, sizeof(*msg));
        atomic_set(&msg->usage, 1);
 
        INIT_LIST_HEAD(&msg->link);
@@ -675,6 +673,7 @@ int rxrpc_conn_receive_call_packet(struct rxrpc_connection *conn,
                                   struct rxrpc_message *msg)
 {
        struct rxrpc_message *pmsg;
+       struct dst_entry *dst;
        struct list_head *_p;
        unsigned cix, seq;
        int ret = 0;
@@ -710,10 +709,10 @@ int rxrpc_conn_receive_call_packet(struct rxrpc_connection *conn,
 
        call->pkt_rcv_count++;
 
-       if (msg->pkt->dst && msg->pkt->dst->dev)
+       dst = msg->pkt->dst;
+       if (dst && dst->dev)
                conn->peer->if_mtu =
-                       msg->pkt->dst->dev->mtu -
-                       msg->pkt->dst->dev->hard_header_len;
+                       dst->dev->mtu - dst->dev->hard_header_len;
 
        /* queue on the call in seq order */
        rxrpc_get_message(msg);