1. 24 6月, 2016 5 次提交
    • P
      netfilter: nf_tables: add generation mask to chains · 664b0f8c
      Pablo Neira Ayuso 提交于
      Similar to ("netfilter: nf_tables: add generation mask to tables").
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      664b0f8c
    • P
      netfilter: nf_tables: add generation mask to tables · f2a6d766
      Pablo Neira Ayuso 提交于
      This patch addresses two problems:
      
      1) The netlink dump is inconsistent when interfering with an ongoing
         transaction update for several reasons:
      
      1.a) We don't honor the internal NFT_TABLE_INACTIVE flag, and we should
           be skipping these inactive objects in the dump.
      
      1.b) We perform speculative deletion during the preparation phase, that
           may result in skipping active objects.
      
      1.c) The listing order changes, which generates noise when tracking
           incremental ruleset update via tools like git or our own
           testsuite.
      
      2) We don't allow to add and to update the object in the same batch,
         eg. add table x; add table x { flags dormant\; }.
      
      In order to resolve these problems:
      
      1) If the user requests a deletion, the object becomes inactive in the
         next generation. Then, ignore objects that scheduled to be deleted
         from the lookup path, as they will be effectively removed in the
         next generation.
      
      2) From the get/dump path, if the object is not currently active, we
         skip it.
      
      3) Support 'add X -> update X' sequence from a transaction.
      
      After this update, we obtain a consistent list as long as we stay
      in the same generation. The userspace side can detect interferences
      through the generation counter so it can restart the dumping.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      f2a6d766
    • P
      netfilter: nf_tables: add generic macros to check for generation mask · 889f7ee7
      Pablo Neira Ayuso 提交于
      Thus, we can reuse these to check the genmask of any object type, not
      only rules. This is required now that tables, chain and sets will get a
      generation mask field too in follow up patches.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      889f7ee7
    • V
      netfilter: xt_NFLOG: nflog-range does not truncate packets · 7643507f
      Vishwanath Pai 提交于
      li->u.ulog.copy_len is currently ignored by the kernel, we should truncate
      the packet to either li->u.ulog.copy_len (if set) or copy_range before
      sending it to userspace. 0 is a valid input for copy_len, so add a new
      flag to indicate whether this was option was specified by the user or not.
      
      Add two flags to indicate whether nflog-size/copy_len was set or not.
      XT_NFLOG_F_COPY_LEN is for XT_NFLOG and NFLOG_F_COPY_LEN for nfnetlink_log
      
      On the userspace side, this was initially represented by the option
      nflog-range, this will be replaced by --nflog-size now. --nflog-range would
      still exist but does not do anything.
      Reported-by: NJoe Dollard <jdollard@akamai.com>
      Reviewed-by: NJosh Hunt <johunt@akamai.com>
      Signed-off-by: NVishwanath Pai <vpai@akamai.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      7643507f
    • L
      netfilter: nf_reject_ipv4: don't send tcp RST if the packet is non-TCP · e1dbbc59
      Liping Zhang 提交于
      In iptables, if the user add a rule to send tcp RST and specify the
      non-TCP protocol, such as UDP, kernel will reject this request. But
      in nftables, this validity check only occurs in nft tool, i.e. only
      in userspace.
      
      This means that user can add such a rule like follows via nfnetlink:
        "nft add rule filter forward ip protocol udp reject with tcp reset"
      
      This will generate some confusing tcp RST packets. So we should send
      tcp RST only when it is TCP packet.
      Signed-off-by: NLiping Zhang <liping.zhang@spreadtrum.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      e1dbbc59
  2. 23 6月, 2016 8 次提交
  3. 07 6月, 2016 6 次提交
    • F
      netfilter: helper: avoid extra expectation iterations on unregister · 436a850d
      Florian Westphal 提交于
      The expectation table is not duplicated per net namespace anymore, so we can move
      the expectation table and conntrack table iteration out of the per-net loop.
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      436a850d
    • T
      bridge: netfilter: checkpatch data type fixes · 402f9030
      Tobin C Harding 提交于
      checkpatch produces data type 'checks'.
      
      This patch amends them by changing, for example:
      uint8_t -> u8
      Signed-off-by: NTobin C Harding <me@tobin.cc>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      402f9030
    • D
      Merge branch 'vrf-local' · 2fb7ea45
      David S. Miller 提交于
      David Ahern says:
      
      ====================
      net: vrf: Add support for local traffic to local addresses
      
      Add support for locally originated traffic to VRF-local addresses,
      be it addresses on enslaved devices or addresses on the VRF device:
      
      $ ip addr show dev red
      33: red: <NOARP,MASTER,UP,LOWER_UP> mtu 65536 qdisc pfifo_fast state UP group default qlen 1000
          link/ether be:00:53:b5:e4:25 brd ff:ff:ff:ff:ff:ff
          inet 1.1.1.1/32 scope global red
             valid_lft forever preferred_lft forever
          inet6 1111:1::1/128 scope global
             valid_lft forever preferred_lft forever
      
      $ ip addr show dev eth1
      3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master red state UP group default qlen 1000
          link/ether 02:e0:f9:79:34:bd brd ff:ff:ff:ff:ff:ff
          inet 10.100.1.1/24 brd 10.100.1.255 scope global eth1
             valid_lft forever preferred_lft forever
          inet6 2100:1::1/120 scope global
             valid_lft forever preferred_lft forever
          inet6 fe80::e0:f9ff:fe79:34bd/64 scope link
             valid_lft forever preferred_lft forever
      
      $ ping -c1 -I red 10.100.1.1
          ping: Warning: source address might be selected on device other than red.
          PING 10.100.1.1 (10.100.1.1) from 10.100.1.1 red: 56(84) bytes of data.
          64 bytes from 10.100.1.1: icmp_seq=1 ttl=64 time=0.057 ms
      
      $ ping -c1 -I red 1.1.1.1
      PING 1.1.1.1 (1.1.1.1) from 1.1.1.1 red: 56(84) bytes of data.
      64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.136 ms
      
      --- 1.1.1.1 ping statistics ---
      1 packets transmitted, 1 received, 0% packet loss, time 0ms
      rtt min/avg/max/mdev = 0.136/0.136/0.136/0.000 ms
      
      $ ping6 -c1 -I red  2100:1::1
      ping6: Warning: source address might be selected on device other than red.
      PING 2100:1::1(2100:1::1) from 2100:1::1 red: 56 data bytes
      64 bytes from 2100:1::1: icmp_seq=1 ttl=64 time=0.167 ms
      
      --- 2100:1::1 ping statistics ---
      1 packets transmitted, 1 received, 0% packet loss, time 0ms
      rtt min/avg/max/mdev = 0.167/0.167/0.167/0.000 ms
      
      $ ping6 -c1 -I red 1111::1
      PING 1111::1(1111::1) from 1111:1::1 red: 56 data bytes
      64 bytes from 1111::1: icmp_seq=1 ttl=64 time=0.187 ms
      
      --- 1111::1 ping statistics ---
      1 packets transmitted, 1 received, 0% packet loss, time 0ms
      rtt min/avg/max/mdev = 0.187/0.187/0.187/0.000 ms
      
      This change also enables use of loopback address on the VRF device:
      $ ip addr add dev red 127.0.0.1/8
      
      $ ping -c1 -I red 127.0.0.1
      PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 red: 56(84) bytes of data.
      64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.058 ms
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2fb7ea45
    • D
      net: vrf: ipv6 support for local traffic to local addresses · 625b47b5
      David Ahern 提交于
      Add support for locally originated traffic to VRF-local IPv6 addresses.
      Similar to IPv4 a local dst is set on the skb and the packet is
      reinserted with a call to netif_rx. With this patch, ping, tcp and udp
      packets to a local IPv6 address are successfully routed:
      
          $ ip addr show dev eth1
          4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master red state UP group default qlen 1000
              link/ether 02:e0:f9:1c:b9:74 brd ff:ff:ff:ff:ff:ff
              inet 10.100.1.1/24 brd 10.100.1.255 scope global eth1
                 valid_lft forever preferred_lft forever
              inet6 2100:1::1/120 scope global
                 valid_lft forever preferred_lft forever
              inet6 fe80::e0:f9ff:fe1c:b974/64 scope link
                 valid_lft forever preferred_lft forever
      
          $ ping6 -c1 -I red 2100:1::1
          ping6: Warning: source address might be selected on device other than red.
          PING 2100:1::1(2100:1::1) from 2100:1::1 red: 56 data bytes
          64 bytes from 2100:1::1: icmp_seq=1 ttl=64 time=0.098 ms
      
      ip6_input is exported so the VRF driver can use it for the dst input
      function. The dst_alloc function for IPv4 defaults to setting the input and
      output functions; IPv6's does not. VRF does not need to duplicate the Rx path
      so just export the ipv6 input function.
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      625b47b5
    • D
      net: vrf: ipv4 support for local traffic to local addresses · 671cd19a
      David Ahern 提交于
      Add support for locally originated traffic to VRF-local addresses. If
      destination device for an skb is the loopback or VRF device then set
      its dst to a local version of the VRF cached dst_entry and call netif_rx
      to insert the packet onto the rx queue - similar to what is done for
      loopback. This patch handles IPv4 support; follow on patch handles IPv6.
      
      With this patch, ping, tcp and udp packets to a local IPv4 address are
      successfully routed:
      
          $ ip addr show dev eth1
          4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master red state UP group default qlen 1000
              link/ether 02:e0:f9:1c:b9:74 brd ff:ff:ff:ff:ff:ff
              inet 10.100.1.1/24 brd 10.100.1.255 scope global eth1
                 valid_lft forever preferred_lft forever
              inet6 2100:1::1/120 scope global
                 valid_lft forever preferred_lft forever
              inet6 fe80::e0:f9ff:fe1c:b974/64 scope link
                 valid_lft forever preferred_lft forever
      
          $ ping -c1 -I red 10.100.1.1
          ping: Warning: source address might be selected on device other than red.
          PING 10.100.1.1 (10.100.1.1) from 10.100.1.1 red: 56(84) bytes of data.
          64 bytes from 10.100.1.1: icmp_seq=1 ttl=64 time=0.057 ms
      
      This patch also enables use of IPv4 loopback address on the VRF device:
          $ ip addr add dev red 127.0.0.1/8
      
          $ ping -c1 -I red 127.0.0.1
          PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 red: 56(84) bytes of data.
          64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.058 ms
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      671cd19a
    • D
      net: vrf: Minor refactoring for local address patches · 09fcf916
      David Ahern 提交于
      Move the stripping of the ethernet header from is_ip_tx_frame into the
      ipv4 and ipv6 outbound functions. If the packet is destined to a local
      address the header is retained since the packet is sent back to netif_rx.
      
      Collapse vrf_send_v4_prep into vrf_process_v4_outbound.
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09fcf916
  4. 06 6月, 2016 7 次提交
  5. 05 6月, 2016 14 次提交