batman-adv: refactor batadv_neigh_node_* functions to follow common style
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
This commit is contained in:

committed by
Simon Wunderlich

parent
21c02be7cf
commit
6f0a6b5ee8
@@ -602,19 +602,19 @@ batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
|
||||
}
|
||||
|
||||
/**
|
||||
* batadv_neigh_node_new - create and init a new neigh_node object
|
||||
* batadv_neigh_node_create - create a neigh node object
|
||||
* @orig_node: originator object representing the neighbour
|
||||
* @hard_iface: the interface where the neighbour is connected to
|
||||
* @neigh_addr: the mac address of the neighbour interface
|
||||
*
|
||||
* Allocates a new neigh_node object and initialises all the generic fields.
|
||||
*
|
||||
* Return: neighbor when found. Othwerwise NULL
|
||||
* Return: the neighbour node if found or created or NULL otherwise.
|
||||
*/
|
||||
struct batadv_neigh_node *
|
||||
batadv_neigh_node_new(struct batadv_orig_node *orig_node,
|
||||
struct batadv_hard_iface *hard_iface,
|
||||
const u8 *neigh_addr)
|
||||
static struct batadv_neigh_node *
|
||||
batadv_neigh_node_create(struct batadv_orig_node *orig_node,
|
||||
struct batadv_hard_iface *hard_iface,
|
||||
const u8 *neigh_addr)
|
||||
{
|
||||
struct batadv_neigh_node *neigh_node;
|
||||
struct batadv_hardif_neigh_node *hardif_neigh = NULL;
|
||||
@@ -666,6 +666,29 @@ out:
|
||||
return neigh_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* batadv_neigh_node_get_or_create - retrieve or create a neigh node object
|
||||
* @orig_node: originator object representing the neighbour
|
||||
* @hard_iface: the interface where the neighbour is connected to
|
||||
* @neigh_addr: the mac address of the neighbour interface
|
||||
*
|
||||
* Return: the neighbour node if found or created or NULL otherwise.
|
||||
*/
|
||||
struct batadv_neigh_node *
|
||||
batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
|
||||
struct batadv_hard_iface *hard_iface,
|
||||
const u8 *neigh_addr)
|
||||
{
|
||||
struct batadv_neigh_node *neigh_node = NULL;
|
||||
|
||||
/* first check without locking to avoid the overhead */
|
||||
neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr);
|
||||
if (neigh_node)
|
||||
return neigh_node;
|
||||
|
||||
return batadv_neigh_node_create(orig_node, hard_iface, neigh_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* batadv_hardif_neigh_seq_print_text - print the single hop neighbour list
|
||||
* @seq: neighbour table seq_file struct
|
||||
|
Reference in New Issue
Block a user