提交 99519122 编写于 作者: X Xin Long 提交者: David S. Miller

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: NXin Long <lucien.xin@gmail.com>
Reviewed-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: NNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 60d061e3
...@@ -1133,6 +1133,11 @@ struct sctp_input_cb { ...@@ -1133,6 +1133,11 @@ struct sctp_input_cb {
}; };
#define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0])) #define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0]))
struct sctp_output_cb {
struct sk_buff *last;
};
#define SCTP_OUTPUT_CB(__skb) ((struct sctp_output_cb *)&((__skb)->cb[0]))
static inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb) static inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb)
{ {
const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk; const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
......
...@@ -409,6 +409,21 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) ...@@ -409,6 +409,21 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
refcount_inc(&sk->sk_wmem_alloc); refcount_inc(&sk->sk_wmem_alloc);
} }
static void sctp_packet_gso_append(struct sk_buff *head, struct sk_buff *skb)
{
if (SCTP_OUTPUT_CB(head)->last == head)
skb_shinfo(head)->frag_list = skb;
else
SCTP_OUTPUT_CB(head)->last->next = skb;
SCTP_OUTPUT_CB(head)->last = skb;
head->truesize += skb->truesize;
head->data_len += skb->len;
head->len += skb->len;
__skb_header_release(skb);
}
static int sctp_packet_pack(struct sctp_packet *packet, static int sctp_packet_pack(struct sctp_packet *packet,
struct sk_buff *head, int gso, gfp_t gfp) struct sk_buff *head, int gso, gfp_t gfp)
{ {
...@@ -422,7 +437,7 @@ static int sctp_packet_pack(struct sctp_packet *packet, ...@@ -422,7 +437,7 @@ static int sctp_packet_pack(struct sctp_packet *packet,
if (gso) { if (gso) {
skb_shinfo(head)->gso_type = sk->sk_gso_type; skb_shinfo(head)->gso_type = sk->sk_gso_type;
NAPI_GRO_CB(head)->last = head; SCTP_OUTPUT_CB(head)->last = head;
} else { } else {
nskb = head; nskb = head;
pkt_size = packet->size; pkt_size = packet->size;
...@@ -503,15 +518,8 @@ static int sctp_packet_pack(struct sctp_packet *packet, ...@@ -503,15 +518,8 @@ static int sctp_packet_pack(struct sctp_packet *packet,
&packet->chunk_list); &packet->chunk_list);
} }
if (gso) { if (gso)
if (skb_gro_receive(&head, nskb)) { sctp_packet_gso_append(head, nskb);
kfree_skb(nskb);
return 0;
}
if (WARN_ON_ONCE(skb_shinfo(head)->gso_segs >=
sk->sk_gso_max_segs))
return 0;
}
pkt_count++; pkt_count++;
} while (!list_empty(&packet->chunk_list)); } while (!list_empty(&packet->chunk_list));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册