From aaf68cfbf2241d24d46583423f6bff5c47e088b3 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 8 Feb 2007 14:20:30 -0800 Subject: [PATCH] knfsd: fix a race in closing NFSd connections If you lose this race, it can iput a socket inode twice and you get a BUG in fs/inode.c When I added the option for user-space to close a socket, I added some cruft to svc_delete_socket so that I could call that function when closing a socket per user-space request. This was the wrong thing to do. I should have just set SK_CLOSE and let normal mechanisms do the work. Not only wrong, but buggy. The locking is all wrong and it openned up a race where-by a socket could be closed twice. So this patch: Introduces svc_close_socket which sets SK_CLOSE then either leave the close up to a thread, or calls svc_delete_socket if it can get SK_BUSY. Adds a bias to sk_busy which is removed when SK_DEAD is set, This avoid races around shutting down the socket. Changes several 'spin_lock' to 'spin_lock_bh' where the _bh was missing. Bugzilla-url: http://bugzilla.kernel.org/show_bug.cgi?id=7916 Signed-off-by: Neil Brown Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svc.c | 4 ++-- net/sunrpc/svcsock.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 16 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 4c161121111..c1f878131ac 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -386,7 +386,7 @@ svc_destroy(struct svc_serv *serv) svsk = list_entry(serv->sv_tempsocks.next, struct svc_sock, sk_list); - svc_delete_socket(svsk); + svc_close_socket(svsk); } if (serv->sv_shutdown) serv->sv_shutdown(serv); @@ -395,7 +395,7 @@ svc_destroy(struct svc_serv *serv) svsk = list_entry(serv->sv_permsocks.next, struct svc_sock, sk_list); - svc_delete_socket(svsk); + svc_close_socket(svsk); } cache_clean_deferred(serv); diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index ff1f8bf680a..cf93cd1d857 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -62,6 +62,12 @@ * after a clear, the socket must be read/accepted * if this succeeds, it must be set again. * SK_CLOSE can set at any time. It is never cleared. + * sk_inuse contains a bias of '1' until SK_DEAD is set. + * so when sk_inuse hits zero, we know the socket is dead + * and no-one is using it. + * SK_DEAD can only be set while SK_BUSY is held which ensures + * no other thread will be using the socket or will try to + * set SK_DEAD. * */ @@ -70,6 +76,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, int *errp, int pmap_reg); +static void svc_delete_socket(struct svc_sock *svsk); static void svc_udp_data_ready(struct sock *, int); static int svc_udp_recvfrom(struct svc_rqst *); static int svc_udp_sendto(struct svc_rqst *); @@ -329,8 +336,9 @@ void svc_reserve(struct svc_rqst *rqstp, int space) static inline void svc_sock_put(struct svc_sock *svsk) { - if (atomic_dec_and_test(&svsk->sk_inuse) && - test_bit(SK_DEAD, &svsk->sk_flags)) { + if (atomic_dec_and_test(&svsk->sk_inuse)) { + BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags)); + dprintk("svc: releasing dead socket\n"); if (svsk->sk_sock->file) sockfd_put(svsk->sk_sock); @@ -520,7 +528,7 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose) if (!serv) return 0; - spin_lock(&serv->sv_lock); + spin_lock_bh(&serv->sv_lock); list_for_each_entry(svsk, &serv->sv_permsocks, sk_list) { int onelen = one_sock_name(buf+len, svsk); if (toclose && strcmp(toclose, buf+len) == 0) @@ -528,12 +536,12 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose) else len += onelen; } - spin_unlock(&serv->sv_lock); + spin_unlock_bh(&serv->sv_lock); if (closesk) /* Should unregister with portmap, but you cannot * unregister just one protocol... */ - svc_delete_socket(closesk); + svc_close_socket(closesk); else if (toclose) return -ENOENT; return len; @@ -683,6 +691,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) return svc_deferred_recv(rqstp); } + if (test_bit(SK_CLOSE, &svsk->sk_flags)) { + svc_delete_socket(svsk); + return 0; + } + clear_bit(SK_DATA, &svsk->sk_flags); while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) { if (err == -EAGAIN) { @@ -1176,7 +1189,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp) rqstp->rq_sock->sk_server->sv_name, (sent<0)?"got error":"sent only", sent, xbufp->len); - svc_delete_socket(rqstp->rq_sock); + set_bit(SK_CLOSE, &rqstp->rq_sock->sk_flags); + svc_sock_enqueue(rqstp->rq_sock); sent = -EAGAIN; } return sent; @@ -1495,7 +1509,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock, svsk->sk_odata = inet->sk_data_ready; svsk->sk_owspace = inet->sk_write_space; svsk->sk_server = serv; - atomic_set(&svsk->sk_inuse, 0); + atomic_set(&svsk->sk_inuse, 1); svsk->sk_lastrecv = get_seconds(); spin_lock_init(&svsk->sk_defer_lock); INIT_LIST_HEAD(&svsk->sk_deferred); @@ -1618,7 +1632,7 @@ bummer: /* * Remove a dead socket */ -void +static void svc_delete_socket(struct svc_sock *svsk) { struct svc_serv *serv; @@ -1644,16 +1658,26 @@ svc_delete_socket(struct svc_sock *svsk) * while still attached to a queue, the queue itself * is about to be destroyed (in svc_destroy). */ - if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) + if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) { + BUG_ON(atomic_read(&svsk->sk_inuse)<2); + atomic_dec(&svsk->sk_inuse); if (test_bit(SK_TEMP, &svsk->sk_flags)) serv->sv_tmpcnt--; + } - /* This atomic_inc should be needed - svc_delete_socket - * should have the semantic of dropping a reference. - * But it doesn't yet.... - */ - atomic_inc(&svsk->sk_inuse); spin_unlock_bh(&serv->sv_lock); +} + +void svc_close_socket(struct svc_sock *svsk) +{ + set_bit(SK_CLOSE, &svsk->sk_flags); + if (test_and_set_bit(SK_BUSY, &svsk->sk_flags)) + /* someone else will have to effect the close */ + return; + + atomic_inc(&svsk->sk_inuse); + svc_delete_socket(svsk); + clear_bit(SK_BUSY, &svsk->sk_flags); svc_sock_put(svsk); } -- cgit v1.2.3 From cca5172a7ec10dfdb0b787cd8e9d5b0b8f179793 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Fri, 9 Feb 2007 15:38:13 -0800 Subject: [NET] SUNRPC: Fix whitespace errors. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- net/sunrpc/auth.c | 2 +- net/sunrpc/auth_gss/auth_gss.c | 20 +++++------ net/sunrpc/auth_gss/gss_generic_token.c | 10 +++--- net/sunrpc/auth_gss/gss_krb5_crypto.c | 4 +-- net/sunrpc/auth_gss/gss_krb5_seqnum.c | 4 +-- net/sunrpc/auth_gss/gss_mech_switch.c | 4 +-- net/sunrpc/auth_gss/gss_spkm3_token.c | 48 ++++++++++++------------- net/sunrpc/auth_gss/gss_spkm3_unseal.c | 2 +- net/sunrpc/auth_gss/svcauth_gss.c | 6 ++-- net/sunrpc/cache.c | 64 ++++++++++++++++----------------- net/sunrpc/clnt.c | 28 +++++++-------- net/sunrpc/pmap_clnt.c | 4 +-- net/sunrpc/sched.c | 8 ++--- net/sunrpc/svc.c | 24 ++++++------- net/sunrpc/svcauth.c | 4 +-- net/sunrpc/svcauth_unix.c | 12 +++---- net/sunrpc/svcsock.c | 36 +++++++++---------- net/sunrpc/sysctl.c | 10 +++--- net/sunrpc/xdr.c | 6 ++-- net/sunrpc/xprt.c | 4 +-- 20 files changed, 150 insertions(+), 150 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 993ff1a5d94..76f7eac4082 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -213,7 +213,7 @@ retry: rpcauth_gc_credcache(auth, &free); hlist_for_each_safe(pos, next, &cache->hashtable[nr]) { struct rpc_cred *entry; - entry = hlist_entry(pos, struct rpc_cred, cr_hash); + entry = hlist_entry(pos, struct rpc_cred, cr_hash); if (entry->cr_ops->crmatch(acred, entry, flags)) { hlist_del(&entry->cr_hash); cred = entry; diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index e1a104abb78..718fb94ad0f 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -2,7 +2,7 @@ * linux/net/sunrpc/auth_gss/auth_gss.c * * RPCSEC_GSS client authentication. - * + * * Copyright (c) 2000 The Regents of the University of Michigan. * All rights reserved. * @@ -74,7 +74,7 @@ static struct rpc_credops gss_credops; * as it is passed to gssd to signal the use of * machine creds should be part of the shared rpc interface */ -#define CA_RUN_AS_MACHINE 0x00000200 +#define CA_RUN_AS_MACHINE 0x00000200 /* dump the buffer in `emacs-hexl' style */ #define isprint(c) ((c > 0x1f) && (c < 0x7f)) @@ -607,8 +607,8 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) } } -/* - * NOTE: we have the opportunity to use different +/* + * NOTE: we have the opportunity to use different * parameters based on the input flavor (which must be a pseudoflavor) */ static struct rpc_auth * @@ -869,7 +869,7 @@ gss_validate(struct rpc_task *task, __be32 *p) flav = ntohl(*p++); if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE) - goto out_bad; + goto out_bad; if (flav != RPC_AUTH_GSS) goto out_bad; seq = htonl(task->tk_rqstp->rq_seqno); @@ -925,7 +925,7 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, *integ_len = htonl(integ_buf.len); /* guess whether we're in the head or the tail: */ - if (snd_buf->page_len || snd_buf->tail[0].iov_len) + if (snd_buf->page_len || snd_buf->tail[0].iov_len) iov = snd_buf->tail; else iov = snd_buf->head; @@ -1030,7 +1030,7 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages); /* RPC_SLACK_SPACE should prevent this ever happening: */ BUG_ON(snd_buf->len > snd_buf->buflen); - status = -EIO; + status = -EIO; /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was * done anyway, so it's safe to put the request on the wire: */ if (maj_stat == GSS_S_CONTEXT_EXPIRED) @@ -1079,7 +1079,7 @@ gss_wrap_req(struct rpc_task *task, status = gss_wrap_req_integ(cred, ctx, encode, rqstp, p, obj); break; - case RPC_GSS_SVC_PRIVACY: + case RPC_GSS_SVC_PRIVACY: status = gss_wrap_req_priv(cred, ctx, encode, rqstp, p, obj); break; @@ -1179,7 +1179,7 @@ gss_unwrap_resp(struct rpc_task *task, if (status) goto out; break; - case RPC_GSS_SVC_PRIVACY: + case RPC_GSS_SVC_PRIVACY: status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); if (status) goto out; @@ -1196,7 +1196,7 @@ out: status); return status; } - + static struct rpc_authops authgss_ops = { .owner = THIS_MODULE, .au_flavor = RPC_AUTH_GSS, diff --git a/net/sunrpc/auth_gss/gss_generic_token.c b/net/sunrpc/auth_gss/gss_generic_token.c index 826df44e7fc..ea8c92ecdae 100644 --- a/net/sunrpc/auth_gss/gss_generic_token.c +++ b/net/sunrpc/auth_gss/gss_generic_token.c @@ -11,7 +11,7 @@ /* * Copyright 1993 by OpenVision Technologies, Inc. - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appears in all copies and @@ -21,7 +21,7 @@ * without specific, written prior permission. OpenVision makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. - * + * * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR @@ -201,7 +201,7 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size, return(G_BAD_TOK_HEADER); if (*buf++ != 0x06) return(G_BAD_TOK_HEADER); - + if ((toksize-=1) < 0) return(G_BAD_TOK_HEADER); toid.len = *buf++; @@ -211,9 +211,9 @@ g_verify_token_header(struct xdr_netobj *mech, int *body_size, toid.data = buf; buf+=toid.len; - if (! g_OID_equal(&toid, mech)) + if (! g_OID_equal(&toid, mech)) ret = G_WRONG_MECH; - + /* G_WRONG_MECH is not returned immediately because it's more important to return G_BAD_TOK_HEADER if the token header is in fact bad */ diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index d926cda8862..0a9948de099 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -58,7 +58,7 @@ krb5_encrypt( int length) { u32 ret = -EINVAL; - struct scatterlist sg[1]; + struct scatterlist sg[1]; u8 local_iv[16] = {0}; struct blkcipher_desc desc = { .tfm = tfm, .info = local_iv }; @@ -67,7 +67,7 @@ krb5_encrypt( if (crypto_blkcipher_ivsize(tfm) > 16) { dprintk("RPC: gss_k5encrypt: tfm iv size to large %d\n", - crypto_blkcipher_ivsize(tfm)); + crypto_blkcipher_ivsize(tfm)); goto out; } diff --git a/net/sunrpc/auth_gss/gss_krb5_seqnum.c b/net/sunrpc/auth_gss/gss_krb5_seqnum.c index c604baf3a5f..3e315a68efa 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seqnum.c +++ b/net/sunrpc/auth_gss/gss_krb5_seqnum.c @@ -11,7 +11,7 @@ /* * Copyright 1993 by OpenVision Technologies, Inc. - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appears in all copies and @@ -21,7 +21,7 @@ * without specific, written prior permission. OpenVision makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. - * + * * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c index 3db745379d0..3423890e4a3 100644 --- a/net/sunrpc/auth_gss/gss_mech_switch.c +++ b/net/sunrpc/auth_gss/gss_mech_switch.c @@ -6,14 +6,14 @@ * * J. Bruce Fields * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the + * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived diff --git a/net/sunrpc/auth_gss/gss_spkm3_token.c b/net/sunrpc/auth_gss/gss_spkm3_token.c index 35188b6ea8f..8400b621971 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_token.c +++ b/net/sunrpc/auth_gss/gss_spkm3_token.c @@ -59,7 +59,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits) /* count trailing 0's */ for(i = in->len; i > 0; i--) { - if (*ptr == 0) { + if (*ptr == 0) { ptr--; elen--; } else @@ -82,7 +82,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits) /* * decode_asn1_bitstring() - * + * * decode a bitstring into a buffer of the expected length. * enclen = bit string length * explen = expected length (define in rfc) @@ -97,9 +97,9 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen) return 1; } -/* +/* * SPKMInnerContextToken choice SPKM_MIC asn1 token layout - * + * * contextid is always 16 bytes plain data. max asn1 bitstring len = 17. * * tokenlen = pos[0] to end of token (max pos[45] with MD5 cksum) @@ -107,21 +107,21 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen) * pos value * ---------- * [0] a4 SPKM-MIC tag - * [1] ?? innertoken length (max 44) - * - * - * tok_hdr piece of checksum data starts here + * [1] ?? innertoken length (max 44) + * + * + * tok_hdr piece of checksum data starts here * - * the maximum mic-header len = 9 + 17 = 26 + * the maximum mic-header len = 9 + 17 = 26 * mic-header * ---------- - * [2] 30 SEQUENCE tag - * [3] ?? mic-header length: (max 23) = TokenID + ContextID + * [2] 30 SEQUENCE tag + * [3] ?? mic-header length: (max 23) = TokenID + ContextID * * TokenID - all fields constant and can be hardcoded * ------- * [4] 02 Type 2 - * [5] 02 Length 2 + * [5] 02 Length 2 * [6][7] 01 01 TokenID (SPKM_MIC_TOK) * * ContextID - encoded length not constant, calculated @@ -131,17 +131,17 @@ decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen) * [10] ?? ctxzbit * [11] contextid * - * mic_header piece of checksum data ends here. + * mic_header piece of checksum data ends here. * * int-cksum - encoded length not constant, calculated * --------- * [??] 03 Type 3 - * [??] ?? encoded length - * [??] ?? md5zbit + * [??] ?? encoded length + * [??] ?? md5zbit * [??] int-cksum (NID_md5 = 16) * - * maximum SPKM-MIC innercontext token length = - * 10 + encoded contextid_size(17 max) + 2 + encoded + * maximum SPKM-MIC innercontext token length = + * 10 + encoded contextid_size(17 max) + 2 + encoded * cksum_size (17 maxfor NID_md5) = 46 */ @@ -178,8 +178,8 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct /* * spkm3_mic_innercontext_token() * - * *tokp points to the beginning of the SPKM_MIC token described - * in rfc 2025, section 3.2.1: + * *tokp points to the beginning of the SPKM_MIC token described + * in rfc 2025, section 3.2.1: * * toklen is the inner token length */ @@ -209,7 +209,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck /* spkm3 innercontext token preamble */ if ((ptr[0] != 0xa4) || (ptr[2] != 0x30)) { - dprintk("RPC: BAD SPKM ictoken preamble\n"); + dprintk("RPC: BAD SPKM ictoken preamble\n"); goto out; } @@ -245,9 +245,9 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck goto out; /* - * in the current implementation: the optional int-alg is not present - * so the default int-alg (md5) is used the optional snd-seq field is - * also not present + * in the current implementation: the optional int-alg is not present + * so the default int-alg (md5) is used the optional snd-seq field is + * also not present */ if (*mic_hdrlen != 6 + ctxelen) { @@ -255,7 +255,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck goto out; } /* checksum */ - *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */ + *cksum = (&ptr[10] + ctxelen); /* ctxelen includes ptr[10] */ ret = GSS_S_COMPLETE; out: diff --git a/net/sunrpc/auth_gss/gss_spkm3_unseal.c b/net/sunrpc/auth_gss/gss_spkm3_unseal.c index e54581ca757..35a1b34c4a1 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_unseal.c +++ b/net/sunrpc/auth_gss/gss_spkm3_unseal.c @@ -45,7 +45,7 @@ /* * spkm3_read_token() - * + * * only SPKM_MIC_TOK with md5 intg-alg is supported */ u32 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 066c64a97fd..8fde38ecaf2 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -172,8 +172,8 @@ static struct cache_head *rsi_alloc(void) } static void rsi_request(struct cache_detail *cd, - struct cache_head *h, - char **bpp, int *blen) + struct cache_head *h, + char **bpp, int *blen) { struct rsi *rsii = container_of(h, struct rsi, h); @@ -184,7 +184,7 @@ static void rsi_request(struct cache_detail *cd, static int rsi_parse(struct cache_detail *cd, - char *mesg, int mlen) + char *mesg, int mlen) { /* context token expiry major minor context token */ char *buf = mesg; diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 14274490f92..c80df455802 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -274,7 +274,7 @@ int cache_check(struct cache_detail *detail, * * A table is then only scanned if the current time is at least * the nextcheck time. - * + * */ static LIST_HEAD(cache_list); @@ -296,16 +296,16 @@ void cache_register(struct cache_detail *cd) struct proc_dir_entry *p; cd->proc_ent->owner = cd->owner; cd->channel_ent = cd->content_ent = NULL; - - p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, - cd->proc_ent); + + p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, + cd->proc_ent); cd->flush_ent = p; - if (p) { - p->proc_fops = &cache_flush_operations; - p->owner = cd->owner; - p->data = cd; - } - + if (p) { + p->proc_fops = &cache_flush_operations; + p->owner = cd->owner; + p->data = cd; + } + if (cd->cache_request || cd->cache_parse) { p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent); @@ -316,16 +316,16 @@ void cache_register(struct cache_detail *cd) p->data = cd; } } - if (cd->cache_show) { - p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, - cd->proc_ent); + if (cd->cache_show) { + p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, + cd->proc_ent); cd->content_ent = p; - if (p) { - p->proc_fops = &content_file_operations; - p->owner = cd->owner; - p->data = cd; - } - } + if (p) { + p->proc_fops = &content_file_operations; + p->owner = cd->owner; + p->data = cd; + } + } } rwlock_init(&cd->hash_lock); INIT_LIST_HEAD(&cd->queue); @@ -417,15 +417,15 @@ static int cache_clean(void) current_index++; /* find a cleanable entry in the bucket and clean it, or set to next bucket */ - + if (current_detail && current_index < current_detail->hash_size) { struct cache_head *ch, **cp; struct cache_detail *d; - + write_lock(¤t_detail->hash_lock); /* Ok, now to clean this strand */ - + cp = & current_detail->hash_table[current_index]; ch = *cp; for (; ch; cp= & ch->next, ch= *cp) { @@ -477,9 +477,9 @@ static void do_cache_clean(struct work_struct *work) } -/* +/* * Clean all caches promptly. This just calls cache_clean - * repeatedly until we are sure that every cache has had a chance to + * repeatedly until we are sure that every cache has had a chance to * be fully cleaned */ void cache_flush(void) @@ -508,7 +508,7 @@ void cache_purge(struct cache_detail *detail) * All deferred requests are stored in a hash table, * indexed by "struct cache_head *". * As it may be wasteful to store a whole request - * structure, we allow the request to provide a + * structure, we allow the request to provide a * deferred form, which must contain a * 'struct cache_deferred_req' * This cache_deferred_req contains a method to allow @@ -584,7 +584,7 @@ static void cache_revisit_request(struct cache_head *item) INIT_LIST_HEAD(&pending); spin_lock(&cache_defer_lock); - + lp = cache_defer_hash[hash].next; if (lp) { while (lp != &cache_defer_hash[hash]) { @@ -614,7 +614,7 @@ void cache_clean_deferred(void *owner) INIT_LIST_HEAD(&pending); spin_lock(&cache_defer_lock); - + list_for_each_entry_safe(dreq, tmp, &cache_defer_list, recent) { if (dreq->owner == owner) { list_del(&dreq->hash); @@ -639,7 +639,7 @@ void cache_clean_deferred(void *owner) * On write, an update request is processed * Poll works if anything to read, and always allows write * - * Implemented by linked list of requests. Each open file has + * Implemented by linked list of requests. Each open file has * a ->private that also exists in this list. New request are added * to the end and may wakeup and preceding readers. * New readers are added to the head. If, on read, an item is found with @@ -1059,10 +1059,10 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) * Messages are, like requests, separated into fields by * spaces and dequotes as \xHEXSTRING or embedded \nnn octal * - * Message is + * Message is * reply cachename expiry key ... content.... * - * key and content are both parsed by cache + * key and content are both parsed by cache */ #define isodigit(c) (isdigit(c) && c <= '7') @@ -1132,7 +1132,7 @@ static void *c_start(struct seq_file *m, loff_t *pos) unsigned hash, entry; struct cache_head *ch; struct cache_detail *cd = ((struct handle*)m->private)->cd; - + read_lock(&cd->hash_lock); if (!n--) @@ -1147,7 +1147,7 @@ static void *c_start(struct seq_file *m, loff_t *pos) do { hash++; n += 1LL<<32; - } while(hash < cd->hash_size && + } while(hash < cd->hash_size && cd->hash_table[hash]==NULL); if (hash >= cd->hash_size) return NULL; diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 16c9fbc1db6..c95a61736d1 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -410,7 +410,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old, rpc_shutdown_client(clnt); clnt = ERR_PTR(err); } -out: +out: return clnt; } @@ -431,7 +431,7 @@ static const struct rpc_call_ops rpc_default_ops = { * sleeps on RPC calls */ #define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM)) - + static void rpc_save_sigmask(sigset_t *oldset, int intr) { unsigned long sigallow = sigmask(SIGKILL); @@ -474,7 +474,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) int status; /* If this client is slain all further I/O fails */ - if (clnt->cl_dead) + if (clnt->cl_dead) return -EIO; BUG_ON(flags & RPC_TASK_ASYNC); @@ -515,7 +515,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, /* If this client is slain all further I/O fails */ status = -EIO; - if (clnt->cl_dead) + if (clnt->cl_dead) goto out_release; flags |= RPC_TASK_ASYNC; @@ -526,7 +526,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, goto out_release; /* Mask signals on GSS_AUTH upcalls */ - rpc_task_sigmask(task, &oldset); + rpc_task_sigmask(task, &oldset); rpc_call_setup(task, msg, 0); @@ -537,7 +537,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, else rpc_put_task(task); - rpc_restore_sigmask(&oldset); + rpc_restore_sigmask(&oldset); return status; out_release: rpc_release_calldata(tk_ops, data); @@ -749,7 +749,7 @@ call_allocate(struct rpc_task *task) struct rpc_xprt *xprt = task->tk_xprt; unsigned int bufsiz; - dprintk("RPC: %4d call_allocate (status %d)\n", + dprintk("RPC: %4d call_allocate (status %d)\n", task->tk_pid, task->tk_status); task->tk_action = call_bind; if (req->rq_buffer) @@ -761,7 +761,7 @@ call_allocate(struct rpc_task *task) if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL) return; - printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task); + printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task); if (RPC_IS_ASYNC(task) || !signalled()) { xprt_release(task); @@ -798,7 +798,7 @@ call_encode(struct rpc_task *task) kxdrproc_t encode; __be32 *p; - dprintk("RPC: %4d call_encode (status %d)\n", + dprintk("RPC: %4d call_encode (status %d)\n", task->tk_pid, task->tk_status); /* Default buffer setup */ @@ -933,7 +933,7 @@ call_connect_status(struct rpc_task *task) struct rpc_clnt *clnt = task->tk_client; int status = task->tk_status; - dprintk("RPC: %5u call_connect_status (status %d)\n", + dprintk("RPC: %5u call_connect_status (status %d)\n", task->tk_pid, task->tk_status); task->tk_status = 0; @@ -966,7 +966,7 @@ call_connect_status(struct rpc_task *task) static void call_transmit(struct rpc_task *task) { - dprintk("RPC: %4d call_transmit (status %d)\n", + dprintk("RPC: %4d call_transmit (status %d)\n", task->tk_pid, task->tk_status); task->tk_action = call_status; @@ -1028,7 +1028,7 @@ call_status(struct rpc_task *task) if (req->rq_received > 0 && !req->rq_bytes_sent) task->tk_status = req->rq_received; - dprintk("RPC: %4d call_status (status %d)\n", + dprintk("RPC: %4d call_status (status %d)\n", task->tk_pid, task->tk_status); status = task->tk_status; @@ -1118,7 +1118,7 @@ call_decode(struct rpc_task *task) kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode; __be32 *p; - dprintk("RPC: %4d call_decode (status %d)\n", + dprintk("RPC: %4d call_decode (status %d)\n", task->tk_pid, task->tk_status); if (task->tk_flags & RPC_CALL_MAJORSEEN) { @@ -1196,7 +1196,7 @@ static void call_refreshresult(struct rpc_task *task) { int status = task->tk_status; - dprintk("RPC: %4d call_refreshresult (status %d)\n", + dprintk("RPC: %4d call_refreshresult (status %d)\n", task->tk_pid, task->tk_status); task->tk_status = 0; diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c index 3946ec3eb51..f4e1357bc18 100644 --- a/net/sunrpc/pmap_clnt.c +++ b/net/sunrpc/pmap_clnt.c @@ -329,7 +329,7 @@ static int xdr_decode_bool(struct rpc_rqst *req, __be32 *p, unsigned int *boolp) static struct rpc_procinfo pmap_procedures[] = { [PMAP_SET] = { .p_proc = PMAP_SET, - .p_encode = (kxdrproc_t) xdr_encode_mapping, + .p_encode = (kxdrproc_t) xdr_encode_mapping, .p_decode = (kxdrproc_t) xdr_decode_bool, .p_bufsiz = 4, .p_count = 1, @@ -338,7 +338,7 @@ static struct rpc_procinfo pmap_procedures[] = { }, [PMAP_UNSET] = { .p_proc = PMAP_UNSET, - .p_encode = (kxdrproc_t) xdr_encode_mapping, + .p_encode = (kxdrproc_t) xdr_encode_mapping, .p_decode = (kxdrproc_t) xdr_decode_bool, .p_bufsiz = 4, .p_count = 1, diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index fc083f0b354..54a6b92525e 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -4,7 +4,7 @@ * Scheduling for synchronous and asynchronous RPC requests. * * Copyright (C) 1996 Olaf Kirch, - * + * * TCP NFS related read + write fixes * (C) 1999 Dave Airlie, University of Limerick, Ireland */ @@ -307,7 +307,7 @@ EXPORT_SYMBOL(__rpc_wait_for_completion_task); /* * Make an RPC task runnable. * - * Note: If the task is ASYNC, this must be called with + * Note: If the task is ASYNC, this must be called with * the spinlock held to protect the wait queue operation. */ static void rpc_make_runnable(struct rpc_task *task) @@ -646,8 +646,8 @@ static int __rpc_execute(struct rpc_task *task) if (RPC_DO_CALLBACK(task)) { /* Define a callback save pointer */ void (*save_callback)(struct rpc_task *); - - /* + + /* * If a callback exists, save it, reset it, * call it. * The save is needed to stop from resetting diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index c1f878131ac..b00511d39b6 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -397,7 +397,7 @@ svc_destroy(struct svc_serv *serv) sk_list); svc_close_socket(svsk); } - + cache_clean_deferred(serv); /* Unregister service with the portmapper */ @@ -415,7 +415,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size) { int pages; int arghi; - + pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply. * We assume one is at most one page */ @@ -514,7 +514,7 @@ choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state) if (pool != NULL) return pool; - return &serv->sv_pools[(*state)++ % serv->sv_nrpools]; + return &serv->sv_pools[(*state)++ % serv->sv_nrpools]; } /* @@ -530,13 +530,13 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state) spin_lock_bh(&pool->sp_lock); } else { /* choose a pool in round-robin fashion */ - for (i = 0; i < serv->sv_nrpools; i++) { - pool = &serv->sv_pools[--(*state) % serv->sv_nrpools]; + for (i = 0; i < serv->sv_nrpools; i++) { + pool = &serv->sv_pools[--(*state) % serv->sv_nrpools]; spin_lock_bh(&pool->sp_lock); - if (!list_empty(&pool->sp_all_threads)) - goto found_pool; + if (!list_empty(&pool->sp_all_threads)) + goto found_pool; spin_unlock_bh(&pool->sp_lock); - } + } return NULL; } @@ -551,7 +551,7 @@ found_pool: rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all); list_del_init(&rqstp->rq_all); task = rqstp->rq_task; - } + } spin_unlock_bh(&pool->sp_lock); return task; @@ -636,7 +636,7 @@ svc_exit_thread(struct svc_rqst *rqstp) /* * Register an RPC service with the local portmapper. - * To unregister a service, call this routine with + * To unregister a service, call this routine with * proto and port == 0. */ int @@ -709,7 +709,7 @@ svc_process(struct svc_rqst *rqstp) goto err_short_len; /* setup response xdr_buf. - * Initially it has just one page + * Initially it has just one page */ rqstp->rq_resused = 1; resv->iov_base = page_address(rqstp->rq_respages[0]); @@ -811,7 +811,7 @@ svc_process(struct svc_rqst *rqstp) memset(rqstp->rq_argp, 0, procp->pc_argsize); memset(rqstp->rq_resp, 0, procp->pc_ressize); - /* un-reserve some of the out-queue now that we have a + /* un-reserve some of the out-queue now that we have a * better idea of reply size */ if (procp->pc_xdrressize) diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c index c7bb5f7f21a..811a24c8326 100644 --- a/net/sunrpc/svcauth.c +++ b/net/sunrpc/svcauth.c @@ -2,7 +2,7 @@ * linux/net/sunrpc/svcauth.c * * The generic interface for RPC authentication on the server side. - * + * * Copyright (C) 1995, 1996 Olaf Kirch * * CHANGES @@ -74,7 +74,7 @@ int svc_authorise(struct svc_rqst *rqstp) int rv = 0; rqstp->rq_authop = NULL; - + if (aops) { rv = aops->release(rqstp); module_put(aops->owner); diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 0d1e8fb83b9..987244f9590 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -151,7 +151,7 @@ static void ip_map_request(struct cache_detail *cd, char text_addr[20]; struct ip_map *im = container_of(h, struct ip_map, h); __be32 addr = im->m_addr.s_addr; - + snprintf(text_addr, 20, "%u.%u.%u.%u", ntohl(addr) >> 24 & 0xff, ntohl(addr) >> 16 & 0xff, @@ -198,7 +198,7 @@ static int ip_map_parse(struct cache_detail *cd, if (sscanf(buf, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) return -EINVAL; - + expiry = get_expiry(&mesg); if (expiry ==0) return -EINVAL; @@ -248,7 +248,7 @@ static int ip_map_show(struct seq_file *m, /* class addr domain */ addr = im->m_addr; - if (test_bit(CACHE_VALID, &h->flags) && + if (test_bit(CACHE_VALID, &h->flags) && !test_bit(CACHE_NEGATIVE, &h->flags)) dom = im->m_client->h.name; @@ -262,7 +262,7 @@ static int ip_map_show(struct seq_file *m, ); return 0; } - + struct cache_detail ip_map_cache = { .owner = THIS_MODULE, @@ -343,7 +343,7 @@ int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom) int auth_unix_forget_old(struct auth_domain *dom) { struct unix_domain *udom; - + if (dom->flavour != &svcauth_unix) return -EINVAL; udom = container_of(dom, struct unix_domain, h); @@ -465,7 +465,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp) if (argv->iov_len < 3*4) return SVC_GARBAGE; - if (svc_getu32(argv) != 0) { + if (svc_getu32(argv) != 0) { dprintk("svc: bad null cred\n"); *authp = rpc_autherr_badcred; return SVC_DENIED; diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index cf93cd1d857..2fd0ba2b20d 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -58,7 +58,7 @@ * providing that certain rules are followed: * * SK_CONN, SK_DATA, can be set or cleared at any time. - * after a set, svc_sock_enqueue must be called. + * after a set, svc_sock_enqueue must be called. * after a clear, the socket must be read/accepted * if this succeeds, it must be set again. * SK_CLOSE can set at any time. It is never cleared. @@ -252,7 +252,7 @@ svc_sock_enqueue(struct svc_sock *svsk) svsk->sk_sk, rqstp); svc_thread_dequeue(pool, rqstp); if (rqstp->rq_sock) - printk(KERN_ERR + printk(KERN_ERR "svc_sock_enqueue: server %p, rq_sock=%p!\n", rqstp, rqstp->rq_sock); rqstp->rq_sock = svsk; @@ -484,7 +484,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) if (xdr->tail[0].iov_len) { result = kernel_sendpage(sock, rqstp->rq_respages[0], ((unsigned long)xdr->tail[0].iov_base) - & (PAGE_SIZE-1), + & (PAGE_SIZE-1), xdr->tail[0].iov_len, 0); if (result > 0) @@ -711,7 +711,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) tv.tv_sec = xtime.tv_sec; tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC; skb_set_timestamp(skb, &tv); - /* Don't enable netstamp, sunrpc doesn't + /* Don't enable netstamp, sunrpc doesn't need that much accuracy */ } skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); @@ -743,7 +743,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) return 0; } local_bh_enable(); - skb_free_datagram(svsk->sk_sk, skb); + skb_free_datagram(svsk->sk_sk, skb); } else { /* we can use it in-place */ rqstp->rq_arg.head[0].iov_base = skb->data + sizeof(struct udphdr); @@ -794,7 +794,7 @@ svc_udp_init(struct svc_sock *svsk) svsk->sk_sendto = svc_udp_sendto; /* initialise setting must have enough space to - * receive and respond to one request. + * receive and respond to one request. * svc_udp_recvfrom will re-adjust if necessary */ svc_sock_setbufsize(svsk->sk_sock, @@ -923,7 +923,7 @@ svc_tcp_accept(struct svc_sock *svsk) if (ntohs(sin.sin_port) >= 1024) { dprintk(KERN_WARNING "%s: connect from unprivileged port: %u.%u.%u.%u:%d\n", - serv->sv_name, + serv->sv_name, NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); } @@ -1038,7 +1038,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) * on the number of threads which will access the socket. * * rcvbuf just needs to be able to hold a few requests. - * Normally they will be removed from the queue + * Normally they will be removed from the queue * as soon a a complete request arrives. */ svc_sock_setbufsize(svsk->sk_sock, @@ -1063,7 +1063,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) if (len < want) { dprintk("svc: short recvfrom while reading record length (%d of %lu)\n", - len, want); + len, want); svc_sock_received(svsk); return -EAGAIN; /* record header not complete */ } @@ -1221,7 +1221,7 @@ svc_tcp_init(struct svc_sock *svsk) tp->nonagle = 1; /* disable Nagle's algorithm */ /* initialise setting must have enough space to - * receive and respond to one request. + * receive and respond to one request. * svc_tcp_recvfrom will re-adjust if necessary */ svc_sock_setbufsize(svsk->sk_sock, @@ -1230,7 +1230,7 @@ svc_tcp_init(struct svc_sock *svsk) set_bit(SK_CHNGBUF, &svsk->sk_flags); set_bit(SK_DATA, &svsk->sk_flags); - if (sk->sk_state != TCP_ESTABLISHED) + if (sk->sk_state != TCP_ESTABLISHED) set_bit(SK_CLOSE, &svsk->sk_flags); } } @@ -1246,7 +1246,7 @@ svc_sock_update_bufs(struct svc_serv *serv) spin_lock_bh(&serv->sv_lock); list_for_each(le, &serv->sv_permsocks) { - struct svc_sock *svsk = + struct svc_sock *svsk = list_entry(le, struct svc_sock, sk_list); set_bit(SK_CHNGBUF, &svsk->sk_flags); } @@ -1278,11 +1278,11 @@ svc_recv(struct svc_rqst *rqstp, long timeout) rqstp, timeout); if (rqstp->rq_sock) - printk(KERN_ERR + printk(KERN_ERR "svc_recv: service %p, socket not NULL!\n", rqstp); if (waitqueue_active(&rqstp->rq_wait)) - printk(KERN_ERR + printk(KERN_ERR "svc_recv: service %p, wait queue active!\n", rqstp); @@ -1371,7 +1371,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) return len; } -/* +/* * Drop request */ void @@ -1651,7 +1651,7 @@ svc_delete_socket(struct svc_sock *svsk) if (!test_and_set_bit(SK_DETACHED, &svsk->sk_flags)) list_del_init(&svsk->sk_list); - /* + /* * We used to delete the svc_sock from whichever list * it's sk_ready node was on, but we don't actually * need to. This is because the only time we're called @@ -1697,7 +1697,7 @@ svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) } /* - * Handle defer and revisit of requests + * Handle defer and revisit of requests */ static void svc_revisit(struct cache_deferred_req *dreq, int too_many) @@ -1776,7 +1776,7 @@ static int svc_deferred_recv(struct svc_rqst *rqstp) static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk) { struct svc_deferred_req *dr = NULL; - + if (!test_bit(SK_DEFERRED, &svsk->sk_flags)) return NULL; spin_lock_bh(&svsk->sk_defer_lock); diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 82b27528d0c..47d8df2b5eb 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -42,7 +42,7 @@ rpc_register_sysctl(void) sunrpc_table[0].de->owner = THIS_MODULE; #endif } - + } void @@ -126,7 +126,7 @@ static ctl_table debug_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dodebug - }, + }, { .ctl_name = CTL_NFSDEBUG, .procname = "nfs_debug", @@ -134,7 +134,7 @@ static ctl_table debug_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dodebug - }, + }, { .ctl_name = CTL_NFSDDEBUG, .procname = "nfsd_debug", @@ -142,7 +142,7 @@ static ctl_table debug_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dodebug - }, + }, { .ctl_name = CTL_NLMDEBUG, .procname = "nlm_debug", @@ -150,7 +150,7 @@ static ctl_table debug_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dodebug - }, + }, { .ctl_name = 0 } }; diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index a0af250ca31..6a59180e166 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -302,7 +302,7 @@ _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len) * @buf: xdr_buf * @len: bytes to remove from buf->head[0] * - * Shrinks XDR buffer's header kvec buf->head[0] by + * Shrinks XDR buffer's header kvec buf->head[0] by * 'len' bytes. The extra data is not lost, but is instead * moved into the inlined pages and/or the tail. */ @@ -375,7 +375,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) * @buf: xdr_buf * @len: bytes to remove from buf->pages * - * Shrinks XDR buffer's page array buf->pages by + * Shrinks XDR buffer's page array buf->pages by * 'len' bytes. The extra data is not lost, but is instead * moved into the tail. */ @@ -1024,7 +1024,7 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base, int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, - int (*actor)(struct scatterlist *, void *), void *data) + int (*actor)(struct scatterlist *, void *), void *data) { int i, ret = 0; unsigned page_len, thislen, page_offset; diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 7a3999f0a4a..e7c71a1ea3d 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -410,7 +410,7 @@ void xprt_set_retrans_timeout_def(struct rpc_task *task) /* * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout * @task: task whose timeout is to be set - * + * * Set a request's retransmit timeout using the RTT estimator. */ void xprt_set_retrans_timeout_rtt(struct rpc_task *task) @@ -873,7 +873,7 @@ void xprt_release(struct rpc_task *task) */ void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) { - to->to_initval = + to->to_initval = to->to_increment = incr; to->to_maxval = to->to_initval + (incr * retr); to->to_retries = retr; -- cgit v1.2.3 From 6b174337e5126de834a971d3edc3681bbfa45e2c Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:28 -0800 Subject: [PATCH] knfsd: SUNRPC: update internal API: separate pmap register and temp sockets Currently in the RPC server, registering with the local portmapper and creating "permanent" sockets are tied together. Expand the internal APIs to allow these two socket characteristics to be separately specified. This will be externalized in the next patch. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 2fd0ba2b20d..27ba34a152e 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -75,7 +75,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, - int *errp, int pmap_reg); + int *errp, int flags); static void svc_delete_socket(struct svc_sock *svsk); static void svc_udp_data_ready(struct sock *, int); static int svc_udp_recvfrom(struct svc_rqst *); @@ -935,7 +935,8 @@ svc_tcp_accept(struct svc_sock *svsk) */ newsock->sk->sk_sndtimeo = HZ*30; - if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 0))) + if (!(newsvsk = svc_setup_socket(serv, newsock, &err, + (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) goto failed; @@ -1476,12 +1477,14 @@ svc_age_temp_sockets(unsigned long closure) * Initialize socket for RPC use and create svc_sock struct * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF. */ -static struct svc_sock * -svc_setup_socket(struct svc_serv *serv, struct socket *sock, - int *errp, int pmap_register) +static struct svc_sock *svc_setup_socket(struct svc_serv *serv, + struct socket *sock, + int *errp, int flags) { struct svc_sock *svsk; struct sock *inet; + int pmap_register = !(flags & SVC_SOCK_ANONYMOUS); + int is_temporary = flags & SVC_SOCK_TEMPORARY; dprintk("svc: svc_setup_socket %p\n", sock); if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) { @@ -1523,7 +1526,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock, svc_tcp_init(svsk); spin_lock_bh(&serv->sv_lock); - if (!pmap_register) { + if (is_temporary) { set_bit(SK_TEMP, &svsk->sk_flags); list_add(&svsk->sk_list, &serv->sv_tempsocks); serv->sv_tmpcnt++; @@ -1567,7 +1570,7 @@ int svc_addsock(struct svc_serv *serv, else if (so->state > SS_UNCONNECTED) err = -EISCONN; else { - svsk = svc_setup_socket(serv, so, &err, 1); + svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS); if (svsk) err = 0; } @@ -1583,8 +1586,8 @@ EXPORT_SYMBOL_GPL(svc_addsock); /* * Create socket for RPC service. */ -static int -svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) +static int svc_create_socket(struct svc_serv *serv, int protocol, + struct sockaddr_in *sin, int flags) { struct svc_sock *svsk; struct socket *sock; @@ -1620,8 +1623,8 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) goto bummer; } - if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL) - return 0; + if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) + return ntohs(inet_sk(svsk->sk_sk)->sport); bummer: dprintk("svc: svc_create_socket error = %d\n", -error); @@ -1681,19 +1684,23 @@ void svc_close_socket(struct svc_sock *svsk) svc_sock_put(svsk); } -/* - * Make a socket for nfsd and lockd +/** + * svc_makesock - Make a socket for nfsd and lockd + * @serv: RPC server structure + * @protocol: transport protocol to use + * @port: port to use + * */ -int -svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) +int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) { - struct sockaddr_in sin; + struct sockaddr_in sin = { + .sin_family = AF_INET, + .sin_addr.s_addr = INADDR_ANY, + .sin_port = htons(port), + }; dprintk("svc: creating socket proto = %d\n", protocol); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = htons(port); - return svc_create_socket(serv, protocol, &sin); + return svc_create_socket(serv, protocol, &sin, SVC_SOCK_DEFAULTS); } /* -- cgit v1.2.3 From 482fb94e1b0c2efe8258334aa2a68d4f4a91de9c Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:29 -0800 Subject: [PATCH] knfsd: SUNRPC: allow creating an RPC service without registering with portmapper Sometimes we need to create an RPC service but not register it with the local portmapper. NFSv4 delegation callback, for example. Change the svc_makesock() API to allow optionally creating temporary or permanent sockets, optionally registering with the local portmapper, and make it return the ephemeral port of the new socket. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 27ba34a152e..d120fadeb1a 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1689,9 +1689,11 @@ void svc_close_socket(struct svc_sock *svsk) * @serv: RPC server structure * @protocol: transport protocol to use * @port: port to use + * @flags: requested socket characteristics * */ -int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) +int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port, + int flags) { struct sockaddr_in sin = { .sin_family = AF_INET, @@ -1700,7 +1702,7 @@ int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) }; dprintk("svc: creating socket proto = %d\n", protocol); - return svc_create_socket(serv, protocol, &sin, SVC_SOCK_DEFAULTS); + return svc_create_socket(serv, protocol, &sin, flags); } /* -- cgit v1.2.3 From e79eff1f90826b207b1152fc87aa97fa74fb7f9c Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 12 Feb 2007 00:53:30 -0800 Subject: [PATCH] knfsd: SUNRPC: aplit svc_sock_enqueue out of svc_setup_socket Rather than calling svc_sock_enqueue at the end of svc_setup_socket, we now call it (via svc_sock_recieved) after calling svc_setup_socket at each call site. We do this because a subsequent patch will insert some code between the two calls at one call site. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index d120fadeb1a..7292baf5a74 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -938,7 +938,7 @@ svc_tcp_accept(struct svc_sock *svsk) if (!(newsvsk = svc_setup_socket(serv, newsock, &err, (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) goto failed; - + svc_sock_received(newsvsk); /* make sure that we don't have too many active connections. * If we have, something must be dropped. @@ -1546,8 +1546,6 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, dprintk("svc: svc_setup_socket created %p (inet %p)\n", svsk, svsk->sk_sk); - clear_bit(SK_BUSY, &svsk->sk_flags); - svc_sock_enqueue(svsk); return svsk; } @@ -1571,8 +1569,10 @@ int svc_addsock(struct svc_serv *serv, err = -EISCONN; else { svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS); - if (svsk) + if (svsk) { + svc_sock_received(svsk); err = 0; + } } if (err) { sockfd_put(so); @@ -1623,8 +1623,10 @@ static int svc_create_socket(struct svc_serv *serv, int protocol, goto bummer; } - if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) + if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) { + svc_sock_received(svsk); return ntohs(inet_sk(svsk->sk_sk)->sport); + } bummer: dprintk("svc: svc_create_socket error = %d\n", -error); -- cgit v1.2.3 From 067d7817310569f7b76ca08c4d071ca95ad4c1d3 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:30 -0800 Subject: [PATCH] knfsd: SUNRPC: Cache remote peer's address in svc_sock The remote peer's address won't change after the socket has been accepted. We don't need to call ->getname on every incoming request. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 7292baf5a74..1f97ed49fee 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -568,12 +568,13 @@ svc_recv_available(struct svc_sock *svsk) static int svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) { + struct svc_sock *svsk = rqstp->rq_sock; struct msghdr msg; struct socket *sock; - int len, alen; + int len; rqstp->rq_addrlen = sizeof(rqstp->rq_addr); - sock = rqstp->rq_sock->sk_sock; + sock = svsk->sk_sock; msg.msg_name = &rqstp->rq_addr; msg.msg_namelen = sizeof(rqstp->rq_addr); @@ -585,11 +586,9 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT); /* sock_recvmsg doesn't fill in the name/namelen, so we must.. - * possibly we should cache this in the svc_sock structure - * at accept time. FIXME */ - alen = sizeof(rqstp->rq_addr); - kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen); + memcpy(&rqstp->rq_addr, &svsk->sk_remote, svsk->sk_remotelen); + rqstp->rq_addrlen = svsk->sk_remotelen; dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); @@ -938,6 +937,9 @@ svc_tcp_accept(struct svc_sock *svsk) if (!(newsvsk = svc_setup_socket(serv, newsock, &err, (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) goto failed; + memcpy(&newsvsk->sk_remote, &sin, slen); + newsvsk->sk_remotelen = slen; + svc_sock_received(newsvsk); /* make sure that we don't have too many active connections. -- cgit v1.2.3 From 1ba951053f07187f6e77be664a4b6f8bf0ba7ae4 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:31 -0800 Subject: [PATCH] knfsd: SUNRPC: Don't set msg_name and msg_namelen when calling sock_recvmsg Clean-up: msg_name and msg_namelen are not used by sock_recvmsg, so don't bother to set them in svc_recvfrom. Signed-off-by: Chuck Lever Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 1f97ed49fee..a98be09768a 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -569,21 +569,13 @@ static int svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) { struct svc_sock *svsk = rqstp->rq_sock; - struct msghdr msg; - struct socket *sock; - int len; - - rqstp->rq_addrlen = sizeof(rqstp->rq_addr); - sock = svsk->sk_sock; - - msg.msg_name = &rqstp->rq_addr; - msg.msg_namelen = sizeof(rqstp->rq_addr); - msg.msg_control = NULL; - msg.msg_controllen = 0; - - msg.msg_flags = MSG_DONTWAIT; + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT, + }; + int len; - len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT); + len = kernel_recvmsg(svsk->sk_sock, &msg, iov, nr, buflen, + msg.msg_flags); /* sock_recvmsg doesn't fill in the name/namelen, so we must.. */ @@ -591,7 +583,7 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) rqstp->rq_addrlen = svsk->sk_remotelen; dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", - rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); + svsk, iov[0].iov_base, iov[0].iov_len, len); return len; } -- cgit v1.2.3 From ad06e4bd62351bc569cca0f25d68c58dbd298146 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:32 -0800 Subject: [PATCH] knfsd: SUNRPC: Add a function to format the address in an svc_rqst for printing There are loads of places where the RPC server assumes that the rq_addr fields contains an IPv4 address. Top among these are error and debugging messages that display the server's IP address. Let's refactor the address printing into a separate function that's smart enough to figure out the difference between IPv4 and IPv6 addresses. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 76 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 19 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index a98be09768a..08de328ce43 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -121,6 +122,41 @@ static inline void svc_reclassify_socket(struct socket *sock) } #endif +static char *__svc_print_addr(struct sockaddr *addr, char *buf, size_t len) +{ + switch (addr->sa_family) { + case AF_INET: + snprintf(buf, len, "%u.%u.%u.%u, port=%u", + NIPQUAD(((struct sockaddr_in *) addr)->sin_addr), + htons(((struct sockaddr_in *) addr)->sin_port)); + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: + snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u", + NIP6(((struct sockaddr_in6 *) addr)->sin6_addr), + htons(((struct sockaddr_in6 *) addr)->sin6_port)); + break; +#endif + default: + snprintf(buf, len, "unknown address type: %d", addr->sa_family); + break; + } + return buf; +} + +/** + * svc_print_addr - Format rq_addr field for printing + * @rqstp: svc_rqst struct containing address to print + * @buf: target buffer for formatted address + * @len: length of target buffer + * + */ +char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len) +{ + return __svc_print_addr((struct sockaddr *) &rqstp->rq_addr, buf, len); +} +EXPORT_SYMBOL_GPL(svc_print_addr); + /* * Queue up an idle server thread. Must have pool->sp_lock held. * Note: this is really a stack rather than a queue, so that we only @@ -429,6 +465,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) size_t base = xdr->page_base; unsigned int pglen = xdr->page_len; unsigned int flags = MSG_MORE; + char buf[RPC_MAX_ADDRBUFLEN]; slen = xdr->len; @@ -491,9 +528,9 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) len += result; } out: - dprintk("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %x)\n", - rqstp->rq_sock, xdr->head[0].iov_base, xdr->head[0].iov_len, xdr->len, len, - rqstp->rq_addr.sin_addr.s_addr); + dprintk("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %s)\n", + rqstp->rq_sock, xdr->head[0].iov_base, xdr->head[0].iov_len, + xdr->len, len, svc_print_addr(rqstp, buf, sizeof(buf))); return len; } @@ -878,6 +915,7 @@ svc_tcp_accept(struct svc_sock *svsk) struct socket *newsock; struct svc_sock *newsvsk; int err, slen; + char buf[RPC_MAX_ADDRBUFLEN]; dprintk("svc: tcp_accept %p sock %p\n", svsk, sock); if (!sock) @@ -908,18 +946,19 @@ svc_tcp_accept(struct svc_sock *svsk) } /* Ideally, we would want to reject connections from unauthorized - * hosts here, but when we get encription, the IP of the host won't - * tell us anything. For now just warn about unpriv connections. + * hosts here, but when we get encryption, the IP of the host won't + * tell us anything. For now just warn about unpriv connections. */ if (ntohs(sin.sin_port) >= 1024) { dprintk(KERN_WARNING - "%s: connect from unprivileged port: %u.%u.%u.%u:%d\n", + "%s: connect from unprivileged port: %s\n", serv->sv_name, - NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); + __svc_print_addr((struct sockaddr *) &sin, buf, + sizeof(buf))); } - - dprintk("%s: connect from %u.%u.%u.%u:%04x\n", serv->sv_name, - NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port)); + dprintk("%s: connect from %s\n", serv->sv_name, + __svc_print_addr((struct sockaddr *) &sin, buf, + sizeof(buf))); /* make sure that a write doesn't block forever when * low on memory @@ -955,11 +994,9 @@ svc_tcp_accept(struct svc_sock *svsk) "sockets, consider increasing the " "number of nfsd threads\n", serv->sv_name); - printk(KERN_NOTICE "%s: last TCP connect from " - "%u.%u.%u.%u:%d\n", - serv->sv_name, - NIPQUAD(sin.sin_addr.s_addr), - ntohs(sin.sin_port)); + printk(KERN_NOTICE + "%s: last TCP connect from %s\n", + serv->sv_name, buf); } /* * Always select the oldest socket. It's not fair, @@ -1587,11 +1624,12 @@ static int svc_create_socket(struct svc_serv *serv, int protocol, struct socket *sock; int error; int type; + char buf[RPC_MAX_ADDRBUFLEN]; - dprintk("svc: svc_create_socket(%s, %d, %u.%u.%u.%u:%d)\n", - serv->sv_program->pg_name, protocol, - NIPQUAD(sin->sin_addr.s_addr), - ntohs(sin->sin_port)); + dprintk("svc: svc_create_socket(%s, %d, %s)\n", + serv->sv_program->pg_name, protocol, + __svc_print_addr((struct sockaddr *) sin, buf, + sizeof(buf))); if (protocol != IPPROTO_UDP && protocol != IPPROTO_TCP) { printk(KERN_WARNING "svc: only UDP and TCP " -- cgit v1.2.3 From 2442222283918c2d1c20ae651d95fe168757938b Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:33 -0800 Subject: [PATCH] knfsd: SUNRPC: Use sockaddr_storage to store address in svc_deferred_req Sockaddr_storage will allow us to store arbitrary socket addresses in the svc_deferred_req struct. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 08de328ce43..6680e0f0560 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1785,7 +1785,8 @@ svc_defer(struct cache_req *req) dr->handle.owner = rqstp->rq_server; dr->prot = rqstp->rq_prot; - dr->addr = rqstp->rq_addr; + memcpy(&dr->addr, &rqstp->rq_addr, rqstp->rq_addrlen); + dr->addrlen = rqstp->rq_addrlen; dr->daddr = rqstp->rq_daddr; dr->argslen = rqstp->rq_arg.len >> 2; memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2); @@ -1809,7 +1810,8 @@ static int svc_deferred_recv(struct svc_rqst *rqstp) rqstp->rq_arg.page_len = 0; rqstp->rq_arg.len = dr->argslen<<2; rqstp->rq_prot = dr->prot; - rqstp->rq_addr = dr->addr; + memcpy(&rqstp->rq_addr, &dr->addr, dr->addrlen); + rqstp->rq_addrlen = dr->addrlen; rqstp->rq_daddr = dr->daddr; rqstp->rq_respages = rqstp->rq_pages; return dr->argslen<<2; -- cgit v1.2.3 From 27459f0940e16c68e080f5fc7e85aa9eb3f74528 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:34 -0800 Subject: [PATCH] knfsd: SUNRPC: Provide room in svc_rqst for larger addresses Expand the rq_addr field to allow it to contain larger addresses. Specifically, we replace a 'sockaddr_in' with a 'sockaddr_storage', then everywhere the 'sockaddr_in' was referenced, we use instead an accessor function (svc_addr_in) which safely casts the _storage to _in. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcauth_unix.c | 3 ++- net/sunrpc/svcsock.c | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 987244f9590..4b775dbf580 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -421,6 +421,7 @@ svcauth_unix_info_release(void *info) static int svcauth_unix_set_client(struct svc_rqst *rqstp) { + struct sockaddr_in *sin = svc_addr_in(rqstp); struct ip_map *ipm; rqstp->rq_client = NULL; @@ -430,7 +431,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) ipm = ip_map_cached_get(rqstp); if (ipm == NULL) ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class, - rqstp->rq_addr.sin_addr); + sin->sin_addr); if (ipm == NULL) return SVC_DENIED; diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 6680e0f0560..b11669670ba 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -153,7 +153,7 @@ static char *__svc_print_addr(struct sockaddr *addr, char *buf, size_t len) */ char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len) { - return __svc_print_addr((struct sockaddr *) &rqstp->rq_addr, buf, len); + return __svc_print_addr(svc_addr(rqstp), buf, len); } EXPORT_SYMBOL_GPL(svc_print_addr); @@ -473,7 +473,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) /* set the source and destination */ struct msghdr msg; msg.msg_name = &rqstp->rq_addr; - msg.msg_namelen = sizeof(rqstp->rq_addr); + msg.msg_namelen = rqstp->rq_addrlen; msg.msg_iov = NULL; msg.msg_iovlen = 0; msg.msg_flags = MSG_MORE; @@ -696,6 +696,7 @@ svc_write_space(struct sock *sk) static int svc_udp_recvfrom(struct svc_rqst *rqstp) { + struct sockaddr_in *sin = svc_addr_in(rqstp); struct svc_sock *svsk = rqstp->rq_sock; struct svc_serv *serv = svsk->sk_server; struct sk_buff *skb; @@ -756,9 +757,12 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_prot = IPPROTO_UDP; /* Get sender address */ - rqstp->rq_addr.sin_family = AF_INET; - rqstp->rq_addr.sin_port = skb->h.uh->source; - rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; + sin->sin_family = AF_INET; + sin->sin_port = skb->h.uh->source; + sin->sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_addrlen = sizeof(struct sockaddr_in); + + /* Remember which interface received this request */ rqstp->rq_daddr = skb->nh.iph->daddr; if (skb_is_nonlinear(skb)) { @@ -1298,7 +1302,8 @@ svc_sock_update_bufs(struct svc_serv *serv) int svc_recv(struct svc_rqst *rqstp, long timeout) { - struct svc_sock *svsk =NULL; + struct svc_sock *svsk = NULL; + struct sockaddr_in *sin = svc_addr_in(rqstp); struct svc_serv *serv = rqstp->rq_server; struct svc_pool *pool = rqstp->rq_pool; int len, i; @@ -1395,7 +1400,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) svsk->sk_lastrecv = get_seconds(); clear_bit(SK_OLD, &svsk->sk_flags); - rqstp->rq_secure = ntohs(rqstp->rq_addr.sin_port) < 1024; + rqstp->rq_secure = ntohs(sin->sin_port) < PROT_SOCK; rqstp->rq_chandle.defer = svc_defer; if (serv->sv_stats) -- cgit v1.2.3 From 73df0dbaff8d0853387e140f52b6250c486b18a1 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:35 -0800 Subject: [PATCH] knfsd: SUNRPC: Make rq_daddr field address-version independent The rq_daddr field must support larger addresses. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index b11669670ba..9d7a819149c 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -484,7 +484,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) cmh->cmsg_level = SOL_IP; cmh->cmsg_type = IP_PKTINFO; pki->ipi_ifindex = 0; - pki->ipi_spec_dst.s_addr = rqstp->rq_daddr; + pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr; if (sock_sendmsg(sock, &msg, 0) < 0) goto out; @@ -763,7 +763,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_addrlen = sizeof(struct sockaddr_in); /* Remember which interface received this request */ - rqstp->rq_daddr = skb->nh.iph->daddr; + rqstp->rq_daddr.addr.s_addr = skb->nh.iph->daddr; if (skb_is_nonlinear(skb)) { /* we have to copy */ -- cgit v1.2.3 From b92503b25c3f794cff5f96626ea3ecba8d10d254 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:36 -0800 Subject: [PATCH] knfsd: SUNRPC: teach svc_sendto() to deal with IPv6 addresses CMSG_DATA comes in different sizes, depending on address family. [akpm@linux-foundation.org: remove unneeded do/while (0)] Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 65 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 17 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 9d7a819149c..a89d04bd385 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -446,6 +447,43 @@ svc_wake_up(struct svc_serv *serv) } } +union svc_pktinfo_u { + struct in_pktinfo pkti; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + struct in6_pktinfo pkti6; +#endif +}; + +static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh) +{ + switch (rqstp->rq_sock->sk_sk->sk_family) { + case AF_INET: { + struct in_pktinfo *pki = CMSG_DATA(cmh); + + cmh->cmsg_level = SOL_IP; + cmh->cmsg_type = IP_PKTINFO; + pki->ipi_ifindex = 0; + pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr; + cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); + } + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: { + struct in6_pktinfo *pki = CMSG_DATA(cmh); + + cmh->cmsg_level = SOL_IPV6; + cmh->cmsg_type = IPV6_PKTINFO; + pki->ipi6_ifindex = 0; + ipv6_addr_copy(&pki->ipi6_addr, + &rqstp->rq_daddr.addr6); + cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); + } + break; +#endif + } + return; +} + /* * Generic sendto routine */ @@ -455,9 +493,8 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) struct svc_sock *svsk = rqstp->rq_sock; struct socket *sock = svsk->sk_sock; int slen; - char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))]; + char buffer[CMSG_SPACE(sizeof(union svc_pktinfo_u))]; struct cmsghdr *cmh = (struct cmsghdr *)buffer; - struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmh); int len = 0; int result; int size; @@ -470,21 +507,15 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) slen = xdr->len; if (rqstp->rq_prot == IPPROTO_UDP) { - /* set the source and destination */ - struct msghdr msg; - msg.msg_name = &rqstp->rq_addr; - msg.msg_namelen = rqstp->rq_addrlen; - msg.msg_iov = NULL; - msg.msg_iovlen = 0; - msg.msg_flags = MSG_MORE; - - msg.msg_control = cmh; - msg.msg_controllen = sizeof(buffer); - cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); - cmh->cmsg_level = SOL_IP; - cmh->cmsg_type = IP_PKTINFO; - pki->ipi_ifindex = 0; - pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr; + struct msghdr msg = { + .msg_name = &rqstp->rq_addr, + .msg_namelen = rqstp->rq_addrlen, + .msg_control = cmh, + .msg_controllen = sizeof(buffer), + .msg_flags = MSG_MORE, + }; + + svc_set_cmsg_data(rqstp, cmh); if (sock_sendmsg(sock, &msg, 0) < 0) goto out; -- cgit v1.2.3 From bcdb81ae29091f6a66369aabfd8324e4a53d05dc Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:37 -0800 Subject: [PATCH] knfsd: SUNRPC: add a "generic" function to see if the peer uses a secure port The only reason svcsock.c looks at a sockaddr's port is to check whether the remote peer is connecting from a privileged port. Refactor this check to hide processing that is specific to address format. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index a89d04bd385..01e77b8208c 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -938,6 +938,22 @@ svc_tcp_data_ready(struct sock *sk, int count) wake_up_interruptible(sk->sk_sleep); } +static inline int svc_port_is_privileged(struct sockaddr *sin) +{ + switch (sin->sa_family) { + case AF_INET: + return ntohs(((struct sockaddr_in *)sin)->sin_port) + < PROT_SOCK; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: + return ntohs(((struct sockaddr_in6 *)sin)->sin6_port) + < PROT_SOCK; +#endif + default: + return 0; + } +} + /* * Accept a TCP connection */ @@ -984,7 +1000,7 @@ svc_tcp_accept(struct svc_sock *svsk) * hosts here, but when we get encryption, the IP of the host won't * tell us anything. For now just warn about unpriv connections. */ - if (ntohs(sin.sin_port) >= 1024) { + if (!svc_port_is_privileged((struct sockaddr *) &sin)) { dprintk(KERN_WARNING "%s: connect from unprivileged port: %s\n", serv->sv_name, @@ -1334,7 +1350,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) { struct svc_sock *svsk = NULL; - struct sockaddr_in *sin = svc_addr_in(rqstp); struct svc_serv *serv = rqstp->rq_server; struct svc_pool *pool = rqstp->rq_pool; int len, i; @@ -1431,7 +1446,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) svsk->sk_lastrecv = get_seconds(); clear_bit(SK_OLD, &svsk->sk_flags); - rqstp->rq_secure = ntohs(sin->sin_port) < PROT_SOCK; + rqstp->rq_secure = svc_port_is_privileged(svc_addr(rqstp)); rqstp->rq_chandle.defer = svc_defer; if (serv->sv_stats) -- cgit v1.2.3 From cdd88b9f3ed5013de0f1085e0e2f9123c798609d Mon Sep 17 00:00:00 2001 From: "akpm@linux-foundation.org" Date: Mon, 12 Feb 2007 00:53:38 -0800 Subject: [PATCH] knfsd: SUNRPC: Support IPv6 addresses in svc_tcp_accept Modify svc_tcp_accept to support connecting on IPv6 sockets. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 01e77b8208c..72831b8a58f 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -960,7 +960,8 @@ static inline int svc_port_is_privileged(struct sockaddr *sin) static void svc_tcp_accept(struct svc_sock *svsk) { - struct sockaddr_in sin; + struct sockaddr_storage addr; + struct sockaddr *sin = (struct sockaddr *) &addr; struct svc_serv *serv = svsk->sk_server; struct socket *sock = svsk->sk_sock; struct socket *newsock; @@ -987,8 +988,7 @@ svc_tcp_accept(struct svc_sock *svsk) set_bit(SK_CONN, &svsk->sk_flags); svc_sock_enqueue(svsk); - slen = sizeof(sin); - err = kernel_getpeername(newsock, (struct sockaddr *) &sin, &slen); + err = kernel_getpeername(newsock, sin, &slen); if (err < 0) { if (net_ratelimit()) printk(KERN_WARNING "%s: peername failed (err %d)!\n", @@ -1000,16 +1000,14 @@ svc_tcp_accept(struct svc_sock *svsk) * hosts here, but when we get encryption, the IP of the host won't * tell us anything. For now just warn about unpriv connections. */ - if (!svc_port_is_privileged((struct sockaddr *) &sin)) { + if (!svc_port_is_privileged(sin)) { dprintk(KERN_WARNING "%s: connect from unprivileged port: %s\n", serv->sv_name, - __svc_print_addr((struct sockaddr *) &sin, buf, - sizeof(buf))); + __svc_print_addr(sin, buf, sizeof(buf))); } dprintk("%s: connect from %s\n", serv->sv_name, - __svc_print_addr((struct sockaddr *) &sin, buf, - sizeof(buf))); + __svc_print_addr(sin, buf, sizeof(buf))); /* make sure that a write doesn't block forever when * low on memory @@ -1019,7 +1017,7 @@ svc_tcp_accept(struct svc_sock *svsk) if (!(newsvsk = svc_setup_socket(serv, newsock, &err, (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) goto failed; - memcpy(&newsvsk->sk_remote, &sin, slen); + memcpy(&newsvsk->sk_remote, sin, slen); newsvsk->sk_remotelen = slen; svc_sock_received(newsvsk); -- cgit v1.2.3 From 95756482c9bfa375418c5a32455494a3042f65cd Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:38 -0800 Subject: [PATCH] knfsd: SUNRPC: support IPv6 addresses in RPC server's UDP receive path Add support for IPv6 addresses in the RPC server's UDP receive path. [akpm@linux-foundation.org: cleanups] Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 53 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 72831b8a58f..6f509b9cae2 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -721,13 +721,53 @@ svc_write_space(struct sock *sk) } } +static void svc_udp_get_sender_address(struct svc_rqst *rqstp, + struct sk_buff *skb) +{ + switch (rqstp->rq_sock->sk_sk->sk_family) { + case AF_INET: { + /* this seems to come from net/ipv4/udp.c:udp_recvmsg */ + struct sockaddr_in *sin = svc_addr_in(rqstp); + + sin->sin_family = AF_INET; + sin->sin_port = skb->h.uh->source; + sin->sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_addrlen = sizeof(struct sockaddr_in); + /* Remember which interface received this request */ + rqstp->rq_daddr.addr.s_addr = skb->nh.iph->daddr; + } + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: { + /* this is derived from net/ipv6/udp.c:udpv6_recvmesg */ + struct sockaddr_in6 *sin6 = svc_addr_in6(rqstp); + + sin6->sin6_family = AF_INET6; + sin6->sin6_port = skb->h.uh->source; + sin6->sin6_flowinfo = 0; + sin6->sin6_scope_id = 0; + if (ipv6_addr_type(&sin6->sin6_addr) & + IPV6_ADDR_LINKLOCAL) + sin6->sin6_scope_id = IP6CB(skb)->iif; + ipv6_addr_copy(&sin6->sin6_addr, + &skb->nh.ipv6h->saddr); + rqstp->rq_addrlen = sizeof(struct sockaddr_in); + /* Remember which interface received this request */ + ipv6_addr_copy(&rqstp->rq_daddr.addr6, + &skb->nh.ipv6h->saddr); + } + break; +#endif + } + return; +} + /* * Receive a datagram from a UDP socket. */ static int svc_udp_recvfrom(struct svc_rqst *rqstp) { - struct sockaddr_in *sin = svc_addr_in(rqstp); struct svc_sock *svsk = rqstp->rq_sock; struct svc_serv *serv = svsk->sk_server; struct sk_buff *skb; @@ -785,16 +825,9 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) len = skb->len - sizeof(struct udphdr); rqstp->rq_arg.len = len; - rqstp->rq_prot = IPPROTO_UDP; - - /* Get sender address */ - sin->sin_family = AF_INET; - sin->sin_port = skb->h.uh->source; - sin->sin_addr.s_addr = skb->nh.iph->saddr; - rqstp->rq_addrlen = sizeof(struct sockaddr_in); + rqstp->rq_prot = IPPROTO_UDP; - /* Remember which interface received this request */ - rqstp->rq_daddr.addr.s_addr = skb->nh.iph->daddr; + svc_udp_get_sender_address(rqstp, skb); if (skb_is_nonlinear(skb)) { /* we have to copy */ -- cgit v1.2.3 From 77f1f67a1a56defa210c3d8857f3e5eee3990a99 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 12 Feb 2007 00:53:39 -0800 Subject: [PATCH] knfsd: SUNRPC: fix up svc_create_socket() to take a sockaddr struct + length Replace existing svc_create_socket() API to allow callers to pass addresses larger than a sockaddr_in. Signed-off-by: Chuck Lever Cc: Aurelien Charbon Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 6f509b9cae2..63ae94771b8 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1700,7 +1700,7 @@ EXPORT_SYMBOL_GPL(svc_addsock); * Create socket for RPC service. */ static int svc_create_socket(struct svc_serv *serv, int protocol, - struct sockaddr_in *sin, int flags) + struct sockaddr *sin, int len, int flags) { struct svc_sock *svsk; struct socket *sock; @@ -1710,8 +1710,7 @@ static int svc_create_socket(struct svc_serv *serv, int protocol, dprintk("svc: svc_create_socket(%s, %d, %s)\n", serv->sv_program->pg_name, protocol, - __svc_print_addr((struct sockaddr *) sin, buf, - sizeof(buf))); + __svc_print_addr(sin, buf, sizeof(buf))); if (protocol != IPPROTO_UDP && protocol != IPPROTO_TCP) { printk(KERN_WARNING "svc: only UDP and TCP " @@ -1720,15 +1719,15 @@ static int svc_create_socket(struct svc_serv *serv, int protocol, } type = (protocol == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM; - if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0) + error = sock_create_kern(sin->sa_family, type, protocol, &sock); + if (error < 0) return error; svc_reclassify_socket(sock); if (type == SOCK_STREAM) - sock->sk->sk_reuse = 1; /* allow address reuse */ - error = kernel_bind(sock, (struct sockaddr *) sin, - sizeof(*sin)); + sock->sk->sk_reuse = 1; /* allow address reuse */ + error = kernel_bind(sock, sin, len); if (error < 0) goto bummer; @@ -1818,7 +1817,8 @@ int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port, }; dprintk("svc: creating socket proto = %d\n", protocol); - return svc_create_socket(serv, protocol, &sin, flags); + return svc_create_socket(serv, protocol, (struct sockaddr *) &sin, + sizeof(sin), flags); } /* -- cgit v1.2.3 From da7071d7e32d15149cc513f096a3638097b66387 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 12 Feb 2007 00:55:36 -0800 Subject: [PATCH] mark struct file_operations const 8 Many struct file_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/cache.c | 12 ++++++------ net/sunrpc/rpc_pipe.c | 4 ++-- net/sunrpc/stats.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'net/sunrpc') diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index c80df455802..8612044b918 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -282,9 +282,9 @@ static DEFINE_SPINLOCK(cache_list_lock); static struct cache_detail *current_detail; static int current_index; -static struct file_operations cache_file_operations; -static struct file_operations content_file_operations; -static struct file_operations cache_flush_operations; +static const struct file_operations cache_file_operations; +static const struct file_operations content_file_operations; +static const struct file_operations cache_flush_operations; static void do_cache_clean(struct work_struct *work); static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); @@ -887,7 +887,7 @@ cache_release(struct inode *inode, struct file *filp) -static struct file_operations cache_file_operations = { +static const struct file_operations cache_file_operations = { .owner = THIS_MODULE, .llseek = no_llseek, .read = cache_read, @@ -1245,7 +1245,7 @@ static int content_release(struct inode *inode, struct file *file) return seq_release(inode, file); } -static struct file_operations content_file_operations = { +static const struct file_operations content_file_operations = { .open = content_open, .read = seq_read, .llseek = seq_lseek, @@ -1297,7 +1297,7 @@ static ssize_t write_flush(struct file * file, const char __user * buf, return count; } -static struct file_operations cache_flush_operations = { +static const struct file_operations cache_flush_operations = { .open = nonseekable_open, .read = read_flush, .write = write_flush, diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 89273d35e0c..e1fad77a225 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -309,7 +309,7 @@ rpc_pipe_ioctl(struct inode *ino, struct file *filp, } } -static struct file_operations rpc_pipe_fops = { +static const struct file_operations rpc_pipe_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = rpc_pipe_read, @@ -366,7 +366,7 @@ rpc_info_release(struct inode *inode, struct file *file) return single_release(inode, file); } -static struct file_operations rpc_info_operations = { +static const struct file_operations rpc_info_operations = { .owner = THIS_MODULE, .open = rpc_info_open, .read = seq_read, diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index bd98124c3a6..044d9484bb8 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -66,7 +66,7 @@ static int rpc_proc_open(struct inode *inode, struct file *file) return single_open(file, rpc_proc_show, PDE(inode)->data); } -static struct file_operations rpc_proc_fops = { +static const struct file_operations rpc_proc_fops = { .owner = THIS_MODULE, .open = rpc_proc_open, .read = seq_read, -- cgit v1.2.3