X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fnetfilter%2Fxt_tcpmss.c;h=acf7f533e9f1928c4b03bcacbbe2fd19f499fc1a;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=cf7d335cadcd157aaa242a0ed13afe4f0a3735fc;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/net/netfilter/xt_tcpmss.c b/net/netfilter/xt_tcpmss.c index cf7d335ca..acf7f533e 100644 --- a/net/netfilter/xt_tcpmss.c +++ b/net/netfilter/xt_tcpmss.c @@ -81,7 +81,6 @@ static int 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, @@ -93,44 +92,81 @@ match(const struct sk_buff *skb, info->invert, hotdrop); } +static int +checkentry(const char *tablename, + const void *ipinfo, + void *matchinfo, + unsigned int matchsize, + unsigned int hook_mask) +{ + const struct ipt_ip *ip = ipinfo; + if (matchsize != XT_ALIGN(sizeof(struct xt_tcpmss_match_info))) + return 0; + + /* Must specify -p tcp */ + if (ip->proto != IPPROTO_TCP || (ip->invflags & IPT_INV_PROTO)) { + printk("tcpmss: Only works on TCP packets\n"); + return 0; + } + + return 1; +} + +static int +checkentry6(const char *tablename, + const void *ipinfo, + void *matchinfo, + unsigned int matchsize, + unsigned int hook_mask) +{ + const struct ip6t_ip6 *ip = ipinfo; + + if (matchsize != XT_ALIGN(sizeof(struct xt_tcpmss_match_info))) + return 0; + + /* Must specify -p tcp */ + if (ip->proto != IPPROTO_TCP || (ip->invflags & XT_INV_PROTO)) { + printk("tcpmss: Only works on TCP packets\n"); + return 0; + } + + return 1; +} + static struct xt_match tcpmss_match = { .name = "tcpmss", - .match = match, - .matchsize = sizeof(struct xt_tcpmss_match_info), - .proto = IPPROTO_TCP, - .family = AF_INET, + .match = &match, + .checkentry = &checkentry, .me = THIS_MODULE, }; static struct xt_match tcpmss6_match = { .name = "tcpmss", - .match = match, - .matchsize = sizeof(struct xt_tcpmss_match_info), - .proto = IPPROTO_TCP, - .family = AF_INET6, + .match = &match, + .checkentry = &checkentry6, .me = THIS_MODULE, }; -static int __init xt_tcpmss_init(void) +static int __init init(void) { int ret; - ret = xt_register_match(&tcpmss_match); + ret = xt_register_match(AF_INET, &tcpmss_match); if (ret) return ret; - ret = xt_register_match(&tcpmss6_match); + ret = xt_register_match(AF_INET6, &tcpmss6_match); if (ret) - xt_unregister_match(&tcpmss_match); + xt_unregister_match(AF_INET, &tcpmss_match); return ret; } -static void __exit xt_tcpmss_fini(void) +static void __exit fini(void) { - xt_unregister_match(&tcpmss6_match); - xt_unregister_match(&tcpmss_match); + xt_unregister_match(AF_INET6, &tcpmss6_match); + xt_unregister_match(AF_INET, &tcpmss_match); } -module_init(xt_tcpmss_init); -module_exit(xt_tcpmss_fini); +module_init(init); +module_exit(fini);