git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git]
/
net
/
ipv4
/
netfilter
/
ip_conntrack_tftp.c
diff --git
a/net/ipv4/netfilter/ip_conntrack_tftp.c
b/net/ipv4/netfilter/ip_conntrack_tftp.c
index
9515974
..
7e33d3b
100644
(file)
--- a/
net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/
net/ipv4/netfilter/ip_conntrack_tftp.c
@@
-19,18
+19,17
@@
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
#include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
#include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
+#include <linux/moduleparam.h>
MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
MODULE_DESCRIPTION("tftp connection tracking helper");
MODULE_LICENSE("GPL");
#define MAX_PORTS 8
MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
MODULE_DESCRIPTION("tftp connection tracking helper");
MODULE_LICENSE("GPL");
#define MAX_PORTS 8
-static
in
t ports[MAX_PORTS];
+static
unsigned shor
t ports[MAX_PORTS];
static int ports_c;
static int ports_c;
-#ifdef MODULE_PARM
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
+module_param_array(ports, ushort, &ports_c, 0400);
MODULE_PARM_DESC(ports, "port numbers of tftp servers");
MODULE_PARM_DESC(ports, "port numbers of tftp servers");
-#endif
#if 0
#define DEBUGP(format, args...) printk("%s:%s:" format, \
#if 0
#define DEBUGP(format, args...) printk("%s:%s:" format, \
@@
-39,18
+38,26
@@
MODULE_PARM_DESC(ports, "port numbers of tftp servers");
#define DEBUGP(format, args...)
#endif
#define DEBUGP(format, args...)
#endif
-static int tftp_help(struct sk_buff *skb,
+unsigned int (*ip_nat_tftp_hook)(struct sk_buff **pskb,
+ enum ip_conntrack_info ctinfo,
+ struct ip_conntrack_expect *exp);
+EXPORT_SYMBOL_GPL(ip_nat_tftp_hook);
+
+static int tftp_help(struct sk_buff **pskb,
struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo)
{
struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo)
{
- struct tftphdr
tftp
h;
+ struct tftphdr
_tftph, *tf
h;
struct ip_conntrack_expect *exp;
struct ip_conntrack_expect *exp;
+ unsigned int ret = NF_ACCEPT;
- if (skb_copy_bits(skb, skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
- &tftph, sizeof(tftph)) != 0)
+ tfh = skb_header_pointer(*pskb,
+ (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr),
+ sizeof(_tftph), &_tftph);
+ if (tfh == NULL)
return NF_ACCEPT;
return NF_ACCEPT;
- switch (ntohs(tf
tph.
opcode)) {
+ switch (ntohs(tf
h->
opcode)) {
/* RRQ and WRQ works the same way */
case TFTP_OPCODE_READ:
case TFTP_OPCODE_WRITE:
/* RRQ and WRQ works the same way */
case TFTP_OPCODE_READ:
case TFTP_OPCODE_WRITE:
@@
-58,21
+65,27
@@
static int tftp_help(struct sk_buff *skb,
DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
- exp = ip_conntrack_expect_alloc();
+ exp = ip_conntrack_expect_alloc(
ct
);
if (exp == NULL)
if (exp == NULL)
- return NF_
ACCEPT
;
+ return NF_
DROP
;
exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
exp->mask.src.ip = 0xffffffff;
exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
exp->mask.src.ip = 0xffffffff;
+ exp->mask.src.u.udp.port = 0;
exp->mask.dst.ip = 0xffffffff;
exp->mask.dst.u.udp.port = 0xffff;
exp->mask.dst.ip = 0xffffffff;
exp->mask.dst.u.udp.port = 0xffff;
- exp->mask.dst.protonum = 0xff
ff
;
+ exp->mask.dst.protonum = 0xff;
exp->expectfn = NULL;
exp->expectfn = NULL;
+ exp->flags = 0;
DEBUGP("expect: ");
DUMP_TUPLE(&exp->tuple);
DUMP_TUPLE(&exp->mask);
DEBUGP("expect: ");
DUMP_TUPLE(&exp->tuple);
DUMP_TUPLE(&exp->mask);
- ip_conntrack_expect_related(exp, ct);
+ if (ip_nat_tftp_hook)
+ ret = ip_nat_tftp_hook(pskb, ctinfo, exp);
+ else if (ip_conntrack_expect_related(exp) != 0)
+ ret = NF_DROP;
+ ip_conntrack_expect_put(exp);
break;
case TFTP_OPCODE_DATA:
case TFTP_OPCODE_ACK:
break;
case TFTP_OPCODE_DATA:
case TFTP_OPCODE_ACK:
@@
-88,9
+101,9
@@
static int tftp_help(struct sk_buff *skb,
}
static struct ip_conntrack_helper tftp[MAX_PORTS];
}
static struct ip_conntrack_helper tftp[MAX_PORTS];
-static char tftp_names[MAX_PORTS][
10
];
+static char tftp_names[MAX_PORTS][
sizeof("tftp-65535")
];
-static void fini(void)
+static void
ip_conntrack_tftp_
fini(void)
{
int i;
{
int i;
@@
-101,25
+114,24
@@
static void fini(void)
}
}
}
}
-static int __init init(void)
+static int __init i
p_conntrack_tftp_i
nit(void)
{
int i, ret;
char *tmpname;
{
int i, ret;
char *tmpname;
- if (
!ports[0]
)
- ports[
0]=
TFTP_PORT;
+ if (
ports_c == 0
)
+ ports[
ports_c++] =
TFTP_PORT;
- for (i = 0
; (i < MAX_PORTS) && ports[i]
; i++) {
+ for (i = 0
; i < ports_c
; i++) {
/* Create helper structure */
memset(&tftp[i], 0, sizeof(struct ip_conntrack_helper));
tftp[i].tuple.dst.protonum = IPPROTO_UDP;
tftp[i].tuple.src.u.udp.port = htons(ports[i]);
/* Create helper structure */
memset(&tftp[i], 0, sizeof(struct ip_conntrack_helper));
tftp[i].tuple.dst.protonum = IPPROTO_UDP;
tftp[i].tuple.src.u.udp.port = htons(ports[i]);
- tftp[i].mask.dst.protonum = 0xFF
FF
;
+ tftp[i].mask.dst.protonum = 0xFF;
tftp[i].mask.src.u.udp.port = 0xFFFF;
tftp[i].max_expected = 1;
tftp[i].mask.src.u.udp.port = 0xFFFF;
tftp[i].max_expected = 1;
- tftp[i].timeout = 0;
- tftp[i].flags = IP_CT_HELPER_F_REUSE_EXPECT;
+ tftp[i].timeout = 5 * 60; /* 5 minutes */
tftp[i].me = THIS_MODULE;
tftp[i].help = tftp_help;
tftp[i].me = THIS_MODULE;
tftp[i].help = tftp_help;
@@
-136,15
+148,12
@@
static int __init init(void)
if (ret) {
printk("ERROR registering helper for port %d\n",
ports[i]);
if (ret) {
printk("ERROR registering helper for port %d\n",
ports[i]);
- fini();
+
ip_conntrack_tftp_
fini();
return(ret);
}
return(ret);
}
- ports_c++;
}
return(0);
}
}
return(0);
}
-PROVIDES_CONNTRACK(tftp);
-
-module_init(init);
-module_exit(fini);
+module_init(ip_conntrack_tftp_init);
+module_exit(ip_conntrack_tftp_fini);