Lines Matching defs: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;
124 sctp_packet_append_chunk(packet, chunk);
130 /* set packet max_size with gso_max_size if gso is enabled*/
136 packet->max_size = sk_can_gso(sk) ? tp->dst->dev->gso_max_size
141 /* Initialize the packet structure. */
142 void sctp_packet_init(struct sctp_packet *packet,
146 pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport);
148 packet->transport = transport;
149 packet->source_port = sport;
150 packet->destination_port = dport;
151 INIT_LIST_HEAD(&packet->chunk_list);
153 packet->overhead = 0;
154 sctp_packet_reset(packet);
155 packet->vtag = 0;
158 /* Free a packet. */
159 void sctp_packet_free(struct sctp_packet *packet)
163 pr_debug("%s: packet:%p\n", __func__, packet);
165 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
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.
178 enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet,
184 pr_debug("%s: packet:%p size:%zu chunk:%p size:%d\n", __func__,
185 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1);
187 switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) {
189 if (!packet->has_cookie_echo) {
192 error = sctp_packet_transmit(packet, gfp);
196 /* If we have an empty packet, then we can NOT ever
200 retval = sctp_packet_append_chunk(packet,
214 /* Try to bundle an auth chunk into the packet. */
253 /* Try to bundle a SACK with the packet. */
260 * bundle one in to the packet.
299 /* Append a chunk to the offered packet reporting back any inability to do
302 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet,
308 /* Check to see if this chunk will fit into the packet */
309 retval = sctp_packet_will_fit(packet, chunk, chunk_len);
313 /* We believe that this chunk is OK to add to the packet */
317 /* Account for the data being in the packet */
318 sctp_packet_append_data(packet, chunk);
320 packet->has_sack = 1;
322 packet->has_auth = 1;
323 /* Let it be knows that packet has DATA in it */
324 packet->has_data = 1;
331 packet->has_cookie_echo = 1;
335 packet->has_sack = 1;
341 packet->has_auth = 1;
342 packet->auth = chunk;
347 list_add_tail(&chunk->list, &packet->chunk_list);
348 packet->size += chunk_len;
349 chunk->transport = packet->transport;
354 /* Append a chunk to the offered packet reporting back any inability to do
357 enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet,
362 pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk);
365 * bundle into this packet, check to see if we are allowed to
369 retval = sctp_packet_can_append_data(packet, chunk);
375 retval = sctp_packet_bundle_auth(packet, chunk);
380 retval = sctp_packet_bundle_sack(packet, chunk);
384 retval = __sctp_packet_append_chunk(packet, chunk);
406 static int sctp_packet_pack(struct sctp_packet *packet,
409 struct sctp_transport *tp = packet->transport;
422 pkt_size = packet->size;
428 pkt_size = packet->overhead;
429 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list,
433 if (chunk == packet->auth)
435 else if (auth_len + padded + packet->overhead >
445 skb_reserve(nskb, packet->overhead + MAX_HEADER);
449 pkt_size -= packet->overhead;
450 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
466 if (chunk == packet->auth)
482 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth)
491 packet->auth->shkey, gfp);
493 if (list_empty(&packet->chunk_list))
494 sctp_chunk_free(packet->auth);
496 list_add(&packet->auth->list,
497 &packet->chunk_list);
504 } while (!list_empty(&packet->chunk_list));
524 dst_xfrm(skb_dst(head)) || packet->ipfragok) {
545 int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
547 struct sctp_transport *tp = packet->transport;
556 pr_debug("%s: packet:%p\n", __func__, packet);
557 if (list_empty(&packet->chunk_list))
559 chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list);
563 if (packet->size > tp->pathmtu && !packet->ipfragok) {
572 head = alloc_skb((gso ? packet->overhead : packet->size) +
576 skb_reserve(head, packet->overhead + MAX_HEADER);
582 sh->source = htons(packet->source_port);
583 sh->dest = htons(packet->destination_port);
584 sh->vtag = htonl(packet->vtag);
587 /* drop packet if no dst */
597 pkt_count = sctp_packet_pack(packet, head, gso, gfp);
605 if (packet->has_data && sctp_state(asoc, ESTABLISHED) &&
623 head->ignore_df = packet->ipfragok;
634 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
639 sctp_packet_reset(packet);
648 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet,
652 struct sctp_transport *transport = packet->transport;
697 /* Nagle's algorithm to solve small-packet problem:
708 if (!sctp_packet_empty(packet))
709 /* Append to packet */
716 * or delay in hopes of bundling a full sized packet.
719 packet->overhead - sctp_datachk_len(&chunk->asoc->stream) - 4)
720 /* Enough data queued to fill a packet */
727 /* Defer until all data acked or packet full */
732 static void sctp_packet_append_data(struct sctp_packet *packet,
735 struct sctp_transport *transport = packet->transport;
757 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet,
764 /* Don't bundle in this packet if this chunk's auth key doesn't
765 * match other chunks already enqueued on this packet. Also,
767 * packet don't have auth key.
769 if ((packet->auth && chunk->shkey != packet->auth->shkey) ||
770 (!packet->auth && chunk->shkey &&
774 psize = packet->size;
775 if (packet->transport->asoc)
776 pmtu = packet->transport->asoc->pathmtu;
778 pmtu = packet->transport->pathmtu;
784 * 1. The packet is empty (meaning this chunk is greater
786 * 2. The packet doesn't have any data in it yet and data
789 if (sctp_packet_empty(packet) ||
790 (!packet->has_data && chunk->auth)) {
795 packet->ipfragok = 1;
801 * if the packet already contains something, we need to
804 maxsize = pmtu - packet->overhead;
805 if (packet->auth)
806 maxsize -= SCTP_PAD4(packet->auth->skb->len);
811 * adding is a control chunk, but only if current packet
814 * fragmentation by forcing it to be in a new packet.
816 if (!sctp_chunk_is_data(chunk) && packet->has_data)
819 if (psize + chunk_len > packet->max_size)
823 if (!packet->transport->burst_limited &&
824 psize + chunk_len > (packet->transport->cwnd >> 1))
825 /* Do not allow a single GSO packet to use more
830 if (packet->transport->burst_limited &&
831 psize + chunk_len > (packet->transport->burst_limited >> 1))
832 /* Do not allow a single GSO packet to use more
836 /* Otherwise it will fit in the GSO packet */