24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

31 Dec, 2019

1 commit

  • sctp_outq_sack is the main function handles SACK, it is called very
    frequently. As the commit "move trace_sctp_probe_path into sctp_outq_sack"
    added below code to this function, sctp tracepoint is disabled most of time,
    but the loop of transport list will be always called even though the
    tracepoint is disabled, this is unnecessary.

    + /* SCTP path tracepoint for congestion control debugging. */
    + list_for_each_entry(transport, transport_list, transports) {
    + trace_sctp_probe_path(transport, asoc);
    + }

    This patch is to add tracepoint enabled check at outside of the loop of
    transport list, and avoid traversing the loop when trace is disabled,
    it is a small optimization.

    Signed-off-by: Kevin Kou
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Kevin Kou
     

27 Dec, 2019

1 commit

  • The original patch bringed in the "SCTP ACK tracking trace event"
    feature was committed at Dec.20, 2017, it replaced jprobe usage
    with trace events, and bringed in two trace events, one is
    TRACE_EVENT(sctp_probe), another one is TRACE_EVENT(sctp_probe_path).
    The original patch intended to trigger the trace_sctp_probe_path in
    TRACE_EVENT(sctp_probe) as below code,

    +TRACE_EVENT(sctp_probe,
    +
    + TP_PROTO(const struct sctp_endpoint *ep,
    + const struct sctp_association *asoc,
    + struct sctp_chunk *chunk),
    +
    + TP_ARGS(ep, asoc, chunk),
    +
    + TP_STRUCT__entry(
    + __field(__u64, asoc)
    + __field(__u32, mark)
    + __field(__u16, bind_port)
    + __field(__u16, peer_port)
    + __field(__u32, pathmtu)
    + __field(__u32, rwnd)
    + __field(__u16, unack_data)
    + ),
    +
    + TP_fast_assign(
    + struct sk_buff *skb = chunk->skb;
    +
    + __entry->asoc = (unsigned long)asoc;
    + __entry->mark = skb->mark;
    + __entry->bind_port = ep->base.bind_addr.port;
    + __entry->peer_port = asoc->peer.port;
    + __entry->pathmtu = asoc->pathmtu;
    + __entry->rwnd = asoc->peer.rwnd;
    + __entry->unack_data = asoc->unack_data;
    +
    + if (trace_sctp_probe_path_enabled()) {
    + struct sctp_transport *sp;
    +
    + list_for_each_entry(sp, &asoc->peer.transport_addr_list,
    + transports) {
    + trace_sctp_probe_path(sp, asoc);
    + }
    + }
    + ),

    But I found it did not work when I did testing, and trace_sctp_probe_path
    had no output, I finally found that there is trace buffer lock
    operation(trace_event_buffer_reserve) in include/trace/trace_events.h:

    static notrace void \
    trace_event_raw_event_##call(void *__data, proto) \
    { \
    struct trace_event_file *trace_file = __data; \
    struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
    struct trace_event_buffer fbuffer; \
    struct trace_event_raw_##call *entry; \
    int __data_size; \
    \
    if (trace_trigger_soft_disabled(trace_file)) \
    return; \
    \
    __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
    \
    entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
    sizeof(*entry) + __data_size); \
    \
    if (!entry) \
    return; \
    \
    tstruct \
    \
    { assign; } \
    \
    trace_event_buffer_commit(&fbuffer); \
    }

    The reason caused no output of trace_sctp_probe_path is that
    trace_sctp_probe_path written in TP_fast_assign part of
    TRACE_EVENT(sctp_probe), and it will be placed( { assign; } ) after the
    trace_event_buffer_reserve() when compiler expands Macro,

    entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
    sizeof(*entry) + __data_size); \
    \
    if (!entry) \
    return; \
    \
    tstruct \
    \
    { assign; } \

    so trace_sctp_probe_path finally can not acquire trace_event_buffer
    and return no output, that is to say the nest of tracepoint entry function
    is not allowed. The function call flow is:

    trace_sctp_probe()
    -> trace_event_raw_event_sctp_probe()
    -> lock buffer
    -> trace_sctp_probe_path()
    -> trace_event_raw_event_sctp_probe_path() --nested
    -> buffer has been locked and return no output.

    This patch is to remove trace_sctp_probe_path from the TP_fast_assign
    part of TRACE_EVENT(sctp_probe) to avoid the nest of entry function,
    and trigger sctp_probe_path_trace in sctp_outq_sack.

    After this patch, you can enable both events individually,
    # cd /sys/kernel/debug/tracing
    # echo 1 > events/sctp/sctp_probe/enable
    # echo 1 > events/sctp/sctp_probe_path/enable

    Or, you can enable all the events under sctp.

    # echo 1 > events/sctp/enable

    Signed-off-by: Kevin Kou
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Kevin Kou
     

10 Dec, 2019

1 commit

  • Commit 312434617cb1 ("sctp: cache netns in sctp_ep_common") set netns
    in asoc and ep base since they're created, and it will never change.
    It's a better way to get netns from asoc and ep base, comparing to
    calling sock_net().

    This patch is to replace them.

    v1->v2:
    - no change.

    Suggested-by: Marcelo Ricardo Leitner
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this sctp implementation is free software you can redistribute it
    and or modify it under the terms of the gnu general public license
    as published by the free software foundation either version 2 or at
    your option any later version this sctp implementation is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with gnu cc see the file copying if not see
    http www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 42 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Richard Fontana
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190523091649.683323110@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

30 Jan, 2019

1 commit


04 Nov, 2018

1 commit

  • According to rfc8260#section-4.3.2, SCTP_SS_DEFAULT is required to
    defined as SCTP_SS_FCFS or SCTP_SS_RR.

    SCTP_SS_FCFS is used for SCTP_SS_DEFAULT's value in this patch.

    Fixes: 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
    Reported-by: Jianwen Ji
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

19 Oct, 2018

1 commit

  • Now it's confusing that asoc sndbuf_used is doing memory accounting with
    SCTP_DATA_SNDSIZE(chunk) + sizeof(sk_buff) + sizeof(sctp_chunk) while sk
    sk_wmem_alloc is doing that with skb->truesize + sizeof(sctp_chunk).

    It also causes sctp_prsctp_prune to count with a wrong freed memory when
    sndbuf_policy is not set.

    To make this right and also keep consistent between asoc sndbuf_used, sk
    sk_wmem_alloc and sk_wmem_queued, use skb->truesize + sizeof(sctp_chunk)
    for them.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

04 Oct, 2018

1 commit


12 Aug, 2018

1 commit

  • This patch introduces wrappers for accessing in/out streams indirectly.
    This will enable to replace physically contiguous memory arrays
    of streams with flexible arrays (or maybe any other appropriate
    mechanism) which do memory allocation on a per-page basis.

    Signed-off-by: Oleg Babin
    Signed-off-by: Konstantin Khorenko
    Signed-off-by: David S. Miller

    Konstantin Khorenko
     

15 May, 2018

11 commits


26 Apr, 2018

1 commit

  • It's currently written as:

    if (!tchunk->tsn_gap_acked) { [1]
    tchunk->tsn_gap_acked = 1;
    ...
    }

    if (TSN_lte(tsn, sack_ctsn)) {
    if (!tchunk->tsn_gap_acked) {
    /* SFR-CACC processing */
    ...
    }
    }

    Which causes the SFR-CACC processing on ack reception to never process,
    as tchunk->tsn_gap_acked is always true by then. Block [1] was
    moved to that position by the commit marked below.

    This patch fixes it by doing SFR-CACC processing earlier, before
    tsn_gap_acked is set to true.

    Fixes: 31b02e154940 ("sctp: Failover transmitted list on transport delete")
    Signed-off-by: Marcelo Ricardo Leitner
    Reviewed-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

17 Jan, 2018

1 commit


16 Jan, 2018

1 commit


16 Dec, 2017

1 commit

  • generate_ftsn is added as a member of sctp_stream_interleave, used to
    create fwdtsn or ifwdtsn chunk according to abandoned chunks, called
    in sctp_retransmit and sctp_outq_sack.

    sctp_generate_iftsn works for ifwdtsn, and sctp_generate_fwdtsn is
    still used for making fwdtsn.

    Signed-off-by: Xin Long
    Acked-by: Marcelo R. Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

02 Dec, 2017

3 commits

  • Now for the abandoned chunks in unsent outq, it would just free the chunks.
    Because no tsn is assigned to them yet, there's no need to send fwd tsn to
    peer, unlike for the abandoned chunks in sent outq.

    The problem is when parts of the msg have been sent and the other frags
    are still in unsent outq, if they are abandoned/dropped, the peer would
    never get this msg reassembled.

    So these frags in unsent outq can't be dropped if this msg already has
    outstanding frags.

    This patch does the check in sctp_chunk_abandoned and
    sctp_prsctp_prune_unsent.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     
  • As rfc3758#section-3.1 demands:

    A3) When a TSN is "abandoned", if it is part of a fragmented message,
    all other TSN's within that fragmented message MUST be abandoned
    at the same time.

    Besides, if it couldn't handle this, the rest frags would never get
    assembled in peer side.

    This patch supports it by adding abandoned flag in sctp_datamsg, when
    one chunk is being abandoned, set chunk->msg->abandoned as well. Next
    time when checking for abandoned, go checking chunk->msg->abandoned
    first.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     
  • Now outstanding_bytes is only increased when appending chunks into one
    packet and sending it at 1st time, while decreased when it is about to
    move into retransmit queue. It means outstanding_bytes value is already
    decreased for all chunks in retransmit queue.

    However sctp_prsctp_prune_sent is a common function to check the chunks
    in both transmitted and retransmit queue, it decrease outstanding_bytes
    when moving a chunk into abandoned queue from either of them.

    It could cause outstanding_bytes underflow, as it also decreases it's
    value for the chunks in retransmit queue.

    This patch fixes it by only updating outstanding_bytes for transmitted
    queue when pruning queues for prsctp prio policy, the same fix is also
    needed in sctp_check_transmitted.

    Fixes: 8dbdf1f5b09c ("sctp: implement prsctp PRIO policy")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

04 Oct, 2017

2 commits

  • This patch introduces the hooks necessary to do stream scheduling, as
    per RFC Draft ndata. It also introduces the first scheduler, which is
    what we do today but now factored out: first come first served (FCFS).

    With stream scheduling now we have to track which chunk was enqueued on
    which stream and be able to select another other than the in front of
    the main outqueue. So we introduce a list on sctp_stream_out_ext
    structure for this purpose.

    We reuse sctp_chunk->transmitted_list space for the list above, as the
    chunk cannot belong to the two lists at the same time. By using the
    union in there, we can have distinct names for these moments.

    sctp_sched_ops are the operations expected to be implemented by each
    scheduler. The dequeueing is a bit particular to this implementation but
    it is to match how we dequeue packets today. We first dequeue and then
    check if it fits the packet and if not, we requeue it at head. Thus why
    we don't have a peek operation but have dequeue_done instead, which is
    called once the chunk can be safely considered as transmitted.

    The check removed from sctp_outq_flush is now performed by
    sctp_stream_outq_migrate, which is only called during assoc setup.
    (sctp_sendmsg() also checks for it)

    The only operation that is foreseen but not yet added here is a way to
    signalize that a new packet is starting or that the packet is done, for
    round robin scheduler per packet, but is intentionally left to the
    patch that actually implements it.

    Support for I-DATA chunks, also described in this RFC, with user message
    interleaving is straightforward as it just requires the schedulers to
    probe for the feature and ignore datamsg boundaries when dequeueing.

    See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
    Tested-by: Xin Long
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     
  • With the stream schedulers, sctp_stream_out will become too big to be
    allocated by kmalloc and as we need to allocate with BH disabled, we
    cannot use __vmalloc in sctp_stream_init().

    This patch moves out the stats from sctp_stream_out to
    sctp_stream_out_ext, which will be allocated only when the application
    tries to sendmsg something on it.

    Just the introduction of sctp_stream_out_ext would already fix the issue
    described above by splitting the allocation in two. Moving the stats
    to it also reduces the pressure on the allocator as we will ask for less
    memory atomically when creating the socket and we will use GFP_KERNEL
    later.

    Then, for stream schedulers, we will just use sctp_stream_out_ext.

    Tested-by: Xin Long
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

07 Aug, 2017

2 commits


25 Jul, 2017

1 commit

  • This patch is to remove the typedef sctp_sack_variable_t, and
    replace with union sctp_sack_variable in the places where it's
    using this typedef.

    It is also to fix some indents in sctp_acked().

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

01 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena
     

03 Jun, 2017

1 commit

  • As Marcelo's suggestion, stream is a fixed size member of asoc and would
    not grow with more streams. To avoid an allocation for it, this patch is
    to define it as an object instead of pointer and update the places using
    it, also create sctp_stream_update() called in sctp_assoc_update() to
    migrate the stream info from one stream to another.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

06 Apr, 2017

1 commit


04 Apr, 2017

1 commit

  • Before when implementing sctp prsctp, SCTP_PR_STREAM_STATUS wasn't
    added, as it needs to save abandoned_(un)sent for every stream.

    After sctp stream reconf is added in sctp, assoc has structure
    sctp_stream_out to save per stream info.

    This patch is to add SCTP_PR_STREAM_STATUS by putting the prsctp
    per stream statistics into sctp_stream_out.

    v1->v2:
    fix an indent issue.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

02 Apr, 2017

1 commit

  • Since sctp reconf was added in sctp, the real cnt of in/out stream
    have not been c.sinit_max_instreams and c.sinit_num_ostreams any
    more.

    This patch is to replace them with stream->in/outcnt.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

22 Mar, 2017

1 commit


08 Feb, 2017

1 commit

  • Add new transport flag to allow sockets to confirm neighbour.
    When same struct dst_entry can be used for many different
    neighbours we can not use it for pending confirmations.
    The flag is propagated from transport to every packet.
    It is reset when cached dst is reset.

    Reported-by: YueHaibing
    Fixes: 5110effee8fd ("net: Do delayed neigh confirmation.")
    Fixes: f2bb4bedf35d ("ipv4: Cache output routes in fib_info nexthops.")
    Signed-off-by: Julian Anastasov
    Acked-by: Eric Dumazet
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Julian Anastasov