Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71298
b: refs/heads/master
c: 009e8c9
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan authored and David S. Miller committed Oct 18, 2007
1 parent 3b94f4c commit 8784d04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b83336bb9fa4f110b5b0a4378a82cd5f0fd0ac8
refs/heads/master: 009e8c965fd72a78636b9a96c7015109c5c70176
13 changes: 5 additions & 8 deletions trunk/include/linux/netfilter/xt_sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#define XT_SCTP_VALID_FLAGS 0x07

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


struct xt_sctp_flag_info {
u_int8_t chunktype;
u_int8_t flag;
Expand Down Expand Up @@ -59,29 +56,29 @@ struct xt_sctp_info {
#define SCTP_CHUNKMAP_RESET(chunkmap) \
do { \
int i; \
for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
for (i = 0; i < ARRAY_SIZE(chunkmap); i++) \
chunkmap[i] = 0; \
} while (0)

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

#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
do { \
int i; \
for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
for (i = 0; i < ARRAY_SIZE(srcmap); i++) \
destmap[i] = srcmap[i]; \
} while (0)

#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
({ \
int i; \
int flag = 1; \
for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \
if (chunkmap[i]) { \
flag = 0; \
break; \
Expand All @@ -94,7 +91,7 @@ struct xt_sctp_info {
({ \
int i; \
int flag = 1; \
for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \
if (chunkmap[i] != ~0) { \
flag = 0; \
break; \
Expand Down
18 changes: 8 additions & 10 deletions trunk/net/netfilter/xt_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ 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);
Expand All @@ -73,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,
Expand Down Expand Up @@ -104,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:
Expand Down Expand Up @@ -148,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);
}

Expand Down

0 comments on commit 8784d04

Please sign in to comment.