1. 26 9月, 2016 1 次提交
    • P
      netfilter: nf_tables: add range expression · 0f3cd9b3
      Pablo Neira Ayuso 提交于
      Inverse ranges != [a,b] are not currently possible because rules are
      composites of && operations, and we need to express this:
      
      	data < a || data > b
      
      This patch adds a new range expression. Positive ranges can be already
      through two cmp expressions:
      
      	cmp(sreg, data, >=)
      	cmp(sreg, data, <=)
      
      This new range expression provides an alternative way to express this.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0f3cd9b3
  2. 25 9月, 2016 10 次提交
    • F
      netfilter: evict stale entries when user reads /proc/net/nf_conntrack · 58e207e4
      Florian Westphal 提交于
      Fabian reports a possible conntrack memory leak (could not reproduce so
      far), however, one minor issue can be easily resolved:
      
      > cat /proc/net/nf_conntrack | wc -l = 5
      > 4 minutes required to clean up the table.
      
      We should not report those timed-out entries to the user in first place.
      And instead of just skipping those timed-out entries while iterating over
      the table we can also zap them (we already do this during ctnetlink
      walks, but I forgot about the /proc interface).
      
      Fixes: f330a7fd ("netfilter: conntrack: get rid of conntrack timer")
      Reported-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      58e207e4
    • V
      netfilter: xt_hashlimit: Create revision 2 to support higher pps rates · 11d5f157
      Vishwanath Pai 提交于
      Create a new revision for the hashlimit iptables extension module. Rev 2
      will support higher pps of upto 1 million, Version 1 supports only 10k.
      
      To support this we have to increase the size of the variables avg and
      burst in hashlimit_cfg to 64-bit. Create two new structs hashlimit_cfg2
      and xt_hashlimit_mtinfo2 and also create newer versions of all the
      functions for match, checkentry and destroy.
      
      Some of the functions like hashlimit_mt, hashlimit_mt_check etc are very
      similar in both rev1 and rev2 with only minor changes, so I have split
      those functions and moved all the common code to a *_common function.
      Signed-off-by: NVishwanath Pai <vpai@akamai.com>
      Signed-off-by: NJoshua Hunt <johunt@akamai.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      11d5f157
    • V
      netfilter: xt_hashlimit: Prepare for revision 2 · 0dc60a45
      Vishwanath Pai 提交于
      I am planning to add a revision 2 for the hashlimit xtables module to
      support higher packets per second rates. This patch renames all the
      functions and variables related to revision 1 by adding _v1 at the
      end of the names.
      Signed-off-by: NVishwanath Pai <vpai@akamai.com>
      Signed-off-by: NJoshua Hunt <johunt@akamai.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0dc60a45
    • L
      netfilter: nft_ct: report error if mark and dir specified simultaneously · 7bfdde70
      Liping Zhang 提交于
      NFT_CT_MARK is unrelated to direction, so if NFTA_CT_DIRECTION attr is
      specified, report EINVAL to the userspace. This validation check was
      already done at nft_ct_get_init, but we missed it in nft_ct_set_init.
      Signed-off-by: NLiping Zhang <liping.zhang@spreadtrum.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      7bfdde70
    • L
      netfilter: nft_ct: unnecessary to require dir when use ct l3proto/protocol · d767ff2c
      Liping Zhang 提交于
      Currently, if the user want to match ct l3proto, we must specify the
      direction, for example:
        # nft add rule filter input ct original l3proto ipv4
                                       ^^^^^^^^
      Otherwise, error message will be reported:
        # nft add rule filter input ct l3proto ipv4
        nft add rule filter input ct l3proto ipv4
        <cmdline>:1:1-38: Error: Could not process rule: Invalid argument
        add rule filter input ct l3proto ipv4
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      
      Actually, there's no need to require NFTA_CT_DIRECTION attr, because
      ct l3proto and protocol are unrelated to direction.
      
      And for compatibility, even if the user specify the NFTA_CT_DIRECTION
      attr, do not report error, just skip it.
      Signed-off-by: NLiping Zhang <liping.zhang@spreadtrum.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      d767ff2c
    • G
      netfilter: seqadj: Fix the wrong ack adjust for the RST packet without ack · 8d11350f
      Gao Feng 提交于
      It is valid that the TCP RST packet which does not set ack flag, and bytes
      of ack number are zero. But current seqadj codes would adjust the "0" ack
      to invalid ack number. Actually seqadj need to check the ack flag before
      adjust it for these RST packets.
      
      The following is my test case
      
      client is 10.26.98.245, and add one iptable rule:
      iptables  -I INPUT -p tcp --sport 12345 -m connbytes --connbytes 2:
      --connbytes-dir reply --connbytes-mode packets -j REJECT --reject-with
      tcp-reset
      This iptables rule could generate on TCP RST without ack flag.
      
      server:10.172.135.55
      Enable the synproxy with seqadjust by the following iptables rules
      iptables -t raw -A PREROUTING -i eth0 -p tcp -d 10.172.135.55 --dport 12345
      -m tcp --syn -j CT --notrack
      
      iptables -A INPUT -i eth0 -p tcp -d 10.172.135.55 --dport 12345 -m conntrack
      --ctstate INVALID,UNTRACKED -j SYNPROXY --sack-perm --timestamp --wscale 7
      --mss 1460
      iptables -A OUTPUT -o eth0 -p tcp -s 10.172.135.55 --sport 12345 -m conntrack
      --ctstate INVALID,UNTRACKED -m tcp --tcp-flags SYN,RST,ACK SYN,ACK -j ACCEPT
      
      The following is my test result.
      
      1. packet trace on client
      root@routers:/tmp# tcpdump -i eth0 tcp port 12345 -n
      tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
      listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
      IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [S], seq 3695959829,
      win 29200, options [mss 1460,sackOK,TS val 452367884 ecr 0,nop,wscale 7],
      length 0
      IP 10.172.135.55.12345 > 10.26.98.245.45154: Flags [S.], seq 546723266,
      ack 3695959830, win 0, options [mss 1460,sackOK,TS val 15643479 ecr 452367884,
      nop,wscale 7], length 0
      IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [.], ack 1, win 229,
      options [nop,nop,TS val 452367885 ecr 15643479], length 0
      IP 10.172.135.55.12345 > 10.26.98.245.45154: Flags [.], ack 1, win 226,
      options [nop,nop,TS val 15643479 ecr 452367885], length 0
      IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [R], seq 3695959830,
      win 0, length 0
      
      2. seqadj log on server
      [62873.867319] Adjusting sequence number from 602341895->546723267,
      ack from 3695959830->3695959830
      [62873.867644] Adjusting sequence number from 602341895->546723267,
      ack from 3695959830->3695959830
      [62873.869040] Adjusting sequence number from 3695959830->3695959830,
      ack from 0->55618628
      
      To summarize, it is clear that the seqadj codes adjust the 0 ack when receive
      one TCP RST packet without ack.
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      8d11350f
    • A
      netfilter: replace list_head with single linked list · e3b37f11
      Aaron Conole 提交于
      The netfilter hook list never uses the prev pointer, and so can be trimmed to
      be a simple singly-linked list.
      
      In addition to having a more light weight structure for hook traversal,
      struct net becomes 5568 bytes (down from 6400) and struct net_device becomes
      2176 bytes (down from 2240).
      Signed-off-by: NAaron Conole <aconole@bytheb.org>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      e3b37f11
    • A
      netfilter: Only allow sane values in nf_register_net_hook · d4bb5caa
      Aaron Conole 提交于
      This commit adds an upfront check for sane values to be passed when
      registering a netfilter hook.  This will be used in a future patch for a
      simplified hook list traversal.
      Signed-off-by: NAaron Conole <aconole@bytheb.org>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      d4bb5caa
    • A
      netfilter: Remove explicit rcu_read_lock in nf_hook_slow · e2361cb9
      Aaron Conole 提交于
      All of the callers of nf_hook_slow already hold the rcu_read_lock, so this
      cleanup removes the recursive call.  This is just a cleanup, as the locking
      code gracefully handles this situation.
      Signed-off-by: NAaron Conole <aconole@bytheb.org>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      e2361cb9
    • G
      netfilter: xt_TCPMSS: Refactor the codes to decrease one condition check and more readable · 50f4c7b7
      Gao Feng 提交于
      The origin codes perform two condition checks with dst_mtu(skb_dst(skb))
      and in_mtu. And the last statement is "min(dst_mtu(skb_dst(skb)),
      in_mtu) - minlen". It may let reader think about how about the result.
      Would it be negative.
      
      Now assign the result of min(dst_mtu(skb_dst(skb)), in_mtu) to a new
      variable, then only perform one condition check, and it is more readable.
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      50f4c7b7
  3. 23 9月, 2016 7 次提交
  4. 22 9月, 2016 1 次提交
  5. 13 9月, 2016 10 次提交
  6. 09 9月, 2016 1 次提交
  7. 07 9月, 2016 10 次提交
    • M
      netfilter: nf_ct_sip: allow tab character in SIP headers · 1bcabc81
      Marco Angaroni 提交于
      Current parsing methods for SIP headers do not allow the presence of
      tab characters between header name and header value. As a result Call-ID
      SIP headers like the following are discarded by IPVS SIP persistence
      engine:
      
      "Call-ID\t: mycallid@abcde"
      "Call-ID:\tmycallid@abcde"
      
      In above examples Call-IDs are represented as strings in C language.
      Obviously in real message we have byte "09" before/after colon (":").
      
      Proposed fix is in nf_conntrack_sip module.
      Function sip_skip_whitespace() should skip tabs in addition to spaces,
      since in SIP grammar whitespace (WSP) corresponds to space or tab.
      
      Below is an extract of relevant SIP ABNF syntax.
      
      Call-ID  =  ( "Call-ID" / "i" ) HCOLON callid
      callid   =  word [ "@" word ]
      
      HCOLON  =  *( SP / HTAB ) ":" SWS
      SWS     =  [LWS] ; sep whitespace
      LWS     =  [*WSP CRLF] 1*WSP ; linear whitespace
      WSP     =  SP / HTAB
      word    =  1*(alphanum / "-" / "." / "!" / "%" / "*" /
                 "_" / "+" / "`" / "'" / "~" /
                 "(" / ")" / "<" / ">" /
                 ":" / "\" / DQUOTE /
                 "/" / "[" / "]" / "?" /
                 "{" / "}" )
      Signed-off-by: NMarco Angaroni <marcoangaroni@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      1bcabc81
    • P
      netfilter: nft_quota: introduce nft_overquota() · 22609b43
      Pablo Neira Ayuso 提交于
      This is patch renames the existing function to nft_overquota() and make
      it return a boolean that tells us if we have exceeded our byte quota.
      Just a cleanup.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      22609b43
    • P
      netfilter: nft_quota: fix overquota logic · db6d857b
      Pablo Neira Ayuso 提交于
      Use xor to decide to break further rule evaluation or not, since the
      existing logic doesn't achieve the expected inversion.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      db6d857b
    • L
      netfilter: nft_numgen: rename until attribute by modulus · 0d9932b2
      Laura Garcia Liebana 提交于
      The _until_ attribute is renamed to _modulus_ as the behaviour is similar to
      other expresions with number limits (ex. nft_hash).
      
      Renaming is possible because there isn't a kernel release yet with these
      changes.
      Signed-off-by: NLaura Garcia Liebana <nevola@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0d9932b2
    • G
      netfilter: ftp: Remove the useless code · ddb075b0
      Gao Feng 提交于
      There are some debug code which are commented out in find_pattern by #if 0.
      Now remove them.
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      ddb075b0
    • G
      netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern · 723eb299
      Gao Feng 提交于
      The caller function "help" has already make sure the datalen could not be zero
      before invoke find_pattern as a parameter by the following codes
      
              if (dataoff >= skb->len) {
                      pr_debug("ftp: dataoff(%u) >= skblen(%u)\n", dataoff,
                               skb->len);
                      return NF_ACCEPT;
              }
              datalen = skb->len - dataoff;
      
      And the latter codes "ends_in_nl = (fb_ptr[datalen - 1] == '\n');" use datalen
      directly without checking if it is zero.
      
      So it is unneccessary to check it in find_pattern too.
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      723eb299
    • M
      netfilter: nf_ct_sip: correct allowed characters in Call-ID SIP header · f0608cea
      Marco Angaroni 提交于
      Current parsing methods for SIP header Call-ID do not check correctly all
      characters allowed by RFC 3261. In particular "," character is allowed
      instead of "'" character. As a result Call-ID headers like the following
      are discarded by IPVS SIP persistence engine.
      
      Call-ID: -.!%*_+`'~()<>:\"/[]?{}
      
      Above example is composed using all non-alphanumeric characters listed
      in RFC 3261 for Call-ID header syntax.
      
      Proposed fix is in nf_conntrack_sip module; function iswordc() checks this
      range: (c >= '(' && c <= '/') which includes these characters: ()*+,-./
      They are all allowed except ",". Instead "'" is not included in the list.
      
      Below is an extract of relevant SIP ABNF syntax.
      
      Call-ID  =  ( "Call-ID" / "i" ) HCOLON callid
      callid   =  word [ "@" word ]
      
      HCOLON  =  *( SP / HTAB ) ":" SWS
      SWS     =  [LWS] ; sep whitespace
      LWS     =  [*WSP CRLF] 1*WSP ; linear whitespace
      WSP     =  SP / HTAB
      word    =  1*(alphanum / "-" / "." / "!" / "%" / "*" /
                 "_" / "+" / "`" / "'" / "~" /
                 "(" / ")" / "<" / ">" /
                 ":" / "\" / DQUOTE /
                 "/" / "[" / "]" / "?" /
                 "{" / "}" )
      Signed-off-by: NMarco Angaroni <marcoangaroni@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      f0608cea
    • M
      netfilter: nf_ct_sip: correct parsing of continuation lines in SIP headers · 68cb9fe4
      Marco Angaroni 提交于
      Current parsing methods for SIP headers do not properly manage
      continuation lines: in case of Call-ID header the first character of
      Call-ID header value is truncated. As a result IPVS SIP persistence
      engine hashes over a call-id that is not exactly the one present in
      the originale message.
      
      Example: "Call-ID: \r\n abcdeABCDE1234"
      results in extracted call-id equal to "bcdeABCDE1234".
      
      In above example Call-ID is represented as a string in C language.
      Obviously in real message the first bytes after colon (":") are
      "20 0d 0a 20".
      
      Proposed fix is in nf_conntrack_sip module.
      Since sip_follow_continuation() function walks past the leading
      spaces or tabs of the continuation line, sip_skip_whitespace()
      should simply return the ouput of sip_follow_continuation().
      Otherwise another iteration of the for loop is done and dptr
      is incremented by one pointing to the second character of the
      first word in the header.
      
      Below is an extract of relevant SIP ABNF syntax.
      
      Call-ID  =  ( "Call-ID" / "i" ) HCOLON callid
      callid   =  word [ "@" word ]
      
      HCOLON  =  *( SP / HTAB ) ":" SWS
      SWS     =  [LWS] ; sep whitespace
      LWS     =  [*WSP CRLF] 1*WSP ; linear whitespace
      WSP     =  SP / HTAB
      word    =  1*(alphanum / "-" / "." / "!" / "%" / "*" /
                 "_" / "+" / "`" / "'" / "~" /
                 "(" / ")" / "<" / ">" /
                 ":" / "\" / DQUOTE /
                 "/" / "[" / "]" / "?" /
                 "{" / "}" )
      Signed-off-by: NMarco Angaroni <marcoangaroni@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      68cb9fe4
    • G
      netfilter: gre: Use consistent GRE and PTTP header structure instead of the... · c579a9e7
      Gao Feng 提交于
      netfilter: gre: Use consistent GRE and PTTP header structure instead of the ones defined by netfilter
      
      There are two existing strutures which defines the GRE and PPTP header.
      So use these two structures instead of the ones defined by netfilter to
      keep consitent with other codes.
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      c579a9e7
    • G
      netfilter: gre: Use consistent GRE_* macros instead of ones defined by netfilter. · ecc6569f
      Gao Feng 提交于
      There are already some GRE_* macros in kernel, so it is unnecessary
      to define these macros. And remove some useless macros
      Signed-off-by: NGao Feng <fgao@ikuai8.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      ecc6569f