Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 1 | /* SCTP kernel implementation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * (C) Copyright IBM Corp. 2001, 2004 |
| 3 | * Copyright (c) 1999-2000 Cisco, Inc. |
| 4 | * Copyright (c) 1999-2001 Motorola, Inc. |
| 5 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 6 | * This file is part of the SCTP kernel implementation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
| 8 | * These functions handle output processing. |
| 9 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 10 | * This SCTP implementation is free software; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * you can redistribute it and/or modify it under the terms of |
| 12 | * the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
| 14 | * any later version. |
| 15 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 16 | * This SCTP implementation is distributed in the hope that it |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 18 | * ************************ |
| 19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | * See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
Jeff Kirsher | 4b2f13a | 2013-12-06 06:28:48 -0800 | [diff] [blame] | 23 | * along with GNU CC; see the file COPYING. If not, see |
| 24 | * <http://www.gnu.org/licenses/>. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | * |
| 26 | * Please send any bug reports or fixes you make to the |
| 27 | * email address(es): |
Daniel Borkmann | 91705c6 | 2013-07-23 14:51:47 +0200 | [diff] [blame] | 28 | * lksctp developers <linux-sctp@vger.kernel.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | * Written or modified by: |
| 31 | * La Monte H.P. Yarroll <piggy@acm.org> |
| 32 | * Karl Knutson <karl@athena.chicago.il.us> |
| 33 | * Jon Grimm <jgrimm@austin.ibm.com> |
| 34 | * Sridhar Samudrala <sri@us.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | */ |
| 36 | |
Joe Perches | 145ce50 | 2010-08-24 13:21:08 +0000 | [diff] [blame] | 37 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/types.h> |
| 40 | #include <linux/kernel.h> |
| 41 | #include <linux/wait.h> |
| 42 | #include <linux/time.h> |
| 43 | #include <linux/ip.h> |
| 44 | #include <linux/ipv6.h> |
| 45 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 46 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <net/inet_ecn.h> |
Vlad Yasevich | 8d2f9e81 | 2009-03-21 13:41:09 -0700 | [diff] [blame] | 48 | #include <net/ip.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <net/icmp.h> |
Pavel Emelyanov | 7c73a6f | 2008-07-16 20:20:11 -0700 | [diff] [blame] | 50 | #include <net/net_namespace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/socket.h> /* for sa_family_t */ |
| 53 | #include <net/sock.h> |
| 54 | |
| 55 | #include <net/sctp/sctp.h> |
| 56 | #include <net/sctp/sm.h> |
Vlad Yasevich | 9ad0977 | 2007-12-16 14:06:41 -0800 | [diff] [blame] | 57 | #include <net/sctp/checksum.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* Forward declarations for private helpers. */ |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 60 | static sctp_xmit_t __sctp_packet_append_chunk(struct sctp_packet *packet, |
| 61 | struct sctp_chunk *chunk); |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 62 | static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | struct sctp_chunk *chunk); |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 64 | static void sctp_packet_append_data(struct sctp_packet *packet, |
| 65 | struct sctp_chunk *chunk); |
| 66 | static sctp_xmit_t sctp_packet_will_fit(struct sctp_packet *packet, |
| 67 | struct sctp_chunk *chunk, |
| 68 | u16 chunk_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Wei Yongjun | be29714 | 2009-09-04 14:34:06 +0800 | [diff] [blame] | 70 | static void sctp_packet_reset(struct sctp_packet *packet) |
| 71 | { |
| 72 | packet->size = packet->overhead; |
| 73 | packet->has_cookie_echo = 0; |
| 74 | packet->has_sack = 0; |
| 75 | packet->has_data = 0; |
| 76 | packet->has_auth = 0; |
| 77 | packet->ipfragok = 0; |
| 78 | packet->auth = NULL; |
| 79 | } |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* Config a packet. |
| 82 | * This appears to be a followup set of initializations. |
| 83 | */ |
| 84 | struct sctp_packet *sctp_packet_config(struct sctp_packet *packet, |
| 85 | __u32 vtag, int ecn_capable) |
| 86 | { |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 87 | struct sctp_transport *tp = packet->transport; |
| 88 | struct sctp_association *asoc = tp->asoc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 90 | pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | packet->vtag = vtag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 94 | if (asoc && tp->dst) { |
| 95 | struct sock *sk = asoc->base.sk; |
| 96 | |
| 97 | rcu_read_lock(); |
| 98 | if (__sk_dst_get(sk) != tp->dst) { |
| 99 | dst_hold(tp->dst); |
| 100 | sk_setup_caps(sk, tp->dst); |
| 101 | } |
| 102 | |
| 103 | if (sk_can_gso(sk)) { |
| 104 | struct net_device *dev = tp->dst->dev; |
| 105 | |
| 106 | packet->max_size = dev->gso_max_size; |
| 107 | } else { |
| 108 | packet->max_size = asoc->pathmtu; |
| 109 | } |
| 110 | rcu_read_unlock(); |
| 111 | |
| 112 | } else { |
| 113 | packet->max_size = tp->pathmtu; |
| 114 | } |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | if (ecn_capable && sctp_packet_empty(packet)) { |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 117 | struct sctp_chunk *chunk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
| 119 | /* If there a is a prepend chunk stick it on the list before |
YOSHIFUJI Hideaki | d808ad9 | 2007-02-09 23:25:18 +0900 | [diff] [blame] | 120 | * any other chunks get appended. |
| 121 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 122 | chunk = sctp_get_ecne_prepend(asoc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | if (chunk) |
| 124 | sctp_packet_append_chunk(packet, chunk); |
| 125 | } |
| 126 | |
| 127 | return packet; |
| 128 | } |
| 129 | |
| 130 | /* Initialize the packet structure. */ |
| 131 | struct sctp_packet *sctp_packet_init(struct sctp_packet *packet, |
| 132 | struct sctp_transport *transport, |
| 133 | __u16 sport, __u16 dport) |
| 134 | { |
| 135 | struct sctp_association *asoc = transport->asoc; |
| 136 | size_t overhead; |
| 137 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 138 | pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
| 140 | packet->transport = transport; |
| 141 | packet->source_port = sport; |
| 142 | packet->destination_port = dport; |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 143 | INIT_LIST_HEAD(&packet->chunk_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | if (asoc) { |
YOSHIFUJI Hideaki | d808ad9 | 2007-02-09 23:25:18 +0900 | [diff] [blame] | 145 | struct sctp_sock *sp = sctp_sk(asoc->base.sk); |
| 146 | overhead = sp->pf->af->net_header_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | } else { |
| 148 | overhead = sizeof(struct ipv6hdr); |
| 149 | } |
| 150 | overhead += sizeof(struct sctphdr); |
| 151 | packet->overhead = overhead; |
Wei Yongjun | be29714 | 2009-09-04 14:34:06 +0800 | [diff] [blame] | 152 | sctp_packet_reset(packet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | packet->vtag = 0; |
Daniel Borkmann | 3e3251b | 2013-04-18 21:59:37 +0000 | [diff] [blame] | 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | return packet; |
| 156 | } |
| 157 | |
| 158 | /* Free a packet. */ |
| 159 | void sctp_packet_free(struct sctp_packet *packet) |
| 160 | { |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 161 | struct sctp_chunk *chunk, *tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 163 | pr_debug("%s: packet:%p\n", __func__, packet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 165 | list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { |
| 166 | list_del_init(&chunk->list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | sctp_chunk_free(chunk); |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 168 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /* This routine tries to append the chunk to the offered packet. If adding |
| 172 | * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO chunk |
| 173 | * is not present in the packet, it transmits the input packet. |
| 174 | * Data can be bundled with a packet containing a COOKIE_ECHO chunk as long |
| 175 | * as it can fit in the packet, but any more data that does not fit in this |
| 176 | * packet can be sent only after receiving the COOKIE_ACK. |
| 177 | */ |
| 178 | sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet, |
Vlad Yasevich | 2e3216c | 2008-06-19 16:08:18 -0700 | [diff] [blame] | 179 | struct sctp_chunk *chunk, |
Marcelo Ricardo Leitner | cea8768 | 2016-03-10 18:33:07 -0300 | [diff] [blame] | 180 | int one_packet, gfp_t gfp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | { |
| 182 | sctp_xmit_t retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
David S. Miller | 3b55a53 | 2016-06-03 22:53:26 -0700 | [diff] [blame] | 184 | pr_debug("%s: packet:%p size:%Zu chunk:%p size:%d\n", __func__, |
Marcelo Ricardo Leitner | 942b323 | 2016-06-02 15:05:44 -0300 | [diff] [blame] | 185 | packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
| 187 | switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) { |
| 188 | case SCTP_XMIT_PMTU_FULL: |
| 189 | if (!packet->has_cookie_echo) { |
Xin Long | 6451944 | 2016-09-14 02:04:21 +0800 | [diff] [blame] | 190 | int error = 0; |
| 191 | |
Marcelo Ricardo Leitner | cea8768 | 2016-03-10 18:33:07 -0300 | [diff] [blame] | 192 | error = sctp_packet_transmit(packet, gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | if (error < 0) |
| 194 | chunk->skb->sk->sk_err = -error; |
| 195 | |
| 196 | /* If we have an empty packet, then we can NOT ever |
| 197 | * return PMTU_FULL. |
| 198 | */ |
Vlad Yasevich | 2e3216c | 2008-06-19 16:08:18 -0700 | [diff] [blame] | 199 | if (!one_packet) |
| 200 | retval = sctp_packet_append_chunk(packet, |
| 201 | chunk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | } |
| 203 | break; |
| 204 | |
| 205 | case SCTP_XMIT_RWND_FULL: |
| 206 | case SCTP_XMIT_OK: |
David Laight | 526cbef | 2014-07-22 08:59:14 +0000 | [diff] [blame] | 207 | case SCTP_XMIT_DELAY: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | break; |
Stephen Hemminger | 3ff50b7 | 2007-04-20 17:09:22 -0700 | [diff] [blame] | 209 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
| 211 | return retval; |
| 212 | } |
| 213 | |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 214 | /* Try to bundle an auth chunk into the packet. */ |
| 215 | static sctp_xmit_t sctp_packet_bundle_auth(struct sctp_packet *pkt, |
| 216 | struct sctp_chunk *chunk) |
| 217 | { |
| 218 | struct sctp_association *asoc = pkt->transport->asoc; |
| 219 | struct sctp_chunk *auth; |
| 220 | sctp_xmit_t retval = SCTP_XMIT_OK; |
| 221 | |
| 222 | /* if we don't have an association, we can't do authentication */ |
| 223 | if (!asoc) |
| 224 | return retval; |
| 225 | |
| 226 | /* See if this is an auth chunk we are bundling or if |
| 227 | * auth is already bundled. |
| 228 | */ |
Vlad Yasevich | 4007cc8 | 2009-09-04 18:21:00 -0400 | [diff] [blame] | 229 | if (chunk->chunk_hdr->type == SCTP_CID_AUTH || pkt->has_auth) |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 230 | return retval; |
| 231 | |
| 232 | /* if the peer did not request this chunk to be authenticated, |
| 233 | * don't do it |
| 234 | */ |
| 235 | if (!chunk->auth) |
| 236 | return retval; |
| 237 | |
| 238 | auth = sctp_make_auth(asoc); |
| 239 | if (!auth) |
| 240 | return retval; |
| 241 | |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 242 | retval = __sctp_packet_append_chunk(pkt, auth); |
| 243 | |
| 244 | if (retval != SCTP_XMIT_OK) |
| 245 | sctp_chunk_free(auth); |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 246 | |
| 247 | return retval; |
| 248 | } |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | /* Try to bundle a SACK with the packet. */ |
| 251 | static sctp_xmit_t sctp_packet_bundle_sack(struct sctp_packet *pkt, |
| 252 | struct sctp_chunk *chunk) |
| 253 | { |
| 254 | sctp_xmit_t retval = SCTP_XMIT_OK; |
| 255 | |
| 256 | /* If sending DATA and haven't aleady bundled a SACK, try to |
| 257 | * bundle one in to the packet. |
| 258 | */ |
| 259 | if (sctp_chunk_is_data(chunk) && !pkt->has_sack && |
| 260 | !pkt->has_cookie_echo) { |
| 261 | struct sctp_association *asoc; |
Doug Graham | af87b82 | 2009-07-29 12:05:57 -0400 | [diff] [blame] | 262 | struct timer_list *timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | asoc = pkt->transport->asoc; |
Doug Graham | af87b82 | 2009-07-29 12:05:57 -0400 | [diff] [blame] | 264 | timer = &asoc->timers[SCTP_EVENT_TIMEOUT_SACK]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
Doug Graham | af87b82 | 2009-07-29 12:05:57 -0400 | [diff] [blame] | 266 | /* If the SACK timer is running, we have a pending SACK */ |
| 267 | if (timer_pending(timer)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | struct sctp_chunk *sack; |
Neil Horman | 4244854 | 2012-06-30 03:04:26 +0000 | [diff] [blame] | 269 | |
| 270 | if (pkt->transport->sack_generation != |
| 271 | pkt->transport->asoc->peer.sack_generation) |
| 272 | return retval; |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | asoc->a_rwnd = asoc->rwnd; |
| 275 | sack = sctp_make_sack(asoc); |
| 276 | if (sack) { |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 277 | retval = __sctp_packet_append_chunk(pkt, sack); |
| 278 | if (retval != SCTP_XMIT_OK) { |
| 279 | sctp_chunk_free(sack); |
| 280 | goto out; |
| 281 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | asoc->peer.sack_needed = 0; |
Doug Graham | af87b82 | 2009-07-29 12:05:57 -0400 | [diff] [blame] | 283 | if (del_timer(timer)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | sctp_association_put(asoc); |
| 285 | } |
| 286 | } |
| 287 | } |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 288 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | return retval; |
| 290 | } |
| 291 | |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 292 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | /* Append a chunk to the offered packet reporting back any inability to do |
| 294 | * so. |
| 295 | */ |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 296 | static sctp_xmit_t __sctp_packet_append_chunk(struct sctp_packet *packet, |
| 297 | struct sctp_chunk *chunk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
| 299 | sctp_xmit_t retval = SCTP_XMIT_OK; |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 300 | __u16 chunk_len = SCTP_PAD4(ntohs(chunk->chunk_hdr->length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 302 | /* Check to see if this chunk will fit into the packet */ |
| 303 | retval = sctp_packet_will_fit(packet, chunk, chunk_len); |
| 304 | if (retval != SCTP_XMIT_OK) |
| 305 | goto finish; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 307 | /* We believe that this chunk is OK to add to the packet */ |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 308 | switch (chunk->chunk_hdr->type) { |
wangweidong | f7010e6 | 2013-12-23 12:16:52 +0800 | [diff] [blame] | 309 | case SCTP_CID_DATA: |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 310 | /* Account for the data being in the packet */ |
| 311 | sctp_packet_append_data(packet, chunk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | /* Disallow SACK bundling after DATA. */ |
| 313 | packet->has_sack = 1; |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 314 | /* Disallow AUTH bundling after DATA */ |
| 315 | packet->has_auth = 1; |
| 316 | /* Let it be knows that packet has DATA in it */ |
| 317 | packet->has_data = 1; |
Vlad Yasevich | 759af00 | 2009-01-22 14:53:01 -0800 | [diff] [blame] | 318 | /* timestamp the chunk for rtx purposes */ |
| 319 | chunk->sent_at = jiffies; |
Xin Long | a6c2f79 | 2016-07-09 19:47:43 +0800 | [diff] [blame] | 320 | /* Mainly used for prsctp RTX policy */ |
| 321 | chunk->sent_count++; |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 322 | break; |
wangweidong | f7010e6 | 2013-12-23 12:16:52 +0800 | [diff] [blame] | 323 | case SCTP_CID_COOKIE_ECHO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | packet->has_cookie_echo = 1; |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 325 | break; |
| 326 | |
wangweidong | f7010e6 | 2013-12-23 12:16:52 +0800 | [diff] [blame] | 327 | case SCTP_CID_SACK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | packet->has_sack = 1; |
Michele Baldessari | 196d675 | 2012-12-01 04:49:42 +0000 | [diff] [blame] | 329 | if (chunk->asoc) |
| 330 | chunk->asoc->stats.osacks++; |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 331 | break; |
| 332 | |
wangweidong | f7010e6 | 2013-12-23 12:16:52 +0800 | [diff] [blame] | 333 | case SCTP_CID_AUTH: |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 334 | packet->has_auth = 1; |
| 335 | packet->auth = chunk; |
| 336 | break; |
| 337 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | /* It is OK to send this chunk. */ |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 340 | list_add_tail(&chunk->list, &packet->chunk_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | packet->size += chunk_len; |
| 342 | chunk->transport = packet->transport; |
| 343 | finish: |
| 344 | return retval; |
| 345 | } |
| 346 | |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 347 | /* Append a chunk to the offered packet reporting back any inability to do |
| 348 | * so. |
| 349 | */ |
| 350 | sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet, |
| 351 | struct sctp_chunk *chunk) |
| 352 | { |
| 353 | sctp_xmit_t retval = SCTP_XMIT_OK; |
| 354 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 355 | pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk); |
Neil Horman | ed10627 | 2012-07-02 09:59:24 +0000 | [diff] [blame] | 356 | |
| 357 | /* Data chunks are special. Before seeing what else we can |
| 358 | * bundle into this packet, check to see if we are allowed to |
| 359 | * send this DATA. |
| 360 | */ |
| 361 | if (sctp_chunk_is_data(chunk)) { |
| 362 | retval = sctp_packet_can_append_data(packet, chunk); |
| 363 | if (retval != SCTP_XMIT_OK) |
| 364 | goto finish; |
| 365 | } |
| 366 | |
| 367 | /* Try to bundle AUTH chunk */ |
| 368 | retval = sctp_packet_bundle_auth(packet, chunk); |
| 369 | if (retval != SCTP_XMIT_OK) |
| 370 | goto finish; |
| 371 | |
| 372 | /* Try to bundle SACK chunk */ |
| 373 | retval = sctp_packet_bundle_sack(packet, chunk); |
| 374 | if (retval != SCTP_XMIT_OK) |
| 375 | goto finish; |
| 376 | |
| 377 | retval = __sctp_packet_append_chunk(packet, chunk); |
| 378 | |
| 379 | finish: |
| 380 | return retval; |
| 381 | } |
| 382 | |
Thomas Graf | 4c3a5bd | 2012-09-03 04:27:42 +0000 | [diff] [blame] | 383 | static void sctp_packet_release_owner(struct sk_buff *skb) |
| 384 | { |
| 385 | sk_free(skb->sk); |
| 386 | } |
| 387 | |
| 388 | static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) |
| 389 | { |
| 390 | skb_orphan(skb); |
| 391 | skb->sk = sk; |
| 392 | skb->destructor = sctp_packet_release_owner; |
| 393 | |
| 394 | /* |
| 395 | * The data chunks have already been accounted for in sctp_sendmsg(), |
| 396 | * therefore only reserve a single byte to keep socket around until |
| 397 | * the packet has been transmitted. |
| 398 | */ |
| 399 | atomic_inc(&sk->sk_wmem_alloc); |
| 400 | } |
| 401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | /* All packets are sent to the network through this function from |
| 403 | * sctp_outq_tail(). |
| 404 | * |
| 405 | * The return value is a normal kernel error return value. |
| 406 | */ |
Marcelo Ricardo Leitner | cea8768 | 2016-03-10 18:33:07 -0300 | [diff] [blame] | 407 | int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | { |
| 409 | struct sctp_transport *tp = packet->transport; |
| 410 | struct sctp_association *asoc = tp->asoc; |
| 411 | struct sctphdr *sh; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 412 | struct sk_buff *nskb = NULL, *head = NULL; |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 413 | struct sctp_chunk *chunk, *tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | struct sock *sk; |
| 415 | int err = 0; |
| 416 | int padding; /* How much padding do we need? */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 417 | int pkt_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | __u8 has_data = 0; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 419 | int gso = 0; |
| 420 | int pktcount = 0; |
Xin Long | ecc515d | 2016-10-24 01:01:09 +0800 | [diff] [blame] | 421 | int auth_len = 0; |
wangweidong | 0438816 | 2013-12-26 13:55:56 +0800 | [diff] [blame] | 422 | struct dst_entry *dst; |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 423 | unsigned char *auth = NULL; /* pointer to auth in skb data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 425 | pr_debug("%s: packet:%p\n", __func__, packet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
| 427 | /* Do NOT generate a chunkless packet. */ |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 428 | if (list_empty(&packet->chunk_list)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | return err; |
| 430 | |
| 431 | /* Set up convenience variables... */ |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 432 | chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | sk = chunk->skb->sk; |
| 434 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 435 | /* Allocate the head skb, or main one if not in GSO */ |
| 436 | if (packet->size > tp->pathmtu && !packet->ipfragok) { |
| 437 | if (sk_can_gso(sk)) { |
| 438 | gso = 1; |
| 439 | pkt_size = packet->overhead; |
| 440 | } else { |
| 441 | /* If this happens, we trash this packet and try |
| 442 | * to build a new one, hopefully correct this |
| 443 | * time. Application may notice this error. |
| 444 | */ |
| 445 | pr_err_once("Trying to GSO but underlying device doesn't support it."); |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 446 | goto err; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 447 | } |
| 448 | } else { |
| 449 | pkt_size = packet->size; |
| 450 | } |
| 451 | head = alloc_skb(pkt_size + MAX_HEADER, gfp); |
| 452 | if (!head) |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 453 | goto err; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 454 | if (gso) { |
| 455 | NAPI_GRO_CB(head)->last = head; |
| 456 | skb_shinfo(head)->gso_type = sk->sk_gso_type; |
| 457 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
| 459 | /* Make sure the outbound skb has enough header room reserved. */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 460 | skb_reserve(head, packet->overhead + MAX_HEADER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | /* Set the owning socket so that we know where to get the |
| 463 | * destination IP address. |
| 464 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 465 | sctp_packet_set_owner_w(head, sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Nicolas Dichtel | e026886 | 2012-05-04 05:24:54 +0000 | [diff] [blame] | 467 | if (!sctp_transport_dst_check(tp)) { |
Sridhar Samudrala | 503b55f | 2006-06-17 22:57:28 -0700 | [diff] [blame] | 468 | sctp_transport_route(tp, NULL, sctp_sk(sk)); |
| 469 | if (asoc && (asoc->param_flags & SPP_PMTUD_ENABLE)) { |
David S. Miller | 02f3d4c | 2012-07-16 03:57:14 -0700 | [diff] [blame] | 470 | sctp_assoc_sync_pmtu(sk, asoc); |
Sridhar Samudrala | 503b55f | 2006-06-17 22:57:28 -0700 | [diff] [blame] | 471 | } |
| 472 | } |
Eric Dumazet | adf3090 | 2009-06-02 05:19:30 +0000 | [diff] [blame] | 473 | dst = dst_clone(tp->dst); |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 474 | if (!dst) { |
| 475 | if (asoc) |
| 476 | IP_INC_STATS(sock_net(asoc->base.sk), |
| 477 | IPSTATS_MIB_OUTNOROUTES); |
| 478 | goto nodst; |
| 479 | } |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 480 | skb_dst_set(head, dst); |
Sridhar Samudrala | 503b55f | 2006-06-17 22:57:28 -0700 | [diff] [blame] | 481 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | /* Build the SCTP header. */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 483 | sh = (struct sctphdr *)skb_push(head, sizeof(struct sctphdr)); |
| 484 | skb_reset_transport_header(head); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | sh->source = htons(packet->source_port); |
| 486 | sh->dest = htons(packet->destination_port); |
| 487 | |
| 488 | /* From 6.8 Adler-32 Checksum Calculation: |
| 489 | * After the packet is constructed (containing the SCTP common |
| 490 | * header and one or more control or DATA chunks), the |
| 491 | * transmitter shall: |
| 492 | * |
| 493 | * 1) Fill in the proper Verification Tag in the SCTP common |
| 494 | * header and initialize the checksum field to 0's. |
| 495 | */ |
| 496 | sh->vtag = htonl(packet->vtag); |
| 497 | sh->checksum = 0; |
| 498 | |
Daniel Borkmann | bb33381 | 2013-06-28 19:49:40 +0200 | [diff] [blame] | 499 | pr_debug("***sctp_transmit_packet***\n"); |
| 500 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 501 | do { |
| 502 | /* Set up convenience variables... */ |
| 503 | chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list); |
| 504 | pktcount++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 506 | /* Calculate packet size, so it fits in PMTU. Leave |
| 507 | * other chunks for the next packets. |
| 508 | */ |
| 509 | if (gso) { |
| 510 | pkt_size = packet->overhead; |
| 511 | list_for_each_entry(chunk, &packet->chunk_list, list) { |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 512 | int padded = SCTP_PAD4(chunk->skb->len); |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 513 | |
Xin Long | ecc515d | 2016-10-24 01:01:09 +0800 | [diff] [blame] | 514 | if (chunk == packet->auth) |
| 515 | auth_len = padded; |
| 516 | else if (auth_len + padded + packet->overhead > |
| 517 | tp->pathmtu) |
| 518 | goto nomem; |
| 519 | else if (pkt_size + padded > tp->pathmtu) |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 520 | break; |
| 521 | pkt_size += padded; |
Neil Horman | d8dd157 | 2009-11-23 15:54:00 -0500 | [diff] [blame] | 522 | } |
Xufeng Zhang | 6eabca5 | 2013-11-25 11:26:57 +0800 | [diff] [blame] | 523 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 524 | /* Allocate a new skb. */ |
| 525 | nskb = alloc_skb(pkt_size + MAX_HEADER, gfp); |
| 526 | if (!nskb) |
| 527 | goto nomem; |
| 528 | |
| 529 | /* Make sure the outbound skb has enough header |
| 530 | * room reserved. |
| 531 | */ |
| 532 | skb_reserve(nskb, packet->overhead + MAX_HEADER); |
| 533 | } else { |
| 534 | nskb = head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | } |
| 536 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 537 | /** |
| 538 | * 3.2 Chunk Field Descriptions |
| 539 | * |
| 540 | * The total length of a chunk (including Type, Length and |
| 541 | * Value fields) MUST be a multiple of 4 bytes. If the length |
| 542 | * of the chunk is not a multiple of 4 bytes, the sender MUST |
| 543 | * pad the chunk with all zero bytes and this padding is not |
| 544 | * included in the chunk length field. The sender should |
| 545 | * never pad with more than 3 bytes. |
| 546 | * |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 547 | * [This whole comment explains SCTP_PAD4() below.] |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 548 | */ |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 549 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 550 | pkt_size -= packet->overhead; |
| 551 | list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { |
| 552 | list_del_init(&chunk->list); |
| 553 | if (sctp_chunk_is_data(chunk)) { |
| 554 | /* 6.3.1 C4) When data is in flight and when allowed |
| 555 | * by rule C5, a new RTT measurement MUST be made each |
| 556 | * round trip. Furthermore, new RTT measurements |
| 557 | * SHOULD be made no more than once per round-trip |
| 558 | * for a given destination transport address. |
| 559 | */ |
| 560 | |
| 561 | if (!chunk->resent && !tp->rto_pending) { |
| 562 | chunk->rtt_in_progress = 1; |
| 563 | tp->rto_pending = 1; |
| 564 | } |
| 565 | |
| 566 | has_data = 1; |
| 567 | } |
| 568 | |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 569 | padding = SCTP_PAD4(chunk->skb->len) - chunk->skb->len; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 570 | if (padding) |
| 571 | memset(skb_put(chunk->skb, padding), 0, padding); |
| 572 | |
| 573 | /* if this is the auth chunk that we are adding, |
| 574 | * store pointer where it will be added and put |
| 575 | * the auth into the packet. |
| 576 | */ |
| 577 | if (chunk == packet->auth) |
| 578 | auth = skb_tail_pointer(nskb); |
| 579 | |
| 580 | memcpy(skb_put(nskb, chunk->skb->len), |
Sridhar Samudrala | 503b55f | 2006-06-17 22:57:28 -0700 | [diff] [blame] | 581 | chunk->skb->data, chunk->skb->len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 583 | pr_debug("*** Chunk:%p[%s] %s 0x%x, length:%d, chunk->skb->len:%d, rtt_in_progress:%d\n", |
| 584 | chunk, |
| 585 | sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)), |
| 586 | chunk->has_tsn ? "TSN" : "No TSN", |
| 587 | chunk->has_tsn ? ntohl(chunk->subh.data_hdr->tsn) : 0, |
| 588 | ntohs(chunk->chunk_hdr->length), chunk->skb->len, |
| 589 | chunk->rtt_in_progress); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 591 | /* If this is a control chunk, this is our last |
| 592 | * reference. Free data chunks after they've been |
| 593 | * acknowledged or have failed. |
| 594 | * Re-queue auth chunks if needed. |
| 595 | */ |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 596 | pkt_size -= SCTP_PAD4(chunk->skb->len); |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 597 | |
Marcelo Ricardo Leitner | f1533cc | 2016-07-07 09:39:29 -0300 | [diff] [blame] | 598 | if (!sctp_chunk_is_data(chunk) && chunk != packet->auth) |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 599 | sctp_chunk_free(chunk); |
| 600 | |
| 601 | if (!pkt_size) |
| 602 | break; |
| 603 | } |
| 604 | |
| 605 | /* SCTP-AUTH, Section 6.2 |
| 606 | * The sender MUST calculate the MAC as described in RFC2104 [2] |
| 607 | * using the hash function H as described by the MAC Identifier and |
| 608 | * the shared association key K based on the endpoint pair shared key |
| 609 | * described by the shared key identifier. The 'data' used for the |
| 610 | * computation of the AUTH-chunk is given by the AUTH chunk with its |
| 611 | * HMAC field set to zero (as shown in Figure 6) followed by all |
| 612 | * chunks that are placed after the AUTH chunk in the SCTP packet. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 614 | if (auth) |
| 615 | sctp_auth_calculate_hmac(asoc, nskb, |
| 616 | (struct sctp_auth_chunk *)auth, |
| 617 | gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Marcelo Ricardo Leitner | f1533cc | 2016-07-07 09:39:29 -0300 | [diff] [blame] | 619 | if (packet->auth) { |
| 620 | if (!list_empty(&packet->chunk_list)) { |
| 621 | /* We will generate more packets, so re-queue |
| 622 | * auth chunk. |
| 623 | */ |
Xin Long | 1aa25ec | 2016-07-30 13:58:35 +0800 | [diff] [blame] | 624 | list_add(&packet->auth->list, |
| 625 | &packet->chunk_list); |
Marcelo Ricardo Leitner | f1533cc | 2016-07-07 09:39:29 -0300 | [diff] [blame] | 626 | } else { |
| 627 | sctp_chunk_free(packet->auth); |
| 628 | packet->auth = NULL; |
| 629 | } |
| 630 | } |
| 631 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 632 | if (!gso) |
| 633 | break; |
| 634 | |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 635 | if (skb_gro_receive(&head, nskb)) { |
| 636 | kfree_skb(nskb); |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 637 | goto nomem; |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 638 | } |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 639 | nskb = NULL; |
| 640 | if (WARN_ON_ONCE(skb_shinfo(head)->gso_segs >= |
| 641 | sk->sk_gso_max_segs)) |
| 642 | goto nomem; |
| 643 | } while (!list_empty(&packet->chunk_list)); |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 644 | |
| 645 | /* 2) Calculate the Adler-32 checksum of the whole packet, |
| 646 | * including the SCTP common header and all the |
| 647 | * chunks. |
| 648 | * |
| 649 | * Note: Adler-32 is no longer applicable, as has been replaced |
| 650 | * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>. |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 651 | * |
| 652 | * If it's a GSO packet, it's postponed to sctp_skb_segment. |
Vlad Yasevich | 4cd57c8 | 2007-09-16 19:32:45 -0700 | [diff] [blame] | 653 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 654 | if (!sctp_checksum_disable || gso) { |
| 655 | if (!gso && (!(dst->dev->features & NETIF_F_SCTP_CRC) || |
| 656 | dst_xfrm(dst) || packet->ipfragok)) { |
| 657 | sh->checksum = sctp_compute_cksum(head, 0); |
Michał Mirosław | b73c43f | 2011-07-13 14:10:29 +0000 | [diff] [blame] | 658 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 659 | /* no need to seed pseudo checksum for SCTP */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 660 | head->ip_summed = CHECKSUM_PARTIAL; |
| 661 | head->csum_start = skb_transport_header(head) - head->head; |
| 662 | head->csum_offset = offsetof(struct sctphdr, checksum); |
Jesse Brandeburg | 8dc92f7 | 2009-04-27 22:35:52 +0000 | [diff] [blame] | 663 | } |
| 664 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | /* IP layer ECN support |
| 667 | * From RFC 2481 |
| 668 | * "The ECN-Capable Transport (ECT) bit would be set by the |
| 669 | * data sender to indicate that the end-points of the |
| 670 | * transport protocol are ECN-capable." |
| 671 | * |
| 672 | * Now setting the ECT bit all the time, as it should not cause |
| 673 | * any problems protocol-wise even if our peer ignores it. |
| 674 | * |
| 675 | * Note: The works for IPv6 layer checks this bit too later |
| 676 | * in transmission. See IP6_ECN_flow_xmit(). |
| 677 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 678 | tp->af_specific->ecn_capable(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | /* Set up the IP options. */ |
| 681 | /* BUG: not implemented |
| 682 | * For v4 this all lives somewhere in sk->sk_opt... |
| 683 | */ |
| 684 | |
| 685 | /* Dump that on IP! */ |
Michele Baldessari | 196d675 | 2012-12-01 04:49:42 +0000 | [diff] [blame] | 686 | if (asoc) { |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 687 | asoc->stats.opackets += pktcount; |
Michele Baldessari | 196d675 | 2012-12-01 04:49:42 +0000 | [diff] [blame] | 688 | if (asoc->peer.last_sent_to != tp) |
| 689 | /* Considering the multiple CPU scenario, this is a |
| 690 | * "correcter" place for last_sent_to. --xguo |
| 691 | */ |
| 692 | asoc->peer.last_sent_to = tp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | if (has_data) { |
| 696 | struct timer_list *timer; |
| 697 | unsigned long timeout; |
| 698 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | /* Restart the AUTOCLOSE timer when sending data. */ |
Neil Horman | 9f70f46 | 2013-12-10 06:48:15 -0500 | [diff] [blame] | 700 | if (sctp_state(asoc, ESTABLISHED) && |
| 701 | asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | timer = &asoc->timers[SCTP_EVENT_TIMEOUT_AUTOCLOSE]; |
| 703 | timeout = asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]; |
| 704 | |
| 705 | if (!mod_timer(timer, jiffies + timeout)) |
| 706 | sctp_association_hold(asoc); |
| 707 | } |
| 708 | } |
| 709 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 710 | pr_debug("***sctp_transmit_packet*** skb->len:%d\n", head->len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 712 | if (gso) { |
| 713 | /* Cleanup our debris for IP stacks */ |
| 714 | memset(head->cb, 0, max(sizeof(struct inet_skb_parm), |
| 715 | sizeof(struct inet6_skb_parm))); |
| 716 | |
| 717 | skb_shinfo(head)->gso_segs = pktcount; |
| 718 | skb_shinfo(head)->gso_size = GSO_BY_FRAGS; |
| 719 | |
| 720 | /* We have to refresh this in case we are xmiting to |
| 721 | * more than one transport at a time |
| 722 | */ |
| 723 | rcu_read_lock(); |
| 724 | if (__sk_dst_get(sk) != tp->dst) { |
| 725 | dst_hold(tp->dst); |
| 726 | sk_setup_caps(sk, tp->dst); |
| 727 | } |
| 728 | rcu_read_unlock(); |
| 729 | } |
| 730 | head->ignore_df = packet->ipfragok; |
| 731 | tp->af_specific->sctp_xmit(head, tp); |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 732 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 734 | nomem: |
| 735 | if (packet->auth && list_empty(&packet->auth->list)) |
| 736 | sctp_chunk_free(packet->auth); |
Alexander Sverdlin | 29c4afc | 2015-06-29 10:41:03 +0200 | [diff] [blame] | 737 | |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 738 | nodst: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | /* FIXME: Returning the 'err' will effect all the associations |
| 740 | * associated with a socket, although only one of the paths of the |
| 741 | * association is unreachable. |
| 742 | * The real failure of a transport or association can be passed on |
| 743 | * to the user via notifications. So setting this error may not be |
| 744 | * required. |
| 745 | */ |
| 746 | /* err = -EHOSTUNREACH; */ |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 747 | kfree_skb(head); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 749 | err: |
David S. Miller | 79af02c | 2005-07-08 21:47:49 -0700 | [diff] [blame] | 750 | list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { |
| 751 | list_del_init(&chunk->list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | if (!sctp_chunk_is_data(chunk)) |
YOSHIFUJI Hideaki | d808ad9 | 2007-02-09 23:25:18 +0900 | [diff] [blame] | 753 | sctp_chunk_free(chunk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | } |
Xin Long | 41001fa | 2016-09-14 02:04:23 +0800 | [diff] [blame] | 755 | |
| 756 | out: |
| 757 | sctp_packet_reset(packet); |
| 758 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | /******************************************************************** |
| 762 | * 2nd Level Abstractions |
| 763 | ********************************************************************/ |
| 764 | |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 765 | /* This private function check to see if a chunk can be added */ |
| 766 | static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | struct sctp_chunk *chunk) |
| 768 | { |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 769 | size_t datasize, rwnd, inflight, flight_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | struct sctp_transport *transport = packet->transport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | struct sctp_association *asoc = transport->asoc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | struct sctp_outq *q = &asoc->outqueue; |
| 773 | |
| 774 | /* RFC 2960 6.1 Transmission of DATA Chunks |
| 775 | * |
| 776 | * A) At any given time, the data sender MUST NOT transmit new data to |
| 777 | * any destination transport address if its peer's rwnd indicates |
| 778 | * that the peer has no buffer space (i.e. rwnd is 0, see Section |
| 779 | * 6.2.1). However, regardless of the value of rwnd (including if it |
| 780 | * is 0), the data sender can always have one DATA chunk in flight to |
| 781 | * the receiver if allowed by cwnd (see rule B below). This rule |
| 782 | * allows the sender to probe for a change in rwnd that the sender |
| 783 | * missed due to the SACK having been lost in transit from the data |
| 784 | * receiver to the data sender. |
| 785 | */ |
| 786 | |
| 787 | rwnd = asoc->peer.rwnd; |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 788 | inflight = q->outstanding_bytes; |
| 789 | flight_size = transport->flight_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
| 791 | datasize = sctp_data_size(chunk); |
| 792 | |
David Laight | 723189f | 2014-07-22 08:59:08 +0000 | [diff] [blame] | 793 | if (datasize > rwnd && inflight > 0) |
| 794 | /* We have (at least) one data chunk in flight, |
| 795 | * so we can't fall back to rule 6.1 B). |
| 796 | */ |
| 797 | return SCTP_XMIT_RWND_FULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | /* RFC 2960 6.1 Transmission of DATA Chunks |
| 800 | * |
| 801 | * B) At any given time, the sender MUST NOT transmit new data |
| 802 | * to a given transport address if it has cwnd or more bytes |
| 803 | * of data outstanding to that transport address. |
| 804 | */ |
| 805 | /* RFC 7.2.4 & the Implementers Guide 2.8. |
| 806 | * |
| 807 | * 3) ... |
| 808 | * When a Fast Retransmit is being performed the sender SHOULD |
| 809 | * ignore the value of cwnd and SHOULD NOT delay retransmission. |
| 810 | */ |
David Laight | 723189f | 2014-07-22 08:59:08 +0000 | [diff] [blame] | 811 | if (chunk->fast_retransmit != SCTP_NEED_FRTX && |
| 812 | flight_size >= transport->cwnd) |
| 813 | return SCTP_XMIT_RWND_FULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
| 815 | /* Nagle's algorithm to solve small-packet problem: |
| 816 | * Inhibit the sending of new chunks when new outgoing data arrives |
| 817 | * if any previously transmitted data on the connection remains |
| 818 | * unacknowledged. |
| 819 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
David Laight | 723189f | 2014-07-22 08:59:08 +0000 | [diff] [blame] | 821 | if (sctp_sk(asoc->base.sk)->nodelay) |
| 822 | /* Nagle disabled */ |
| 823 | return SCTP_XMIT_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | |
David Laight | 723189f | 2014-07-22 08:59:08 +0000 | [diff] [blame] | 825 | if (!sctp_packet_empty(packet)) |
| 826 | /* Append to packet */ |
| 827 | return SCTP_XMIT_OK; |
| 828 | |
| 829 | if (inflight == 0) |
| 830 | /* Nothing unacked */ |
| 831 | return SCTP_XMIT_OK; |
| 832 | |
| 833 | if (!sctp_state(asoc, ESTABLISHED)) |
| 834 | return SCTP_XMIT_OK; |
| 835 | |
| 836 | /* Check whether this chunk and all the rest of pending data will fit |
| 837 | * or delay in hopes of bundling a full sized packet. |
| 838 | */ |
Marcelo Ricardo Leitner | e43569e | 2016-04-01 14:05:48 -0300 | [diff] [blame] | 839 | if (chunk->skb->len + q->out_qlen > |
| 840 | transport->pathmtu - packet->overhead - sizeof(sctp_data_chunk_t) - 4) |
David Laight | 723189f | 2014-07-22 08:59:08 +0000 | [diff] [blame] | 841 | /* Enough data queued to fill a packet */ |
| 842 | return SCTP_XMIT_OK; |
| 843 | |
| 844 | /* Don't delay large message writes that may have been fragmented */ |
| 845 | if (!chunk->msg->can_delay) |
| 846 | return SCTP_XMIT_OK; |
| 847 | |
| 848 | /* Defer until all data acked or packet full */ |
David Laight | 526cbef | 2014-07-22 08:59:14 +0000 | [diff] [blame] | 849 | return SCTP_XMIT_DELAY; |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | /* This private function does management things when adding DATA chunk */ |
| 853 | static void sctp_packet_append_data(struct sctp_packet *packet, |
| 854 | struct sctp_chunk *chunk) |
| 855 | { |
| 856 | struct sctp_transport *transport = packet->transport; |
| 857 | size_t datasize = sctp_data_size(chunk); |
| 858 | struct sctp_association *asoc = transport->asoc; |
| 859 | u32 rwnd = asoc->peer.rwnd; |
| 860 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | /* Keep track of how many bytes are in flight over this transport. */ |
| 862 | transport->flight_size += datasize; |
| 863 | |
| 864 | /* Keep track of how many bytes are in flight to the receiver. */ |
| 865 | asoc->outqueue.outstanding_bytes += datasize; |
| 866 | |
Thomas Graf | a76c0ad | 2011-12-19 04:11:40 +0000 | [diff] [blame] | 867 | /* Update our view of the receiver's rwnd. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | if (datasize < rwnd) |
| 869 | rwnd -= datasize; |
| 870 | else |
| 871 | rwnd = 0; |
| 872 | |
| 873 | asoc->peer.rwnd = rwnd; |
| 874 | /* Has been accepted for transmission. */ |
| 875 | if (!asoc->peer.prsctp_capable) |
| 876 | chunk->msg->can_abandon = 0; |
Neil Horman | d8dd157 | 2009-11-23 15:54:00 -0500 | [diff] [blame] | 877 | sctp_chunk_assign_tsn(chunk); |
| 878 | sctp_chunk_assign_ssn(chunk); |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 879 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 881 | static sctp_xmit_t sctp_packet_will_fit(struct sctp_packet *packet, |
| 882 | struct sctp_chunk *chunk, |
| 883 | u16 chunk_len) |
| 884 | { |
Marcelo Ricardo Leitner | 7303a14 | 2016-09-08 17:54:11 +0800 | [diff] [blame] | 885 | size_t psize, pmtu, maxsize; |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 886 | sctp_xmit_t retval = SCTP_XMIT_OK; |
| 887 | |
| 888 | psize = packet->size; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 889 | if (packet->transport->asoc) |
| 890 | pmtu = packet->transport->asoc->pathmtu; |
| 891 | else |
| 892 | pmtu = packet->transport->pathmtu; |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 893 | |
| 894 | /* Decide if we need to fragment or resubmit later. */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 895 | if (psize + chunk_len > pmtu) { |
| 896 | /* It's OK to fragment at IP level if any one of the following |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 897 | * is true: |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 898 | * 1. The packet is empty (meaning this chunk is greater |
| 899 | * the MTU) |
| 900 | * 2. The packet doesn't have any data in it yet and data |
| 901 | * requires authentication. |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 902 | */ |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 903 | if (sctp_packet_empty(packet) || |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 904 | (!packet->has_data && chunk->auth)) { |
| 905 | /* We no longer do re-fragmentation. |
| 906 | * Just fragment at the IP layer, if we |
| 907 | * actually hit this condition |
| 908 | */ |
| 909 | packet->ipfragok = 1; |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 910 | goto out; |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 911 | } |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 912 | |
Marcelo Ricardo Leitner | 7303a14 | 2016-09-08 17:54:11 +0800 | [diff] [blame] | 913 | /* Similarly, if this chunk was built before a PMTU |
| 914 | * reduction, we have to fragment it at IP level now. So |
| 915 | * if the packet already contains something, we need to |
| 916 | * flush. |
| 917 | */ |
| 918 | maxsize = pmtu - packet->overhead; |
| 919 | if (packet->auth) |
Marcelo Ricardo Leitner | e2f036a | 2016-09-21 08:45:55 -0300 | [diff] [blame] | 920 | maxsize -= SCTP_PAD4(packet->auth->skb->len); |
Marcelo Ricardo Leitner | 7303a14 | 2016-09-08 17:54:11 +0800 | [diff] [blame] | 921 | if (chunk_len > maxsize) |
| 922 | retval = SCTP_XMIT_PMTU_FULL; |
| 923 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 924 | /* It is also okay to fragment if the chunk we are |
| 925 | * adding is a control chunk, but only if current packet |
| 926 | * is not a GSO one otherwise it causes fragmentation of |
| 927 | * a large frame. So in this case we allow the |
| 928 | * fragmentation by forcing it to be in a new packet. |
| 929 | */ |
| 930 | if (!sctp_chunk_is_data(chunk) && packet->has_data) |
| 931 | retval = SCTP_XMIT_PMTU_FULL; |
| 932 | |
| 933 | if (psize + chunk_len > packet->max_size) |
| 934 | /* Hit GSO/PMTU limit, gotta flush */ |
| 935 | retval = SCTP_XMIT_PMTU_FULL; |
| 936 | |
| 937 | if (!packet->transport->burst_limited && |
| 938 | psize + chunk_len > (packet->transport->cwnd >> 1)) |
| 939 | /* Do not allow a single GSO packet to use more |
| 940 | * than half of cwnd. |
| 941 | */ |
| 942 | retval = SCTP_XMIT_PMTU_FULL; |
| 943 | |
| 944 | if (packet->transport->burst_limited && |
| 945 | psize + chunk_len > (packet->transport->burst_limited >> 1)) |
| 946 | /* Do not allow a single GSO packet to use more |
| 947 | * than half of original cwnd. |
| 948 | */ |
| 949 | retval = SCTP_XMIT_PMTU_FULL; |
| 950 | /* Otherwise it will fit in the GSO packet */ |
Vlad Yasevich | e83963b | 2009-08-07 10:43:07 -0400 | [diff] [blame] | 951 | } |
| 952 | |
Marcelo Ricardo Leitner | 90017ac | 2016-06-02 15:05:43 -0300 | [diff] [blame] | 953 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | return retval; |
| 955 | } |