]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/xt_time.c
serial: fix enable_irq_wake/disable_irq_wake imbalance in serial_core.c
[linux-2.6-omap-h63xx.git] / net / netfilter / xt_time.c
index ff44f86c24cefe4e9a613178434bb06089b9cc61..ed76baab47349c609c6de4cdf07c36ec12f98c21 100644 (file)
@@ -95,8 +95,11 @@ static inline void localtime_2(struct xtm *r, time_t time)
         */
        r->dse = time / 86400;
 
-       /* 1970-01-01 (w=0) was a Thursday (4). */
-       r->weekday = (4 + r->dse) % 7;
+       /*
+        * 1970-01-01 (w=0) was a Thursday (4).
+        * -1 and +1 map Sunday properly onto 7.
+        */
+       r->weekday = (4 + r->dse - 1) % 7 + 1;
 }
 
 static void localtime_3(struct xtm *r, time_t time)
@@ -147,11 +150,10 @@ static void localtime_3(struct xtm *r, time_t time)
        return;
 }
 
-static bool xt_time_match(const struct sk_buff *skb,
-                          const struct net_device *in,
-                          const struct net_device *out,
-                          const struct xt_match *match, const void *matchinfo,
-                          int offset, unsigned int protoff, bool *hotdrop)
+static bool
+time_mt(const struct sk_buff *skb, const struct net_device *in,
+        const struct net_device *out, const struct xt_match *match,
+        const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop)
 {
        const struct xt_time_info *info = matchinfo;
        unsigned int packet_time;
@@ -170,7 +172,7 @@ static bool xt_time_match(const struct sk_buff *skb,
        if (skb->tstamp.tv64 == 0)
                __net_timestamp((struct sk_buff *)skb);
 
-       stamp = skb->tstamp.tv64;
+       stamp = ktime_to_ns(skb->tstamp);
        do_div(stamp, NSEC_PER_SEC);
 
        if (info->flags & XT_TIME_LOCAL_TZ)
@@ -216,11 +218,12 @@ static bool xt_time_match(const struct sk_buff *skb,
        return true;
 }
 
-static bool xt_time_check(const char *tablename, const void *ip,
-                          const struct xt_match *match, void *matchinfo,
-                          unsigned int hook_mask)
+static bool
+time_mt_check(const char *tablename, const void *ip,
+              const struct xt_match *match, void *matchinfo,
+              unsigned int hook_mask)
 {
-       struct xt_time_info *info = matchinfo;
+       const struct xt_time_info *info = matchinfo;
 
        if (info->daytime_start > XT_TIME_MAX_DAYTIME ||
            info->daytime_stop > XT_TIME_MAX_DAYTIME) {
@@ -232,39 +235,39 @@ static bool xt_time_check(const char *tablename, const void *ip,
        return true;
 }
 
-static struct xt_match xt_time_reg[] __read_mostly = {
+static struct xt_match time_mt_reg[] __read_mostly = {
        {
                .name       = "time",
                .family     = AF_INET,
-               .match      = xt_time_match,
+               .match      = time_mt,
                .matchsize  = sizeof(struct xt_time_info),
-               .checkentry = xt_time_check,
+               .checkentry = time_mt_check,
                .me         = THIS_MODULE,
        },
        {
                .name       = "time",
                .family     = AF_INET6,
-               .match      = xt_time_match,
+               .match      = time_mt,
                .matchsize  = sizeof(struct xt_time_info),
-               .checkentry = xt_time_check,
+               .checkentry = time_mt_check,
                .me         = THIS_MODULE,
        },
 };
 
-static int __init xt_time_init(void)
+static int __init time_mt_init(void)
 {
-       return xt_register_matches(xt_time_reg, ARRAY_SIZE(xt_time_reg));
+       return xt_register_matches(time_mt_reg, ARRAY_SIZE(time_mt_reg));
 }
 
-static void __exit xt_time_exit(void)
+static void __exit time_mt_exit(void)
 {
-       xt_unregister_matches(xt_time_reg, ARRAY_SIZE(xt_time_reg));
+       xt_unregister_matches(time_mt_reg, ARRAY_SIZE(time_mt_reg));
 }
 
-module_init(xt_time_init);
-module_exit(xt_time_exit);
+module_init(time_mt_init);
+module_exit(time_mt_exit);
 MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
-MODULE_DESCRIPTION("netfilter time match");
+MODULE_DESCRIPTION("Xtables: time-based matching");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ipt_time");
 MODULE_ALIAS("ip6t_time");