Lines Matching refs:packet
45 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet,
47 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet,
49 static void sctp_packet_append_data(struct sctp_packet *packet,
51 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet,
55 static void sctp_packet_reset(struct sctp_packet *packet)
60 packet->size = packet->overhead;
62 packet->has_cookie_echo = 0;
63 packet->has_sack = 0;
64 packet->has_data = 0;
65 packet->has_auth = 0;
66 packet->ipfragok = 0;
67 packet->auth = NULL;
70 /* Config a packet.
73 void sctp_packet_config(struct sctp_packet *packet, __u32 vtag,
76 struct sctp_transport *tp = packet->transport;
81 pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag);
82 packet->vtag = vtag;
85 if (!sctp_packet_empty(packet))
88 /* set packet max_size with pathmtu, then calculate overhead */
89 packet->max_size = tp->pathmtu;
95 packet->overhead = sctp_mtu_payload(sp, 0, 0);
96 packet->size = packet->overhead;
125 sctp_packet_append_chunk(packet, chunk);
131 /* set packet max_size with gso_max_size if gso is enabled*/
137 packet->max_size = sk_can_gso(sk) ? min(READ_ONCE(tp->dst->dev->gso_max_size),
143 /* Initialize the packet structure. */
144 void sctp_packet_init(struct sctp_packet *packet,
148 pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport);
150 packet->transport = transport;
151 packet->source_port = sport;
152 packet->destination_port = dport;
153 INIT_LIST_HEAD(&packet->chunk_list);
155 packet->overhead = 0;
156 sctp_packet_reset(packet);
157 packet->vtag = 0;
160 /* Free a packet. */
161 void sctp_packet_free(struct sctp_packet *packet)
165 pr_debug("%s: packet:%p\n", __func__, packet);
167 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
173 /* This routine tries to append the chunk to the offered packet. If adding
174 * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO chunk
175 * is not present in the packet, it transmits the input packet.
176 * Data can be bundled with a packet containing a COOKIE_ECHO chunk as long
177 * as it can fit in the packet, but any more data that does not fit in this
178 * packet can be sent only after receiving the COOKIE_ACK.
180 enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet,
186 pr_debug("%s: packet:%p size:%zu chunk:%p size:%d\n", __func__,
187 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1);
189 switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) {
191 if (!packet->has_cookie_echo) {
194 error = sctp_packet_transmit(packet, gfp);
198 /* If we have an empty packet, then we can NOT ever
202 retval = sctp_packet_append_chunk(packet,
216 /* Try to bundle a pad chunk into a packet with a heartbeat chunk for PLPMTUTD probe */
240 /* Try to bundle an auth chunk into the packet. */
279 /* Try to bundle a SACK with the packet. */
286 * bundle one in to the packet.
325 /* Append a chunk to the offered packet reporting back any inability to do
328 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet,
334 /* Check to see if this chunk will fit into the packet */
335 retval = sctp_packet_will_fit(packet, chunk, chunk_len);
339 /* We believe that this chunk is OK to add to the packet */
343 /* Account for the data being in the packet */
344 sctp_packet_append_data(packet, chunk);
346 packet->has_sack = 1;
348 packet->has_auth = 1;
349 /* Let it be knows that packet has DATA in it */
350 packet->has_data = 1;
357 packet->has_cookie_echo = 1;
361 packet->has_sack = 1;
367 packet->has_auth = 1;
368 packet->auth = chunk;
373 list_add_tail(&chunk->list, &packet->chunk_list);
374 packet->size += chunk_len;
375 chunk->transport = packet->transport;
380 /* Append a chunk to the offered packet reporting back any inability to do
383 enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet,
388 pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk);
391 * bundle into this packet, check to see if we are allowed to
395 retval = sctp_packet_can_append_data(packet, chunk);
401 retval = sctp_packet_bundle_auth(packet, chunk);
406 retval = sctp_packet_bundle_sack(packet, chunk);
410 retval = __sctp_packet_append_chunk(packet, chunk);
414 retval = sctp_packet_bundle_pad(packet, chunk);
436 static int sctp_packet_pack(struct sctp_packet *packet,
439 struct sctp_transport *tp = packet->transport;
452 pkt_size = packet->size;
458 pkt_size = packet->overhead;
459 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list,
463 if (chunk == packet->auth)
465 else if (auth_len + padded + packet->overhead >
475 skb_reserve(nskb, packet->overhead + MAX_HEADER);
479 pkt_size -= packet->overhead;
480 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
496 if (chunk == packet->auth)
512 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth)
521 packet->auth->shkey, gfp);
523 if (list_empty(&packet->chunk_list))
524 sctp_chunk_free(packet->auth);
526 list_add(&packet->auth->list,
527 &packet->chunk_list);
534 } while (!list_empty(&packet->chunk_list));
548 dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) {
569 int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
571 struct sctp_transport *tp = packet->transport;
579 pr_debug("%s: packet:%p\n", __func__, packet);
580 if (list_empty(&packet->chunk_list))
582 chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list);
585 if (packet->size > tp->pathmtu && !packet->ipfragok && !chunk->pmtu_probe) {
587 packet->ipfragok = 1;
598 head = alloc_skb((gso ? packet->overhead : packet->size) +
602 skb_reserve(head, packet->overhead + MAX_HEADER);
608 sh->source = htons(packet->source_port);
609 sh->dest = htons(packet->destination_port);
610 sh->vtag = htonl(packet->vtag);
613 /* drop packet if no dst */
621 pkt_count = sctp_packet_pack(packet, head, gso, gfp);
629 if (packet->has_data && sctp_state(asoc, ESTABLISHED) &&
647 head->ignore_df = packet->ipfragok;
658 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
663 sctp_packet_reset(packet);
672 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet,
676 struct sctp_transport *transport = packet->transport;
721 /* Nagle's algorithm to solve small-packet problem:
732 if (!sctp_packet_empty(packet))
733 /* Append to packet */
740 * or delay in hopes of bundling a full sized packet.
743 packet->overhead - sctp_datachk_len(&chunk->asoc->stream) - 4)
744 /* Enough data queued to fill a packet */
751 /* Defer until all data acked or packet full */
756 static void sctp_packet_append_data(struct sctp_packet *packet,
759 struct sctp_transport *transport = packet->transport;
781 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet,
788 /* Don't bundle in this packet if this chunk's auth key doesn't
789 * match other chunks already enqueued on this packet. Also,
791 * packet don't have auth key.
793 if ((packet->auth && chunk->shkey != packet->auth->shkey) ||
794 (!packet->auth && chunk->shkey &&
798 psize = packet->size;
799 if (packet->transport->asoc)
800 pmtu = packet->transport->asoc->pathmtu;
802 pmtu = packet->transport->pathmtu;
808 * 1. The packet is empty (meaning this chunk is greater
810 * 2. The packet doesn't have any data in it yet and data
813 if (sctp_packet_empty(packet) ||
814 (!packet->has_data && chunk->auth)) {
819 packet->ipfragok = 1;
825 * if the packet already contains something, we need to
828 maxsize = pmtu - packet->overhead;
829 if (packet->auth)
830 maxsize -= SCTP_PAD4(packet->auth->skb->len);
835 * adding is a control chunk, but only if current packet
838 * fragmentation by forcing it to be in a new packet.
840 if (!sctp_chunk_is_data(chunk) && packet->has_data)
843 if (psize + chunk_len > packet->max_size)
847 if (!packet->transport->burst_limited &&
848 psize + chunk_len > (packet->transport->cwnd >> 1))
849 /* Do not allow a single GSO packet to use more
854 if (packet->transport->burst_limited &&
855 psize + chunk_len > (packet->transport->burst_limited >> 1))
856 /* Do not allow a single GSO packet to use more
860 /* Otherwise it will fit in the GSO packet */