1. 26 10月, 2014 1 次提交
  2. 26 8月, 2014 1 次提交
    • W
      xen-netback: move netif_napi_add before binding interrupt · e24f8191
      Wei Liu 提交于
      Interrupt is enabled when bind_interdomain_evtchn_to_irqhandler returns.
      If there's interrupt pending interrupt handler is invoked.
      
      NAPI needs to be initialised before binding interrupt otherwise the
      interrupt handler will try to scheduling a NAPI instance that is not
      initialised yet, resulting in kernel OOPS.
      
      This fixes a regression introduced in ea2c5e13 ("xen-netback: move NAPI
      add/remove calls").
      
      Ideally function calls to create kthreads should also be moved before
      binding but I intent to fix this regression with minimal changes and
      refactor the code with another patch.
      Reported-by: NThomas Leonard <talex5@gmail.com>
      Signed-off-by: NWei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e24f8191
  3. 14 8月, 2014 3 次提交
  4. 12 8月, 2014 1 次提交
  5. 06 8月, 2014 2 次提交
    • Z
      xen-netback: Turn off the carrier if the guest is not able to receive · f34a4cf9
      Zoltan Kiss 提交于
      Currently when the guest is not able to receive more packets, qdisc layer starts
      a timer, and when it goes off, qdisc is started again to deliver a packet again.
      This is a very slow way to drain the queues, consumes unnecessary resources and
      slows down other guests shutdown.
      This patch change the behaviour by turning the carrier off when that timer
      fires, so all the packets are freed up which were stucked waiting for that vif.
      Instead of the rx_queue_purge bool it uses the VIF_STATUS_RX_PURGE_EVENT bit to
      signal the thread that either the timeout happened or an RX interrupt arrived,
      so the thread can check what it should do. It also disables NAPI, so the guest
      can't transmit, but leaves the interrupts on, so it can resurrect.
      Only the queues which brought down the interface can enable it again, the bit
      QUEUE_STATUS_RX_STALLED makes sure of that.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: xen-devel@lists.xenproject.org
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f34a4cf9
    • Z
      xen-netback: Using a new state bit instead of carrier · 3d1af1df
      Zoltan Kiss 提交于
      This patch introduces a new state bit VIF_STATUS_CONNECTED to track whether the
      vif is in a connected state. Using carrier will not work with the next patch
      in this series, which aims to turn the carrier temporarily off if the guest
      doesn't seem to be able to receive packets.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: xen-devel@lists.xenproject.org
      
      v2:
      - rename the bitshift type to "enum state_bit_shift" here, not in the next patch
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3d1af1df
  6. 16 7月, 2014 1 次提交
    • T
      net: set name_assign_type in alloc_netdev() · c835a677
      Tom Gundersen 提交于
      Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
      all users to pass NET_NAME_UNKNOWN.
      
      Coccinelle patch:
      
      @@
      expression sizeof_priv, name, setup, txqs, rxqs, count;
      @@
      
      (
      -alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
      +alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
      |
      -alloc_netdev_mq(sizeof_priv, name, setup, count)
      +alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
      |
      -alloc_netdev(sizeof_priv, name, setup)
      +alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
      )
      
      v9: move comments here from the wrong commit
      Signed-off-by: NTom Gundersen <teg@jklm.no>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c835a677
  7. 09 7月, 2014 1 次提交
    • Z
      xen-netback: Adding debugfs "io_ring_qX" files · f51de243
      Zoltan Kiss 提交于
      This patch adds debugfs capabilities to netback. There used to be a similar
      patch floating around for classic kernel, but it used procfs. It is based on a
      very similar blkback patch.
      It creates xen-netback/[vifname]/io_ring_q[queueno] files, reading them output
      various ring variables etc. Writing "kick" into it imitates an interrupt
      happened, it can be useful to check whether the ring is just stalled due to a
      missed interrupt.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: xen-devel@lists.xenproject.org
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f51de243
  8. 26 6月, 2014 1 次提交
    • W
      xen-netback: bookkeep number of active queues in our own module · f7b50c4e
      Wei Liu 提交于
      The original code uses netdev->real_num_tx_queues to bookkeep number of
      queues and invokes netif_set_real_num_tx_queues to set the number of
      queues. However, netif_set_real_num_tx_queues doesn't allow
      real_num_tx_queues to be smaller than 1, which means setting the number
      to 0 will not work and real_num_tx_queues is untouched.
      
      This is bogus when xenvif_free is invoked before any number of queues is
      allocated. That function needs to iterate through all queues to free
      resources. Using the wrong number of queues results in NULL pointer
      dereference.
      
      So we bookkeep the number of queues in xen-netback to solve this
      problem. This fixes a regression introduced by multiqueue patchset in
      3.16-rc1.
      
      There's another bug in original code that the real number of RX queues
      is never set. In current Xen multiqueue design, the number of TX queues
      and RX queues are in fact the same. We need to set the numbers of TX and
      RX queues to the same value.
      
      Also remove xenvif_select_queue and leave queue selection to core
      driver, as suggested by David Miller.
      Reported-by: NBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: NWei Liu <wei.liu2@citrix.com>
      CC: Ian Campbell <ian.campbell@citrix.com>
      CC: Paul Durrant <paul.durrant@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f7b50c4e
  9. 12 6月, 2014 1 次提交
    • A
      net: xen-netback: include linux/vmalloc.h again · e7b599d7
      Arnd Bergmann 提交于
      commit e9ce7cb6 ("xen-netback: Factor queue-specific data into
      queue struct") added a use of vzalloc/vfree to interface.c, but
      removed the #include <linux/vmalloc.h> statement at the same time,
      which causes this build error:
      
      drivers/net/xen-netback/interface.c: In function 'xenvif_free':
      drivers/net/xen-netback/interface.c:754:2: error: implicit declaration of function 'vfree' [-Werror=implicit-function-declaration]
        vfree(vif->queues);
        ^
      cc1: some warnings being treated as errors
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Wei Liu <wei.liu2@citrix.com>
      Cc: Andrew J. Bennieston <andrew.bennieston@citrix.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e7b599d7
  10. 05 6月, 2014 3 次提交
  11. 17 5月, 2014 1 次提交
  12. 14 5月, 2014 1 次提交
  13. 02 4月, 2014 1 次提交
    • W
      xen-netback: disable rogue vif in kthread context · e9d8b2c2
      Wei Liu 提交于
      When netback discovers frontend is sending malformed packet it will
      disables the interface which serves that frontend.
      
      However disabling a network interface involving taking a mutex which
      cannot be done in softirq context, so we need to defer this process to
      kthread context.
      
      This patch does the following:
      1. introduce a flag to indicate the interface is disabled.
      2. check that flag in TX path, don't do any work if it's true.
      3. check that flag in RX path, turn off that interface if it's true.
      
      The reason to disable it in RX path is because RX uses kthread. After
      this change the behavior of netback is still consistent -- it won't do
      any TX work for a rogue frontend, and the interface will be eventually
      turned off.
      
      Also change a "continue" to "break" after xenvif_fatal_tx_err, as it
      doesn't make sense to continue processing packets if frontend is rogue.
      
      This is a fix for XSA-90.
      Reported-by: NTörök Edwin <edwin@etorok.net>
      Signed-off-by: NWei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Reviewed-by: NDavid Vrabel <david.vrabel@citrix.com>
      Acked-by: NIan Campbell <ian.campbell@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e9d8b2c2
  14. 27 3月, 2014 2 次提交
    • Z
      xen-netback: Non-functional follow-up patch for grant mapping series · 0e59a4a5
      Zoltan Kiss 提交于
      Ian made some late comments about the grant mapping series, I incorporated the
      non-functional outcomes into this patch:
      
      - typo fixes in a comment of xenvif_free(), and add another one there as well
      - typo fix for comment of rx_drain_timeout_msecs
      - remove stale comment before calling xenvif_grant_handle_reset()
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0e59a4a5
    • Z
      xen-netback: Stop using xenvif_tx_pending_slots_available · 869b9b19
      Zoltan Kiss 提交于
      Since the early days TX stops if there isn't enough free pending slots to
      consume a maximum sized (slot-wise) packet. Probably the reason for that is to
      avoid the case when we don't have enough free pending slot in the ring to finish
      the packet. But if we make sure that the pending ring has the same size as the
      shared ring, that shouldn't really happen. The frontend can only post packets
      which fit the to the free space of the shared ring. If it doesn't, the frontend
      has to stop, as it can only increase the req_prod when the whole packet fits
      onto the ring.
      This patch avoid using this checking, makes sure the 2 ring has the same size,
      and remove a checking from the callback. As now we don't stop the NAPI instance
      on this condition, we don't have to wake it up if we free pending slots up.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      869b9b19
  15. 26 3月, 2014 1 次提交
  16. 13 3月, 2014 1 次提交
  17. 08 3月, 2014 6 次提交
    • Z
      xen-netback: Aggregate TX unmap operations · e9275f5e
      Zoltan Kiss 提交于
      Unmapping causes TLB flushing, therefore we should make it in the largest
      possible batches. However we shouldn't starve the guest for too long. So if
      the guest has space for at least two big packets and we don't have at least a
      quarter ring to unmap, delay it for at most 1 milisec.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e9275f5e
    • Z
      xen-netback: Timeout packets in RX path · 09350788
      Zoltan Kiss 提交于
      A malicious or buggy guest can leave its queue filled indefinitely, in which
      case qdisc start to queue packets for that VIF. If those packets came from an
      another guest, it can block its slots and prevent shutdown. To avoid that, we
      make sure the queue is drained in every 10 seconds.
      The QDisc queue in worst case takes 3 round to flush usually.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09350788
    • Z
      xen-netback: Handle guests with too many frags · e3377f36
      Zoltan Kiss 提交于
      Xen network protocol had implicit dependency on MAX_SKB_FRAGS. Netback has to
      handle guests sending up to XEN_NETBK_LEGACY_SLOTS_MAX slots. To achieve that:
      - create a new skb
      - map the leftover slots to its frags (no linear buffer here!)
      - chain it to the previous through skb_shinfo(skb)->frag_list
      - map them
      - copy and coalesce the frags into a brand new one and send it to the stack
      - unmap the 2 old skb's pages
      
      It's also introduces new stat counters, which help determine how often the guest
      sends a packet with more than MAX_SKB_FRAGS frags.
      
      NOTE: if bisect brought you here, you should apply the series up until
      "xen-netback: Timeout packets in RX path", otherwise malicious guests can block
      other guests by not releasing their sent packets.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e3377f36
    • Z
      xen-netback: Add stat counters for zerocopy · 1bb332af
      Zoltan Kiss 提交于
      These counters help determine how often the buffers had to be copied. Also
      they help find out if packets are leaked, as if "sent != success + fail",
      there are probably packets never freed up properly.
      
      NOTE: if bisect brought you here, you should apply the series up until
      "xen-netback: Timeout packets in RX path", otherwise Windows guests can't work
      properly and malicious guests can block other guests by not releasing their sent
      packets.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1bb332af
    • Z
      xen-netback: Introduce TX grant mapping · f53c3fe8
      Zoltan Kiss 提交于
      This patch introduces grant mapping on netback TX path. It replaces grant copy
      operations, ditching grant copy coalescing along the way. Another solution for
      copy coalescing is introduced in "xen-netback: Handle guests with too many
      frags", older guests and Windows can broke before that patch applies.
      There is a callback (xenvif_zerocopy_callback) from core stack to release the
      slots back to the guests when kfree_skb or skb_orphan_frags called. It feeds a
      separate dealloc thread, as scheduling NAPI instance from there is inefficient,
      therefore we can't do dealloc from the instance.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f53c3fe8
    • Z
      xen-netback: Minor refactoring of netback code · 121fa4b7
      Zoltan Kiss 提交于
      This patch contains a few bits of refactoring before introducing the grant
      mapping changes:
      - introducing xenvif_tx_pending_slots_available(), as this is used several
        times, and will be used more often
      - rename the thread to vifX.Y-guest-rx, to signify it does RX work from the
        guest point of view
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      121fa4b7
  18. 06 2月, 2014 1 次提交
    • Z
      xen-netback: Fix Rx stall due to race condition · 9ab9831b
      Zoltan Kiss 提交于
      The recent patch to fix receive side flow control
      (11b57f90: xen-netback: stop vif thread
      spinning if frontend is unresponsive) solved the spinning thread problem,
      however caused an another one. The receive side can stall, if:
      - [THREAD] xenvif_rx_action sets rx_queue_stopped to true
      - [INTERRUPT] interrupt happens, and sets rx_event to true
      - [THREAD] then xenvif_kthread sets rx_event to false
      - [THREAD] rx_work_todo doesn't return true anymore
      
      Also, if interrupt sent but there is still no room in the ring, it take quite a
      long time until xenvif_rx_action realize it. This patch ditch that two variable,
      and rework rx_work_todo. If the thread finds it can't fit more skb's into the
      ring, it saves the last slot estimation into rx_last_skb_slots, otherwise it's
      kept as 0. Then rx_work_todo will check if:
      - there is something to send to the ring (like before)
      - there is space for the topmost packet in the queue
      
      I think that's more natural and optimal thing to test than two bool which are
      set somewhere else.
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Reviewed-by: NPaul Durrant <paul.durrant@citrix.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9ab9831b
  19. 06 1月, 2014 1 次提交
  20. 30 12月, 2013 1 次提交
    • P
      xen-netback: fix guest-receive-side array sizes · ac3d5ac2
      Paul Durrant 提交于
      The sizes chosen for the metadata and grant_copy_op arrays on the guest
      receive size are wrong;
      
      - The meta array is needlessly twice the ring size, when we only ever
        consume a single array element per RX ring slot
      - The grant_copy_op array is way too small. It's sized based on a bogus
        assumption: that at most two copy ops will be used per ring slot. This
        may have been true at some point in the past but it's clear from looking
        at start_new_rx_buffer() that a new ring slot is only consumed if a frag
        would overflow the current slot (plus some other conditions) so the actual
        limit is MAX_SKB_FRAGS grant_copy_ops per ring slot.
      
      This patch fixes those two sizing issues and, because grant_copy_ops grows
      so much, it pulls it out into a separate chunk of vmalloc()ed memory.
      Signed-off-by: NPaul Durrant <paul.durrant@citrix.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ac3d5ac2
  21. 10 12月, 2013 1 次提交
    • P
      xen-netback: improve guest-receive-side flow control · ca2f09f2
      Paul Durrant 提交于
      The way that flow control works without this patch is that, in start_xmit()
      the code uses xenvif_count_skb_slots() to predict how many slots
      xenvif_gop_skb() will consume and then adds this to a 'req_cons_peek'
      counter which it then uses to determine if the shared ring has that amount
      of space available by checking whether 'req_prod' has passed that value.
      If the ring doesn't have space the tx queue is stopped.
      xenvif_gop_skb() will then consume slots and update 'req_cons' and issue
      responses, updating 'rsp_prod' as it goes. The frontend will consume those
      responses and post new requests, by updating req_prod. So, req_prod chases
      req_cons which chases rsp_prod, and can never exceed that value. Thus if
      xenvif_count_skb_slots() ever returns a number of slots greater than
      xenvif_gop_skb() uses, req_cons_peek will get to a value that req_prod cannot
      possibly achieve (since it's limited by the 'real' req_cons) and, if this
      happens enough times, req_cons_peek gets more than a ring size ahead of
      req_cons and the tx queue then remains stopped forever waiting for an
      unachievable amount of space to become available in the ring.
      
      Having two routines trying to calculate the same value is always going to be
      fragile, so this patch does away with that. All we essentially need to do is
      make sure that we have 'enough stuff' on our internal queue without letting
      it build up uncontrollably. So start_xmit() makes a cheap optimistic check
      of how much space is needed for an skb and only turns the queue off if that
      is unachievable. net_rx_action() is the place where we could do with an
      accurate predicition but, since that has proven tricky to calculate, a cheap
      worse-case (but not too bad) estimate is all we really need since the only
      thing we *must* prevent is xenvif_gop_skb() consuming more slots than are
      available.
      
      Without this patch I can trivially stall netback permanently by just doing
      a large guest to guest file copy between two Windows Server 2008R2 VMs on a
      single host.
      
      Patch tested with frontends in:
      - Windows Server 2008R2
      - CentOS 6.0
      - Debian Squeeze
      - Debian Wheezy
      - SLES11
      Signed-off-by: NPaul Durrant <paul.durrant@citrix.com>
      Cc: Wei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: Annie Li <annie.li@oracle.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ca2f09f2
  22. 04 12月, 2013 1 次提交
    • P
      xen-netback: clear vif->task on disconnect · 67fa3660
      Paul Durrant 提交于
      xenvif_start_xmit() relies on checking vif->task for NULL to determine
      whether the vif is ready to accept packets. The task thread is stopped in
      xenvif_disconnect() but task is not set to NULL. Thus, on a re-connect the
      check will give a false positive.
      
      Also since commit ea732dff (Handle backend
      state transitions in a more robust way) it should not be possible for
      xenvif_connect() to be called if the vif is already connected so change the
      check of vif->tx_irq to a BUG_ON() and also add a BUG_ON(vif->task).
      Signed-off-by: NPaul Durrant <paul.durrant@citrix.com>
      Cc: Wei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      67fa3660
  23. 22 11月, 2013 1 次提交
  24. 29 10月, 2013 1 次提交
  25. 18 10月, 2013 3 次提交
  26. 20 9月, 2013 1 次提交
    • P
      xen-netback: Don't destroy the netdev until the vif is shut down · 279f438e
      Paul Durrant 提交于
      Without this patch, if a frontend cycles through states Closing
      and Closed (which Windows frontends need to do) then the netdev
      will be destroyed and requires re-invocation of hotplug scripts
      to restore state before the frontend can move to Connected. Thus
      when udev is not in use the backend gets stuck in InitWait.
      
      With this patch, the netdev is left alone whilst the backend is
      still online and is only de-registered and freed just prior to
      destroying the vif (which is also nicely symmetrical with the
      netdev allocation and registration being done during probe) so
      no re-invocation of hotplug scripts is required.
      Signed-off-by: NPaul Durrant <paul.durrant@citrix.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: Wei Liu <wei.liu2@citrix.com>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      279f438e
  27. 13 9月, 2013 1 次提交