netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
@ 2007-10-12  5:45 lizf
  2007-10-15  6:07 ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: lizf @ 2007-10-12  5:45 UTC (permalink / raw)
  To: kaber, netfilter-devel

Hi,

Macros like SCTP_CHUNKMAP_XXX(chukmap) require chukmap to be an array,
We can see from below:

#define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))

#define SCTP_CHUNKMAP_RESET(chunkmap)				\
	do {							\
		int i;						\
		for (i = 0; i < ELEMCOUNT(chunkmap); i++)	\
			chunkmap[i] = 0;			\
	} while (0)

But match_packet() passes a pointer to these macros. Here's the patch.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index c002153..f65c71c 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -41,21 +41,22 @@ match_flags(const struct xt_sctp_flag_info *flag_info,
 static inline bool
 match_packet(const struct sk_buff *skb,
 	     unsigned int offset,
-	     const u_int32_t *chunkmap,
-	     int chunk_match_type,
-	     const struct xt_sctp_flag_info *flag_info,
-	     const int flag_count,
+	     const struct xt_sctp_info *info,
 	     bool *hotdrop)
 {
 	u_int32_t chunkmapcopy[256 / sizeof (u_int32_t)];
 	sctp_chunkhdr_t _sch, *sch;
 
+	int chunk_match_type = info->chunk_match_type;
+	const struct xt_sctp_flag_info *flag_info = info->flag_info;
+	int flag_count = info->flag_count;
+
 #ifdef DEBUG_SCTP
 	int i = 0;
 #endif
 
 	if (chunk_match_type == SCTP_CHUNK_MATCH_ALL)
-		SCTP_CHUNKMAP_COPY(chunkmapcopy, chunkmap);
+		SCTP_CHUNKMAP_COPY(chunkmapcopy, info->chunkmap);
 
 	do {
 		sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch);
@@ -72,7 +73,7 @@ match_packet(const struct sk_buff *skb,
 
 		duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);
 
-		if (SCTP_CHUNKMAP_IS_SET(chunkmap, sch->type)) {
+		if (SCTP_CHUNKMAP_IS_SET(info->chunkmap, sch->type)) {
 			switch (chunk_match_type) {
 			case SCTP_CHUNK_MATCH_ANY:
 				if (match_flags(flag_info, flag_count,
@@ -103,7 +104,7 @@ match_packet(const struct sk_buff *skb,
 
 	switch (chunk_match_type) {
 	case SCTP_CHUNK_MATCH_ALL:
-		return SCTP_CHUNKMAP_IS_CLEAR(chunkmap);
+		return SCTP_CHUNKMAP_IS_CLEAR(info->chunkmap);
 	case SCTP_CHUNK_MATCH_ANY:
 		return false;
 	case SCTP_CHUNK_MATCH_ONLY:
@@ -147,9 +148,7 @@ match(const struct sk_buff *skb,
 			&& ntohs(sh->dest) <= info->dpts[1],
 			XT_SCTP_DEST_PORTS, info->flags, info->invflags)
 		&& SCCHECK(match_packet(skb, protoff + sizeof (sctp_sctphdr_t),
-					info->chunkmap, info->chunk_match_type,
-					info->flag_info, info->flag_count,
-					hotdrop),
+					info, hotdrop),
 			   XT_SCTP_CHUNK_TYPES, info->flags, info->invflags);
 }
 


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

* Re: [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
  2007-10-12  5:45 [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required lizf
@ 2007-10-15  6:07 ` Patrick McHardy
  2007-10-15 10:00   ` lizf
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2007-10-15  6:07 UTC (permalink / raw)
  To: lizf; +Cc: netfilter-devel

lizf wrote:
> Hi,
> 
> Macros like SCTP_CHUNKMAP_XXX(chukmap) require chukmap to be an array,
> We can see from below:
> 
> #define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))
> 
> #define SCTP_CHUNKMAP_RESET(chunkmap)                \
>     do {                            \
>         int i;                        \
>         for (i = 0; i < ELEMCOUNT(chunkmap); i++)    \
>             chunkmap[i] = 0;            \
>     } while (0)
> 
> But match_packet() passes a pointer to these macros. Here's the patch.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>


Thanks, but your mailer corrupted the patch by converting tabs to
spaces. Please resend as attachment so I can apply it.



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

* Re: [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
  2007-10-15  6:07 ` Patrick McHardy
@ 2007-10-15 10:00   ` lizf
  2007-10-18  9:01     ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: lizf @ 2007-10-15 10:00 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Patrick McHardy wrote:
>> Macros like SCTP_CHUNKMAP_XXX(chukmap) require chukmap to be an array,
>> We can see from below:
>>
>> #define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))
>>
>> #define SCTP_CHUNKMAP_RESET(chunkmap)                \
>>     do {                            \
>>         int i;                        \
>>         for (i = 0; i < ELEMCOUNT(chunkmap); i++)    \
>>             chunkmap[i] = 0;            \
>>     } while (0)
>>
>> But match_packet() passes a pointer to these macros. Here's the patch.
>>
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> 
> Thanks, but your mailer corrupted the patch by converting tabs to
> spaces. Please resend as attachment so I can apply it.
> 
> 

Sorry for the noise, I've configed my mailer according to a kernel doc,
but i'm still not sure whether it works. So here's the attachment.

Li Zefan


[-- Attachment #2: xt_sctp.patch --]
[-- Type: text/x-patch, Size: 2054 bytes --]

diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index c002153..f65c71c 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -41,21 +41,22 @@ match_flags(const struct xt_sctp_flag_info *flag_info,
 static inline bool
 match_packet(const struct sk_buff *skb,
 	     unsigned int offset,
-	     const u_int32_t *chunkmap,
-	     int chunk_match_type,
-	     const struct xt_sctp_flag_info *flag_info,
-	     const int flag_count,
+	     const struct xt_sctp_info *info,
 	     bool *hotdrop)
 {
 	u_int32_t chunkmapcopy[256 / sizeof (u_int32_t)];
 	sctp_chunkhdr_t _sch, *sch;
 
+	int chunk_match_type = info->chunk_match_type;
+	const struct xt_sctp_flag_info *flag_info = info->flag_info;
+	int flag_count = info->flag_count;
+
 #ifdef DEBUG_SCTP
 	int i = 0;
 #endif
 
 	if (chunk_match_type == SCTP_CHUNK_MATCH_ALL)
-		SCTP_CHUNKMAP_COPY(chunkmapcopy, chunkmap);
+		SCTP_CHUNKMAP_COPY(chunkmapcopy, info->chunkmap);
 
 	do {
 		sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch);
@@ -72,7 +73,7 @@ match_packet(const struct sk_buff *skb,
 
 		duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);
 
-		if (SCTP_CHUNKMAP_IS_SET(chunkmap, sch->type)) {
+		if (SCTP_CHUNKMAP_IS_SET(info->chunkmap, sch->type)) {
 			switch (chunk_match_type) {
 			case SCTP_CHUNK_MATCH_ANY:
 				if (match_flags(flag_info, flag_count,
@@ -103,7 +104,7 @@ match_packet(const struct sk_buff *skb,
 
 	switch (chunk_match_type) {
 	case SCTP_CHUNK_MATCH_ALL:
-		return SCTP_CHUNKMAP_IS_CLEAR(chunkmap);
+		return SCTP_CHUNKMAP_IS_CLEAR(info->chunkmap);
 	case SCTP_CHUNK_MATCH_ANY:
 		return false;
 	case SCTP_CHUNK_MATCH_ONLY:
@@ -147,9 +148,7 @@ match(const struct sk_buff *skb,
 			&& ntohs(sh->dest) <= info->dpts[1],
 			XT_SCTP_DEST_PORTS, info->flags, info->invflags)
 		&& SCCHECK(match_packet(skb, protoff + sizeof (sctp_sctphdr_t),
-					info->chunkmap, info->chunk_match_type,
-					info->flag_info, info->flag_count,
-					hotdrop),
+					info, hotdrop),
 			   XT_SCTP_CHUNK_TYPES, info->flags, info->invflags);
 }
 

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

* Re: [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
  2007-10-15 10:00   ` lizf
@ 2007-10-18  9:01     ` Patrick McHardy
  2007-10-18  9:05       ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2007-10-18  9:01 UTC (permalink / raw)
  To: lizf; +Cc: netfilter-devel

lizf wrote:
> Sorry for the noise, I've configed my mailer according to a kernel doc,
> but i'm still not sure whether it works. So here's the attachment.
> 

Thanks, the attachment applies fine, but does not compile:


   CC [M]  net/netfilter/xt_sctp.o
net/netfilter/xt_sctp.c: In function 'match_packet':
net/netfilter/xt_sctp.c:60: error: 'chunkmap' undeclared (first use in 
this function)
net/netfilter/xt_sctp.c:60: error: (Each undeclared identifier is 
reported only once
net/netfilter/xt_sctp.c:60: error: for each function it appears in.)
make[1]: *** [net/netfilter/xt_sctp.o] Error 1
make: *** [net/netfilter/xt_sctp.o] Error 2

The SCTP_CHUNKMAP_COPY uses "chunkmap" internally. What tree did
you base this patch on?

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

* Re: [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
  2007-10-18  9:01     ` Patrick McHardy
@ 2007-10-18  9:05       ` Patrick McHardy
  2007-10-18  9:14         ` lizf
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2007-10-18  9:05 UTC (permalink / raw)
  To: lizf; +Cc: netfilter-devel

Patrick McHardy wrote:
> lizf wrote:
>> Sorry for the noise, I've configed my mailer according to a kernel doc,
>> but i'm still not sure whether it works. So here's the attachment.
>>
> 
> Thanks, the attachment applies fine, but does not compile:
> 
> 
>   CC [M]  net/netfilter/xt_sctp.o
> net/netfilter/xt_sctp.c: In function 'match_packet':
> net/netfilter/xt_sctp.c:60: error: 'chunkmap' undeclared (first use in 
> this function)
> net/netfilter/xt_sctp.c:60: error: (Each undeclared identifier is 
> reported only once
> net/netfilter/xt_sctp.c:60: error: for each function it appears in.)
> make[1]: *** [net/netfilter/xt_sctp.o] Error 1
> make: *** [net/netfilter/xt_sctp.o] Error 2
> 
> The SCTP_CHUNKMAP_COPY uses "chunkmap" internally. What tree did
> you base this patch on?


Never mind, I figured out that both patches combined compile,
so I've combined them in one. For the future: each patch should
always compile on its own without errors.


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

* Re: [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required
  2007-10-18  9:05       ` Patrick McHardy
@ 2007-10-18  9:14         ` lizf
  0 siblings, 0 replies; 6+ messages in thread
From: lizf @ 2007-10-18  9:14 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

Patrick McHardy wrote:
> Patrick McHardy wrote:
>> lizf wrote:
>>> Sorry for the noise, I've configed my mailer according to a kernel doc,
>>> but i'm still not sure whether it works. So here's the attachment.
>>>
>>
>> Thanks, the attachment applies fine, but does not compile:
>>
>>
>>   CC [M]  net/netfilter/xt_sctp.o
>> net/netfilter/xt_sctp.c: In function 'match_packet':
>> net/netfilter/xt_sctp.c:60: error: 'chunkmap' undeclared (first use in
>> this function)
>> net/netfilter/xt_sctp.c:60: error: (Each undeclared identifier is
>> reported only once
>> net/netfilter/xt_sctp.c:60: error: for each function it appears in.)
>> make[1]: *** [net/netfilter/xt_sctp.o] Error 1
>> make: *** [net/netfilter/xt_sctp.o] Error 2
>>
>> The SCTP_CHUNKMAP_COPY uses "chunkmap" internally. What tree did
>> you base this patch on?
> 
> 
> Never mind, I figured out that both patches combined compile,
> so I've combined them in one. For the future: each patch should
> always compile on its own without errors.
> 
> 
> 

I just thought out why it doesn't compile. I should have been more
careful. Thanks for your patience.

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

end of thread, other threads:[~2007-10-18  9:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12  5:45 [PATCH 1/2] netfilter: fix - mistake to pass a pointer where array is required lizf
2007-10-15  6:07 ` Patrick McHardy
2007-10-15 10:00   ` lizf
2007-10-18  9:01     ` Patrick McHardy
2007-10-18  9:05       ` Patrick McHardy
2007-10-18  9:14         ` lizf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).