X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fipv4%2Fnetfilter%2Fip_conntrack_amanda.c;h=3dbddd062605a73fcb0d09a727aab0f521d18107;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=ae1bc2509dd25b1f48cfa49f942033c2ed3c69e5;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c index ae1bc2509..3dbddd062 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,7 @@ static unsigned int master_timeout = 300; MODULE_AUTHOR("Brian J. Murrell "); MODULE_DESCRIPTION("Amanda connection tracking module"); MODULE_LICENSE("GPL"); -MODULE_PARM(master_timeout, "i"); +module_param(master_timeout, int, 0600); MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); static char *conns[] = { "DATA ", "MESG ", "INDEX " }; @@ -43,14 +44,21 @@ static char *conns[] = { "DATA ", "MESG ", "INDEX " }; static char amanda_buffer[65536]; static DECLARE_LOCK(amanda_buffer_lock); -static int help(struct sk_buff *skb, +unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb, + enum ip_conntrack_info ctinfo, + unsigned int matchoff, + unsigned int matchlen, + struct ip_conntrack_expect *exp); +EXPORT_SYMBOL_GPL(ip_nat_amanda_hook); + +static int help(struct sk_buff **pskb, struct ip_conntrack *ct, enum ip_conntrack_info ctinfo) { struct ip_conntrack_expect *exp; - struct ip_ct_amanda_expect *exp_amanda_info; char *data, *data_limit, *tmp; unsigned int dataoff, i; u_int16_t port, len; + int ret = NF_ACCEPT; /* Only look at packets from the Amanda server */ if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) @@ -58,20 +66,20 @@ static int help(struct sk_buff *skb, /* increase the UDP timeout of the master connection as replies from * Amanda clients to the server can be quite delayed */ - ip_ct_refresh(ct, master_timeout * HZ); + ip_ct_refresh_acct(ct, ctinfo, NULL, master_timeout * HZ); /* No data? */ - dataoff = skb->nh.iph->ihl*4 + sizeof(struct udphdr); - if (dataoff >= skb->len) { + dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); + if (dataoff >= (*pskb)->len) { if (net_ratelimit()) - printk("amanda_help: skblen = %u\n", skb->len); + printk("amanda_help: skblen = %u\n", (*pskb)->len); return NF_ACCEPT; } LOCK_BH(&amanda_buffer_lock); - skb_copy_bits(skb, dataoff, amanda_buffer, skb->len - dataoff); + skb_copy_bits(*pskb, dataoff, amanda_buffer, (*pskb)->len - dataoff); data = amanda_buffer; - data_limit = amanda_buffer + skb->len - dataoff; + data_limit = amanda_buffer + (*pskb)->len - dataoff; *data_limit = '\0'; /* Search for the CONNECT string */ @@ -95,36 +103,44 @@ static int help(struct sk_buff *skb, break; exp = ip_conntrack_expect_alloc(); - if (exp == NULL) + if (exp == NULL) { + ret = NF_DROP; goto out; + } + + exp->expectfn = NULL; + exp->master = ct; exp->tuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; + exp->tuple.src.u.tcp.port = 0; exp->tuple.dst.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; exp->tuple.dst.protonum = IPPROTO_TCP; + exp->tuple.dst.u.tcp.port = htons(port); + exp->mask.src.ip = 0xFFFFFFFF; + exp->mask.src.u.tcp.port = 0; exp->mask.dst.ip = 0xFFFFFFFF; - exp->mask.dst.protonum = 0xFFFF; + exp->mask.dst.protonum = 0xFF; exp->mask.dst.u.tcp.port = 0xFFFF; - exp_amanda_info = &exp->help.exp_amanda_info; - exp_amanda_info->offset = data - amanda_buffer; - exp_amanda_info->port = port; - exp_amanda_info->len = len; - - exp->tuple.dst.u.tcp.port = htons(port); - - ip_conntrack_expect_related(exp, ct); + if (ip_nat_amanda_hook) + ret = ip_nat_amanda_hook(pskb, ctinfo, + tmp - amanda_buffer, + len, exp); + else if (ip_conntrack_expect_related(exp) != 0) { + ip_conntrack_expect_free(exp); + ret = NF_DROP; + } } out: UNLOCK_BH(&amanda_buffer_lock); - return NF_ACCEPT; + return ret; } static struct ip_conntrack_helper amanda_helper = { .max_expected = ARRAY_SIZE(conns), .timeout = 180, - .flags = IP_CT_HELPER_F_REUSE_EXPECT, .me = THIS_MODULE, .help = help, .name = "amanda", @@ -133,7 +149,7 @@ static struct ip_conntrack_helper amanda_helper = { .dst = { .protonum = IPPROTO_UDP }, }, .mask = { .src = { .u = { 0xFFFF } }, - .dst = { .protonum = 0xFFFF }, + .dst = { .protonum = 0xFF }, }, }; @@ -147,6 +163,5 @@ static int __init init(void) return ip_conntrack_helper_register(&amanda_helper); } -PROVIDES_CONNTRACK(amanda); module_init(init); module_exit(fini);