X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fnetfilter%2Fxt_time.c;h=9fa2e0824708f1acf62ab9c803a38eb4b4b2e408;hb=ff2bac6a63e3694e7a97152b7e934fe244e2a858;hp=ef48bbd93573080b3489f378a4cb3755d8c20e36;hpb=4d5709a7b7d54fc5882d2943a14988a92d48c00a;p=linux-2.6 diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c index ef48bbd935..9fa2e08247 100644 --- a/net/netfilter/xt_time.c +++ b/net/netfilter/xt_time.c @@ -1,6 +1,7 @@ /* * xt_time - * Copyright © Jan Engelhardt , 2007 + * Copyright © CC Computer Consultants GmbH, 2007 + * Contact: * * based on ipt_time by Fabrice MARIE * This is a module which is used for time matching @@ -94,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) @@ -146,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; @@ -169,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) @@ -215,9 +218,10 @@ 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; @@ -231,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 "); -MODULE_DESCRIPTION("netfilter time match"); +MODULE_DESCRIPTION("Xtables: time-based matching"); MODULE_LICENSE("GPL"); MODULE_ALIAS("ipt_time"); MODULE_ALIAS("ip6t_time");