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) 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()
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()
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()
137 packet->max_size = sk_can_gso(sk) ? min(READ_ONCE(tp->dst->dev->gso_max_size), in sctp_packet_config()
144 void sctp_packet_init(struct sctp_packet *packet, in sctp_packet_init() argument
148 pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport); in sctp_packet_init()
150 packet->transport = transport; in sctp_packet_init()
151 packet->source_port = sport; in sctp_packet_init()
152 packet->destination_port = dport; in sctp_packet_init()
153 INIT_LIST_HEAD(&packet->chunk_list); in sctp_packet_init()
155 packet->overhead = 0; in sctp_packet_init()
156 sctp_packet_reset(packet); in sctp_packet_init()
157 packet->vtag = 0; in sctp_packet_init()
161 void sctp_packet_free(struct sctp_packet *packet) in sctp_packet_free() argument
165 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_free()
167 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_free()
180 enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet, in sctp_packet_transmit_chunk() argument
187 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : -1); in sctp_packet_transmit_chunk()
189 switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) { in sctp_packet_transmit_chunk()
191 if (!packet->has_cookie_echo) { in sctp_packet_transmit_chunk()
194 error = sctp_packet_transmit(packet, gfp); in sctp_packet_transmit_chunk()
202 retval = sctp_packet_append_chunk(packet, in sctp_packet_transmit_chunk()
328 static enum sctp_xmit __sctp_packet_append_chunk(struct sctp_packet *packet, in __sctp_packet_append_chunk() argument
335 retval = sctp_packet_will_fit(packet, chunk, chunk_len); in __sctp_packet_append_chunk()
344 sctp_packet_append_data(packet, chunk); in __sctp_packet_append_chunk()
346 packet->has_sack = 1; in __sctp_packet_append_chunk()
348 packet->has_auth = 1; in __sctp_packet_append_chunk()
350 packet->has_data = 1; in __sctp_packet_append_chunk()
357 packet->has_cookie_echo = 1; in __sctp_packet_append_chunk()
361 packet->has_sack = 1; in __sctp_packet_append_chunk()
367 packet->has_auth = 1; in __sctp_packet_append_chunk()
368 packet->auth = chunk; in __sctp_packet_append_chunk()
373 list_add_tail(&chunk->list, &packet->chunk_list); in __sctp_packet_append_chunk()
374 packet->size += chunk_len; in __sctp_packet_append_chunk()
375 chunk->transport = packet->transport; in __sctp_packet_append_chunk()
383 enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet, in sctp_packet_append_chunk() argument
388 pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk); in sctp_packet_append_chunk()
395 retval = sctp_packet_can_append_data(packet, chunk); in sctp_packet_append_chunk()
401 retval = sctp_packet_bundle_auth(packet, chunk); in sctp_packet_append_chunk()
406 retval = sctp_packet_bundle_sack(packet, chunk); in sctp_packet_append_chunk()
410 retval = __sctp_packet_append_chunk(packet, chunk); in sctp_packet_append_chunk()
414 retval = sctp_packet_bundle_pad(packet, chunk); in sctp_packet_append_chunk()
436 static int sctp_packet_pack(struct sctp_packet *packet, in sctp_packet_pack() argument
439 struct sctp_transport *tp = packet->transport; in sctp_packet_pack()
452 pkt_size = packet->size; in sctp_packet_pack()
458 pkt_size = packet->overhead; in sctp_packet_pack()
459 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, in sctp_packet_pack()
463 if (chunk == packet->auth) in sctp_packet_pack()
465 else if (auth_len + padded + packet->overhead > in sctp_packet_pack()
475 skb_reserve(nskb, packet->overhead + MAX_HEADER); in sctp_packet_pack()
479 pkt_size -= packet->overhead; in sctp_packet_pack()
480 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_pack()
496 if (chunk == packet->auth) in sctp_packet_pack()
512 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth) in sctp_packet_pack()
521 packet->auth->shkey, gfp); in sctp_packet_pack()
523 if (list_empty(&packet->chunk_list)) in sctp_packet_pack()
524 sctp_chunk_free(packet->auth); in sctp_packet_pack()
526 list_add(&packet->auth->list, in sctp_packet_pack()
527 &packet->chunk_list); in sctp_packet_pack()
534 } while (!list_empty(&packet->chunk_list)); in sctp_packet_pack()
548 dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) { in sctp_packet_pack()
569 int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) in sctp_packet_transmit() argument
571 struct sctp_transport *tp = packet->transport; in sctp_packet_transmit()
579 pr_debug("%s: packet:%p\n", __func__, packet); in sctp_packet_transmit()
580 if (list_empty(&packet->chunk_list)) in sctp_packet_transmit()
582 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()
587 packet->ipfragok = 1; in sctp_packet_transmit()
598 head = alloc_skb((gso ? packet->overhead : packet->size) + in sctp_packet_transmit()
602 skb_reserve(head, packet->overhead + MAX_HEADER); in sctp_packet_transmit()
608 sh->source = htons(packet->source_port); in sctp_packet_transmit()
609 sh->dest = htons(packet->destination_port); in sctp_packet_transmit()
610 sh->vtag = htonl(packet->vtag); in sctp_packet_transmit()
621 pkt_count = sctp_packet_pack(packet, head, gso, gfp); in sctp_packet_transmit()
629 if (packet->has_data && sctp_state(asoc, ESTABLISHED) && in sctp_packet_transmit()
647 head->ignore_df = packet->ipfragok; in sctp_packet_transmit()
658 list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { in sctp_packet_transmit()
663 sctp_packet_reset(packet); in sctp_packet_transmit()
672 static enum sctp_xmit sctp_packet_can_append_data(struct sctp_packet *packet, in sctp_packet_can_append_data() argument
676 struct sctp_transport *transport = packet->transport; in sctp_packet_can_append_data()
732 if (!sctp_packet_empty(packet)) in sctp_packet_can_append_data()
743 packet->overhead - sctp_datachk_len(&chunk->asoc->stream) - 4) in sctp_packet_can_append_data()
756 static void sctp_packet_append_data(struct sctp_packet *packet, in sctp_packet_append_data() argument
759 struct sctp_transport *transport = packet->transport; in sctp_packet_append_data()
781 static enum sctp_xmit sctp_packet_will_fit(struct sctp_packet *packet, in sctp_packet_will_fit() argument
793 if ((packet->auth && chunk->shkey != packet->auth->shkey) || in sctp_packet_will_fit()
794 (!packet->auth && chunk->shkey && in sctp_packet_will_fit()
798 psize = packet->size; in sctp_packet_will_fit()
799 if (packet->transport->asoc) in sctp_packet_will_fit()
800 pmtu = packet->transport->asoc->pathmtu; in sctp_packet_will_fit()
802 pmtu = packet->transport->pathmtu; in sctp_packet_will_fit()
813 if (sctp_packet_empty(packet) || in sctp_packet_will_fit()
814 (!packet->has_data && chunk->auth)) { in sctp_packet_will_fit()
819 packet->ipfragok = 1; in sctp_packet_will_fit()
828 maxsize = pmtu - packet->overhead; in sctp_packet_will_fit()
829 if (packet->auth) in sctp_packet_will_fit()
830 maxsize -= SCTP_PAD4(packet->auth->skb->len); in sctp_packet_will_fit()
840 if (!sctp_chunk_is_data(chunk) && packet->has_data) in sctp_packet_will_fit()
843 if (psize + chunk_len > packet->max_size) in sctp_packet_will_fit()
847 if (!packet->transport->burst_limited && in sctp_packet_will_fit()
848 psize + chunk_len > (packet->transport->cwnd >> 1)) in sctp_packet_will_fit()
854 if (packet->transport->burst_limited && in sctp_packet_will_fit()
855 psize + chunk_len > (packet->transport->burst_limited >> 1)) in sctp_packet_will_fit()