Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / net / ipv6 / netfilter / ip6t_LOG.c
index 73c6300109d61d7243e89f5268d3d9fbe3ec3e30..dc9ec93057782a0ea1900da5bf19e0819aa06047 100644 (file)
@@ -21,6 +21,7 @@
 #include <net/tcp.h>
 #include <net/ipv6.h>
 #include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 
 MODULE_AUTHOR("Jan Rekorajski <baggins@pld.org.pl>");
@@ -69,9 +70,9 @@ static void dump_packet(const struct nf_loginfo *info,
        /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
        printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
               ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
-              (ntohl(*(u_int32_t *)ih) & 0x0ff00000) >> 20,
+              (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
               ih->hop_limit,
-              (ntohl(*(u_int32_t *)ih) & 0x000fffff));
+              (ntohl(*(__be32 *)ih) & 0x000fffff));
 
        fragment = 0;
        ptr = ip6hoff + sizeof(struct ipv6hdr);
@@ -144,7 +145,7 @@ static void dump_packet(const struct nf_loginfo *info,
                                                        &_ahdr);
                                if (ah == NULL) {
                                        /*
-                                        * Max length: 26 "INCOMPLETE [65535    
+                                        * Max length: 26 "INCOMPLETE [65535
                                         *  bytes] )"
                                         */
                                        printk("INCOMPLETE [%u bytes] )",
@@ -270,11 +271,15 @@ static void dump_packet(const struct nf_loginfo *info,
                }
                break;
        }
-       case IPPROTO_UDP: {
+       case IPPROTO_UDP:
+       case IPPROTO_UDPLITE: {
                struct udphdr _udph, *uh;
 
-               /* Max length: 10 "PROTO=UDP " */
-               printk("PROTO=UDP ");
+               if (currenthdr == IPPROTO_UDP)
+                       /* Max length: 10 "PROTO=UDP "     */
+                       printk("PROTO=UDP " );
+               else    /* Max length: 14 "PROTO=UDPLITE " */
+                       printk("PROTO=UDPLITE ");
 
                if (fragment)
                        break;
@@ -382,7 +387,7 @@ ip6t_log_packet(unsigned int pf,
                loginfo = &default_loginfo;
 
        spin_lock_bh(&log_lock);
-       printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, 
+       printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
                prefix,
                in ? in->name : "",
                out ? out->name : "");
@@ -427,8 +432,7 @@ ip6t_log_target(struct sk_buff **pskb,
                const struct net_device *out,
                unsigned int hooknum,
                const struct xt_target *target,
-               const void *targinfo,
-               void *userinfo)
+               const void *targinfo)
 {
        const struct ip6t_log_info *loginfo = targinfo;
        struct nf_loginfo li;
@@ -437,14 +441,9 @@ ip6t_log_target(struct sk_buff **pskb,
        li.u.log.level = loginfo->level;
        li.u.log.logflags = loginfo->logflags;
 
-       if (loginfo->logflags & IP6T_LOG_NFLOG)
-               nf_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
-                             "%s", loginfo->prefix);
-       else
-               ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
-                               loginfo->prefix);
-
-       return IP6T_CONTINUE;
+       ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
+                       loginfo->prefix);
+       return XT_CONTINUE;
 }
 
 
@@ -452,7 +451,6 @@ static int ip6t_log_checkentry(const char *tablename,
                               const void *entry,
                               const struct xt_target *target,
                               void *targinfo,
-                              unsigned int targinfosize,
                               unsigned int hook_mask)
 {
        const struct ip6t_log_info *loginfo = targinfo;
@@ -469,11 +467,12 @@ static int ip6t_log_checkentry(const char *tablename,
        return 1;
 }
 
-static struct ip6t_target ip6t_log_reg = {
+static struct xt_target ip6t_log_reg = {
        .name           = "LOG",
-       .target         = ip6t_log_target, 
+       .family         = AF_INET6,
+       .target         = ip6t_log_target,
        .targetsize     = sizeof(struct ip6t_log_info),
-       .checkentry     = ip6t_log_checkentry, 
+       .checkentry     = ip6t_log_checkentry,
        .me             = THIS_MODULE,
 };
 
@@ -485,8 +484,11 @@ static struct nf_logger ip6t_logger = {
 
 static int __init ip6t_log_init(void)
 {
-       if (ip6t_register_target(&ip6t_log_reg))
-               return -EINVAL;
+       int ret;
+
+       ret = xt_register_target(&ip6t_log_reg);
+       if (ret < 0)
+               return ret;
        if (nf_log_register(PF_INET6, &ip6t_logger) < 0) {
                printk(KERN_WARNING "ip6t_LOG: not logging via system console "
                       "since somebody else already registered for PF_INET6\n");
@@ -500,7 +502,7 @@ static int __init ip6t_log_init(void)
 static void __exit ip6t_log_fini(void)
 {
        nf_log_unregister_logger(&ip6t_logger);
-       ip6t_unregister_target(&ip6t_log_reg);
+       xt_unregister_target(&ip6t_log_reg);
 }
 
 module_init(ip6t_log_init);