|
@@ -1,3 +1,4 @@
|
|
|
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
#include <linux/module.h>
|
|
|
#include <linux/skbuff.h>
|
|
|
#include <net/ip.h>
|
|
@@ -15,12 +16,6 @@ MODULE_DESCRIPTION("Xtables: SCTP protocol packet match");
|
|
|
MODULE_ALIAS("ipt_sctp");
|
|
|
MODULE_ALIAS("ip6t_sctp");
|
|
|
|
|
|
-#ifdef DEBUG_SCTP
|
|
|
-#define duprintf(format, args...) printk(format , ## args)
|
|
|
-#else
|
|
|
-#define duprintf(format, args...)
|
|
|
-#endif
|
|
|
-
|
|
|
#define SCCHECK(cond, option, flag, invflag) (!((flag) & (option)) \
|
|
|
|| (!!((invflag) & (option)) ^ (cond)))
|
|
|
|
|
@@ -52,7 +47,7 @@ match_packet(const struct sk_buff *skb,
|
|
|
const struct xt_sctp_flag_info *flag_info = info->flag_info;
|
|
|
int flag_count = info->flag_count;
|
|
|
|
|
|
-#ifdef DEBUG_SCTP
|
|
|
+#ifdef DEBUG
|
|
|
int i = 0;
|
|
|
#endif
|
|
|
|
|
@@ -62,17 +57,19 @@ match_packet(const struct sk_buff *skb,
|
|
|
do {
|
|
|
sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch);
|
|
|
if (sch == NULL || sch->length == 0) {
|
|
|
- duprintf("Dropping invalid SCTP packet.\n");
|
|
|
+ pr_debug("Dropping invalid SCTP packet.\n");
|
|
|
*hotdrop = true;
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n",
|
|
|
- ++i, offset, sch->type, htons(sch->length), sch->flags);
|
|
|
-
|
|
|
+#ifdef DEBUG
|
|
|
+ pr_debug("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d"
|
|
|
+ "\tflags: %x\n",
|
|
|
+ ++i, offset, sch->type, htons(sch->length),
|
|
|
+ sch->flags);
|
|
|
+#endif
|
|
|
offset += (ntohs(sch->length) + 3) & ~3;
|
|
|
|
|
|
- duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);
|
|
|
+ pr_debug("skb->len: %d\toffset: %d\n", skb->len, offset);
|
|
|
|
|
|
if (SCTP_CHUNKMAP_IS_SET(info->chunkmap, sch->type)) {
|
|
|
switch (chunk_match_type) {
|
|
@@ -124,17 +121,17 @@ sctp_mt(const struct sk_buff *skb, const struct xt_match_param *par)
|
|
|
sctp_sctphdr_t _sh;
|
|
|
|
|
|
if (par->fragoff != 0) {
|
|
|
- duprintf("Dropping non-first fragment.. FIXME\n");
|
|
|
+ pr_debug("Dropping non-first fragment.. FIXME\n");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
sh = skb_header_pointer(skb, par->thoff, sizeof(_sh), &_sh);
|
|
|
if (sh == NULL) {
|
|
|
- duprintf("Dropping evil TCP offset=0 tinygram.\n");
|
|
|
+ pr_debug("Dropping evil TCP offset=0 tinygram.\n");
|
|
|
*par->hotdrop = true;
|
|
|
return false;
|
|
|
}
|
|
|
- duprintf("spt: %d\tdpt: %d\n", ntohs(sh->source), ntohs(sh->dest));
|
|
|
+ pr_debug("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],
|