Skip to content

Commit 9951912

Browse files
lxindavem330
authored andcommitted
sctp: define sctp_packet_gso_append to build GSO frames
Now sctp GSO uses skb_gro_receive() to append the data into head skb frag_list. However it actually only needs very few code from skb_gro_receive(). Besides, NAPI_GRO_CB has to be set while most of its members are not needed here. This patch is to add sctp_packet_gso_append() to build GSO frames instead of skb_gro_receive(), and it would avoid many unnecessary checks and make the code clearer. Note that sctp will use page frags instead of frag_list to build GSO frames in another patch. But it may take time, as sctp's GSO frames may have different size. skb_segment() can only split it into the frags with the same size, which would break the border of sctp chunks. Signed-off-by: Xin Long <[email protected]> Reviewed-by: Marcelo Ricardo Leitner <[email protected]> Acked-by: Neil Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 60d061e commit 9951912

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

include/net/sctp/structs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,11 @@ struct sctp_input_cb {
11331133
};
11341134
#define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0]))
11351135

1136+
struct sctp_output_cb {
1137+
struct sk_buff *last;
1138+
};
1139+
#define SCTP_OUTPUT_CB(__skb) ((struct sctp_output_cb *)&((__skb)->cb[0]))
1140+
11361141
static inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb)
11371142
{
11381143
const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;

net/sctp/output.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,21 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
409409
refcount_inc(&sk->sk_wmem_alloc);
410410
}
411411

412+
static void sctp_packet_gso_append(struct sk_buff *head, struct sk_buff *skb)
413+
{
414+
if (SCTP_OUTPUT_CB(head)->last == head)
415+
skb_shinfo(head)->frag_list = skb;
416+
else
417+
SCTP_OUTPUT_CB(head)->last->next = skb;
418+
SCTP_OUTPUT_CB(head)->last = skb;
419+
420+
head->truesize += skb->truesize;
421+
head->data_len += skb->len;
422+
head->len += skb->len;
423+
424+
__skb_header_release(skb);
425+
}
426+
412427
static int sctp_packet_pack(struct sctp_packet *packet,
413428
struct sk_buff *head, int gso, gfp_t gfp)
414429
{
@@ -422,7 +437,7 @@ static int sctp_packet_pack(struct sctp_packet *packet,
422437

423438
if (gso) {
424439
skb_shinfo(head)->gso_type = sk->sk_gso_type;
425-
NAPI_GRO_CB(head)->last = head;
440+
SCTP_OUTPUT_CB(head)->last = head;
426441
} else {
427442
nskb = head;
428443
pkt_size = packet->size;
@@ -503,15 +518,8 @@ static int sctp_packet_pack(struct sctp_packet *packet,
503518
&packet->chunk_list);
504519
}
505520

506-
if (gso) {
507-
if (skb_gro_receive(&head, nskb)) {
508-
kfree_skb(nskb);
509-
return 0;
510-
}
511-
if (WARN_ON_ONCE(skb_shinfo(head)->gso_segs >=
512-
sk->sk_gso_max_segs))
513-
return 0;
514-
}
521+
if (gso)
522+
sctp_packet_gso_append(head, nskb);
515523

516524
pkt_count++;
517525
} while (!list_empty(&packet->chunk_list));

0 commit comments

Comments
 (0)