]> git.neil.brown.name Git - history.git/commitdiff
Import 2.1.38 2.1.38
authorLinus Torvalds <torvalds@linuxfoundation.org>
Fri, 23 Nov 2007 20:13:17 +0000 (15:13 -0500)
committerLinus Torvalds <torvalds@linuxfoundation.org>
Fri, 23 Nov 2007 20:13:17 +0000 (15:13 -0500)
20 files changed:
Documentation/ioctl-number.txt
arch/i386/Makefile
arch/i386/kernel/setup.c
arch/sparc/kernel/ptrace.c
arch/sparc/kernel/signal.c
arch/sparc/mm/asyncd.c
arch/sparc/mm/fault.c
arch/sparc64/mm/asyncd.c
arch/sparc64/mm/fault.c
fs/autofs/autofs_i.h
fs/autofs/init.c
fs/autofs/root.c
fs/autofs/waitq.c
include/linux/in6.h
include/linux/socket.h
mm/memory.c
net/core/scm.c
net/ipv4/ip_sockglue.c
net/ipv6/datagram.c
net/ipv6/ipv6_sockglue.c

index 4e1eba41eb9c09420afc1f565cbf67e76591a76a..7d86d3168a01412d76bdaa07dc355c7edd35e08e 100644 (file)
@@ -1,5 +1,5 @@
 Ioctl Numbers
-5 Apr 1997
+10 Apr 1997
 Michael Chastain
 <mec@shout.net>
 
@@ -87,6 +87,8 @@ Code  Seq#    Include File            Comments
 'W'    28-2F   linux/iso16-relay.h     in development
 'Y'    all     linux/cyclades.h
 'a'    all     various, see http://lrcwww.epfl.ch/linux-atm/magic.html
+'b'    00-3F   bit3 vme host bridge    in development:
+                                       <mailto:natalia@nikhefk.nikhef.nl>
 'c'    all     linux/comstats.h
 'f'    all     linux/ext2_fs.h
 'l'    00-3F   linux/tcfs_fs.h         in development:
@@ -94,7 +96,8 @@ Code  Seq#    Include File            Comments
 'm'    all     linux/mtio.h            conflict!
 'm'    all     linux/soundcard.h       conflict!
 'n'    all     linux/ncp_fs.h
-'p'    all     linux/mc146818rtc.h
+'p'    00-3F   linux/mc146818rtc.h
+'p'    40-7F   linux/nvram.h
 'r'    all     linux/msdos_fs.h
 's'    all     linux/cdk.h
 't'    00-7F   linux/if_ppp.h
@@ -108,8 +111,9 @@ Code        Seq#    Include File            Comments
 0x89   F0-FF   linux/sockios.h         SIOCDEVPRIVATE range
 0x8B   all     linux/wireless.h
 0x8C   00-3F   WiNRADiO driver         in development:
-                                       <mailto:brian@proximity.com.au>
+                                       <http://www.proximity.com.au/~brian/winradio/>
 0x90   00      linux/sbpcd.h
+0x93   60-7F   linux/auto_fs.h
 0x99   00-0F   537-Addinboard driver   in development:
                                        <mailto:b.kohl@ipn-b.comlink.apc.org>
 0xA0   all     Small Device Project    in development:
index 7e02bc36f70603d4f5474fc460c15952024b391c..bc4e030299e15f9ecd37f3ba8d0f68abd4119831 100644 (file)
@@ -85,7 +85,7 @@ bzdisk: vmlinux
        @$(MAKEBOOT) BOOTIMAGE=bzImage zdisk
 
 install: vmlinux
-       @$(MAKEBOOT) BOOTIMAGE=zImage install
+       @$(MAKEBOOT) BOOTIMAGE=bzImage install
 
 archclean:
        @$(MAKEBOOT) clean
index a46b0089753f515605b5d3b5150ff4c20d24a731..f62744d11cd0388df24bb8dafc7068f86d04cec9 100644 (file)
@@ -325,6 +325,8 @@ int get_cpuinfo(char * buffer)
 
                        sep_bug = CD(have_cpuid) &&
                                  (CD(x86_capability) & 0x800) &&
+                                 !memcmp(x86_vendor_id, "GenuineIntel", 12) &&
+                                 CD(x86) == 6 &&
                                  CD(x86_model) < 3 &&
                                  CD(x86_mask) < 3;
         
index 1422f1ee37cb3b6edbc4ec5c94bcf55a64b10741..732b3006dd67b96fd578be3edc7a44c1bceb2614 100644 (file)
 
 #define MAGIC_CONSTANT 0x80000000
 
-extern void do_wp_page(struct task_struct * tsk, struct vm_area_struct * vma,
-                      unsigned long address, int write_access);
-
-extern void do_no_page(struct task_struct * tsk, struct vm_area_struct * vma,
-                      unsigned long address, int write_access);
-
 /*
  * This routine gets a long from any process space by following the page
  * tables. NOTE! You should check that the long isn't on a page boundary,
@@ -47,7 +41,7 @@ static unsigned long get_long(struct task_struct * tsk,
 repeat:
        pgdir = pgd_offset(vma->vm_mm, addr);
        if (pgd_none(*pgdir)) {
-               do_no_page(tsk, vma, addr, 0);
+               handle_mm_fault(tsk, vma, addr, 0);
                goto repeat;
        }
        if (pgd_bad(*pgdir)) {
@@ -57,7 +51,7 @@ repeat:
        }
        pgmiddle = pmd_offset(pgdir, addr);
        if (pmd_none(*pgmiddle)) {
-               do_no_page(tsk, vma, addr, 0);
+               handle_mm_fault(tsk, vma, addr, 0);
                goto repeat;
        }
        if (pmd_bad(*pgmiddle)) {
@@ -67,7 +61,7 @@ repeat:
        }
        pgtable = pte_offset(pgmiddle, addr);
        if (!pte_present(*pgtable)) {
-               do_no_page(tsk, vma, addr, 0);
+               handle_mm_fault(tsk, vma, addr, 0);
                goto repeat;
        }
        page = pte_page(*pgtable);
@@ -100,7 +94,7 @@ static void put_long(struct task_struct * tsk, struct vm_area_struct * vma,
 repeat:
        pgdir = pgd_offset(vma->vm_mm, addr);
        if (!pgd_present(*pgdir)) {
-               do_no_page(tsk, vma, addr, 1);
+               handle_mm_fault(tsk, vma, addr, 1);
                goto repeat;
        }
        if (pgd_bad(*pgdir)) {
@@ -110,7 +104,7 @@ repeat:
        }
        pgmiddle = pmd_offset(pgdir, addr);
        if (pmd_none(*pgmiddle)) {
-               do_no_page(tsk, vma, addr, 1);
+               handle_mm_fault(tsk, vma, addr, 1);
                goto repeat;
        }
        if (pmd_bad(*pgmiddle)) {
@@ -120,12 +114,12 @@ repeat:
        }
        pgtable = pte_offset(pgmiddle, addr);
        if (!pte_present(*pgtable)) {
-               do_no_page(tsk, vma, addr, 1);
+               handle_mm_fault(tsk, vma, addr, 1);
                goto repeat;
        }
        page = pte_page(*pgtable);
        if (!pte_write(*pgtable)) {
-               do_wp_page(tsk, vma, addr, 1);
+               handle_mm_fault(tsk, vma, addr, 1);
                goto repeat;
        }
 /* this is a hack for non-kernel-mapped video buffers and similar */
index 8a07ae0beea25ae53bb4b179a14c6b8a62fea682..fd5fa634e35d4e2f3bb4ce580f980527b227fe25 100644 (file)
@@ -1,4 +1,4 @@
-/*  $Id: signal.c,v 1.73 1997/04/16 05:56:05 davem Exp $
+/*  $Id: signal.c,v 1.74 1997/05/15 19:57:09 davem Exp $
  *  linux/arch/sparc/kernel/signal.c
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
@@ -780,8 +780,10 @@ asmlinkage int do_signal(unsigned long oldmask, struct pt_regs * regs,
                        case SIGQUIT: case SIGILL: case SIGTRAP:
                        case SIGABRT: case SIGFPE: case SIGSEGV: case SIGBUS:
                                if(current->binfmt && current->binfmt->core_dump) {
+                                       lock_kernel();
                                        if(current->binfmt->core_dump(signr, regs))
                                                signr |= 0x80;
+                                       unlock_kernel();
                                }
 #ifdef DEBUG_SIGNALS
                                /* Very useful to debug dynamic linker problems */
index 5d9d476a5018b14bf99ae07e4b1aea1e342efabf..46635db97d7c5c109f3eda93b0bfeb61582d84cd 100644 (file)
@@ -1,4 +1,4 @@
-/*  $Id: asyncd.c,v 1.9 1996/12/18 06:43:22 tridge Exp $
+/*  $Id: asyncd.c,v 1.10 1997/05/15 21:14:24 davem Exp $
  *  The asyncd kernel daemon. This handles paging on behalf of 
  *  processes that receive page faults due to remote (async) memory
  *  accesses. 
@@ -153,7 +153,7 @@ static int fault_in_page(int taskid,
        if(!pte)
                goto no_memory;
        if(!pte_present(*pte)) {
-               do_no_page(tsk, vma, address, write);
+               handle_mm_fault(tsk, vma, address, write);
                goto finish_up;
        }
        set_pte(pte, pte_mkyoung(*pte));
@@ -165,12 +165,11 @@ static int fault_in_page(int taskid,
                flush_tlb_page(vma, address);
                goto finish_up;
        }
-       do_wp_page(tsk, vma, address, write);
+       handle_mm_fault(tsk, vma, address, write);
 
        /* Fall through for do_wp_page */
 finish_up:
        stats.success++;
-       update_mmu_cache(vma, address, *pte);
        return 0;
 
 no_memory:
index cfac6bcc23d5b0179bd98f3b66c7af30439c3d81..0d6490860f59e413ec20ac997ec02a41904ecdd9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: fault.c,v 1.91 1997/03/18 17:56:00 jj Exp $
+/* $Id: fault.c,v 1.92 1997/05/15 21:14:21 davem Exp $
  * fault.c:  Page fault handlers for the Sparc.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -229,7 +229,7 @@ good_area:
                if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
                        goto bad_area;
        }
-       handle_mm_fault(vma, address, write);
+       handle_mm_fault(current, vma, address, write);
        up(&mm->mmap_sem);
        goto out;
        /*
@@ -370,7 +370,7 @@ good_area:
        else
                if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
                        goto bad_area;
-       handle_mm_fault(vma, address, write);
+       handle_mm_fault(current, vma, address, write);
        up(&mm->mmap_sem);
        return;
 bad_area:
index 4e7de16fb2f5bb29cb04578468f58323bb2f2ec5..0272b09c216aad4ae851a15a45469ce836b822d4 100644 (file)
@@ -1,4 +1,4 @@
-/*  $Id: asyncd.c,v 1.1 1996/12/26 10:24:24 davem Exp $
+/*  $Id: asyncd.c,v 1.2 1997/05/15 21:14:32 davem Exp $
  *  The asyncd kernel daemon. This handles paging on behalf of 
  *  processes that receive page faults due to remote (async) memory
  *  accesses. 
@@ -153,7 +153,7 @@ static int fault_in_page(int taskid,
        if(!pte)
                goto no_memory;
        if(!pte_present(*pte)) {
-               do_no_page(tsk, vma, address, write);
+               handle_mm_fault(tsk, vma, address, write);
                goto finish_up;
        }
        set_pte(pte, pte_mkyoung(*pte));
@@ -165,12 +165,11 @@ static int fault_in_page(int taskid,
                flush_tlb_page(vma, address);
                goto finish_up;
        }
-       do_wp_page(tsk, vma, address, write);
+       handle_mm_fault(tsk, vma, address, write);
 
        /* Fall through for do_wp_page */
 finish_up:
        stats.success++;
-       update_mmu_cache(vma, address, *pte);
        return 0;
 
 no_memory:
index 0dd118c8ee11ab6d589c30797092088a763b8f01..00250adfe3c3b0ff324e956e3a7be3bd90e285fa 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: fault.c,v 1.4 1997/03/11 17:37:07 jj Exp $
+/* $Id: fault.c,v 1.5 1997/05/15 21:14:31 davem Exp $
  * arch/sparc64/mm/fault.c: Page fault handlers for the 64-bit Sparc.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -168,7 +168,7 @@ good_area:
                if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
                        goto bad_area;
        }
-       handle_mm_fault(vma, address, write);
+       handle_mm_fault(current, vma, address, write);
        up(&mm->mmap_sem);
        goto out;
        /*
index 172e1d4608eee7793174fe666665a9af998767ea..d3b6e484fc8a71af90a9ce8c8682e3607063417c 100644 (file)
 #include <linux/string.h>
 #include <linux/wait.h>
 
-#if LINUX_VERSION_CODE < 0x20100
+#define kver(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 
+
+#if LINUX_VERSION_CODE < kver(2,1,0)
 
 /* Segmentation stuff for pre-2.1 kernels */
 #include <asm/segment.h>
-#define copy_to_user   memcpy_tofs
-#define copy_from_user memcpy_fromfs
+
+static inline int copy_to_user(void *dst, void *src, unsigned long len)
+{
+       int rv = verify_area(VERIFY_WRITE, dst, len);
+       if ( rv )
+               return -1;
+       memcpy_tofs(dst,src,len);
+       return 0;
+}
+
+static inline int copy_from_user(void *dst, void *src, unsigned long len)
+{
+       int rv = verify_area(VERIFY_READ, src, len);
+       if ( rv )
+               return -1;
+       memcpy_fromfs(dst,src,len);
+       return 0;
+}
 
 #else
 
index 23ffb70fe48c331d4f533384785305425d722c30..1b3f6f165dd98c618d01fc3dcc2cf48394d0fbfc 100644 (file)
  *
  * ------------------------------------------------------------------------- */
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include "autofs_i.h"
 
+#if LINUX_VERSION_CODE < kver(2,1,36)
+#define __initfunc(X) X
+#else
+#include <linux/init.h>
+#endif
+
 static struct file_system_type autofs_fs_type = {
        autofs_read_super, "autofs", 0, NULL
 };
index f13472ef406ca4ca2887df02d229196fd5094b06..ddef5858263928dc2579e9c4768b915f963c3766 100644 (file)
@@ -335,9 +335,16 @@ static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
        int rv;
        unsigned long ntimeout;
 
+#if LINUX_VERSION_CODE < kver(2,1,0)
+       if ( (rv = verify_area(VERIFY_WRITE, p, sizeof(unsigned long))) )
+               return rv;
+       ntimeout = get_user(p);
+       put_user(sbi->exp_timeout/HZ, p);
+#else
        if ( (rv = get_user(ntimeout, p)) ||
             (rv = put_user(sbi->exp_timeout/HZ, p)) )
                return rv;
+#endif
 
        if ( ntimeout > ULONG_MAX/HZ )
                sbi->exp_timeout = 0;
@@ -347,6 +354,20 @@ static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
        return 0;
 }
 
+/* Return protocol version */
+static inline int autofs_get_protover(int *p)
+{
+#if LINUX_VERSION_CODE < kver(2,1,0)
+       int rv;
+       if ( (rv = verify_area(VERIFY_WRITE, p, sizeof(int))) )
+               return rv;
+       put_user(AUTOFS_PROTO_VERSION, p);
+       return 0;
+#else
+       return put_user(AUTOFS_PROTO_VERSION, p);
+#endif
+}
+
 /* Perform an expiry operation */
 static inline int autofs_expire_run(struct autofs_sb_info *sbi,
                                    struct autofs_packet_expire *pkt_p)
@@ -402,7 +423,7 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
                autofs_catatonic_mode(sbi);
                return 0;
        case AUTOFS_IOC_PROTOVER: /* Get protocol version */
-               return put_user(AUTOFS_PROTO_VERSION, (int *)arg);
+               return autofs_get_protover((int *)arg);
        case AUTOFS_IOC_SETTIMEOUT:
                return autofs_get_set_timeout(sbi,(unsigned long *)arg);
        case AUTOFS_IOC_EXPIRE:
index 2190817bb6ba5d28be1518383c7e697f998beea8..52ba8f1b0e7a0702004708ee99679d6dbf5ddea9 100644 (file)
@@ -45,7 +45,7 @@ static int autofs_write(struct file *file, const void *addr, int bytes)
        unsigned short fs;
        unsigned long old_signal;
        const char *data = (const char *)addr;
-       int written;
+       int written = 0;
 
        /** WARNING: this is not safe for writing more than PIPE_BUF bytes! **/
 
index 9a6954c2943ef894c3030c528fa2dab3200ff4e9..0996e2d58ae0079149bf272af24751fa2ad4c9b6 100644 (file)
@@ -104,7 +104,7 @@ struct ipv6_mreq {
  */
 
 #define IPV6_ADDRFORM          1
-#define IPV6_RXINFO            2
+#define IPV6_PKTINFO           2
 #define IPV6_RXHOPOPTS         3
 #define IPV6_RXDSTOPTS         4
 #define IPV6_RXSRCRT           5
@@ -115,8 +115,6 @@ struct ipv6_mreq {
 /*
  *     Alternative names
  */
-#define IPV6_TXINFO            IPV6_RXINFO
-#define SCM_SRCINFO            IPV6_TXINFO
 #define SCM_SRCRT              IPV6_RXSRCRT
 
 #define IPV6_UNICAST_HOPS      16
index a75919bf9997b2a943a222e921dd31d87ee5a3fd..67276343bc78ba59d0f9900c84d18406c56629b4 100644 (file)
@@ -50,7 +50,6 @@ struct cmsghdr {
        __kernel_size_t cmsg_len;       /* data byte count, including hdr */
         int            cmsg_level;     /* originating protocol */
         int            cmsg_type;      /* protocol-specific type */
-       unsigned char   cmsg_data[0];
 };
 
 /*
@@ -58,17 +57,13 @@ struct cmsghdr {
  *     Table 5-14 of POSIX 1003.1g
  */
 
-#define CMSG_DATA(cmsg)                (cmsg)->cmsg_data
 #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr(mhdr, cmsg)
 
 #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
 
-/* Stevens's Adv. API specifies CMSG_SPACE & CMSG_LENGTH,
- * I cannot understand, what the differenece? --ANK
- */
-
-#define CMSG_SPACE(len) CMSG_ALIGN((len)+sizeof(struct cmsghdr))
-#define CMSG_LENGTH(len) CMSG_ALIGN((len)+sizeof(struct cmsghdr))
+#define CMSG_DATA(cmsg)        ((void *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))
+#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
+#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
 
 #define        CMSG_FIRSTHDR(msg)      ((msg)->msg_controllen >= sizeof(struct cmsghdr) ? \
                                 (struct cmsghdr *)(msg)->msg_control : \
@@ -148,6 +143,7 @@ struct ucred
 #define AF_DECNET      12      /* Reserved for DECnet project  */
 #define AF_NETBEUI     13      /* Reserved for 802.2LLC project*/
 #define AF_SECURITY    14      /* Security callback pseudo AF */
+#define pseudo_AF_KEY   15      /* PF_KEY key management API */
 #define AF_MAX         32      /* For now.. */
 
 /* Protocol families, same as address families. */
@@ -167,6 +163,7 @@ struct ucred
 #define PF_DECNET      AF_DECNET
 #define PF_NETBEUI     AF_NETBEUI
 #define PF_SECURITY    AF_SECURITY
+#define PF_KEY          pseudo_AF_KEY
 
 #define PF_MAX         AF_MAX
 
index 4e0465a4140c545654fb78bd9aa7181367dc1076..c360ba84af5f7cd275831d33ebb06cba98f378d6 100644 (file)
@@ -637,7 +637,6 @@ static void do_wp_page(struct task_struct * tsk, struct vm_area_struct * vma,
 bad_wp_page:
        printk("do_wp_page: bogus page at address %08lx (%08lx)\n",address,old_page);
        send_sig(SIGKILL, tsk, 1);
-       goto end_wp_page;
 end_wp_page:
        if (new_page)
                free_page(new_page);
index 5c179866ce0b7fa0219b997cfc5f1965087796bf..d88ab0ae758ed4594393cc3e56721ab26d607daf 100644 (file)
@@ -1,6 +1,7 @@
 /* scm.c - Socket level control messages processing.
  *
  * Author:     Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ *              Alignment and value checking mods by Craig Metz
  *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
@@ -60,12 +61,12 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
        int num;
        struct scm_fp_list *fpl = *fplp;
        struct file **fpp;
-       int *fdp = (int*)cmsg->cmsg_data;
+       int *fdp = (int*)CMSG_DATA(cmsg);
        int i;
 
-       num = (cmsg->cmsg_len - sizeof(struct cmsghdr))/sizeof(int);
+       num = (cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)))/sizeof(int);
 
-       if (!num)
+       if (num <= 0)
                return 0;
 
        if (num > SCM_MAX_FD)
@@ -153,9 +154,9 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                                goto error;
                        break;
                case SCM_CREDENTIALS:
-                       if (cmsg->cmsg_len < sizeof(*cmsg) + sizeof(struct ucred))
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct ucred)))
                                goto error;
-                       memcpy(&p->creds, cmsg->cmsg_data, sizeof(struct ucred));
+                       memcpy(&p->creds, CMSG_DATA(cmsg), sizeof(struct ucred));
                        err = scm_check_creds(&p->creds);
                        if (err)
                                goto error;
@@ -163,9 +164,9 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                case SCM_CONNECT:
                        if (scm_flags)
                                goto error;
-                       if (cmsg->cmsg_len < sizeof(*cmsg) + sizeof(int))
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)))
                                goto error;
-                       memcpy(&acc_fd, cmsg->cmsg_data, sizeof(int));
+                       memcpy(&acc_fd, CMSG_DATA(cmsg), sizeof(int));
                        p->sock = NULL;
                        if (acc_fd != -1) {
                                if (acc_fd < 0 || acc_fd >= NR_OPEN ||
@@ -207,7 +208,7 @@ error:
 void put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 {
        struct cmsghdr *cm = (struct cmsghdr*)msg->msg_control;
-       int cmlen = sizeof(*cm) + len;
+       int cmlen = CMSG_LEN(len);
        int err;
 
        if (cm==NULL || msg->msg_controllen < sizeof(*cm)) {
@@ -224,9 +225,9 @@ void put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
        if (!err)
                err = put_user(cmlen, &cm->cmsg_len);
        if (!err)
-               err = copy_to_user(cm->cmsg_data, data, cmlen - sizeof(*cm));
+               err = copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr));
        if (!err) {
-               cmlen = CMSG_ALIGN(cmlen);
+               cmlen = CMSG_SPACE(len);
                msg->msg_control += cmlen;
                msg->msg_controllen -= cmlen;
        }
@@ -246,7 +247,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
        if (fdnum < fdmax)
                fdmax = fdnum;
 
-       for (i=0, cmfptr=(int*)cm->cmsg_data; i<fdmax; i++, cmfptr++)
+       for (i=0, cmfptr=(int*)CMSG_DATA(cm); i<fdmax; i++, cmfptr++)
        {
                int new_fd = get_unused_fd();
                if (new_fd < 0)
@@ -257,7 +258,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 
        if (i > 0)
        {
-               int cmlen = i*sizeof(int) + sizeof(struct cmsghdr);
+               int cmlen = CMSG_LEN(i*sizeof(int));
                if (!err)
                        err = put_user(SOL_SOCKET, &cm->cmsg_level);
                if (!err)
@@ -265,7 +266,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
                if (!err)
                        err = put_user(cmlen, &cm->cmsg_len);
                if (!err) {
-                       cmlen = CMSG_ALIGN(cmlen);
+                       cmlen = CMSG_SPACE(i*sizeof(int));
                        msg->msg_control += cmlen;
                        msg->msg_controllen -= cmlen;
                }
index 9c47df35fb35e6b833e84666fcb2b337cce164fa..8c2463d0447f4f76ad12d5a46a639196d7823870 100644 (file)
@@ -126,26 +126,24 @@ int ip_cmsg_send(struct msghdr *msg, struct ipcm_cookie *ipc, struct device **de
        for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
                if (cmsg->cmsg_level != SOL_IP)
                        continue;
-               switch (cmsg->cmsg_type)
-               {
+               switch (cmsg->cmsg_type) {
                case IP_LOCALADDR:
-                       if (cmsg->cmsg_len < sizeof(struct in_addr)+sizeof(*cmsg))
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in_addr)))
                                return -EINVAL;
-                       memcpy(&ipc->addr, cmsg->cmsg_data, 4);
+                       memcpy(&ipc->addr, CMSG_DATA(cmsg), sizeof(struct in_addr));
                        break;
                case IP_RETOPTS:
-                       err = cmsg->cmsg_len - sizeof(*cmsg);
-                       err = ip_options_get(&ipc->opt, cmsg->cmsg_data,
-                                            err < 40 ? err : 40, 0);
+                       err = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
+                       err = ip_options_get(&ipc->opt, CMSG_DATA(cmsg), err < 40 ? err : 40, 0);
                        if (err)
                                return err;
                        break;
                case IP_TXINFO:
                {
                        struct in_pktinfo *info;
-                       if (cmsg->cmsg_len < sizeof(*info)+sizeof(*cmsg))
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in_pktinfo)))
                                return -EINVAL;
-                       info = (struct in_pktinfo*)cmsg->cmsg_data;
+                       info = (struct in_pktinfo *)CMSG_DATA(cmsg);
                        if (info->ipi_ifindex && !devp)
                                return -EINVAL;
                        if ((*devp = dev_get_by_index(info->ipi_ifindex)) == NULL)
index b5fbbde5fa6ec7b4a779374f658c05308a545b58..90f7b25d911da41131d51750937eaf3489cf5427 100644 (file)
@@ -5,7 +5,7 @@
  *     Authors:
  *     Pedro Roque             <roque@di.fc.ul.pt>     
  *
- *     $Id: datagram.c,v 1.11 1997/05/03 00:58:25 davem Exp $
+ *     $Id: datagram.c,v 1.12 1997/05/15 18:55:09 davem Exp $
  *
  *     This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -39,7 +39,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
 
                src_info.ipi6_ifindex = skb->dev->ifindex;
                ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr);
-               put_cmsg(msg, SOL_IPV6, IPV6_RXINFO, sizeof(src_info), &src_info);
+               put_cmsg(msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info);
        }
 
        if (np->rxhlim) {
@@ -67,20 +67,18 @@ int datagram_send_ctl(struct msghdr *msg, struct device **src_dev,
 
        for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
                if (cmsg->cmsg_level != SOL_IPV6) {
-                       printk(KERN_DEBUG "cmsg_level %d\n", cmsg->cmsg_level);
+                       printk(KERN_DEBUG "invalid cmsg_level %d\n", cmsg->cmsg_level);
                        continue;
                }
 
                switch (cmsg->cmsg_type) {
-
-               case IPV6_TXINFO:
-                       if (cmsg->cmsg_len < (sizeof(struct cmsghdr) +
-                                             sizeof(struct in6_pktinfo))) {
+               case IPV6_PKTINFO:
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in6_pktinfo))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
 
-                       src_info = (struct in6_pktinfo *) cmsg->cmsg_data;
+                       src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
                        
                        if (src_info->ipi6_ifindex) {
                                int index = src_info->ipi6_ifindex;
@@ -104,18 +102,13 @@ int datagram_send_ctl(struct msghdr *msg, struct device **src_dev,
                        break;
                        
                case IPV6_RXSRCRT:
-
-                       len = cmsg->cmsg_len;
-
-                       len -= sizeof(struct cmsghdr);
-
-                       /* validate option length */
-                       if (len < sizeof(struct ipv6_rt_hdr)) {
+                        if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
 
-                       rthdr = (struct ipv6_rt_hdr *) cmsg->cmsg_data;
+                       len = cmsg->cmsg_len - sizeof(struct cmsghdr);
+                       rthdr = (struct ipv6_rt_hdr *)CMSG_DATA(cmsg);
 
                        /*
                         *      TYPE 0
@@ -142,21 +135,16 @@ int datagram_send_ctl(struct msghdr *msg, struct device **src_dev,
                        break;
                        
                case IPV6_HOPLIMIT:
-
-                       len = cmsg->cmsg_len;
-                       len -= sizeof(struct cmsghdr);
-                       
-                       if (len < sizeof(int)) {
+                       if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
                                err = -EINVAL;
                                goto exit_f;
                        }
 
-                       *hlimit = *((int *) cmsg->cmsg_data);
+                       *hlimit = *(int *)CMSG_DATA(cmsg);
                        break;
 
                default:
-                       printk(KERN_DEBUG "invalid cmsg type: %d\n",
-                              cmsg->cmsg_type);
+                       printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type);
                        err = -EINVAL;
                        break;
                };
index 8b91819e30e209ca92d14bc4e532287964d229d5..64cfb00d54accc30fa1c4523cef3fc85e418e7a9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *     Based on linux/net/ipv4/ip_sockglue.c
  *
- *     $Id: ipv6_sockglue.c,v 1.12 1997/04/29 09:38:45 mj Exp $
+ *     $Id: ipv6_sockglue.c,v 1.13 1997/05/15 18:55:10 davem Exp $
  *
  *     This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -121,7 +121,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval,
                }
                break;
 
-       case IPV6_RXINFO:
+       case IPV6_PKTINFO:
                np->rxinfo = val;
                retv = 0;
                break;