Merge tag 'v3.10.95' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / core / sock.c
index 5a954fccc7d3612e9f76f155ee66bb7b8d490bec..66e2ab8888eece6be9ff5cba28c45f08f2889e21 100644 (file)
 
 #include <trace/events/sock.h>
 
+#include <net/af_unix.h>
+
+
 #ifdef CONFIG_INET
 #include <net/tcp.h>
 #endif
+#include <linux/xlog.h>
 
 static DEFINE_MUTEX(proto_list_mutex);
 static LIST_HEAD(proto_list);
@@ -313,7 +317,7 @@ static struct lock_class_key af_callback_keys[AF_MAX];
 /* Run time adjustable parameters. */
 __u32 sysctl_wmem_max __read_mostly = SK_WMEM_MAX;
 EXPORT_SYMBOL(sysctl_wmem_max);
-__u32 sysctl_rmem_max __read_mostly = SK_RMEM_MAX;
+__u32 sysctl_rmem_max __read_mostly = (SK_RMEM_MAX*8);
 EXPORT_SYMBOL(sysctl_rmem_max);
 __u32 sysctl_wmem_default __read_mostly = SK_WMEM_MAX;
 __u32 sysctl_rmem_default __read_mostly = SK_RMEM_MAX;
@@ -725,7 +729,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                val = min_t(u32, val, sysctl_wmem_max);
 set_sndbuf:
                sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
-               sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);
+               sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
                /* Wake up sending tasks if we upped the value. */
                sk->sk_write_space(sk);
                break;
@@ -761,7 +765,7 @@ set_rcvbuf:
                 * returning the value we actually used in getsockopt
                 * is the most desirable behavior.
                 */
-               sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);
+               sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF);
                break;
 
        case SO_RCVBUFFORCE:
@@ -1630,7 +1634,13 @@ EXPORT_SYMBOL(sock_edemux);
 kuid_t sock_i_uid(struct sock *sk)
 {
        kuid_t uid;
-
+       
+       /*mtk_net: fix kernel bug*/
+       if (!sk) {
+               pr_info("sk == NULL for sock_i_uid\n");
+               return GLOBAL_ROOT_UID;
+       }
+       
        read_lock_bh(&sk->sk_callback_lock);
        uid = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : GLOBAL_ROOT_UID;
        read_unlock_bh(&sk->sk_callback_lock);
@@ -1741,6 +1751,111 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
 }
 
 
+//debug funcion
+
+static int sock_dump_info(struct sock *sk)
+{
+    //dump receiver queue 128 bytes
+    //struct sk_buff *skb;
+    //char skbmsg[128];
+    //dump receiver queue 128 bytes end
+
+               if(sk->sk_family == AF_UNIX)
+               {
+                 struct unix_sock *u = unix_sk(sk);
+                 struct sock *other = NULL;
+                 if( (u->path.dentry !=NULL)&&(u->path.dentry->d_iname!=NULL))
+                  //if( (u->dentry !=NULL)&&(u->dentry->d_iname!=NULL))
+                 {
+                         #ifdef CONFIG_MTK_NET_LOGGING  
+                     printk(KERN_INFO "[mtk_net][sock]sockdbg: socket-Name:%s \n",u->path.dentry->d_iname);
+                     #endif
+                 }
+                  else
+                 {
+                          #ifdef CONFIG_MTK_NET_LOGGING  
+               printk(KERN_INFO "[mtk_net][sock]sockdbg:socket Name (NULL)\n" );
+               #endif
+                  }
+                  
+                  if(sk->sk_socket && SOCK_INODE(sk->sk_socket))
+                 {
+                               #ifdef CONFIG_MTK_NET_LOGGING  
+                       printk(KERN_INFO "[mtk_net][sock]sockdbg:socket Inode[%lu]\n" ,SOCK_INODE(sk->sk_socket)->i_ino);
+                       #endif
+                  }             
+
+                   other = unix_sk(sk)->peer ;
+                       if (!other)
+                       {
+                               #ifdef CONFIG_MTK_NET_LOGGING  
+                       printk(KERN_INFO "[mtk_net][sock]sockdbg:peer is (NULL) \n");
+                       #endif
+                        } else{
+                        
+                               if ((((struct unix_sock *)other)->path.dentry != NULL)&&(((struct unix_sock *)other)->path.dentry->d_iname != NULL))
+                                //if ((((struct unix_sock *)other)->dentry != NULL)&&(((struct unix_sock *)other)->dentry->d_iname != NULL))
+                               {
+                                       #ifdef CONFIG_MTK_NET_LOGGING  
+                           printk(KERN_INFO "[mtk_net][sock]sockdbg: Peer Name:%s \n",((struct unix_sock *)other)->path.dentry->d_iname);
+                           #endif
+                                }                              
+                               else
+                               {
+                                       #ifdef CONFIG_MTK_NET_LOGGING  
+                    printk(KERN_INFO "[mtk_net][sock]sockdbg: Peer Name (NULL) \n");
+                    #endif
+                               }
+
+                               if(other->sk_socket && SOCK_INODE(other->sk_socket))
+                                  {
+                                       #ifdef CONFIG_MTK_NET_LOGGING  
+                           printk(KERN_INFO "[mtk_net][sock]sockdbg: Peer Inode [%lu] \n", SOCK_INODE(other->sk_socket)->i_ino);
+                           #endif
+                                   }
+                   #ifdef CONFIG_MTK_NET_LOGGING  
+                               printk(KERN_INFO "[mtk_net][sock]sockdbg: Peer Recieve Queue len:%d \n",other->sk_receive_queue.qlen);
+                #endif
+                                //dump receiver queue 128 bytes
+                                               /* if ((skb = skb_peek_tail(&other->sk_receive_queue)) == NULL) {
+                                       
+                                   printk(KERN_INFO "sockdbg: Peer Recieve Queue is null (warning) \n");
+                                                }else{
+                                                      int i =0 ,len=0;
+                                     if((skb->len !=0) && (skb->data != NULL)){
+
+                                       if(skb->len >= 127){
+                                                                       len = 127 ;                          
+                                                                }else
+                                                                {
+                                          len = skb->len ;
+                                                                }
+                                       for (i=0;i<len;i++)
+                                                                 sprintf(skbmsg+i, "%x", skb->data[i]);
+
+                                                               skbmsg[len]= '\0' ;
+                                                               
+                                       printk(KERN_INFO "sockdbg: Peer Recieve Queue dump(%d bytes):%s\n", len, skbmsg);
+                                                                                               
+                                       
+                                                         }else{                
+                                       printk(KERN_INFO "sockdbg: Peer Recieve skb error \n");
+                                                         }*/
+                     //dump receiver queue 128 bytes end      
+
+                                //}
+                               //dump receiver queue 128 bytes end                              
+
+                        }
+               }
+
+               return 0 ;        
+
+       
+}
+
+
+
 /*
  *     Generic send/receive buffer handlers
  */
@@ -1816,7 +1931,17 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
                        goto failure;
                if (signal_pending(current))
                        goto interrupted;
+
+        sock_dump_info(sk);
+        #ifdef CONFIG_MTK_NET_LOGGING  
+               printk(KERN_INFO "[mtk_net][sock]sockdbg: wait_for_wmem, timeo =%ld, wmem =%d, snd buf =%d \n",
+                        timeo, atomic_read(&sk->sk_wmem_alloc), sk->sk_sndbuf); 
+        #endif
                timeo = sock_wait_for_wmem(sk, timeo);
+               #ifdef CONFIG_MTK_NET_LOGGING  
+               printk(KERN_INFO "[mtk_net][sock]sockdbg: wait_for_wmem done, header_len=0x%lx, data_len=0x%lx,timeo =%ld \n",
+                        header_len, data_len ,timeo);
+           #endif
        }
 
        skb_set_owner_w(skb, sk);