cosmetic ipt_unclean update
Subsystems (2)
PATCH 1/1 cosmetic ipt_unclean update
Hi Davem!
Please apply the following patchto your 2.4 tree and push it to Marcelo. Thanks.
Author: Patrick McHardy <[email protected]>
Use a pre-built table for TCP flag checks instead of individual 'if' statemens in ipt_unclean.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1214 -> 1.1215
# net/ipv4/netfilter/ipt_unclean.c 1.8 -> 1.9
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/07/12 [email protected] 1.1215
# [NETFILTER]: Use pre-built table for TCP flag-check in ipt_unclean. # --------------------------------------------
#
net/ipv4/netfilter/ipt_unclean.c +19 -13
@@ -259,6 +259,24 @@#define TH_ECE 0x40#define TH_CWR 0x80 +/* table of valid flag combinations - ECE and CWR are always valid */ +static u8 tcp_valid_flags[(TH_FIN |TH_SYN |TH_RST |TH_PUSH |TH_ACK |TH_URG ) +1 ] = +{ + [TH_SYN ] =1 , + [TH_SYN |TH_ACK ] =1 , + [TH_RST ] =1 , + [TH_RST |TH_ACK ] =1 , + [TH_RST |TH_ACK |TH_PUSH ] =1 , + [TH_FIN |TH_ACK ] =1 , + [TH_ACK ] =1 , + [TH_ACK |TH_PUSH ] =1 , + [TH_ACK |TH_URG ] =1 , + [TH_ACK |TH_URG |TH_PUSH ] =1 , + [TH_FIN |TH_ACK |TH_PUSH ] =1 , + [TH_FIN |TH_ACK |TH_URG ] =1 , + [TH_FIN |TH_ACK |TH_URG |TH_PUSH ] =1 +}; +/* TCP-specific checks. */ static int check_tcp(const struct iphdr *iph,
@@ -330,19 +348,7 @@/* CHECK: TCP flags. */ tcpflags = (((u_int8_t *)tcph)[13 ] & ~(TH_ECE |TH_CWR )); -if (tcpflags !=TH_SYN - && tcpflags != (TH_SYN |TH_ACK ) - && tcpflags !=TH_RST - && tcpflags != (TH_RST |TH_ACK ) - && tcpflags != (TH_RST |TH_ACK |TH_PUSH ) - && tcpflags != (TH_FIN |TH_ACK ) - && tcpflags !=TH_ACK - && tcpflags != (TH_ACK |TH_PUSH ) - && tcpflags != (TH_ACK |TH_URG ) - && tcpflags != (TH_ACK |TH_URG |TH_PUSH ) - && tcpflags != (TH_FIN |TH_ACK |TH_PUSH ) - && tcpflags != (TH_FIN |TH_ACK |TH_URG ) - && tcpflags != (TH_FIN |TH_ACK |TH_URG |TH_PUSH )) { +if (!tcp_valid_flags[tcpflags]) {limpk ("TCP flags bad: %u\n" , tcpflags);return 0 ; }
David S. Miller
AppliedQuoted 1 line · On Thu, 2 Oct 2003 16:43:00 +0200 Harald Welte <[email protected]> wrote:
Please apply the following patchto your 2.4 tree and push it to Marcelo.
Applied, thanks.