Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=97fc8d0bc58cd09e62dc06ea5a64b58841738934
Commit:     97fc8d0bc58cd09e62dc06ea5a64b58841738934
Parent:     952a10be3272c4b5b7839b09cb0483dc72137101
Author:     YOSHIFUJI Hideaki <[EMAIL PROTECTED]>
AuthorDate: Sat Apr 21 19:52:04 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Apr 25 22:29:37 2007 -0700

    [IPV6] SNMP: Use put_unaligned() instead of memcpy().
    
    Hint from David Miller <[EMAIL PROTECTED]>.
    
    Signed-off-by: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 include/net/ipv6.h |    2 +-
 net/ipv6/proc.c    |   26 ++++++++++----------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 1df360e..4408def 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -172,7 +172,7 @@ int snmp6_alloc_dev(struct inet6_dev *idev);
 int snmp6_free_dev(struct inet6_dev *idev);
 int snmp6_mib_init(void *ptr[2], size_t mibsize, size_t mibalign);
 void snmp6_mib_free(void *ptr[2]);
-void snmp6_fill_stats(void *stats, struct inet6_dev *idev, int attrtype, int 
bytes);
+void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, int 
bytes);
 
 struct ip6_ra_chain
 {
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index aba9431..7a00bed 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -23,6 +23,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/stddef.h>
+#include <asm/unaligned.h>
 #include <net/sock.h>
 #include <net/tcp.h>
 #include <net/transp_v6.h>
@@ -210,30 +211,23 @@ static const struct file_operations snmp6_seq_fops = {
 };
 #endif /* CONFIG_PROC_FS */
 
-/*
- * Stats may not be aligned for u64, so use memcpy to avoid
- * unaligned accesses.
- */
-static inline void __set_u64(void *p, u64 v)
-{
-       memcpy(p, &v, sizeof(u64));
-}
-
 static inline void
-__snmp6_fill_stats(void *stats, void **mib, int items, int bytes)
+__snmp6_fill_stats(u64 *stats, void **mib, int items, int bytes)
 {
        int i;
-       u8 *p = stats;
        int pad = bytes - sizeof(u64) * items;
        BUG_ON(pad < 0);
-       __set_u64(p, items);
-       for (i = 1, p += sizeof(u64); i < items; i++, p += sizeof(u64))
-               __set_u64(p, fold_field(mib, i));
-       memset(p, 0, pad);
+
+       /* Use put_unaligned() because stats may not be aligned for u64. */
+       put_unaligned(items, &stats[0]);
+       for (i = 1; i < items; i++)
+               put_unaligned(fold_field(mib, i), &stats[i]);
+
+       memset(&stats[items], 0, pad);
 }
 
 void
-snmp6_fill_stats(void *stats, struct inet6_dev *idev, int attrtype, int bytes)
+snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, int bytes)
 {
        switch(attrtype) {
        case IFLA_INET6_STATS:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to