• Home
  • Raw
  • Download

Lines Matching full:packet

60 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet,
62 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet,
64 static void sctp_packet_append_data(struct sctp_packet *packet,
66 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet,
70 static void sctp_packet_reset(struct sctp_packet *packet) in sctp_packet_reset() argument
75 packet->size = packet->overhead; in sctp_packet_reset()
77 packet->has_cookie_echo = 0; in sctp_packet_reset()
78 packet->has_sack = 0; in sctp_packet_reset()
79 packet->has_data = 0; in sctp_packet_reset()
80 packet->has_auth = 0; in sctp_packet_reset()
81 packet->ipfragok = 0; in sctp_packet_reset()
82 packet->auth = NULL; in sctp_packet_reset()
85 /* Config a packet.
88 void sctp_packet_config(struct sctp_packet *packet, __u32 vtag, in sctp_packet_config() argument
91 struct sctp_transport *tp = packet->transport; in sctp_packet_config()
96 pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag); in sctp_packet_config()
97 packet->vtag = vtag; in sctp_packet_config()
100 if (!sctp_packet_empty(packet)) in sctp_packet_config()
103 /* set packet max_size with pathmtu, then calculate overhead */ in sctp_packet_config()
104 packet->max_size = tp->pathmtu; in sctp_packet_config()
110 packet->overhead = sctp_mtu_payload(sp, 0, 0); in sctp_packet_config()
111 packet->size = packet->overhead; in sctp_packet_config()
139 sctp_packet_append_chunk(packet, chunk); in sctp_packet_config()
145 /* set packet max_size with gso_max_size if gso is enabled*/ in sctp_packet_config()
151 packet->max_size = sk_can_gso(sk) ? tp->dst->dev->gso_max_size in sctp_packet_config()
156 /* Initialize the packet structure. */
157 void sctp_packet_init(struct sctp_packet *packet, in sctp_packet_init() argument
161 pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport); in sctp_packet_init()
163 packet->transport = transport; in sctp_packet_init()
164 packet->source_port = sport; in sctp_packet_init()
165 packet->destination_port = dport; in sctp_packet_init()
166 INIT_LIST_HEAD(&packet->chunk_list); in sctp_packet_init()
168 packet->overhead = 0; in sctp_packet_init()
169 sctp_packet_reset(packet); in sctp_packet_init()
170 packet->vtag = 0; in sctp_packet_init()
173 /* Free a packet. */
174 void sctp_packet_free(struct sctp_packet *packet) in sctp_packet_free() argument
178 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_free()
180 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_free()
186 /* This routine tries to append the chunk to the offered packet. If adding
187 * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO chunk
188 * is not present in the packet, it transmits the input packet.
189 * Data can be bundled with a packet containing a COOKIE_ECHO chunk as long
190 * as it can fit in the packet, but any more data that does not fit in this
191 * packet can be sent only after receiving the COOKIE_ACK.
193 enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet, in sctp_packet_transmit_chunk() argument
199 pr_debug("%s: packet:%p size:%zu chunk:%p size:%d\n", __func__, in sctp_packet_transmit_chunk()
200 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1); in sctp_packet_transmit_chunk()
202 switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) { in sctp_packet_transmit_chunk()
204 if (!packet->has_cookie_echo) { in sctp_packet_transmit_chunk()
207 error = sctp_packet_transmit(packet, gfp); in sctp_packet_transmit_chunk()
211 /* If we have an empty packet, then we can NOT ever in sctp_packet_transmit_chunk()
215 retval = sctp_packet_append_chunk(packet, in sctp_packet_transmit_chunk()
229 /* Try to bundle an auth chunk into the packet. */
268 /* Try to bundle a SACK with the packet. */
275 * bundle one in to the packet. in sctp_packet_bundle_sack()
311 /* Append a chunk to the offered packet reporting back any inability to do
314 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet, in __sctp_packet_append_chunk() argument
320 /* Check to see if this chunk will fit into the packet */ in __sctp_packet_append_chunk()
321 retval = sctp_packet_will_fit(packet, chunk, chunk_len); in __sctp_packet_append_chunk()
325 /* We believe that this chunk is OK to add to the packet */ in __sctp_packet_append_chunk()
329 /* Account for the data being in the packet */ in __sctp_packet_append_chunk()
330 sctp_packet_append_data(packet, chunk); in __sctp_packet_append_chunk()
332 packet->has_sack = 1; in __sctp_packet_append_chunk()
334 packet->has_auth = 1; in __sctp_packet_append_chunk()
335 /* Let it be knows that packet has DATA in it */ in __sctp_packet_append_chunk()
336 packet->has_data = 1; in __sctp_packet_append_chunk()
343 packet->has_cookie_echo = 1; in __sctp_packet_append_chunk()
347 packet->has_sack = 1; in __sctp_packet_append_chunk()
353 packet->has_auth = 1; in __sctp_packet_append_chunk()
354 packet->auth = chunk; in __sctp_packet_append_chunk()
359 list_add_tail(&chunk->list, &packet->chunk_list); in __sctp_packet_append_chunk()
360 packet->size += chunk_len; in __sctp_packet_append_chunk()
361 chunk->transport = packet->transport; in __sctp_packet_append_chunk()
366 /* Append a chunk to the offered packet reporting back any inability to do
369 enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet, in sctp_packet_append_chunk() argument
374 pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk); in sctp_packet_append_chunk()
377 * bundle into this packet, check to see if we are allowed to in sctp_packet_append_chunk()
381 retval = sctp_packet_can_append_data(packet, chunk); in sctp_packet_append_chunk()
387 retval = sctp_packet_bundle_auth(packet, chunk); in sctp_packet_append_chunk()
392 retval = sctp_packet_bundle_sack(packet, chunk); in sctp_packet_append_chunk()
396 retval = __sctp_packet_append_chunk(packet, chunk); in sctp_packet_append_chunk()
418 static int sctp_packet_pack(struct sctp_packet *packet, in sctp_packet_pack() argument
421 struct sctp_transport *tp = packet->transport; in sctp_packet_pack()
434 pkt_size = packet->size; in sctp_packet_pack()
440 pkt_size = packet->overhead; in sctp_packet_pack()
441 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, in sctp_packet_pack()
445 if (chunk == packet->auth) in sctp_packet_pack()
447 else if (auth_len + padded + packet->overhead > in sctp_packet_pack()
457 skb_reserve(nskb, packet->overhead + MAX_HEADER); in sctp_packet_pack()
461 pkt_size -= packet->overhead; in sctp_packet_pack()
462 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_pack()
478 if (chunk == packet->auth) in sctp_packet_pack()
494 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth) in sctp_packet_pack()
503 packet->auth->shkey, gfp); in sctp_packet_pack()
505 if (list_empty(&packet->chunk_list)) in sctp_packet_pack()
506 sctp_chunk_free(packet->auth); in sctp_packet_pack()
508 list_add(&packet->auth->list, in sctp_packet_pack()
509 &packet->chunk_list); in sctp_packet_pack()
516 } while (!list_empty(&packet->chunk_list)); in sctp_packet_pack()
536 dst_xfrm(skb_dst(head)) || packet->ipfragok) { in sctp_packet_pack()
557 int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) in sctp_packet_transmit() argument
559 struct sctp_transport *tp = packet->transport; in sctp_packet_transmit()
568 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_transmit()
569 if (list_empty(&packet->chunk_list)) in sctp_packet_transmit()
571 chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list); in sctp_packet_transmit()
575 if (packet->size > tp->pathmtu && !packet->ipfragok) { in sctp_packet_transmit()
584 head = alloc_skb((gso ? packet->overhead : packet->size) + in sctp_packet_transmit()
588 skb_reserve(head, packet->overhead + MAX_HEADER); in sctp_packet_transmit()
594 sh->source = htons(packet->source_port); in sctp_packet_transmit()
595 sh->dest = htons(packet->destination_port); in sctp_packet_transmit()
596 sh->vtag = htonl(packet->vtag); in sctp_packet_transmit()
599 /* drop packet if no dst */ in sctp_packet_transmit()
609 pkt_count = sctp_packet_pack(packet, head, gso, gfp); in sctp_packet_transmit()
617 if (packet->has_data && sctp_state(asoc, ESTABLISHED) && in sctp_packet_transmit()
635 head->ignore_df = packet->ipfragok; in sctp_packet_transmit()
646 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_transmit()
651 sctp_packet_reset(packet); in sctp_packet_transmit()
660 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet, in sctp_packet_can_append_data() argument
664 struct sctp_transport *transport = packet->transport; in sctp_packet_can_append_data()
709 /* Nagle's algorithm to solve small-packet problem: in sctp_packet_can_append_data()
720 if (!sctp_packet_empty(packet)) in sctp_packet_can_append_data()
721 /* Append to packet */ in sctp_packet_can_append_data()
728 * or delay in hopes of bundling a full sized packet. in sctp_packet_can_append_data()
731 packet->overhead - sctp_datachk_len(&chunk->asoc->stream) - 4) in sctp_packet_can_append_data()
732 /* Enough data queued to fill a packet */ in sctp_packet_can_append_data()
739 /* Defer until all data acked or packet full */ in sctp_packet_can_append_data()
744 static void sctp_packet_append_data(struct sctp_packet *packet, in sctp_packet_append_data() argument
747 struct sctp_transport *transport = packet->transport; in sctp_packet_append_data()
769 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet, in sctp_packet_will_fit() argument
776 /* Don't bundle in this packet if this chunk's auth key doesn't in sctp_packet_will_fit()
777 * match other chunks already enqueued on this packet. Also, in sctp_packet_will_fit()
779 * packet don't have auth key. in sctp_packet_will_fit()
781 if ((packet->auth && chunk->shkey != packet->auth->shkey) || in sctp_packet_will_fit()
782 (!packet->auth && chunk->shkey && in sctp_packet_will_fit()
786 psize = packet->size; in sctp_packet_will_fit()
787 if (packet->transport->asoc) in sctp_packet_will_fit()
788 pmtu = packet->transport->asoc->pathmtu; in sctp_packet_will_fit()
790 pmtu = packet->transport->pathmtu; in sctp_packet_will_fit()
796 * 1. The packet is empty (meaning this chunk is greater in sctp_packet_will_fit()
798 * 2. The packet doesn't have any data in it yet and data in sctp_packet_will_fit()
801 if (sctp_packet_empty(packet) || in sctp_packet_will_fit()
802 (!packet->has_data && chunk->auth)) { in sctp_packet_will_fit()
807 packet->ipfragok = 1; in sctp_packet_will_fit()
813 * if the packet already contains something, we need to in sctp_packet_will_fit()
816 maxsize = pmtu - packet->overhead; in sctp_packet_will_fit()
817 if (packet->auth) in sctp_packet_will_fit()
818 maxsize -= SCTP_PAD4(packet->auth->skb->len); in sctp_packet_will_fit()
823 * adding is a control chunk, but only if current packet in sctp_packet_will_fit()
826 * fragmentation by forcing it to be in a new packet. in sctp_packet_will_fit()
828 if (!sctp_chunk_is_data(chunk) && packet->has_data) in sctp_packet_will_fit()
831 if (psize + chunk_len > packet->max_size) in sctp_packet_will_fit()
835 if (!packet->transport->burst_limited && in sctp_packet_will_fit()
836 psize + chunk_len > (packet->transport->cwnd >> 1)) in sctp_packet_will_fit()
837 /* Do not allow a single GSO packet to use more in sctp_packet_will_fit()
842 if (packet->transport->burst_limited && in sctp_packet_will_fit()
843 psize + chunk_len > (packet->transport->burst_limited >> 1)) in sctp_packet_will_fit()
844 /* Do not allow a single GSO packet to use more in sctp_packet_will_fit()
848 /* Otherwise it will fit in the GSO packet */ in sctp_packet_will_fit()