// SPDX-License-Identifier: GPL-2.0-only /* * net/dccp/ackvec.c * * An implementation of Ack Vectors for the DCCP protocol * Copyright (c) 2007 University of Aberdeen, Scotland, UK * Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]> */ #include "dccp.h" #include <linux/kernel.h> #include <linux/slab.h> #include <linux/export.h> static struct kmem_cache *dccp_ackvec_slab; static struct kmem_cache *dccp_ackvec_record_slab; struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority) { … } static void dccp_ackvec_purge_records(struct dccp_ackvec *av) { … } void dccp_ackvec_free(struct dccp_ackvec *av) { … } /** * dccp_ackvec_update_records - Record information about sent Ack Vectors * @av: Ack Vector records to update * @seqno: Sequence number of the packet carrying the Ack Vector just sent * @nonce_sum: The sum of all buffer nonces contained in the Ack Vector */ int dccp_ackvec_update_records(struct dccp_ackvec *av, u64 seqno, u8 nonce_sum) { … } static struct dccp_ackvec_record *dccp_ackvec_lookup(struct list_head *av_list, const u64 ackno) { … } /* * Buffer index and length computation using modulo-buffersize arithmetic. * Note that, as pointers move from right to left, head is `before' tail. */ static inline u16 __ackvec_idx_add(const u16 a, const u16 b) { … } static inline u16 __ackvec_idx_sub(const u16 a, const u16 b) { … } u16 dccp_ackvec_buflen(const struct dccp_ackvec *av) { … } /** * dccp_ackvec_update_old - Update previous state as per RFC 4340, 11.4.1 * @av: non-empty buffer to update * @distance: negative or zero distance of @seqno from buf_ackno downward * @seqno: the (old) sequence number whose record is to be updated * @state: state in which packet carrying @seqno was received */ static void dccp_ackvec_update_old(struct dccp_ackvec *av, s64 distance, u64 seqno, enum dccp_ackvec_states state) { … } /* Mark @num entries after buf_head as "Not yet received". */ static void dccp_ackvec_reserve_seats(struct dccp_ackvec *av, u16 num) { … } /** * dccp_ackvec_add_new - Record one or more new entries in Ack Vector buffer * @av: container of buffer to update (can be empty or non-empty) * @num_packets: number of packets to register (must be >= 1) * @seqno: sequence number of the first packet in @num_packets * @state: state in which packet carrying @seqno was received */ static void dccp_ackvec_add_new(struct dccp_ackvec *av, u32 num_packets, u64 seqno, enum dccp_ackvec_states state) { … } /** * dccp_ackvec_input - Register incoming packet in the buffer * @av: Ack Vector to register packet to * @skb: Packet to register */ void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb) { … } /** * dccp_ackvec_clear_state - Perform house-keeping / garbage-collection * @av: Ack Vector record to clean * @ackno: last Ack Vector which has been acknowledged * * This routine is called when the peer acknowledges the receipt of Ack Vectors * up to and including @ackno. While based on section A.3 of RFC 4340, here * are additional precautions to prevent corrupted buffer state. In particular, * we use tail_ackno to identify outdated records; it always marks the earliest * packet of group (2) in 11.4.2. */ void dccp_ackvec_clear_state(struct dccp_ackvec *av, const u64 ackno) { … } /* * Routines to keep track of Ack Vectors received in an skb */ int dccp_ackvec_parsed_add(struct list_head *head, u8 *vec, u8 len, u8 nonce) { … } EXPORT_SYMBOL_GPL(…); void dccp_ackvec_parsed_cleanup(struct list_head *parsed_chunks) { … } EXPORT_SYMBOL_GPL(…); int __init dccp_ackvec_init(void) { … } void dccp_ackvec_exit(void) { … }