All of lore.kernel.org
 help / color / mirror / Atom feed
* What happened to xt_match_param
@ 2012-07-03 13:46 AFT
  2012-07-03 15:03 ` AFT
  2012-07-03 15:57 ` Jan Engelhardt
  0 siblings, 2 replies; 3+ messages in thread
From: AFT @ 2012-07-03 13:46 UTC (permalink / raw)
  To: netfilter-devel



Hi,

In "writing netfilter module", by JAN, there is a inconsistancy in
section 2.5 named "Point of decision".

Here a match function is prototyped as ,

struct bool ipaddr_mt(const struct sk_buff *skb,
                      struct xt_match_param *par);
                      
Now there is no xt_match_param in netfilter.h. The closest thing is
'struct xt_mtchk_param'. which is defined as,

struct xt_mtchk_param {
	struct net *net;
	const char *table;
	const void *entryinfo;
	const struct xt_match *match;
	void *matchinfo;
	unsigned int hook_mask;
	u_int8_t family;
};

So at first i thought i can just replace it with xt_mtchk_param. But the
problem is the text reads following lines which can not be right if i
replace xt_match_param with xt_mtchk_param.

par->in and par->out supposed to point to IN or OUT network devices. but
as you can see there is no such fields in xt_mtchk_param.

These struct net_device *in,out fields are inside struct
xt_action_param.

struct xt_action_param{
       ...........
       struct net_device *in,*out;
       ...........
}

After subsequent reading i understood, it should be struct
xt_action_param in the match function's prototype. so the correct
prototype should be,

static bool ipaddr_mt(const struct sk_buff *skb,
                      struct xt_action_param *par);

So it should be updated so that noobs like me does not get confused.

cheers
aft

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What happened to xt_match_param
  2012-07-03 13:46 What happened to xt_match_param AFT
@ 2012-07-03 15:03 ` AFT
  2012-07-03 15:57 ` Jan Engelhardt
  1 sibling, 0 replies; 3+ messages in thread
From: AFT @ 2012-07-03 15:03 UTC (permalink / raw)
  To: netfilter-devel

AFT <aftnix@gmail.com> writes:

> Hi,
>
> In "writing netfilter module", by JAN, there is a inconsistancy in
> section 2.5 named "Point of decision".
>
> Here a match function is prototyped as ,
>
> struct bool ipaddr_mt(const struct sk_buff *skb,
>                       struct xt_match_param *par);
>                       
> Now there is no xt_match_param in netfilter.h. The closest thing is
> 'struct xt_mtchk_param'. which is defined as,
>
> struct xt_mtchk_param {
> 	struct net *net;
> 	const char *table;
> 	const void *entryinfo;
> 	const struct xt_match *match;
> 	void *matchinfo;
> 	unsigned int hook_mask;
> 	u_int8_t family;
> };
>
> So at first i thought i can just replace it with xt_mtchk_param. But the
> problem is the text reads following lines which can not be right if i
> replace xt_match_param with xt_mtchk_param.
>
> par->in and par->out supposed to point to IN or OUT network devices. but
> as you can see there is no such fields in xt_mtchk_param.
>
> These struct net_device *in,out fields are inside struct
> xt_action_param.
>
> struct xt_action_param{
>        ...........
>        struct net_device *in,*out;
>        ...........
> }
>
> After subsequent reading i understood, it should be struct
> xt_action_param in the match function's prototype. so the correct
> prototype should be,
>
> static bool ipaddr_mt(const struct sk_buff *skb,
>                       struct xt_action_param *par);
>
> So it should be updated so that noobs like me does not get confused.
>
> cheers
> aft

another thing I forgot to mention, why there is a separate structure
struct xt_action_param and struct xt_mtchk_param? where most of the
fields appear to be identical?

struct xt_mtchk_param {
	struct net *net;
	const char *table;
	const void *entryinfo;
	const struct xt_match *match;
	void *matchinfo;
	unsigned int hook_mask;
	u_int8_t family;
};

and 

struct xt_action_param {
	union {
		const struct xt_match *match;
		const struct xt_target *target;
	};
	union {
		const void *matchinfo, *targinfo;
	};
	const struct net_device *in, *out;
	int fragoff;
	unsigned int thoff;
	unsigned int hooknum;
	u_int8_t family;
	bool hotdrop;
};

Although in comments, its mentioned that struct xt_action_param is for
match/target extensions where as struct xt_mtchk_param is for checkentry
functions. these explanations seems superficial to me, so there should
be better explanation. (one thing comes to my mind, that xt_action_param
contains a union for xt_match/xt_target. so checking entry it will not
be usable when this is initialized with xt_target rather than
xt_match. But this explanation also seems a mere technicality, which can
easily be overcome),

cheers
aft

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What happened to xt_match_param
  2012-07-03 13:46 What happened to xt_match_param AFT
  2012-07-03 15:03 ` AFT
@ 2012-07-03 15:57 ` Jan Engelhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Engelhardt @ 2012-07-03 15:57 UTC (permalink / raw)
  To: AFT; +Cc: netfilter-devel

On Tuesday 2012-07-03 15:46, AFT wrote:

>In "writing netfilter module", by JAN, there is a inconsistancy in
>section 2.5 named "Point of decision".
>
>After subsequent reading i understood, it should be struct
>xt_action_param in the match function's prototype. so the correct
>prototype should be,
>
>static bool ipaddr_mt(const struct sk_buff *skb,
>                      struct xt_action_param *par);
>
>So it should be updated so that noobs like me does not get confused.

Corrected now.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-03 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03 13:46 What happened to xt_match_param AFT
2012-07-03 15:03 ` AFT
2012-07-03 15:57 ` Jan Engelhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.