Author: dchagin
Date: Mon May 25 20:24:36 2009
New Revision: 192769
URL: http://svn.freebsd.org/changeset/base/192769

Log:
  Merge r191989 from HEAD to stable/7:
  
  Translate l_timeval arg to native struct timeval in
  linux_setsockopt()/linux_getsockopt() for SO_RCVTIMEO,
  SO_SNDTIMEO opts as l_timeval has MD members.
  
  Remove bogus __packed attribute from l_timeval struct on __amd64__.
  
  PR:           kern/134276
  Submitted by: Thomas Mueller <tmueller sysgo com>
  Approved by:  kib (mentor)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/linux32/linux.h
  stable/7/sys/compat/linux/linux_socket.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)

Modified: stable/7/sys/amd64/linux32/linux.h
==============================================================================
--- stable/7/sys/amd64/linux32/linux.h  Mon May 25 20:07:41 2009        
(r192768)
+++ stable/7/sys/amd64/linux32/linux.h  Mon May 25 20:24:36 2009        
(r192769)
@@ -94,7 +94,7 @@ typedef struct {
 typedef struct {
        l_time_t        tv_sec;
        l_suseconds_t   tv_usec;
-} __packed l_timeval;
+} l_timeval;
 
 #define        l_fd_set        fd_set
 

Modified: stable/7/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/7/sys/compat/linux/linux_socket.c    Mon May 25 20:07:41 2009        
(r192768)
+++ stable/7/sys/compat/linux/linux_socket.c    Mon May 25 20:24:36 2009        
(r192769)
@@ -1073,6 +1073,8 @@ linux_setsockopt(struct thread *td, stru
                caddr_t val;
                int valsize;
        } */ bsd_args;
+       l_timeval linux_tv;
+       struct timeval tv;
        int error, name;
 
        bsd_args.s = args->s;
@@ -1080,6 +1082,23 @@ linux_setsockopt(struct thread *td, stru
        switch (bsd_args.level) {
        case SOL_SOCKET:
                name = linux_to_bsd_so_sockopt(args->optname);
+               switch (name) {
+               case SO_RCVTIMEO:
+                       /* FALLTHROUGH */
+               case SO_SNDTIMEO:
+                       error = copyin(PTRIN(args->optval), &linux_tv,
+                           sizeof(linux_tv));
+                       if (error)
+                               return (error);
+                       tv.tv_sec = linux_tv.tv_sec;
+                       tv.tv_usec = linux_tv.tv_usec;
+                       return (kern_setsockopt(td, args->s, bsd_args.level,
+                           name, &tv, UIO_SYSSPACE, sizeof(tv)));
+                       /* NOTREACHED */
+                       break;
+               default:
+                       break;
+               }
                break;
        case IPPROTO_IP:
                name = linux_to_bsd_ip_sockopt(args->optname);
@@ -1128,6 +1147,9 @@ linux_getsockopt(struct thread *td, stru
                caddr_t val;
                int *avalsize;
        } */ bsd_args;
+       l_timeval linux_tv;
+       struct timeval tv;
+       socklen_t tv_len;
        int error, name;
 
        bsd_args.s = args->s;
@@ -1135,6 +1157,24 @@ linux_getsockopt(struct thread *td, stru
        switch (bsd_args.level) {
        case SOL_SOCKET:
                name = linux_to_bsd_so_sockopt(args->optname);
+               switch (name) {
+               case SO_RCVTIMEO:
+                       /* FALLTHROUGH */
+               case SO_SNDTIMEO:
+                       tv_len = sizeof(tv);
+                       error = kern_getsockopt(td, args->s, bsd_args.level,
+                           name, &tv, UIO_SYSSPACE, &tv_len);
+                       if (error)
+                               return (error);
+                       linux_tv.tv_sec = tv.tv_sec;
+                       linux_tv.tv_usec = tv.tv_usec;
+                       return (copyout(&linux_tv, PTRIN(args->optval),
+                           sizeof(linux_tv)));
+                       /* NOTREACHED */
+                       break;
+               default:
+                       break;
+               }
                break;
        case IPPROTO_IP:
                name = linux_to_bsd_ip_sockopt(args->optname);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to