1. 20 11月, 2018 2 次提交
    • X
      Revert "sctp: remove sctp_transport_pmtu_check" · 69fec325
      Xin Long 提交于
      This reverts commit 22d7be26.
      
      The dst's mtu in transport can be updated by a non sctp place like
      in xfrm where the MTU information didn't get synced between asoc,
      transport and dst, so it is still needed to do the pmtu check
      in sctp_packet_config.
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      69fec325
    • X
      sctp: count sk_wmem_alloc by skb truesize in sctp_packet_transmit · 02968ccf
      Xin Long 提交于
      Now sctp increases sk_wmem_alloc by 1 when doing set_owner_w for the
      skb allocked in sctp_packet_transmit and decreases by 1 when freeing
      this skb.
      
      But when this skb goes through networking stack, some subcomponents
      might change skb->truesize and add the same amount on sk_wmem_alloc.
      However sctp doesn't know the amount to decrease by, it would cause
      a leak on sk->sk_wmem_alloc and the sock can never be freed.
      
      Xiumei found this issue when it hit esp_output_head() by using sctp
      over ipsec, where skb->truesize is added and so is sk->sk_wmem_alloc.
      
      Since sctp has used sk_wmem_queued to count for writable space since
      Commit cd305c74 ("sctp: use sk_wmem_queued to check for writable
      space"), it's ok to fix it by counting sk_wmem_alloc by skb truesize
      in sctp_packet_transmit.
      
      Fixes: cac2661c ("esp4: Avoid skb_cow_data whenever possible")
      Reported-by: NXiumei Mu <xmu@redhat.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      02968ccf
  2. 16 10月, 2018 1 次提交
    • X
      sctp: use the pmtu from the icmp packet to update transport pathmtu · d805397c
      Xin Long 提交于
      Other than asoc pmtu sync from all transports, sctp_assoc_sync_pmtu
      is also processing transport pmtu_pending by icmp packets. But it's
      meaningless to use sctp_dst_mtu(t->dst) as new pmtu for a transport.
      
      The right pmtu value should come from the icmp packet, and it would
      be saved into transport->mtu_info in this patch and used later when
      the pmtu sync happens in sctp_sendmsg_to_asoc or sctp_packet_config.
      
      Besides, without this patch, as pmtu can only be updated correctly
      when receiving a icmp packet and no place is holding sock lock, it
      will take long time if the sock is busy with sending packets.
      
      Note that it doesn't process transport->mtu_info in .release_cb(),
      as there is no enough information for pmtu update, like for which
      asoc or transport. It is not worth traversing all asocs to check
      pmtu_pending. So unlike tcp, sctp does this in tx path, for which
      mtu_info needs to be atomic_t.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d805397c
  3. 15 6月, 2018 1 次提交
  4. 28 4月, 2018 2 次提交
  5. 15 3月, 2018 1 次提交
  6. 27 2月, 2018 1 次提交
  7. 12 12月, 2017 1 次提交
    • X
      sctp: implement assign_number for sctp_stream_interleave · 668c9beb
      Xin Long 提交于
      assign_number is added as a member of sctp_stream_interleave, used
      to assign ssn for data or mid (message id) for idata, called in
      sctp_packet_append_data. sctp_chunk_assign_ssn is left as it is,
      and sctp_chunk_assign_mid is added for sctp_stream_interleave_1.
      
      This procedure is described in section 2.2.2 of RFC8260.
      
      All sizeof(struct sctp_data_chunk) in tx path is replaced with
      sctp_datachk_len, to make it right for idata as well. And also
      adjust sctp_chunk_is_data for SCTP_CID_I_DATA.
      
      After this patch, idata can be built and sent in tx path.
      
      Note that if sp strm_interleave is set, it has to wait_connect in
      sctp_sendmsg, as asoc intl_enable need to be known after 4 shake-
      hands, to decide if it should use data or idata later. data and
      idata can't be mixed to send in one asoc.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      668c9beb
  8. 07 8月, 2017 1 次提交
  9. 02 7月, 2017 1 次提交
  10. 01 7月, 2017 1 次提交
  11. 16 6月, 2017 3 次提交
    • J
      networking: make skb_push & __skb_push return void pointers · d58ff351
      Johannes Berg 提交于
      It seems like a historic accident that these return unsigned char *,
      and in many places that means casts are required, more often than not.
      
      Make these functions return void * and remove all the casts across
      the tree, adding a (u8 *) cast only where the unsigned char pointer
      was used directly, all done with the following spatch:
      
          @@
          expression SKB, LEN;
          typedef u8;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          @@
          - *(fn(SKB, LEN))
          + *(u8 *)fn(SKB, LEN)
      
          @@
          expression E, SKB, LEN;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          type T;
          @@
          - E = ((T *)(fn(SKB, LEN)))
          + E = fn(SKB, LEN)
      
          @@
          expression SKB, LEN;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          @@
          - fn(SKB, LEN)[0]
          + *(u8 *)fn(SKB, LEN)
      
      Note that the last part there converts from push(...)[0] to the
      more idiomatic *(u8 *)push(...).
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d58ff351
    • J
      networking: introduce and use skb_put_data() · 59ae1d12
      Johannes Berg 提交于
      A common pattern with skb_put() is to just want to memcpy()
      some data into the new space, introduce skb_put_data() for
      this.
      
      An spatch similar to the one for skb_put_zero() converts many
      of the places using it:
      
          @@
          identifier p, p2;
          expression len, skb, data;
          type t, t2;
          @@
          (
          -p = skb_put(skb, len);
          +p = skb_put_data(skb, data, len);
          |
          -p = (t)skb_put(skb, len);
          +p = skb_put_data(skb, data, len);
          )
          (
          p2 = (t2)p;
          -memcpy(p2, data, len);
          |
          -memcpy(p, data, len);
          )
      
          @@
          type t, t2;
          identifier p, p2;
          expression skb, data;
          @@
          t *p;
          ...
          (
          -p = skb_put(skb, sizeof(t));
          +p = skb_put_data(skb, data, sizeof(t));
          |
          -p = (t *)skb_put(skb, sizeof(t));
          +p = skb_put_data(skb, data, sizeof(t));
          )
          (
          p2 = (t2)p;
          -memcpy(p2, data, sizeof(*p));
          |
          -memcpy(p, data, sizeof(*p));
          )
      
          @@
          expression skb, len, data;
          @@
          -memcpy(skb_put(skb, len), data, len);
          +skb_put_data(skb, data, len);
      
      (again, manually post-processed to retain some comments)
      Reviewed-by: NStephen Hemminger <stephen@networkplumber.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59ae1d12
    • J
      networking: convert many more places to skb_put_zero() · b080db58
      Johannes Berg 提交于
      There were many places that my previous spatch didn't find,
      as pointed out by yuan linyu in various patches.
      
      The following spatch found many more and also removes the
      now unnecessary casts:
      
          @@
          identifier p, p2;
          expression len;
          expression skb;
          type t, t2;
          @@
          (
          -p = skb_put(skb, len);
          +p = skb_put_zero(skb, len);
          |
          -p = (t)skb_put(skb, len);
          +p = skb_put_zero(skb, len);
          )
          ... when != p
          (
          p2 = (t2)p;
          -memset(p2, 0, len);
          |
          -memset(p, 0, len);
          )
      
          @@
          type t, t2;
          identifier p, p2;
          expression skb;
          @@
          t *p;
          ...
          (
          -p = skb_put(skb, sizeof(t));
          +p = skb_put_zero(skb, sizeof(t));
          |
          -p = (t *)skb_put(skb, sizeof(t));
          +p = skb_put_zero(skb, sizeof(t));
          )
          ... when != p
          (
          p2 = (t2)p;
          -memset(p2, 0, sizeof(*p));
          |
          -memset(p, 0, sizeof(*p));
          )
      
          @@
          expression skb, len;
          @@
          -memset(skb_put(skb, len), 0, len);
          +skb_put_zero(skb, len);
      
      Apply it to the tree (with one manual fixup to keep the
      comment in vxlan.c, which spatch removed.)
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b080db58
  12. 20 5月, 2017 1 次提交
  13. 05 4月, 2017 1 次提交
  14. 04 4月, 2017 1 次提交
    • X
      sctp: check for dst and pathmtu update in sctp_packet_config · df2729c3
      Xin Long 提交于
      This patch is to move sctp_transport_dst_check into sctp_packet_config
      from sctp_packet_transmit and add pathmtu check in sctp_packet_config.
      
      With this fix, sctp can update dst or pathmtu before appending chunks,
      which can void dropping packets in sctp_packet_transmit when dst is
      obsolete or dst's mtu is changed.
      
      This patch is also to improve some other codes in sctp_packet_config.
      It updates packet max_size with gso_max_size, checks for dst and
      pathmtu, and appends ecne chunk only when packet is empty and asoc
      is not NULL.
      
      It makes sctp flush work better, as we only need to set up them once
      for one flush schedule. It's also safe, since asoc is NULL only when
      the packet is created by sctp_ootb_pkt_new in which it just gets the
      new dst, no need to do more things for it other than set packet with
      transport's pathmtu.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      df2729c3
  15. 29 3月, 2017 1 次提交
    • X
      sctp: change to save MSG_MORE flag into assoc · f9ba3501
      Xin Long 提交于
      David Laight noticed the support for MSG_MORE with datamsg->force_delay
      didn't really work as we expected, as the first msg with MSG_MORE set
      would always block the following chunks' dequeuing.
      
      This Patch is to rewrite it by saving the MSG_MORE flag into assoc as
      David Laight suggested.
      
      asoc->force_delay is used to save MSG_MORE flag before a msg is sent.
      All chunks in queue would not be sent out if asoc->force_delay is set
      by the msg with MSG_MORE flag, until a new msg without MSG_MORE flag
      clears asoc->force_delay.
      
      Note that this change would not affect the flush is generated by other
      triggers, like asoc->state != ESTABLISHED, queue size > pmtu etc.
      
      v1->v2:
        Not clear asoc->force_delay after sending the msg with MSG_MORE flag.
      
      Fixes: 4ea0c32f ("sctp: add support for MSG_MORE")
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NDavid Laight <david.laight@aculab.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f9ba3501
  16. 22 3月, 2017 1 次提交
  17. 28 2月, 2017 1 次提交
  18. 20 2月, 2017 1 次提交
    • X
      sctp: add support for MSG_MORE · 4ea0c32f
      Xin Long 提交于
      This patch is to add support for MSG_MORE on sctp.
      
      It adds force_delay in sctp_datamsg to save MSG_MORE, and sets it after
      creating datamsg according to the send flag. sctp_packet_can_append_data
      then uses it to decide if the chunks of this msg will be sent at once or
      delay it.
      
      Note that unlike [1], this patch saves MSG_MORE in datamsg, instead of
      in assoc. As sctp enqueues the chunks first, then dequeue them one by
      one. If it's saved in assoc,the current msg's send flag (MSG_MORE) may
      affect other chunks' bundling.
      
      Since last patch, sctp flush out queue once assoc state falls into
      SHUTDOWN_PENDING, the close block problem mentioned in [1] has been
      solved as well.
      
      [1] https://patchwork.ozlabs.org/patch/372404/Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4ea0c32f
  19. 08 2月, 2017 1 次提交
  20. 29 12月, 2016 1 次提交
  21. 03 11月, 2016 1 次提交
  22. 27 10月, 2016 1 次提交
    • X
      sctp: fix the panic caused by route update · ecc515d7
      Xin Long 提交于
      Commit 7303a147 ("sctp: identify chunks that need to be fragmented
      at IP level") made the chunk be fragmented at IP level in the next round
      if it's size exceed PMTU.
      
      But there still is another case, PMTU can be updated if transport's dst
      expires and transport's pmtu_pending is set in sctp_packet_transmit. If
      the new PMTU is less than the chunk, the same issue with that commit can
      be triggered.
      
      So we should drop this packet and let it retransmit in another round
      where it would be fragmented at IP level.
      
      This patch is to fix it by checking the chunk size after PMTU may be
      updated and dropping this packet if it's size exceed PMTU.
      
      Fixes: 90017acc ("sctp: Add GSO support")
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NNeil Horman <nhorman@txudriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ecc515d7
  23. 13 10月, 2016 2 次提交
  24. 22 9月, 2016 1 次提交
  25. 19 9月, 2016 2 次提交
    • X
      sctp: not return ENOMEM err back in sctp_packet_transmit · 41001faf
      Xin Long 提交于
      As David and Marcelo's suggestion, ENOMEM err shouldn't return back to
      user in transmit path. Instead, sctp's retransmit would take care of
      the chunks that fail to send because of ENOMEM.
      
      This patch is only to do some release job when alloc_skb fails, not to
      return ENOMEM back any more.
      
      Besides, it also cleans up sctp_packet_transmit's err path, and fixes
      some issues in err path:
      
       - It didn't free the head skb in nomem: path.
       - No need to check nskb in no_route: path.
       - It should goto err: path if alloc_skb fails for head.
       - Not all the NOMEMs should free nskb.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      41001faf
    • X
      sctp: save transmit error to sk_err in sctp_outq_flush · 64519440
      Xin Long 提交于
      Every time when sctp calls sctp_outq_flush, it sends out the chunks of
      control queue, retransmit queue and data queue. Even if some trunks are
      failed to transmit, it still has to flush all the transports, as it's
      the only chance to clean that transmit_list.
      
      So the latest transmit error here should be returned back. This transmit
      error is an internal error of sctp stack.
      
      I checked all the places where it uses the transmit error (the return
      value of sctp_outq_flush), most of them are actually just save it to
      sk_err.
      
      Except for sctp_assoc/endpoint_bh_rcv, they will drop the chunk if
      it's failed to send a REPLY, which is actually incorrect, as we can't
      be sure the error that sctp_outq_flush returns is from sending that
      REPLY.
      
      So it's meaningless for sctp_outq_flush to return error back.
      
      This patch is to save transmit error to sk_err in sctp_outq_flush, the
      new error can update the old value. Eventually, sctp_wait_for_* would
      check for it.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      64519440
  26. 10 9月, 2016 1 次提交
    • M
      sctp: identify chunks that need to be fragmented at IP level · 7303a147
      Marcelo Ricardo Leitner 提交于
      Previously, without GSO, it was easy to identify it: if the chunk didn't
      fit and there was no data chunk in the packet yet, we could fragment at
      IP level. So if there was an auth chunk and we were bundling a big data
      chunk, it would fragment regardless of the size of the auth chunk. This
      also works for the context of PMTU reductions.
      
      But with GSO, we cannot distinguish such PMTU events anymore, as the
      packet is allowed to exceed PMTU.
      
      So we need another check: to ensure that the chunk that we are adding,
      actually fits the current PMTU. If it doesn't, trigger a flush and let
      it be fragmented at IP level in the next round.
      Signed-off-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7303a147
  27. 31 7月, 2016 1 次提交
  28. 12 7月, 2016 1 次提交
    • X
      sctp: implement prsctp TTL policy · a6c2f792
      Xin Long 提交于
      prsctp TTL policy is a policy to abandon chunks when they expire
      at the specific time in local stack. It's similar with expires_at
      in struct sctp_datamsg.
      
      This patch uses sinfo->sinfo_timetolive to set the specific time for
      TTL policy. sinfo->sinfo_timetolive is also used for msg->expires_at.
      So if prsctp_enable or TTL policy is not enabled, msg->expires_at
      still works as before.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a6c2f792
  29. 09 7月, 2016 1 次提交
    • M
      sctp: fix panic when sending auth chunks · f1533cce
      Marcelo Ricardo Leitner 提交于
      When we introduced GSO support, if using auth the auth chunk was being
      left queued on the packet even after the final segment was generated.
      Later on sctp_transmit_packet it calls sctp_packet_reset, which zeroed
      the packet len while not accounting for this left-over. This caused more
      space to be used the next packet due to the chunk still being queued,
      but space which wasn't allocated as its size wasn't accounted.
      
      The fix is to only queue it back when we know that we are going to
      generate another segment.
      
      Fixes: 90017acc ("sctp: Add GSO support")
      Signed-off-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f1533cce
  30. 04 6月, 2016 3 次提交
  31. 06 4月, 2016 1 次提交
  32. 31 3月, 2016 1 次提交