sctp: Add process name and pid to deprecation warnings
[deliverable/linux.git] / net / sctp / socket.c
index 72046b9729a8a6a669fb9c75446de8ef2fe345c6..d32dae78a4868439646dbe3b6d418a90ae5b4305 100644 (file)
@@ -28,9 +28,8 @@
  * See the GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with GNU CC; see the file COPYING.  If not, write to
- * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * along with GNU CC; see the file COPYING.  If not, see
+ * <http://www.gnu.org/licenses/>.
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
@@ -83,7 +82,7 @@ static int sctp_writeable(struct sock *sk);
 static void sctp_wfree(struct sk_buff *skb);
 static int sctp_wait_for_sndbuf(struct sctp_association *, long *timeo_p,
                                size_t msg_len);
-static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p);
+static int sctp_wait_for_packet(struct sock *sk, int *err, long *timeo_p);
 static int sctp_wait_for_connect(struct sctp_association *, long *timeo_p);
 static int sctp_wait_for_accept(struct sock *sk, long timeo);
 static void sctp_wait_for_close(struct sock *sk, long timeo);
@@ -953,7 +952,7 @@ int sctp_asconf_mgmt(struct sctp_sock *sp, struct sctp_sockaddr_entry *addrw)
  *
  * Returns 0 if ok, <0 errno code on error.
  */
-static int sctp_setsockopt_bindx(struct socksk,
+static int sctp_setsockopt_bindx(struct sock *sk,
                                 struct sockaddr __user *addrs,
                                 int addrs_size, int op)
 {
@@ -1040,7 +1039,7 @@ out:
  * Common routine for handling connect() and sctp_connectx().
  * Connect will come in with just a single address.
  */
-static int __sctp_connect(struct socksk,
+static int __sctp_connect(struct sock *sk,
                          struct sockaddr *kaddrs,
                          int addrs_size,
                          sctp_assoc_t *assoc_id)
@@ -1300,7 +1299,7 @@ out_free:
  *
  * Returns >=0 if ok, <0 errno code on error.
  */
-static int __sctp_setsockopt_connectx(struct socksk,
+static int __sctp_setsockopt_connectx(struct sock *sk,
                                      struct sockaddr __user *addrs,
                                      int addrs_size,
                                      sctp_assoc_t *assoc_id)
@@ -1338,7 +1337,7 @@ static int __sctp_setsockopt_connectx(struct sock* sk,
  * This is an older interface.  It's kept for backward compatibility
  * to the option that doesn't provide association id.
  */
-static int sctp_setsockopt_connectx_old(struct socksk,
+static int sctp_setsockopt_connectx_old(struct sock *sk,
                                        struct sockaddr __user *addrs,
                                        int addrs_size)
 {
@@ -1351,7 +1350,7 @@ static int sctp_setsockopt_connectx_old(struct sock* sk,
  * indication to the call.  Error is always negative and association id is
  * always positive.
  */
-static int sctp_setsockopt_connectx(struct socksk,
+static int sctp_setsockopt_connectx(struct sock *sk,
                                    struct sockaddr __user *addrs,
                                    int addrs_size)
 {
@@ -1374,7 +1373,7 @@ static int sctp_setsockopt_connectx(struct sock* sk,
  * addrs_num structure member.  That way we can re-use the existing
  * code.
  */
-static int sctp_getsockopt_connectx3(struct socksk, int len,
+static int sctp_getsockopt_connectx3(struct sock *sk, int len,
                                     char __user *optval,
                                     int __user *optlen)
 {
@@ -1569,7 +1568,7 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
        struct net *net = sock_net(sk);
        struct sctp_sock *sp;
        struct sctp_endpoint *ep;
-       struct sctp_association *new_asoc=NULL, *asoc=NULL;
+       struct sctp_association *new_asoc = NULL, *asoc = NULL;
        struct sctp_transport *transport, *chunk_tp;
        struct sctp_chunk *chunk;
        union sctp_addr to;
@@ -2196,6 +2195,7 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
                                     unsigned int optlen)
 {
        struct sctp_sock *sp = sctp_sk(sk);
+       struct net *net = sock_net(sk);
 
        /* Applicable to UDP-style socket only */
        if (sctp_style(sk, TCP))
@@ -2205,6 +2205,9 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
        if (copy_from_user(&sp->autoclose, optval, optlen))
                return -EFAULT;
 
+       if (sp->autoclose > net->sctp.max_autoclose)
+               sp->autoclose = net->sctp.max_autoclose;
+
        return 0;
 }
 
@@ -2459,7 +2462,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
        int hb_change, pmtud_change, sackdelay_change;
 
        if (optlen != sizeof(struct sctp_paddrparams))
-               return - EINVAL;
+               return -EINVAL;
 
        if (copy_from_user(&params, optval, optlen))
                return -EFAULT;
@@ -2480,7 +2483,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
        /* If an address other than INADDR_ANY is specified, and
         * no transport is found, then the request is invalid.
         */
-       if (!sctp_is_any(sk, ( union sctp_addr *)&params.spp_address)) {
+       if (!sctp_is_any(sk, (union sctp_addr *)&params.spp_address)) {
                trans = sctp_addr_id2transport(sk, &params.spp_address,
                                               params.spp_assoc_id);
                if (!trans)
@@ -2575,8 +2578,11 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
                if (params.sack_delay == 0 && params.sack_freq == 0)
                        return 0;
        } else if (optlen == sizeof(struct sctp_assoc_value)) {
-               pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
-               pr_warn("Use struct sctp_sack_info instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of struct sctp_assoc_value in delayed_ack socket option.\n"
+                                   "Use struct sctp_sack_info instead\n",
+                                   current->comm, task_pid_nr(current));
                if (copy_from_user(&params, optval, optlen))
                        return -EFAULT;
 
@@ -2585,7 +2591,7 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
                else
                        params.sack_freq = 0;
        } else
-               return - EINVAL;
+               return -EINVAL;
 
        /* Validate value parameter. */
        if (params.sack_delay > 500)
@@ -2811,6 +2817,8 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
 {
        struct sctp_rtoinfo rtoinfo;
        struct sctp_association *asoc;
+       unsigned long rto_min, rto_max;
+       struct sctp_sock *sp = sctp_sk(sk);
 
        if (optlen != sizeof (struct sctp_rtoinfo))
                return -EINVAL;
@@ -2824,26 +2832,36 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
        if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP))
                return -EINVAL;
 
+       rto_max = rtoinfo.srto_max;
+       rto_min = rtoinfo.srto_min;
+
+       if (rto_max)
+               rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
+       else
+               rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
+
+       if (rto_min)
+               rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
+       else
+               rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
+
+       if (rto_min > rto_max)
+               return -EINVAL;
+
        if (asoc) {
                if (rtoinfo.srto_initial != 0)
                        asoc->rto_initial =
                                msecs_to_jiffies(rtoinfo.srto_initial);
-               if (rtoinfo.srto_max != 0)
-                       asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max);
-               if (rtoinfo.srto_min != 0)
-                       asoc->rto_min = msecs_to_jiffies(rtoinfo.srto_min);
+               asoc->rto_max = rto_max;
+               asoc->rto_min = rto_min;
        } else {
                /* If there is no association or the association-id = 0
                 * set the values to the endpoint.
                 */
-               struct sctp_sock *sp = sctp_sk(sk);
-
                if (rtoinfo.srto_initial != 0)
                        sp->rtoinfo.srto_initial = rtoinfo.srto_initial;
-               if (rtoinfo.srto_max != 0)
-                       sp->rtoinfo.srto_max = rtoinfo.srto_max;
-               if (rtoinfo.srto_min != 0)
-                       sp->rtoinfo.srto_min = rtoinfo.srto_min;
+               sp->rtoinfo.srto_max = rto_max;
+               sp->rtoinfo.srto_min = rto_min;
        }
 
        return 0;
@@ -2979,8 +2997,11 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
        int val;
 
        if (optlen == sizeof(int)) {
-               pr_warn("Use of int in maxseg socket option deprecated\n");
-               pr_warn("Use struct sctp_assoc_value instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of int in maxseg socket option.\n"
+                                   "Use struct sctp_assoc_value instead\n",
+                                   current->comm, task_pid_nr(current));
                if (copy_from_user(&val, optval, optlen))
                        return -EFAULT;
                params.assoc_id = 0;
@@ -3237,8 +3258,11 @@ static int sctp_setsockopt_maxburst(struct sock *sk,
        int assoc_id = 0;
 
        if (optlen == sizeof(int)) {
-               pr_warn("Use of int in max_burst socket option deprecated\n");
-               pr_warn("Use struct sctp_assoc_value instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of int in max_burst socket option deprecated.\n"
+                                   "Use struct sctp_assoc_value instead\n",
+                                   current->comm, task_pid_nr(current));
                if (copy_from_user(&val, optval, optlen))
                        return -EFAULT;
        } else if (optlen == sizeof(struct sctp_assoc_value)) {
@@ -3317,7 +3341,7 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk,
        if (optlen < sizeof(struct sctp_hmacalgo))
                return -EINVAL;
 
-       hmacs= memdup_user(optval, optlen);
+       hmacs = memdup_user(optval, optlen);
        if (IS_ERR(hmacs))
                return PTR_ERR(hmacs);
 
@@ -3355,7 +3379,7 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
        if (optlen <= sizeof(struct sctp_authkey))
                return -EINVAL;
 
-       authkey= memdup_user(optval, optlen);
+       authkey = memdup_user(optval, optlen);
        if (IS_ERR(authkey))
                return PTR_ERR(authkey);
 
@@ -3909,7 +3933,7 @@ static int sctp_init_sock(struct sock *sk)
         */
        sp->hbinterval  = net->sctp.hb_interval;
        sp->pathmaxrxt  = net->sctp.max_retrans_path;
-       sp->pathmtu     = 0; // allow default discovery
+       sp->pathmtu     = 0; /* allow default discovery */
        sp->sackdelay   = net->sctp.sack_timeout;
        sp->sackfreq    = 2;
        sp->param_flags = SPP_HB_ENABLE |
@@ -4452,7 +4476,7 @@ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len,
        /* If an address other than INADDR_ANY is specified, and
         * no transport is found, then the request is invalid.
         */
-       if (!sctp_is_any(sk, ( union sctp_addr *)&params.spp_address)) {
+       if (!sctp_is_any(sk, (union sctp_addr *)&params.spp_address)) {
                trans = sctp_addr_id2transport(sk, &params.spp_address,
                                               params.spp_assoc_id);
                if (!trans) {
@@ -4558,12 +4582,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
                if (copy_from_user(&params, optval, len))
                        return -EFAULT;
        } else if (len == sizeof(struct sctp_assoc_value)) {
-               pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
-               pr_warn("Use struct sctp_sack_info instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of struct sctp_assoc_value in delayed_ack socket option.\n"
+                                   "Use struct sctp_sack_info instead\n",
+                                   current->comm, task_pid_nr(current));
                if (copy_from_user(&params, optval, len))
                        return -EFAULT;
        } else
-               return - EINVAL;
+               return -EINVAL;
 
        /* Get association, if sack_assoc_id != 0 and the socket is a one
         * to many style socket, and an association was not found, then
@@ -4653,8 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
        if (!asoc)
                return -EINVAL;
 
-       to = optval + offsetof(struct sctp_getaddrs,addrs);
-       space_left = len - offsetof(struct sctp_getaddrs,addrs);
+       to = optval + offsetof(struct sctp_getaddrs, addrs);
+       space_left = len - offsetof(struct sctp_getaddrs, addrs);
 
        list_for_each_entry(from, &asoc->peer.transport_addr_list,
                                transports) {
@@ -4714,7 +4741,7 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
                memcpy(to, &temp, addrlen);
 
                to += addrlen;
-               cnt ++;
+               cnt++;
                space_left -= addrlen;
                *bytes_copied += addrlen;
        }
@@ -4763,8 +4790,8 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                bp = &asoc->base.bind_addr;
        }
 
-       to = optval + offsetof(struct sctp_getaddrs,addrs);
-       space_left = len - offsetof(struct sctp_getaddrs,addrs);
+       to = optval + offsetof(struct sctp_getaddrs, addrs);
+       space_left = len - offsetof(struct sctp_getaddrs, addrs);
 
        addrs = kmalloc(space_left, GFP_KERNEL);
        if (!addrs)
@@ -4803,7 +4830,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                memcpy(buf, &temp, addrlen);
                buf += addrlen;
                bytes_copied += addrlen;
-               cnt ++;
+               cnt++;
                space_left -= addrlen;
        }
 
@@ -5075,7 +5102,7 @@ static int sctp_getsockopt_associnfo(struct sock *sk, int len,
                assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life);
 
                list_for_each(pos, &asoc->peer.transport_addr_list) {
-                       cnt ++;
+                       cnt++;
                }
 
                assocparams.sasoc_number_peer_destinations = cnt;
@@ -5203,8 +5230,11 @@ static int sctp_getsockopt_maxseg(struct sock *sk, int len,
        struct sctp_association *asoc;
 
        if (len == sizeof(int)) {
-               pr_warn("Use of int in maxseg socket option deprecated\n");
-               pr_warn("Use struct sctp_assoc_value instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of int in maxseg socket option.\n"
+                                   "Use struct sctp_assoc_value instead\n",
+                                   current->comm, task_pid_nr(current));
                params.assoc_id = 0;
        } else if (len >= sizeof(struct sctp_assoc_value)) {
                len = sizeof(struct sctp_assoc_value);
@@ -5295,8 +5325,11 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
        struct sctp_association *asoc;
 
        if (len == sizeof(int)) {
-               pr_warn("Use of int in max_burst socket option deprecated\n");
-               pr_warn("Use struct sctp_assoc_value instead\n");
+               pr_warn_ratelimited(DEPRECATED
+                                   "%s (pid %d) "
+                                   "Use of int in max_burst socket option.\n"
+                                   "Use struct sctp_assoc_value instead\n",
+                                   current->comm, task_pid_nr(current));
                params.assoc_id = 0;
        } else if (len >= sizeof(struct sctp_assoc_value)) {
                len = sizeof(struct sctp_assoc_value);
@@ -5428,7 +5461,8 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
                return -EFAULT;
 num:
        len = sizeof(struct sctp_authchunks) + num_chunks;
-       if (put_user(len, optlen)) return -EFAULT;
+       if (put_user(len, optlen))
+               return -EFAULT;
        if (put_user(num_chunks, &p->gauth_number_of_chunks))
                return -EFAULT;
        return 0;
@@ -5460,7 +5494,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
                return -EINVAL;
 
        if (asoc)
-               ch = (struct sctp_chunks_param*)asoc->c.auth_chunks;
+               ch = (struct sctp_chunks_param *)asoc->c.auth_chunks;
        else
                ch = sctp_sk(sk)->ep->auth_chunk_list;
 
@@ -6402,7 +6436,7 @@ static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs)
  * Note: This function is the same function as in core/datagram.c
  * with a few modifications to make lksctp work.
  */
-static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p)
+static int sctp_wait_for_packet(struct sock *sk, int *err, long *timeo_p)
 {
        int error;
        DEFINE_WAIT(wait);
This page took 0.029839 seconds and 5 git commands to generate.