1. 19 Jun, 2017 5 commits
    • Jike Song's avatar
      netfilter, kbuild: use canonical method to specify objs. · 2becbbc5
      Jike Song authored
      Should use ":=" instead of "+=".
      Signed-off-by: default avatarJike Song <jike.song@intel.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      2becbbc5
    • Gao Feng's avatar
      netfilter: ebt: Use new helper ebt_invalid_target to check target · e15b9c50
      Gao Feng authored
      Use the new helper function ebt_invalid_target instead of the old
      macro INVALID_TARGET and other duplicated codes to enhance the readability.
      Signed-off-by: default avatarGao Feng <gfree.wind@vip.163.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      e15b9c50
    • Florian Westphal's avatar
      netns: add and use net_ns_barrier · 7866cc57
      Florian Westphal authored
      Quoting Joe Stringer:
        If a user loads nf_conntrack_ftp, sends FTP traffic through a network
        namespace, destroys that namespace then unloads the FTP helper module,
        then the kernel will crash.
      
      Events that lead to the crash:
      1. conntrack is created with ftp helper in netns x
      2. This netns is destroyed
      3. netns destruction is scheduled
      4. netns destruction wq starts, removes netns from global list
      5. ftp helper is unloaded, which resets all helpers of the conntracks
      via for_each_net()
      
      but because netns is already gone from list the for_each_net() loop
      doesn't include it, therefore all of these conntracks are unaffected.
      
      6. helper module unload finishes
      7. netns wq invokes destructor for rmmod'ed helper
      
      CC: "Eric W. Biederman" <ebiederm@xmission.com>
      Reported-by: default avatarJoe Stringer <joe@ovn.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      7866cc57
    • Florian Westphal's avatar
      netfilter: move table iteration out of netns exit paths · 2c41f33c
      Florian Westphal authored
      We only need to iterate & remove in case of module removal;
      for netns destruction all conntracks will be removed anyway.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      2c41f33c
    • Xin Long's avatar
      netfilter: ipt_CLUSTERIP: do not hold dev · 202f59af
      Xin Long authored
      It's a terrible thing to hold dev in iptables target. When the dev is
      being removed, unregister_netdevice has to wait for the dev to become
      free. dmesg will keep logging the err:
      
        kernel:unregister_netdevice: waiting for veth0_in to become free. \
        Usage count = 1
      
      until iptables rules with this target are removed manually.
      
      The worse thing is when deleting a netns, a virtual nic will be deleted
      instead of reset to init_net in default_device_ops exit/exit_batch. As
      it is earlier than to flush the iptables rules in iptable_filter_net_ops
      exit, unregister_netdevice will block to wait for the nic to become free.
      
      As unregister_netdevice is actually waiting for iptables rules flushing
      while iptables rules have to be flushed after unregister_netdevice. This
      'dead lock' will cause unregister_netdevice to block there forever. As
      the netns is not available to operate at that moment, iptables rules can
      not even be flushed manually either.
      
      The reproducer can be:
      
        # ip netns add test
        # ip link add veth0_in type veth peer name veth0_out
        # ip link set veth0_in netns test
        # ip netns exec test ip link set lo up
        # ip netns exec test ip link set veth0_in up
        # ip netns exec test iptables -I INPUT -d 1.2.3.4 -i veth0_in -j \
          CLUSTERIP --new --clustermac 89:d4:47:eb:9a:fa --total-nodes 3 \
          --local-node 1 --hashmode sourceip-sourceport
        # ip netns del test
      
      This issue can be triggered by all virtual nics with ipt_CLUSTERIP.
      
      This patch is to fix it by not holding dev in ipt_CLUSTERIP, but saving
      the dev->ifindex instead of the dev.
      
      As Pablo Neira Ayuso's suggestion, it will refresh c->ifindex and dev's
      mc by registering a netdevice notifier, just as what xt_TEE does. So it
      removes the old codes updating dev's mc, and also no need to initialize
      c->ifindex with dev->ifindex.
      
      But as one config can be shared by more than one targets, and the netdev
      notifier is per config, not per target. It couldn't get e->ip.iniface
      in the notifier handler. So e->ip.iniface has to be saved into config.
      
      Note that for backwards compatibility, this patch doesn't remove the
      codes checking if the dev exists before creating a config.
      
      v1->v2:
        - As Pablo Neira Ayuso's suggestion, register a netdevice notifier to
          manage c->ifindex and dev's mc.
      Reported-by: default avatarJianlin Shi <jishi@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      202f59af
  2. 29 May, 2017 20 commits
  3. 23 May, 2017 10 commits
  4. 22 May, 2017 5 commits
    • Kees Cook's avatar
      efi-pstore: Fix write/erase id tracking · c10e8031
      Kees Cook authored
      Prior to the pstore interface refactoring, the "id" generated during
      a backend pstore_write() was only retained by the internal pstore
      inode tracking list. Additionally the "part" was ignored, so EFI
      would encode this in the id. This corrects the misunderstandings
      and correctly sets "id" during pstore_write(), and uses "part"
      directly during pstore_erase().
      Reported-by: default avatarMarta Lofstedt <marta.lofstedt@intel.com>
      Fixes: 76cc9580 ("pstore: Replace arguments for write() API")
      Fixes: a61072aa ("pstore: Replace arguments for erase() API")
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarMarta Lofstedt <marta.lofstedt@intel.com>
      c10e8031
    • David S. Miller's avatar
      Merge branch 'dsa-distribute-switch-events' · 1db3a610
      David S. Miller authored
      Vivien Didelot says:
      
      ====================
      net: dsa: distribute switch events
      
      DSA is by nature the support for a switch fabric, which can be composed
      of a single, or multiple interconnected Ethernet switch chips.
      
      The current DSA core behavior is to identify the slave port targeted by
      a request (e.g. adding a VLAN entry), and program the switch chip to
      which it belongs accordingly.
      
      This is problematic in a multi-chip environment, since all chips of a
      fabric must be aware of most configuration changes. Here are some
      concrete examples in a 3-chip environment:
      
               [CPU].................... (mdio)
          (eth0) |   :       :          :
                _|_____    _______    _______
               [__sw0__]--[__sw1__]--[__sw2__]
                |  |  |    |  |  |    |  |  |
                v  v  v    v  v  v    v  v  v
                p1 p2 p3   p4 p5 p6   p7 p8 p9
      
      If you add a VLAN entry on p7, sw2 gets programmed, but frames won't
      reach the CPU interface in a VLAN filtered setup. sw0 and sw1 also need
      to be programmed. The same problem comes with MAC addresses (FDB, MDB),
      or ageing time changes for instance.
      
      This patch series uses the notification chain introduced for bridging,
      to notify not only bridge, but switchdev attributes and objects events
      to all switch chips of the fabric.
      
      An ugly debug message printing the ignored event and switch info in the
      code handling the switch VLAN events would give us:
      
          # bridge vlan add dev p7 vid 42
          sw0: ignoring DSA_NOTIFIER_VLAN_ADD for sw2 (prepare phase)
          sw1: ignoring DSA_NOTIFIER_VLAN_ADD for sw2 (prepare phase)
          sw0: ignoring DSA_NOTIFIER_VLAN_ADD for sw2 (commit phase)
          sw1: ignoring DSA_NOTIFIER_VLAN_ADD for sw2 (commit phase)
      
      To achieve that, patches 1-8 change the scope of the bridge and
      switchdev callbacks from the DSA slave device to the generic DSA port,
      so that the port-wide API can be used later for switch ports not exposed
      to userspace, such as CPU and DSA links.
      
      Patches 9-15 move the DSA port specific functions in a new port.c file.
      
      Patches 16-20 introduce new events to notify the fabric about switchdev
      attributes and objects manipulation.
      
      This patch series only adds the plumbing to support a distributed
      configuration, but for the moment, each switch chip ignores events from
      other chips of the fabric, to keep the current behavior.
      
      The next patch series will add support for cross-chip configuration of
      bridge ageing time, VLAN and MAC address databases operations, etc.
      ====================
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1db3a610
    • Vivien Didelot's avatar
      net: dsa: add VLAN notifier · d0c627b8
      Vivien Didelot authored
      Add two new DSA_NOTIFIER_VLAN_ADD and DSA_NOTIFIER_VLAN_DEL events to
      notify not only a single switch, but all switches of a the fabric when
      an VLAN entry is added or removed.
      
      For the moment, keep the current behavior and ignore other switches.
      Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d0c627b8
    • Vivien Didelot's avatar
      net: dsa: add MDB notifier · 8ae5bcdc
      Vivien Didelot authored
      Add two new DSA_NOTIFIER_MDB_ADD and DSA_NOTIFIER_MDB_DEL events to
      notify not only a single switch, but all switches of a the fabric when
      an MDB entry is added or removed.
      
      For the moment, keep the current behavior and ignore other switches.
      Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8ae5bcdc
    • Vivien Didelot's avatar
      net: dsa: add FDB notifier · 685fb6a4
      Vivien Didelot authored
      Add two new DSA_NOTIFIER_FDB_ADD and DSA_NOTIFIER_FDB_DEL events to
      notify not only a single switch, but all switches of a the fabric when
      an FDB entry is added or removed.
      
      For the moment, keep the current behavior and ignore other switches.
      Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      685fb6a4