Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* Copyright (C) 2007-2020  B.A.T.M.A.N. contributors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Marek Lindner, Simon Wunderlich
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define _NET_BATMAN_ADV_ORIGINATOR_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "main.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/jhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) int batadv_originator_init(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) void batadv_originator_free(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) void batadv_orig_node_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 					      const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct batadv_hardif_neigh_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			const u8 *neigh_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) void batadv_hardif_neigh_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct batadv_neigh_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				struct batadv_hard_iface *hard_iface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 				const u8 *neigh_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) void batadv_neigh_node_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct batadv_neigh_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) batadv_orig_router_get(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		       const struct batadv_hard_iface *if_outgoing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) struct batadv_neigh_ifinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			struct batadv_hard_iface *if_outgoing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct batadv_neigh_ifinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			struct batadv_hard_iface *if_outgoing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) void batadv_neigh_ifinfo_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct batadv_orig_ifinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		       struct batadv_hard_iface *if_outgoing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) struct batadv_orig_ifinfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		       struct batadv_hard_iface *if_outgoing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) void batadv_orig_ifinfo_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) struct batadv_orig_node_vlan *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			  unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) struct batadv_orig_node_vlan *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			  unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) void batadv_orig_node_vlan_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * batadv_choose_orig() - Return the index of the orig entry in the hash table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @data: mac address of the originator node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @size: the size of the hash table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Return: the hash index where the object represented by @data should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * stored at.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static inline u32 batadv_choose_orig(const void *data, u32 size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u32 hash = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	hash = jhash(data, ETH_ALEN, hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	return hash % size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) struct batadv_orig_node *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * batadv_orig_node_vlan_put() - decrement the refcounter and possibly release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *  the originator-vlan object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * @orig_vlan: the originator-vlan object to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (!orig_vlan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	kref_put(&orig_vlan->refcount, batadv_orig_node_vlan_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * batadv_neigh_ifinfo_put() - decrement the refcounter and possibly release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *  the neigh_ifinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * @neigh_ifinfo: the neigh_ifinfo object to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (!neigh_ifinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	kref_put(&neigh_ifinfo->refcount, batadv_neigh_ifinfo_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * batadv_hardif_neigh_put() - decrement the hardif neighbors refcounter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *  and possibly release it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * @hardif_neigh: hardif neigh neighbor to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (!hardif_neigh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * batadv_neigh_node_put() - decrement the neighbors refcounter and possibly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *  release it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * @neigh_node: neigh neighbor to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static inline void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (!neigh_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	kref_put(&neigh_node->refcount, batadv_neigh_node_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * batadv_orig_ifinfo_put() - decrement the refcounter and possibly release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  *  the orig_ifinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * @orig_ifinfo: the orig_ifinfo object to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (!orig_ifinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	kref_put(&orig_ifinfo->refcount, batadv_orig_ifinfo_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * batadv_orig_node_put() - decrement the orig node refcounter and possibly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *  release it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * @orig_node: the orig node to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static inline void batadv_orig_node_put(struct batadv_orig_node *orig_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (!orig_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	kref_put(&orig_node->refcount, batadv_orig_node_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */