Lines Matching full: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) in sctp_packet_reset() argument
60 packet->size = packet->overhead; in sctp_packet_reset()
62 packet->has_cookie_echo = 0; in sctp_packet_reset()
63 packet->has_sack = 0; in sctp_packet_reset()
64 packet->has_data = 0; in sctp_packet_reset()
65 packet->has_auth = 0; in sctp_packet_reset()
66 packet->ipfragok = 0; in sctp_packet_reset()
67 packet->auth = NULL; in sctp_packet_reset()
70 /* Config a packet.
73 void sctp_packet_config(struct sctp_packet *packet, __u32 vtag, in sctp_packet_config() argument
76 struct sctp_transport *tp = packet->transport; in sctp_packet_config()
81 pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag); in sctp_packet_config()
82 packet->vtag = vtag; in sctp_packet_config()
85 if (!sctp_packet_empty(packet)) in sctp_packet_config()
88 /* set packet max_size with pathmtu, then calculate overhead */ in sctp_packet_config()
89 packet->max_size = tp->pathmtu; in sctp_packet_config()
95 packet->overhead = sctp_mtu_payload(sp, 0, 0); in sctp_packet_config()
96 packet->size = packet->overhead; in sctp_packet_config()
125 sctp_packet_append_chunk(packet, chunk); in sctp_packet_config()
131 /* set packet max_size with gso_max_size if gso is enabled*/ in sctp_packet_config()
137 packet->max_size = sk_can_gso(sk) ? tp->dst->dev->gso_max_size in sctp_packet_config()
142 /* Initialize the packet structure. */
143 void sctp_packet_init(struct sctp_packet *packet, in sctp_packet_init() argument
147 pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport); in sctp_packet_init()
149 packet->transport = transport; in sctp_packet_init()
150 packet->source_port = sport; in sctp_packet_init()
151 packet->destination_port = dport; in sctp_packet_init()
152 INIT_LIST_HEAD(&packet->chunk_list); in sctp_packet_init()
154 packet->overhead = 0; in sctp_packet_init()
155 sctp_packet_reset(packet); in sctp_packet_init()
156 packet->vtag = 0; in sctp_packet_init()
159 /* Free a packet. */
160 void sctp_packet_free(struct sctp_packet *packet) in sctp_packet_free() argument
164 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_free()
166 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_free()
172 /* This routine tries to append the chunk to the offered packet. If adding
173 * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO chunk
174 * is not present in the packet, it transmits the input packet.
175 * Data can be bundled with a packet containing a COOKIE_ECHO chunk as long
176 * as it can fit in the packet, but any more data that does not fit in this
177 * packet can be sent only after receiving the COOKIE_ACK.
179 enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet, in sctp_packet_transmit_chunk() argument
185 pr_debug("%s: packet:%p size:%zu chunk:%p size:%d\n", __func__, in sctp_packet_transmit_chunk()
186 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1); in sctp_packet_transmit_chunk()
188 switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) { in sctp_packet_transmit_chunk()
190 if (!packet->has_cookie_echo) { in sctp_packet_transmit_chunk()
193 error = sctp_packet_transmit(packet, gfp); in sctp_packet_transmit_chunk()
197 /* If we have an empty packet, then we can NOT ever in sctp_packet_transmit_chunk()
201 retval = sctp_packet_append_chunk(packet, in sctp_packet_transmit_chunk()
215 /* Try to bundle a pad chunk into a packet with a heartbeat chunk for PLPMTUTD probe */
239 /* Try to bundle an auth chunk into the packet. */
278 /* Try to bundle a SACK with the packet. */
285 * bundle one in to the packet. in sctp_packet_bundle_sack()
324 /* Append a chunk to the offered packet reporting back any inability to do
327 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet, in __sctp_packet_append_chunk() argument
333 /* Check to see if this chunk will fit into the packet */ in __sctp_packet_append_chunk()
334 retval = sctp_packet_will_fit(packet, chunk, chunk_len); in __sctp_packet_append_chunk()
338 /* We believe that this chunk is OK to add to the packet */ in __sctp_packet_append_chunk()
342 /* Account for the data being in the packet */ in __sctp_packet_append_chunk()
343 sctp_packet_append_data(packet, chunk); in __sctp_packet_append_chunk()
345 packet->has_sack = 1; in __sctp_packet_append_chunk()
347 packet->has_auth = 1; in __sctp_packet_append_chunk()
348 /* Let it be knows that packet has DATA in it */ in __sctp_packet_append_chunk()
349 packet->has_data = 1; in __sctp_packet_append_chunk()
356 packet->has_cookie_echo = 1; in __sctp_packet_append_chunk()
360 packet->has_sack = 1; in __sctp_packet_append_chunk()
366 packet->has_auth = 1; in __sctp_packet_append_chunk()
367 packet->auth = chunk; in __sctp_packet_append_chunk()
372 list_add_tail(&chunk->list, &packet->chunk_list); in __sctp_packet_append_chunk()
373 packet->size += chunk_len; in __sctp_packet_append_chunk()
374 chunk->transport = packet->transport; in __sctp_packet_append_chunk()
379 /* Append a chunk to the offered packet reporting back any inability to do
382 enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet, in sctp_packet_append_chunk() argument
387 pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk); in sctp_packet_append_chunk()
390 * bundle into this packet, check to see if we are allowed to in sctp_packet_append_chunk()
394 retval = sctp_packet_can_append_data(packet, chunk); in sctp_packet_append_chunk()
400 retval = sctp_packet_bundle_auth(packet, chunk); in sctp_packet_append_chunk()
405 retval = sctp_packet_bundle_sack(packet, chunk); in sctp_packet_append_chunk()
409 retval = __sctp_packet_append_chunk(packet, chunk); in sctp_packet_append_chunk()
413 retval = sctp_packet_bundle_pad(packet, chunk); in sctp_packet_append_chunk()
435 static int sctp_packet_pack(struct sctp_packet *packet, in sctp_packet_pack() argument
438 struct sctp_transport *tp = packet->transport; in sctp_packet_pack()
451 pkt_size = packet->size; in sctp_packet_pack()
457 pkt_size = packet->overhead; in sctp_packet_pack()
458 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, in sctp_packet_pack()
462 if (chunk == packet->auth) in sctp_packet_pack()
464 else if (auth_len + padded + packet->overhead > in sctp_packet_pack()
474 skb_reserve(nskb, packet->overhead + MAX_HEADER); in sctp_packet_pack()
478 pkt_size -= packet->overhead; in sctp_packet_pack()
479 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_pack()
495 if (chunk == packet->auth) in sctp_packet_pack()
511 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth) in sctp_packet_pack()
520 packet->auth->shkey, gfp); in sctp_packet_pack()
522 if (list_empty(&packet->chunk_list)) in sctp_packet_pack()
523 sctp_chunk_free(packet->auth); in sctp_packet_pack()
525 list_add(&packet->auth->list, in sctp_packet_pack()
526 &packet->chunk_list); in sctp_packet_pack()
533 } while (!list_empty(&packet->chunk_list)); in sctp_packet_pack()
547 dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) { in sctp_packet_pack()
568 int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) in sctp_packet_transmit() argument
570 struct sctp_transport *tp = packet->transport; in sctp_packet_transmit()
578 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_transmit()
579 if (list_empty(&packet->chunk_list)) in sctp_packet_transmit()
581 chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list); in sctp_packet_transmit()
585 if (packet->size > tp->pathmtu && !packet->ipfragok && !chunk->pmtu_probe) { in sctp_packet_transmit()
594 head = alloc_skb((gso ? packet->overhead : packet->size) + in sctp_packet_transmit()
598 skb_reserve(head, packet->overhead + MAX_HEADER); in sctp_packet_transmit()
604 sh->source = htons(packet->source_port); in sctp_packet_transmit()
605 sh->dest = htons(packet->destination_port); in sctp_packet_transmit()
606 sh->vtag = htonl(packet->vtag); in sctp_packet_transmit()
609 /* drop packet if no dst */ in sctp_packet_transmit()
617 pkt_count = sctp_packet_pack(packet, head, gso, gfp); in sctp_packet_transmit()
625 if (packet->has_data && sctp_state(asoc, ESTABLISHED) && in sctp_packet_transmit()
643 head->ignore_df = packet->ipfragok; in sctp_packet_transmit()
654 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_transmit()
659 sctp_packet_reset(packet); in sctp_packet_transmit()
668 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet, in sctp_packet_can_append_data() argument
672 struct sctp_transport *transport = packet->transport; in sctp_packet_can_append_data()
717 /* Nagle's algorithm to solve small-packet problem: in sctp_packet_can_append_data()
728 if (!sctp_packet_empty(packet)) in sctp_packet_can_append_data()
729 /* Append to packet */ in sctp_packet_can_append_data()
736 * or delay in hopes of bundling a full sized packet. in sctp_packet_can_append_data()
739 packet->overhead - sctp_datachk_len(&chunk->asoc->stream) - 4) in sctp_packet_can_append_data()
740 /* Enough data queued to fill a packet */ in sctp_packet_can_append_data()
747 /* Defer until all data acked or packet full */ in sctp_packet_can_append_data()
752 static void sctp_packet_append_data(struct sctp_packet *packet, in sctp_packet_append_data() argument
755 struct sctp_transport *transport = packet->transport; in sctp_packet_append_data()
777 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet, in sctp_packet_will_fit() argument
784 /* Don't bundle in this packet if this chunk's auth key doesn't in sctp_packet_will_fit()
785 * match other chunks already enqueued on this packet. Also, in sctp_packet_will_fit()
787 * packet don't have auth key. in sctp_packet_will_fit()
789 if ((packet->auth && chunk->shkey != packet->auth->shkey) || in sctp_packet_will_fit()
790 (!packet->auth && chunk->shkey && in sctp_packet_will_fit()
794 psize = packet->size; in sctp_packet_will_fit()
795 if (packet->transport->asoc) in sctp_packet_will_fit()
796 pmtu = packet->transport->asoc->pathmtu; in sctp_packet_will_fit()
798 pmtu = packet->transport->pathmtu; in sctp_packet_will_fit()
804 * 1. The packet is empty (meaning this chunk is greater in sctp_packet_will_fit()
806 * 2. The packet doesn't have any data in it yet and data in sctp_packet_will_fit()
809 if (sctp_packet_empty(packet) || in sctp_packet_will_fit()
810 (!packet->has_data && chunk->auth)) { in sctp_packet_will_fit()
815 packet->ipfragok = 1; in sctp_packet_will_fit()
821 * if the packet already contains something, we need to in sctp_packet_will_fit()
824 maxsize = pmtu - packet->overhead; in sctp_packet_will_fit()
825 if (packet->auth) in sctp_packet_will_fit()
826 maxsize -= SCTP_PAD4(packet->auth->skb->len); in sctp_packet_will_fit()
831 * adding is a control chunk, but only if current packet in sctp_packet_will_fit()
834 * fragmentation by forcing it to be in a new packet. in sctp_packet_will_fit()
836 if (!sctp_chunk_is_data(chunk) && packet->has_data) in sctp_packet_will_fit()
839 if (psize + chunk_len > packet->max_size) in sctp_packet_will_fit()
843 if (!packet->transport->burst_limited && in sctp_packet_will_fit()
844 psize + chunk_len > (packet->transport->cwnd >> 1)) in sctp_packet_will_fit()
845 /* Do not allow a single GSO packet to use more in sctp_packet_will_fit()
850 if (packet->transport->burst_limited && in sctp_packet_will_fit()
851 psize + chunk_len > (packet->transport->burst_limited >> 1)) in sctp_packet_will_fit()
852 /* Do not allow a single GSO packet to use more in sctp_packet_will_fit()
856 /* Otherwise it will fit in the GSO packet */ in sctp_packet_will_fit()