From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@redhat.com>
Cc: Netfilter Development Mailinglist <netfilter-devel@lists.netfilter.org>
Subject: [PATCH 2.6 3/6]: Convert sctp match to skb_header_pointer
Date: Sun, 26 Sep 2004 23:52:12 +0200 [thread overview]
Message-ID: <41573A0C.4060309@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 60 bytes --]
This patch converts the sctp match to skb_header_pointer.
[-- Attachment #2: 03.diff --]
[-- Type: text/x-patch, Size: 3488 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/09/26 23:16:04+02:00 kaber@coreworks.de
# [NETFILTER]: Convert sctp match to skb_header_pointer
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/ipv4/netfilter/ipt_sctp.c
# 2004/09/26 23:15:40+02:00 kaber@coreworks.de +18 -16
# [NETFILTER]: Convert sctp match to skb_header_pointer
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/net/ipv4/netfilter/ipt_sctp.c b/net/ipv4/netfilter/ipt_sctp.c
--- a/net/ipv4/netfilter/ipt_sctp.c 2004-09-26 23:22:45 +02:00
+++ b/net/ipv4/netfilter/ipt_sctp.c 2004-09-26 23:22:45 +02:00
@@ -42,7 +42,7 @@
{
int offset;
u_int32_t chunkmapcopy[256 / sizeof (u_int32_t)];
- sctp_chunkhdr_t sch;
+ sctp_chunkhdr_t _sch, *sch;
#ifdef DEBUG_SCTP
int i = 0;
@@ -54,38 +54,39 @@
offset = skb->nh.iph->ihl * 4 + sizeof (sctp_sctphdr_t);
do {
- if (skb_copy_bits(skb, offset, &sch, sizeof(sch)) < 0) {
+ sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch);
+ if (sch == NULL) {
duprintf("Dropping invalid SCTP packet.\n");
*hotdrop = 1;
return 0;
}
duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n",
- ++i, offset, sch.type, htons(sch.length), sch.flags);
+ ++i, offset, sch->type, htons(sch->length), sch->flags);
- offset += (htons(sch.length) + 3) & ~3;
+ offset += (htons(sch->length) + 3) & ~3;
duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);
- if (SCTP_CHUNKMAP_IS_SET(chunkmap, sch.type)) {
+ if (SCTP_CHUNKMAP_IS_SET(chunkmap, sch->type)) {
switch (chunk_match_type) {
case SCTP_CHUNK_MATCH_ANY:
if (match_flags(flag_info, flag_count,
- sch.type, sch.flags)) {
+ sch->type, sch->flags)) {
return 1;
}
break;
case SCTP_CHUNK_MATCH_ALL:
if (match_flags(flag_info, flag_count,
- sch.type, sch.flags)) {
- SCTP_CHUNKMAP_CLEAR(chunkmapcopy, sch.type);
+ sch->type, sch->flags)) {
+ SCTP_CHUNKMAP_CLEAR(chunkmapcopy, sch->type);
}
break;
case SCTP_CHUNK_MATCH_ONLY:
if (!match_flags(flag_info, flag_count,
- sch.type, sch.flags)) {
+ sch->type, sch->flags)) {
return 0;
}
break;
@@ -120,7 +121,7 @@
int *hotdrop)
{
const struct ipt_sctp_info *info;
- sctp_sctphdr_t sh;
+ sctp_sctphdr_t _sh, *sh;
info = (const struct ipt_sctp_info *)matchinfo;
@@ -129,18 +130,19 @@
return 0;
}
- if (skb_copy_bits(skb, skb->nh.iph->ihl*4, &sh, sizeof(sh)) < 0) {
+ sh = skb_header_pointer(skb, skb->nh.iph->ihl*4, sizeof(_sh), &_sh);
+ if (sh == NULL) {
duprintf("Dropping evil TCP offset=0 tinygram.\n");
*hotdrop = 1;
return 0;
}
- duprintf("spt: %d\tdpt: %d\n", ntohs(sh.source), ntohs(sh.dest));
+ duprintf("spt: %d\tdpt: %d\n", ntohs(sh->source), ntohs(sh->dest));
- return SCCHECK(((ntohs(sh.source) >= info->spts[0])
- && (ntohs(sh.source) <= info->spts[1])),
+ return SCCHECK(((ntohs(sh->source) >= info->spts[0])
+ && (ntohs(sh->source) <= info->spts[1])),
IPT_SCTP_SRC_PORTS, info->flags, info->invflags)
- && SCCHECK(((ntohs(sh.dest) >= info->dpts[0])
- && (ntohs(sh.dest) <= info->dpts[1])),
+ && SCCHECK(((ntohs(sh->dest) >= info->dpts[0])
+ && (ntohs(sh->dest) <= info->dpts[1])),
IPT_SCTP_DEST_PORTS, info->flags, info->invflags)
&& SCCHECK(match_packet(skb, info->chunkmap, info->chunk_match_type,
info->flag_info, info->flag_count,
reply other threads:[~2004-09-26 21:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41573A0C.4060309@trash.net \
--to=kaber@trash.net \
--cc=davem@redhat.com \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.