diff mbox series

[net-next,12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead

Message ID 3716fc0699dc1d5557574b5227524e80b7fd76b8.1601387231.git.lucien.xin@gmail.com
State Superseded
Headers show
Series sctp: Implement RFC6951: UDP Encapsulation of SCTP | expand

Commit Message

Xin Long Sept. 29, 2020, 1:49 p.m. UTC
sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
Add GSO support"), as:

  "We have to refresh this in case we are xmiting to more than one
   transport at a time"

This actually happens in the loop of sctp_outq_flush_transports(),
and it shouldn't be gso related, so move it out of gso part and
before sctp_packet_pack().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/output.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Marcelo Ricardo Leitner Oct. 3, 2020, 4:09 a.m. UTC | #1
On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> Add GSO support"), as:
> 
>   "We have to refresh this in case we are xmiting to more than one
>    transport at a time"
> 
> This actually happens in the loop of sctp_outq_flush_transports(),
> and it shouldn't be gso related, so move it out of gso part and

To be more precise, "shouldn't be tied to gso"

> before sctp_packet_pack().
Xin Long Oct. 3, 2020, 7:45 a.m. UTC | #2
On Sat, Oct 3, 2020 at 12:09 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> > sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> > Add GSO support"), as:
> >
> >   "We have to refresh this in case we are xmiting to more than one
> >    transport at a time"
> >
> > This actually happens in the loop of sctp_outq_flush_transports(),
> > and it shouldn't be gso related, so move it out of gso part and
>
> To be more precise, "shouldn't be tied to gso"
right.

>
> > before sctp_packet_pack().
diff mbox series

Patch

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 1441eaf..fb16500 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -508,12 +508,6 @@  static int sctp_packet_pack(struct sctp_packet *packet,
 					sizeof(struct inet6_skb_parm)));
 		skb_shinfo(head)->gso_segs = pkt_count;
 		skb_shinfo(head)->gso_size = GSO_BY_FRAGS;
-		rcu_read_lock();
-		if (skb_dst(head) != tp->dst) {
-			dst_hold(tp->dst);
-			sk_setup_caps(sk, tp->dst);
-		}
-		rcu_read_unlock();
 		goto chksum;
 	}
 
@@ -593,6 +587,13 @@  int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	}
 	skb_dst_set(head, dst);
 
+	rcu_read_lock();
+	if (__sk_dst_get(sk) != tp->dst) {
+		dst_hold(tp->dst);
+		sk_setup_caps(sk, tp->dst);
+	}
+	rcu_read_unlock();
+
 	/* pack up chunks */
 	pkt_count = sctp_packet_pack(packet, head, gso, gfp);
 	if (!pkt_count) {