From 8f135d1eb63b3477a85d54bc359dacafd0558649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Caletka?= Date: Sat, 20 Jul 2013 22:52:25 +0200 Subject: [PATCH] Removed unnecessary comments, debugs and whitespace. --- libxt_dns.c | 5 ++--- xt_dns.c | 14 ++------------ xt_dns.h | 3 --- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libxt_dns.c b/libxt_dns.c index 241918b..bbbd7b8 100644 --- a/libxt_dns.c +++ b/libxt_dns.c @@ -200,7 +200,7 @@ static int dns_parse(int c, char **argv, int invert, unsigned int *flags, if (invert) info->invert_flags |= XT_DNS_QTYPE; return true; - break; + case '4': /* edns0 */ if (*flags & XT_DNS_EDNS0) xtables_error(PARAMETER_PROBLEM, "xt_dns: " @@ -210,6 +210,7 @@ static int dns_parse(int c, char **argv, int invert, unsigned int *flags, if (invert) info->invert_flags |= XT_DNS_EDNS0; return true; + case '5': /* bufsize */ if (*flags & XT_DNS_BUFSIZE) xtables_error(PARAMETER_PROBLEM, "xt_dns: " @@ -230,7 +231,6 @@ static void dns_print(const void *ip, const struct xt_entry_match *match, int nu struct xt_dns_info *info = (void *) match->data; const char *name; - printf(S1"dns"S2); if (info->flags & XT_DNS_QUERY) { printf("%s",S1); @@ -341,4 +341,3 @@ void _init(void) xtables_register_match(&dns_match); xtables_register_match(&dns_match6); } - diff --git a/xt_dns.c b/xt_dns.c index cf8e601..dd34bd5 100644 --- a/xt_dns.c +++ b/xt_dns.c @@ -38,11 +38,8 @@ void debug_dump_buf(u8 *dns, size_t len, size_t offset, char *title) { #define debug_dump_buf(dns, len, offset, title) #endif - -// uncomment following line if you get compilation error -//#define HAVE_XT_MATCH_PARAM - #define MAX_MTU 2000 +static u8 pktbuf[MAX_MTU]; /* buffer for whole packet in case skb is fragmented */ static bool skip_name(u8 *dns, size_t len, size_t *offset) { /* skip labels */ @@ -80,8 +77,6 @@ static bool skip_rr(u8 *dns, size_t len, size_t *offset) { return false; } -static u8 pktbuf[MAX_MTU]; /* buffer for whole packet in case skb is fragmented */ - #ifdef HAVE_XT_MATCH_PARAM static bool dns_mt(const struct sk_buff *skb, const struct xt_match_param *par) #else @@ -114,8 +109,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par) pr_warn(KBUILD_MODNAME": skb_header_pointer failed!\n"); return false; } - /*dns = skb->data + (par->thoff + sizeof(struct udphdr)); - len = skb_headlen(skb) - (par->thoff + sizeof(struct udphdr));*/ /* minimum DNS query payload is 17 bytes (for "." root zone) */ if (len < 17) @@ -159,8 +152,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par) if (!is_match) goto qtype_out; - - /* match if type=info->type, class IN */ is_match = (dns[offset-4] == 0x00) && (dns[offset-3] == info->qtype) && (dns[offset-2] == 0x00) && (dns[offset-2] == 0x01); @@ -184,7 +175,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par) } if (!is_match) goto edns0_out; - debug_dump_buf(dns, len, offset, "after_query"); /* skip answer and authority sections */ for (i=0; i<(counts[1]+counts[2]); i++) { @@ -203,7 +193,7 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par) if (!is_match) break; } - if (!is_match || i == counts[3]) { + if (!is_match || (i == counts[3])) { is_match = false; goto edns0_out; } diff --git a/xt_dns.h b/xt_dns.h index f537232..5100450 100644 --- a/xt_dns.h +++ b/xt_dns.h @@ -28,7 +28,4 @@ struct xt_dns_info { u_int16_t bufsize[2]; /* edns0 bufsize [min:max] */ }; - - #endif -