Skip to contentSkip to conversation

No chain/target/match by that name

DISCUSSION Vlad 2 participants 3 messages Mar 17, 2009 3 messages not in the archive netfilter

lore
Share & tools
lore

Vlad

author
#0 lore raw

Hallo , I'm trying to write a new module for iptables. I started with a dummy module. I can successfully compile it. But if I trying to use it, I get an error message:

$ iptables -A INPUT -s 128.0.0.1 -m secan --drop -j DROP
drop frame
iptables: No chain/target/match by that name

Can someone tell me what is a problem? Here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <iptables.h>

#include <linux/netfilter_ipv4/ip_tables.h>
#include "libipt_secan.h"

static void secan_help(void)
{
printf(
"secan options:\n"
" --drop Drop Frame\n"
" --accept Accept Frame\n");
}

static int secan_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct ipt_secan_info *info = (struct ipt_secan_info *) (*match)->data;

   switch (c) {
       case '1':
           if (*flags & SECAN_DROP)
           exit_error(PARAMETER_PROBLEM, "Only use --drop once!");
           *flags |= SECAN_DROP;
           info->flags |= SECAN_DROP;
           printf("drop frame\n");
           break;
       case '2':
           if (*flags & SECAN_ACCEPT)
           exit_error(PARAMETER_PROBLEM, "Only use --accept once!");
           *flags |= SECAN_ACCEPT;
           info->flags |= SECAN_ACCEPT;
           printf("accept frame\n");
           break;
       default:
           return 0;
   }

return 1;
}

static void secan_check(unsigned int flags)
{
if (!flags)
exit_error(PARAMETER_PROBLEM,
"SECAN: You must specify one of "
"--drop', --accept'");
}

static void secan_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
printf("SECAN match ");
}

static void secan_save(const void *ip, const struct xt_entry_match *match) {
const struct ipt_secan_info *info = (struct ipt_secan_info *)
match->data;

if (info->flags & SECAN_DROP)

   {
       printf("--drop ");
   }
   if (info->flags & SECAN_ACCEPT)
   {
       printf("--accept ");

}
printf("save");
}

static const struct option secan_opts[] = {
{ "drop", 0, NULL, '1' },
{ "accept", 0, NULL, '2'},
{ .name = NULL }
};

static struct xtables_match secan_reg = {
.name = "secan",
.version = XTABLES_VERSION,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct ipt_secan_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_secan_info)),
.help = secan_help,
.parse = secan_parse,
.final_check = secan_check,
.print = secan_print,
.save = secan_save,
.extra_opts = secan_opts,
};

void _init(void)
{
xtables_register_match(&secan_reg);
}

As I sad this is only a dummy module now and it doesn't do much.

Sincerely,
Vlad

#1 lore raw
Quoted 10 lines · Vlad

Hallo , I'm trying to write a new module for iptables. I started with a dummy module. I can successfully compile it. But if I trying to use it, I get an error message:

$ iptables -A INPUT -s 128.0.0.1 -m secan --drop -j DROP
drop frame
iptables: No chain/target/match by that name

Can someone tell me what is a problem? Here is my code:
[...]

The iptables code looks fine, but what about the kernel side module?

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 18 lines · Vlad
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines

Hallo , I'm trying to write a new module for iptables. I started with a dummy
module. I can successfully compile it. But if I trying to use it, I get an error message:

Quoted 9 lines
Quoted 7 lines
$ iptables -A INPUT -s 128.0.0.1 -m secan --drop -j DROP
drop frame
iptables: No chain/target/match by that name

Can someone tell me what is a problem? Here is my code:
[...]

The iptables code looks fine, but what about the kernel side module?

All other iptables modules work fine. I'm pretty new to iptables, can you please tell me what kernel side module do you mean?

Quoted 6 lines
Quoted 4 lines

Well, xt_secan.c that you (hopefully) wrote that does implement the actual packet inspection.

I saved my module as libipt_secan.c in derictory iptables/extensions. Where should be xt_secan.c saved?

[ Do not strip CCs! ]

Ehrm, whereever it is convenient.

Since you seem to be not familiar with the matter, I suggest having a read in the “Writing Netfilter modules” e-book, available on
http://jengelh.medozas.de/ .

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html