diff options
author | Daniel Axtens <dja@axtens.net> | 2018-03-08 22:06:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-09 11:41:47 -0500 |
commit | 1dd27cde30e85774c77349c804229431616d594a (patch) | |
tree | dac4ba324dcb8010bacef9054046748ddb0df4db | |
parent | ca0edb131bdf1e6beaeb2b8289fd6b374b74147d (diff) |
net: use skb_is_gso_sctp() instead of open-coding
As well as the basic conversion, I noticed that a lot of the
SCTP code checks gso_type without first checking skb_is_gso()
so I have added that where appropriate.
Also, document the helper.
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | Documentation/networking/segmentation-offloads.txt | 5 | ||||
-rw-r--r-- | net/core/skbuff.c | 2 | ||||
-rw-r--r-- | net/sched/act_csum.c | 2 | ||||
-rw-r--r-- | net/sctp/input.c | 8 | ||||
-rw-r--r-- | net/sctp/inqueue.c | 2 | ||||
-rw-r--r-- | net/sctp/offload.c | 2 |
6 files changed, 12 insertions, 9 deletions
diff --git a/Documentation/networking/segmentation-offloads.txt b/Documentation/networking/segmentation-offloads.txt index fc0c949e7f9c..aca542ec125c 100644 --- a/Documentation/networking/segmentation-offloads.txt +++ b/Documentation/networking/segmentation-offloads.txt | |||
@@ -155,7 +155,10 @@ Therefore, any code in the core networking stack must be aware of the | |||
155 | possibility that gso_size will be GSO_BY_FRAGS and handle that case | 155 | possibility that gso_size will be GSO_BY_FRAGS and handle that case |
156 | appropriately. | 156 | appropriately. |
157 | 157 | ||
158 | There are a couple of helpers to make this easier: | 158 | There are some helpers to make this easier: |
159 | |||
160 | - skb_is_gso(skb) && skb_is_gso_sctp(skb) is the best way to see if | ||
161 | an skb is an SCTP GSO skb. | ||
159 | 162 | ||
160 | - For size checks, the skb_gso_validate_*_len family of helpers correctly | 163 | - For size checks, the skb_gso_validate_*_len family of helpers correctly |
161 | considers GSO_BY_FRAGS. | 164 | considers GSO_BY_FRAGS. |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 0bb0d8877954..baf990528943 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -4904,7 +4904,7 @@ static unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) | |||
4904 | thlen += inner_tcp_hdrlen(skb); | 4904 | thlen += inner_tcp_hdrlen(skb); |
4905 | } else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) { | 4905 | } else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) { |
4906 | thlen = tcp_hdrlen(skb); | 4906 | thlen = tcp_hdrlen(skb); |
4907 | } else if (unlikely(shinfo->gso_type & SKB_GSO_SCTP)) { | 4907 | } else if (unlikely(skb_is_gso_sctp(skb))) { |
4908 | thlen = sizeof(struct sctphdr); | 4908 | thlen = sizeof(struct sctphdr); |
4909 | } | 4909 | } |
4910 | /* UFO sets gso_size to the size of the fragmentation | 4910 | /* UFO sets gso_size to the size of the fragmentation |
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index b7ba9b06b147..24b2e8e681cf 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c | |||
@@ -350,7 +350,7 @@ static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl, | |||
350 | { | 350 | { |
351 | struct sctphdr *sctph; | 351 | struct sctphdr *sctph; |
352 | 352 | ||
353 | if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) | 353 | if (skb_is_gso(skb) && skb_is_gso_sctp(skb)) |
354 | return 1; | 354 | return 1; |
355 | 355 | ||
356 | sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph)); | 356 | sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph)); |
diff --git a/net/sctp/input.c b/net/sctp/input.c index 0247cc432e02..b381d78548ac 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -106,6 +106,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
106 | int family; | 106 | int family; |
107 | struct sctp_af *af; | 107 | struct sctp_af *af; |
108 | struct net *net = dev_net(skb->dev); | 108 | struct net *net = dev_net(skb->dev); |
109 | bool is_gso = skb_is_gso(skb) && skb_is_gso_sctp(skb); | ||
109 | 110 | ||
110 | if (skb->pkt_type != PACKET_HOST) | 111 | if (skb->pkt_type != PACKET_HOST) |
111 | goto discard_it; | 112 | goto discard_it; |
@@ -123,8 +124,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
123 | * it's better to just linearize it otherwise crc computing | 124 | * it's better to just linearize it otherwise crc computing |
124 | * takes longer. | 125 | * takes longer. |
125 | */ | 126 | */ |
126 | if ((!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) && | 127 | if ((!is_gso && skb_linearize(skb)) || |
127 | skb_linearize(skb)) || | ||
128 | !pskb_may_pull(skb, sizeof(struct sctphdr))) | 128 | !pskb_may_pull(skb, sizeof(struct sctphdr))) |
129 | goto discard_it; | 129 | goto discard_it; |
130 | 130 | ||
@@ -135,7 +135,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
135 | if (skb_csum_unnecessary(skb)) | 135 | if (skb_csum_unnecessary(skb)) |
136 | __skb_decr_checksum_unnecessary(skb); | 136 | __skb_decr_checksum_unnecessary(skb); |
137 | else if (!sctp_checksum_disable && | 137 | else if (!sctp_checksum_disable && |
138 | !(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) && | 138 | !is_gso && |
139 | sctp_rcv_checksum(net, skb) < 0) | 139 | sctp_rcv_checksum(net, skb) < 0) |
140 | goto discard_it; | 140 | goto discard_it; |
141 | skb->csum_valid = 1; | 141 | skb->csum_valid = 1; |
@@ -1218,7 +1218,7 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net, | |||
1218 | * issue as packets hitting this are mostly INIT or INIT-ACK and | 1218 | * issue as packets hitting this are mostly INIT or INIT-ACK and |
1219 | * those cannot be on GSO-style anyway. | 1219 | * those cannot be on GSO-style anyway. |
1220 | */ | 1220 | */ |
1221 | if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) | 1221 | if (skb_is_gso(skb) && skb_is_gso_sctp(skb)) |
1222 | return NULL; | 1222 | return NULL; |
1223 | 1223 | ||
1224 | ch = (struct sctp_chunkhdr *)skb->data; | 1224 | ch = (struct sctp_chunkhdr *)skb->data; |
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c index 48392552ee7c..23ebc5318edc 100644 --- a/net/sctp/inqueue.c +++ b/net/sctp/inqueue.c | |||
@@ -170,7 +170,7 @@ next_chunk: | |||
170 | 170 | ||
171 | chunk = list_entry(entry, struct sctp_chunk, list); | 171 | chunk = list_entry(entry, struct sctp_chunk, list); |
172 | 172 | ||
173 | if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { | 173 | if (skb_is_gso(chunk->skb) && skb_is_gso_sctp(chunk->skb)) { |
174 | /* GSO-marked skbs but without frags, handle | 174 | /* GSO-marked skbs but without frags, handle |
175 | * them normally | 175 | * them normally |
176 | */ | 176 | */ |
diff --git a/net/sctp/offload.c b/net/sctp/offload.c index 35bc7106d182..123e9f2dc226 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c | |||
@@ -45,7 +45,7 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, | |||
45 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 45 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
46 | struct sctphdr *sh; | 46 | struct sctphdr *sh; |
47 | 47 | ||
48 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)) | 48 | if (!skb_is_gso_sctp(skb)) |
49 | goto out; | 49 | goto out; |
50 | 50 | ||
51 | sh = sctp_hdr(skb); | 51 | sh = sctp_hdr(skb); |