mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 06:55:45 -04:00
Both OGMv1 (on the primary interface) and OGM2 unconditionally reallocated their packet buffer on every transmission cycle, regardless of whether the required size had changed. This meant a kfree/kmalloc pair even when the TVLV payload size was identical to the previous send. Introduce struct batadv_ogm_buf to encapsulate the OGM packet buffer together with its current length, allocated capacity, and fixed header length. This consolidates the separate buf/len arguments that were previously threaded through each call site. In batadv_tvlv_realloc_packet_buff(), the capacity is rounded up to the next power of two so that small growth or shrinkage in TVLV data does not trigger a reallocation. When kmalloc fails but the existing buffer is large enough to hold the new data, the oversized buffer is reused rather than returning an error. Signed-off-by: Sven Eckelmann <sven@narfation.org>
52 lines
1.8 KiB
C
52 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (C) B.A.T.M.A.N. contributors:
|
|
*
|
|
* Marek Lindner, Simon Wunderlich
|
|
*/
|
|
|
|
#ifndef _NET_BATMAN_ADV_TVLV_H_
|
|
#define _NET_BATMAN_ADV_TVLV_H_
|
|
|
|
#include "main.h"
|
|
|
|
#include <linux/skbuff.h>
|
|
#include <linux/types.h>
|
|
#include <uapi/linux/batadv_packet.h>
|
|
|
|
void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
|
|
u8 type, u8 version,
|
|
void *tvlv_value, u16 tvlv_value_len);
|
|
int batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
|
|
struct batadv_ogm_buf *ogm_buff);
|
|
void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
|
|
struct batadv_ogm_packet *batadv_ogm_packet,
|
|
struct batadv_orig_node *orig_node);
|
|
void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
|
|
u8 type, u8 version);
|
|
|
|
void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
|
|
void (*optr)(struct batadv_priv *bat_priv,
|
|
struct batadv_orig_node *orig,
|
|
u8 flags,
|
|
void *tvlv_value,
|
|
u16 tvlv_value_len),
|
|
int (*uptr)(struct batadv_priv *bat_priv,
|
|
u8 *src, u8 *dst,
|
|
void *tvlv_value,
|
|
u16 tvlv_value_len),
|
|
int (*mptr)(struct batadv_priv *bat_priv,
|
|
struct sk_buff *skb),
|
|
u8 type, u8 version, u8 flags);
|
|
void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
|
|
u8 type, u8 version);
|
|
int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
|
|
u8 packet_type,
|
|
struct batadv_orig_node *orig_node,
|
|
struct sk_buff *skb, void *tvlv_buff,
|
|
u16 tvlv_buff_len);
|
|
void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, const u8 *src,
|
|
const u8 *dst, u8 type, u8 version,
|
|
void *tvlv_value, u16 tvlv_value_len);
|
|
|
|
#endif /* _NET_BATMAN_ADV_TVLV_H_ */
|