conntrack module development problem
Brad Chapman
kakadu@earthlink.net
Sat, 28 Jul 2001 18:03:38 -0400
Mr. Shore,
Change the helper init function to read like this:
int ret;
/* rest of function */
ret = ip_conntrack_helper_register(&icq);
if (ret < 0) {
DEBUGP("KABOOM! Aiee, I'm not in!\n"); ;-)
return ret;
}
DEBUGP("Ahhh, I'm in at last\n"); ;-)
Maybe you have bugs initializing the helper; this will detect that. If it
works, then you initialized it incorrectly in some fashion. BTW will
this actually
become a `real' conntrack helper for ICQ? IIRC, no one else has worked
on it.....
Brad
S. Shore wrote:
> Hi!
>
> I'm trying to make a new conntrack module, but it doesn't seem to be
> receiving packets that I've set the tuple for. See code below.
>
> As you can see, at this point it's very similar to the sample code in the
> netfilter howtos, and it compiles cleanly. I've included the compile
> options specified at the end of the source. It's not supposed to do
> anything useful yet, just print debug messages.
>
> It should printk an "ICQ packet received" whenever an icq packet goes by,
> but it doesn't. It does print the "I'm in!" and "I'm out!" printk's at
> module load and release, though.
>
> What am I missing here? Any assistance would be greatly appreciated.
>
> Cheers,
> Scott <sshore@escape.ca>
>
>
>
> #include <linux/version.h>
> #include <linux/module.h>
> #include <linux/netfilter.h>
> #include <linux/ip.h>
> #include <linux/ctype.h>
> #include <net/checksum.h>
> #include <net/udp.h>
> #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
>
> #define ICQ_PORT 4000
> #define DEBUGP(format, args...) printk(KERN_DEBUG __FILE__ ":" __FUNCTION__ \
> ":" format, ## args)
>
> static int icq_help(const struct iphdr *iph, size_t len,
> struct ip_conntrack *ct,
> enum ip_conntrack_info ct_info)
> {
> DEBUGP("ICQ packet received\n");
>
> return NF_ACCEPT;
> }
>
> static struct ip_conntrack_helper icq;
>
> static int __init init(void)
> {
> memset(&icq, 0, sizeof(struct ip_conntrack_helper));
>
> icq.tuple.dst.protonum = IPPROTO_UDP;
> icq.tuple.dst.u.udp.port = htons(ICQ_PORT);
> icq.mask.dst.protonum = 0xFFFF;
> icq.mask.dst.u.udp.port = 0xFFFF;
> icq.help = icq_help;
>
> DEBUGP("I'm in!\n");
>
> return ip_conntrack_helper_register(&icq);
> }
>
> static void __exit fini(void)
> {
> DEBUGP("I'm out!\n");
> ip_conntrack_helper_unregister(&icq);
> }
>
> module_init(init);
> module_exit(fini);
>
> /* gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2
> -fomit-frame-pointer -fno-strict-aliasing -pipe -march=i486 -DMODULE -c -o
> test.o test.c */
>
>
>
>