Commit b8766e4e authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Antonio Quartulli says:

====================
Included changes:
- code restyling and beautification
- use int kernel types instead of C99
- update kereldoc
- prevent potential hlist double deletion of VLAN objects
- fix gw bandwidth calculation
- convert list to hlist when needed
- add lockdep_asserts calls in function with lock requirements
  described in kerneldoc
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents dafc2199 854d2a63
This diff is collapsed.
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/bitmap.h> #include <linux/bitmap.h>
/* shift the packet array by n places. */ /* shift the packet array by n places. */
static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
{ {
if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE) if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return; return;
...@@ -35,8 +35,8 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n) ...@@ -35,8 +35,8 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
* 1 if the window was moved (either new or very old) * 1 if the window was moved (either new or very old)
* 0 if the window was not moved/shifted. * 0 if the window was not moved/shifted.
*/ */
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
int32_t seq_num_diff, int set_mark) int set_mark)
{ {
struct batadv_priv *bat_priv = priv; struct batadv_priv *bat_priv = priv;
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
* and curr_seqno is within range of last_seqno. Otherwise returns 0. * and curr_seqno is within range of last_seqno. Otherwise returns 0.
*/ */
static inline int batadv_test_bit(const unsigned long *seq_bits, static inline int batadv_test_bit(const unsigned long *seq_bits,
uint32_t last_seqno, uint32_t curr_seqno) u32 last_seqno, u32 curr_seqno)
{ {
int32_t diff; s32 diff;
diff = last_seqno - curr_seqno; diff = last_seqno - curr_seqno;
if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE) if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
...@@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, ...@@ -39,7 +39,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
} }
/* turn corresponding bit on, so we can remember that we got the packet */ /* turn corresponding bit on, so we can remember that we got the packet */
static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n) static inline void batadv_set_bit(unsigned long *seq_bits, s32 n)
{ {
/* if too old, just drop it */ /* if too old, just drop it */
if (n < 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE) if (n < 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
...@@ -51,7 +51,7 @@ static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n) ...@@ -51,7 +51,7 @@ static inline void batadv_set_bit(unsigned long *seq_bits, int32_t n)
/* receive and process one packet, returns 1 if received seq_num is considered /* receive and process one packet, returns 1 if received seq_num is considered
* new, 0 if old * new, 0 if old
*/ */
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
int32_t seq_num_diff, int set_mark); int set_mark);
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */ #endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include "packet.h" #include "packet.h"
#include "translation-table.h" #include "translation-table.h"
static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; static const u8 batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
static void batadv_bla_periodic_work(struct work_struct *work); static void batadv_bla_periodic_work(struct work_struct *work);
static void static void
...@@ -59,10 +59,10 @@ batadv_bla_send_announce(struct batadv_priv *bat_priv, ...@@ -59,10 +59,10 @@ batadv_bla_send_announce(struct batadv_priv *bat_priv,
struct batadv_bla_backbone_gw *backbone_gw); struct batadv_bla_backbone_gw *backbone_gw);
/* return the index of the claim */ /* return the index of the claim */
static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) static inline u32 batadv_choose_claim(const void *data, u32 size)
{ {
struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
uint32_t hash = 0; u32 hash = 0;
hash = jhash(&claim->addr, sizeof(claim->addr), hash); hash = jhash(&claim->addr, sizeof(claim->addr), hash);
hash = jhash(&claim->vid, sizeof(claim->vid), hash); hash = jhash(&claim->vid, sizeof(claim->vid), hash);
...@@ -71,11 +71,10 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) ...@@ -71,11 +71,10 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
} }
/* return the index of the backbone gateway */ /* return the index of the backbone gateway */
static inline uint32_t batadv_choose_backbone_gw(const void *data, static inline u32 batadv_choose_backbone_gw(const void *data, u32 size)
uint32_t size)
{ {
const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
uint32_t hash = 0; u32 hash = 0;
hash = jhash(&claim->addr, sizeof(claim->addr), hash); hash = jhash(&claim->addr, sizeof(claim->addr), hash);
hash = jhash(&claim->vid, sizeof(claim->vid), hash); hash = jhash(&claim->vid, sizeof(claim->vid), hash);
...@@ -89,7 +88,8 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node, ...@@ -89,7 +88,8 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node,
{ {
const void *data1 = container_of(node, struct batadv_bla_backbone_gw, const void *data1 = container_of(node, struct batadv_bla_backbone_gw,
hash_entry); hash_entry);
const struct batadv_bla_backbone_gw *gw1 = data1, *gw2 = data2; const struct batadv_bla_backbone_gw *gw1 = data1;
const struct batadv_bla_backbone_gw *gw2 = data2;
if (!batadv_compare_eth(gw1->orig, gw2->orig)) if (!batadv_compare_eth(gw1->orig, gw2->orig))
return 0; return 0;
...@@ -106,7 +106,8 @@ static int batadv_compare_claim(const struct hlist_node *node, ...@@ -106,7 +106,8 @@ static int batadv_compare_claim(const struct hlist_node *node,
{ {
const void *data1 = container_of(node, struct batadv_bla_claim, const void *data1 = container_of(node, struct batadv_bla_claim,
hash_entry); hash_entry);
const struct batadv_bla_claim *cl1 = data1, *cl2 = data2; const struct batadv_bla_claim *cl1 = data1;
const struct batadv_bla_claim *cl2 = data2;
if (!batadv_compare_eth(cl1->addr, cl2->addr)) if (!batadv_compare_eth(cl1->addr, cl2->addr))
return 0; return 0;
...@@ -192,8 +193,8 @@ static struct batadv_bla_claim ...@@ -192,8 +193,8 @@ static struct batadv_bla_claim
* Returns claim if found or NULL otherwise. * Returns claim if found or NULL otherwise.
*/ */
static struct batadv_bla_backbone_gw * static struct batadv_bla_backbone_gw *
batadv_backbone_hash_find(struct batadv_priv *bat_priv, batadv_backbone_hash_find(struct batadv_priv *bat_priv, u8 *addr,
uint8_t *addr, unsigned short vid) unsigned short vid)
{ {
struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
struct hlist_head *head; struct hlist_head *head;
...@@ -269,14 +270,14 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw) ...@@ -269,14 +270,14 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
* @vid: the VLAN ID * @vid: the VLAN ID
* @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...) * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
*/ */
static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
unsigned short vid, int claimtype) unsigned short vid, int claimtype)
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct batadv_hard_iface *primary_if; struct batadv_hard_iface *primary_if;
struct net_device *soft_iface; struct net_device *soft_iface;
uint8_t *hw_src; u8 *hw_src;
struct batadv_bla_claim_dst local_claim_dest; struct batadv_bla_claim_dst local_claim_dest;
__be32 zeroip = 0; __be32 zeroip = 0;
...@@ -304,13 +305,13 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, ...@@ -304,13 +305,13 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
* with XX = claim type * with XX = claim type
* and YY:YY = group id * and YY:YY = group id
*/ */
(uint8_t *)&local_claim_dest); (u8 *)&local_claim_dest);
if (!skb) if (!skb)
goto out; goto out;
ethhdr = (struct ethhdr *)skb->data; ethhdr = (struct ethhdr *)skb->data;
hw_src = (uint8_t *)ethhdr + ETH_HLEN + sizeof(struct arphdr); hw_src = (u8 *)ethhdr + ETH_HLEN + sizeof(struct arphdr);
/* now we pretend that the client would have sent this ... */ /* now we pretend that the client would have sent this ... */
switch (claimtype) { switch (claimtype) {
...@@ -383,7 +384,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, ...@@ -383,7 +384,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
* be found. * be found.
*/ */
static struct batadv_bla_backbone_gw * static struct batadv_bla_backbone_gw *
batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig,
unsigned short vid, bool own_backbone) unsigned short vid, bool own_backbone)
{ {
struct batadv_bla_backbone_gw *entry; struct batadv_bla_backbone_gw *entry;
...@@ -552,7 +553,7 @@ static void batadv_bla_send_request(struct batadv_bla_backbone_gw *backbone_gw) ...@@ -552,7 +553,7 @@ static void batadv_bla_send_request(struct batadv_bla_backbone_gw *backbone_gw)
static void batadv_bla_send_announce(struct batadv_priv *bat_priv, static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
struct batadv_bla_backbone_gw *backbone_gw) struct batadv_bla_backbone_gw *backbone_gw)
{ {
uint8_t mac[ETH_ALEN]; u8 mac[ETH_ALEN];
__be16 crc; __be16 crc;
memcpy(mac, batadv_announce_mac, 4); memcpy(mac, batadv_announce_mac, 4);
...@@ -571,7 +572,7 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv, ...@@ -571,7 +572,7 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
* @backbone_gw: the backbone gateway which claims it * @backbone_gw: the backbone gateway which claims it
*/ */
static void batadv_bla_add_claim(struct batadv_priv *bat_priv, static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
const uint8_t *mac, const unsigned short vid, const u8 *mac, const unsigned short vid,
struct batadv_bla_backbone_gw *backbone_gw) struct batadv_bla_backbone_gw *backbone_gw)
{ {
struct batadv_bla_claim *claim; struct batadv_bla_claim *claim;
...@@ -635,7 +636,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv, ...@@ -635,7 +636,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
* given mac address and vid. * given mac address and vid.
*/ */
static void batadv_bla_del_claim(struct batadv_priv *bat_priv, static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
const uint8_t *mac, const unsigned short vid) const u8 *mac, const unsigned short vid)
{ {
struct batadv_bla_claim search_claim, *claim; struct batadv_bla_claim search_claim, *claim;
...@@ -659,12 +660,11 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv, ...@@ -659,12 +660,11 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
} }
/* check for ANNOUNCE frame, return 1 if handled */ /* check for ANNOUNCE frame, return 1 if handled */
static int batadv_handle_announce(struct batadv_priv *bat_priv, static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
uint8_t *an_addr, uint8_t *backbone_addr, u8 *backbone_addr, unsigned short vid)
unsigned short vid)
{ {
struct batadv_bla_backbone_gw *backbone_gw; struct batadv_bla_backbone_gw *backbone_gw;
uint16_t crc; u16 crc;
if (memcmp(an_addr, batadv_announce_mac, 4) != 0) if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
return 0; return 0;
...@@ -708,8 +708,8 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, ...@@ -708,8 +708,8 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
/* check for REQUEST frame, return 1 if handled */ /* check for REQUEST frame, return 1 if handled */
static int batadv_handle_request(struct batadv_priv *bat_priv, static int batadv_handle_request(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if, struct batadv_hard_iface *primary_if,
uint8_t *backbone_addr, u8 *backbone_addr, struct ethhdr *ethhdr,
struct ethhdr *ethhdr, unsigned short vid) unsigned short vid)
{ {
/* check for REQUEST frame */ /* check for REQUEST frame */
if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest)) if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
...@@ -732,8 +732,8 @@ static int batadv_handle_request(struct batadv_priv *bat_priv, ...@@ -732,8 +732,8 @@ static int batadv_handle_request(struct batadv_priv *bat_priv,
/* check for UNCLAIM frame, return 1 if handled */ /* check for UNCLAIM frame, return 1 if handled */
static int batadv_handle_unclaim(struct batadv_priv *bat_priv, static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if, struct batadv_hard_iface *primary_if,
uint8_t *backbone_addr, u8 *backbone_addr, u8 *claim_addr,
uint8_t *claim_addr, unsigned short vid) unsigned short vid)
{ {
struct batadv_bla_backbone_gw *backbone_gw; struct batadv_bla_backbone_gw *backbone_gw;
...@@ -761,7 +761,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv, ...@@ -761,7 +761,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
/* check for CLAIM frame, return 1 if handled */ /* check for CLAIM frame, return 1 if handled */
static int batadv_handle_claim(struct batadv_priv *bat_priv, static int batadv_handle_claim(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if, struct batadv_hard_iface *primary_if,
uint8_t *backbone_addr, uint8_t *claim_addr, u8 *backbone_addr, u8 *claim_addr,
unsigned short vid) unsigned short vid)
{ {
struct batadv_bla_backbone_gw *backbone_gw; struct batadv_bla_backbone_gw *backbone_gw;
...@@ -805,10 +805,10 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv, ...@@ -805,10 +805,10 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
*/ */
static int batadv_check_claim_group(struct batadv_priv *bat_priv, static int batadv_check_claim_group(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if, struct batadv_hard_iface *primary_if,
uint8_t *hw_src, uint8_t *hw_dst, u8 *hw_src, u8 *hw_dst,
struct ethhdr *ethhdr) struct ethhdr *ethhdr)
{ {
uint8_t *backbone_addr; u8 *backbone_addr;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
struct batadv_bla_claim_dst *bla_dst, *bla_dst_own; struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
...@@ -877,7 +877,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, ...@@ -877,7 +877,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct batadv_bla_claim_dst *bla_dst, *bla_dst_own; struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
uint8_t *hw_src, *hw_dst; u8 *hw_src, *hw_dst;
struct vlan_hdr *vhdr, vhdr_buf; struct vlan_hdr *vhdr, vhdr_buf;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct arphdr *arphdr; struct arphdr *arphdr;
...@@ -923,7 +923,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, ...@@ -923,7 +923,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
/* pskb_may_pull() may have modified the pointers, get ethhdr again */ /* pskb_may_pull() may have modified the pointers, get ethhdr again */
ethhdr = eth_hdr(skb); ethhdr = eth_hdr(skb);
arphdr = (struct arphdr *)((uint8_t *)ethhdr + headlen); arphdr = (struct arphdr *)((u8 *)ethhdr + headlen);
/* Check whether the ARP frame carries a valid /* Check whether the ARP frame carries a valid
* IP information * IP information
...@@ -937,7 +937,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, ...@@ -937,7 +937,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
if (arphdr->ar_pln != 4) if (arphdr->ar_pln != 4)
return 0; return 0;
hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); hw_src = (u8 *)arphdr + sizeof(struct arphdr);
hw_dst = hw_src + ETH_ALEN + 4; hw_dst = hw_src + ETH_ALEN + 4;
bla_dst = (struct batadv_bla_claim_dst *)hw_dst; bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
bla_dst_own = &bat_priv->bla.claim_dest; bla_dst_own = &bat_priv->bla.claim_dest;
...@@ -1238,9 +1238,9 @@ static struct lock_class_key batadv_backbone_hash_lock_class_key; ...@@ -1238,9 +1238,9 @@ static struct lock_class_key batadv_backbone_hash_lock_class_key;
int batadv_bla_init(struct batadv_priv *bat_priv) int batadv_bla_init(struct batadv_priv *bat_priv)
{ {
int i; int i;
uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; u8 claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
struct batadv_hard_iface *primary_if; struct batadv_hard_iface *primary_if;
uint16_t crc; u16 crc;
unsigned long entrytime; unsigned long entrytime;
spin_lock_init(&bat_priv->bla.bcast_duplist_lock); spin_lock_init(&bat_priv->bla.bcast_duplist_lock);
...@@ -1368,7 +1368,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, ...@@ -1368,7 +1368,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
* *
* Returns true if orig is a backbone for this vid, false otherwise. * Returns true if orig is a backbone for this vid, false otherwise.
*/ */
bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig, bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
unsigned short vid) unsigned short vid)
{ {
struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
...@@ -1647,9 +1647,9 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1647,9 +1647,9 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
struct batadv_bla_claim *claim; struct batadv_bla_claim *claim;
struct batadv_hard_iface *primary_if; struct batadv_hard_iface *primary_if;
struct hlist_head *head; struct hlist_head *head;
uint32_t i; u32 i;
bool is_own; bool is_own;
uint8_t *primary_addr; u8 *primary_addr;
primary_if = batadv_seq_print_text_primary_if_get(seq); primary_if = batadv_seq_print_text_primary_if_get(seq);
if (!primary_if) if (!primary_if)
...@@ -1692,9 +1692,9 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1692,9 +1692,9 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
struct batadv_hard_iface *primary_if; struct batadv_hard_iface *primary_if;
struct hlist_head *head; struct hlist_head *head;
int secs, msecs; int secs, msecs;
uint32_t i; u32 i;
bool is_own; bool is_own;
uint8_t *primary_addr; u8 *primary_addr;
primary_if = batadv_seq_print_text_primary_if_get(seq); primary_if = batadv_seq_print_text_primary_if_get(seq);
if (!primary_if) if (!primary_if)
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_hard_iface;
struct batadv_orig_node;
struct batadv_priv;
struct seq_file; struct seq_file;
struct sk_buff; struct sk_buff;
...@@ -38,7 +35,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, ...@@ -38,7 +35,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
void *offset); void *offset);
bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig, bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
unsigned short vid); unsigned short vid);
int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
struct sk_buff *skb); struct sk_buff *skb);
...@@ -84,8 +81,7 @@ static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, ...@@ -84,8 +81,7 @@ static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
} }
static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
uint8_t *orig, u8 *orig, unsigned short vid)
unsigned short vid)
{ {
return false; return false;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/kconfig.h> #include <linux/kconfig.h>
struct batadv_hard_iface;
struct net_device; struct net_device;
#define BATADV_DEBUGFS_SUBDIR "batman_adv" #define BATADV_DEBUGFS_SUBDIR "batman_adv"
......
...@@ -102,7 +102,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv, ...@@ -102,7 +102,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv,
struct batadv_dat_entry *dat_entry; struct batadv_dat_entry *dat_entry;
struct hlist_node *node_tmp; struct hlist_node *node_tmp;
struct hlist_head *head; struct hlist_head *head;
uint32_t i; u32 i;
if (!bat_priv->dat.hash) if (!bat_priv->dat.hash)
return; return;
...@@ -168,11 +168,11 @@ static int batadv_compare_dat(const struct hlist_node *node, const void *data2) ...@@ -168,11 +168,11 @@ static int batadv_compare_dat(const struct hlist_node *node, const void *data2)
* *
* Returns the value of the hw_src field in the ARP packet. * Returns the value of the hw_src field in the ARP packet.
*/ */
static uint8_t *batadv_arp_hw_src(struct sk_buff *skb, int hdr_size) static u8 *batadv_arp_hw_src(struct sk_buff *skb, int hdr_size)
{ {
uint8_t *addr; u8 *addr;
addr = (uint8_t *)(skb->data + hdr_size); addr = (u8 *)(skb->data + hdr_size);
addr += ETH_HLEN + sizeof(struct arphdr); addr += ETH_HLEN + sizeof(struct arphdr);
return addr; return addr;
...@@ -197,7 +197,7 @@ static __be32 batadv_arp_ip_src(struct sk_buff *skb, int hdr_size) ...@@ -197,7 +197,7 @@ static __be32 batadv_arp_ip_src(struct sk_buff *skb, int hdr_size)
* *
* Returns the value of the hw_dst field in the ARP packet. * Returns the value of the hw_dst field in the ARP packet.
*/ */
static uint8_t *batadv_arp_hw_dst(struct sk_buff *skb, int hdr_size) static u8 *batadv_arp_hw_dst(struct sk_buff *skb, int hdr_size)
{ {
return batadv_arp_hw_src(skb, hdr_size) + ETH_ALEN + 4; return batadv_arp_hw_src(skb, hdr_size) + ETH_ALEN + 4;
} }
...@@ -221,12 +221,12 @@ static __be32 batadv_arp_ip_dst(struct sk_buff *skb, int hdr_size) ...@@ -221,12 +221,12 @@ static __be32 batadv_arp_ip_dst(struct sk_buff *skb, int hdr_size)
* *
* Returns the selected index in the hash table for the given data. * Returns the selected index in the hash table for the given data.
*/ */
static uint32_t batadv_hash_dat(const void *data, uint32_t size) static u32 batadv_hash_dat(const void *data, u32 size)
{ {
uint32_t hash = 0; u32 hash = 0;
const struct batadv_dat_entry *dat = data; const struct batadv_dat_entry *dat = data;
const unsigned char *key; const unsigned char *key;
uint32_t i; u32 i;
key = (const unsigned char *)&dat->ip; key = (const unsigned char *)&dat->ip;
for (i = 0; i < sizeof(dat->ip); i++) { for (i = 0; i < sizeof(dat->ip); i++) {
...@@ -265,7 +265,7 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip, ...@@ -265,7 +265,7 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
struct hlist_head *head; struct hlist_head *head;
struct batadv_dat_entry to_find, *dat_entry, *dat_entry_tmp = NULL; struct batadv_dat_entry to_find, *dat_entry, *dat_entry_tmp = NULL;
struct batadv_hashtable *hash = bat_priv->dat.hash; struct batadv_hashtable *hash = bat_priv->dat.hash;
uint32_t index; u32 index;
if (!hash) if (!hash)
return NULL; return NULL;
...@@ -300,7 +300,7 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip, ...@@ -300,7 +300,7 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
* @vid: VLAN identifier * @vid: VLAN identifier
*/ */
static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
uint8_t *mac_addr, unsigned short vid) u8 *mac_addr, unsigned short vid)
{ {
struct batadv_dat_entry *dat_entry; struct batadv_dat_entry *dat_entry;
int hash_added; int hash_added;
...@@ -357,11 +357,11 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -357,11 +357,11 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
* @msg: message to print together with the debugging information * @msg: message to print together with the debugging information
*/ */
static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
uint16_t type, int hdr_size, char *msg) u16 type, int hdr_size, char *msg)
{ {
struct batadv_unicast_4addr_packet *unicast_4addr_packet; struct batadv_unicast_4addr_packet *unicast_4addr_packet;
struct batadv_bcast_packet *bcast_pkt; struct batadv_bcast_packet *bcast_pkt;
uint8_t *orig_addr; u8 *orig_addr;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
if (msg) if (msg)
...@@ -424,7 +424,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -424,7 +424,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
#else #else
static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
uint16_t type, int hdr_size, char *msg) u16 type, int hdr_size, char *msg)
{ {
} }
...@@ -497,7 +497,8 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, ...@@ -497,7 +497,8 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
int select, batadv_dat_addr_t ip_key, int select, batadv_dat_addr_t ip_key,
batadv_dat_addr_t *last_max) batadv_dat_addr_t *last_max)
{ {
batadv_dat_addr_t max = 0, tmp_max = 0; batadv_dat_addr_t max = 0;
batadv_dat_addr_t tmp_max = 0;
struct batadv_orig_node *orig_node, *max_orig_node = NULL; struct batadv_orig_node *orig_node, *max_orig_node = NULL;
struct batadv_hashtable *hash = bat_priv->orig_hash; struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head; struct hlist_head *head;
...@@ -709,9 +710,8 @@ void batadv_dat_status_update(struct net_device *net_dev) ...@@ -709,9 +710,8 @@ void batadv_dat_status_update(struct net_device *net_dev)
*/ */
static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value, u16 tvlv_value_len)
uint16_t tvlv_value_len)
{ {
if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND)
clear_bit(BATADV_ORIG_CAPA_HAS_DAT, &orig->capabilities); clear_bit(BATADV_ORIG_CAPA_HAS_DAT, &orig->capabilities);
...@@ -787,7 +787,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) ...@@ -787,7 +787,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
struct hlist_head *head; struct hlist_head *head;
unsigned long last_seen_jiffies; unsigned long last_seen_jiffies;
int last_seen_msecs, last_seen_secs, last_seen_mins; int last_seen_msecs, last_seen_secs, last_seen_mins;
uint32_t i; u32 i;
primary_if = batadv_seq_print_text_primary_if_get(seq); primary_if = batadv_seq_print_text_primary_if_get(seq);
if (!primary_if) if (!primary_if)
...@@ -830,14 +830,14 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) ...@@ -830,14 +830,14 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
* *
* Returns the ARP type if the skb contains a valid ARP packet, 0 otherwise. * Returns the ARP type if the skb contains a valid ARP packet, 0 otherwise.
*/ */
static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv, static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
struct sk_buff *skb, int hdr_size) struct sk_buff *skb, int hdr_size)
{ {
struct arphdr *arphdr; struct arphdr *arphdr;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
uint8_t *hw_src, *hw_dst; u8 *hw_src, *hw_dst;
uint16_t type = 0; u16 type = 0;
/* pull the ethernet header */ /* pull the ethernet header */
if (unlikely(!pskb_may_pull(skb, hdr_size + ETH_HLEN))) if (unlikely(!pskb_may_pull(skb, hdr_size + ETH_HLEN)))
...@@ -934,9 +934,9 @@ static unsigned short batadv_dat_get_vid(struct sk_buff *skb, int *hdr_size) ...@@ -934,9 +934,9 @@ static unsigned short batadv_dat_get_vid(struct sk_buff *skb, int *hdr_size)
bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
{ {
uint16_t type = 0; u16 type = 0;
__be32 ip_dst, ip_src; __be32 ip_dst, ip_src;
uint8_t *hw_src; u8 *hw_src;
bool ret = false; bool ret = false;
struct batadv_dat_entry *dat_entry = NULL; struct batadv_dat_entry *dat_entry = NULL;
struct sk_buff *skb_new; struct sk_buff *skb_new;
...@@ -1022,9 +1022,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1022,9 +1022,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
struct sk_buff *skb, int hdr_size) struct sk_buff *skb, int hdr_size)
{ {
uint16_t type; u16 type;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
uint8_t *hw_src; u8 *hw_src;
struct sk_buff *skb_new; struct sk_buff *skb_new;
struct batadv_dat_entry *dat_entry = NULL; struct batadv_dat_entry *dat_entry = NULL;
bool ret = false; bool ret = false;
...@@ -1100,9 +1100,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ...@@ -1100,9 +1100,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
{ {
uint16_t type; u16 type;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
uint8_t *hw_src, *hw_dst; u8 *hw_src, *hw_dst;
int hdr_size = 0; int hdr_size = 0;
unsigned short vid; unsigned short vid;
...@@ -1146,9 +1146,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, ...@@ -1146,9 +1146,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
struct sk_buff *skb, int hdr_size) struct sk_buff *skb, int hdr_size)
{ {
uint16_t type; u16 type;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
uint8_t *hw_src, *hw_dst; u8 *hw_src, *hw_dst;
bool dropped = false; bool dropped = false;
unsigned short vid; unsigned short vid;
...@@ -1202,7 +1202,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, ...@@ -1202,7 +1202,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
struct batadv_forw_packet *forw_packet) struct batadv_forw_packet *forw_packet)
{ {
uint16_t type; u16 type;
__be32 ip_dst; __be32 ip_dst;
struct batadv_dat_entry *dat_entry = NULL; struct batadv_dat_entry *dat_entry = NULL;
bool ret = false; bool ret = false;
......
...@@ -54,7 +54,7 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, ...@@ -54,7 +54,7 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
static inline void static inline void
batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node) batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
{ {
uint32_t addr; u32 addr;
addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX); addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
orig_node->dat_addr = (batadv_dat_addr_t)addr; orig_node->dat_addr = (batadv_dat_addr_t)addr;
...@@ -69,7 +69,7 @@ static inline void ...@@ -69,7 +69,7 @@ static inline void
batadv_dat_init_own_addr(struct batadv_priv *bat_priv, batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if) struct batadv_hard_iface *primary_if)
{ {
uint32_t addr; u32 addr;
addr = batadv_choose_orig(primary_if->net_dev->dev_addr, addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
BATADV_DAT_ADDR_MAX); BATADV_DAT_ADDR_MAX);
...@@ -89,7 +89,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset); ...@@ -89,7 +89,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset);
* Updates the ethtool statistics for the received packet if it is a DAT subtype * Updates the ethtool statistics for the received packet if it is a DAT subtype
*/ */
static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv, static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
uint8_t subtype) u8 subtype)
{ {
switch (subtype) { switch (subtype) {
case BATADV_P_DAT_DHT_GET: case BATADV_P_DAT_DHT_GET:
...@@ -169,7 +169,7 @@ static inline void batadv_dat_free(struct batadv_priv *bat_priv) ...@@ -169,7 +169,7 @@ static inline void batadv_dat_free(struct batadv_priv *bat_priv)
} }
static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv, static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
uint8_t subtype) u8 subtype)
{ {
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/pkt_sched.h> #include <linux/pkt_sched.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -66,7 +67,7 @@ void batadv_frag_purge_orig(struct batadv_orig_node *orig_node, ...@@ -66,7 +67,7 @@ void batadv_frag_purge_orig(struct batadv_orig_node *orig_node,
bool (*check_cb)(struct batadv_frag_table_entry *)) bool (*check_cb)(struct batadv_frag_table_entry *))
{ {
struct batadv_frag_table_entry *chain; struct batadv_frag_table_entry *chain;
uint8_t i; u8 i;
for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) { for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
chain = &orig_node->fragments[i]; chain = &orig_node->fragments[i];
...@@ -110,8 +111,10 @@ static int batadv_frag_size_limit(void) ...@@ -110,8 +111,10 @@ static int batadv_frag_size_limit(void)
* without searching for the right position. * without searching for the right position.
*/ */
static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain, static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain,
uint16_t seqno) u16 seqno)
{ {
lockdep_assert_held(&chain->lock);
if (chain->seqno == seqno) if (chain->seqno == seqno)
return false; return false;
...@@ -145,8 +148,8 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node, ...@@ -145,8 +148,8 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr; struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr;
struct batadv_frag_list_entry *frag_entry_last = NULL; struct batadv_frag_list_entry *frag_entry_last = NULL;
struct batadv_frag_packet *frag_packet; struct batadv_frag_packet *frag_packet;
uint8_t bucket; u8 bucket;
uint16_t seqno, hdr_size = sizeof(struct batadv_frag_packet); u16 seqno, hdr_size = sizeof(struct batadv_frag_packet);
bool ret = false; bool ret = false;
/* Linearize packet to avoid linearizing 16 packets in a row when doing /* Linearize packet to avoid linearizing 16 packets in a row when doing
...@@ -351,7 +354,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, ...@@ -351,7 +354,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
struct batadv_orig_node *orig_node_dst = NULL; struct batadv_orig_node *orig_node_dst = NULL;
struct batadv_neigh_node *neigh_node = NULL; struct batadv_neigh_node *neigh_node = NULL;
struct batadv_frag_packet *packet; struct batadv_frag_packet *packet;
uint16_t total_size; u16 total_size;
bool ret = false; bool ret = false;
packet = (struct batadv_frag_packet *)skb->data; packet = (struct batadv_frag_packet *)skb->data;
......
...@@ -153,9 +153,10 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -153,9 +153,10 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
struct batadv_neigh_node *router; struct batadv_neigh_node *router;
struct batadv_neigh_ifinfo *router_ifinfo; struct batadv_neigh_ifinfo *router_ifinfo;
struct batadv_gw_node *gw_node, *curr_gw = NULL; struct batadv_gw_node *gw_node, *curr_gw = NULL;
uint64_t max_gw_factor = 0, tmp_gw_factor = 0; u64 max_gw_factor = 0;
uint8_t max_tq = 0; u64 tmp_gw_factor = 0;
uint8_t tq_avg; u8 max_tq = 0;
u8 tq_avg;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
rcu_read_lock(); rcu_read_lock();
...@@ -263,7 +264,8 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv) ...@@ -263,7 +264,8 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
void batadv_gw_election(struct batadv_priv *bat_priv) void batadv_gw_election(struct batadv_priv *bat_priv)
{ {
struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL; struct batadv_gw_node *curr_gw = NULL;
struct batadv_gw_node *next_gw = NULL;
struct batadv_neigh_node *router = NULL; struct batadv_neigh_node *router = NULL;
struct batadv_neigh_ifinfo *router_ifinfo = NULL; struct batadv_neigh_ifinfo *router_ifinfo = NULL;
char gw_addr[18] = { '\0' }; char gw_addr[18] = { '\0' };
...@@ -347,8 +349,9 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, ...@@ -347,8 +349,9 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_neigh_ifinfo *router_orig_tq = NULL; struct batadv_neigh_ifinfo *router_orig_tq = NULL;
struct batadv_neigh_ifinfo *router_gw_tq = NULL; struct batadv_neigh_ifinfo *router_gw_tq = NULL;
struct batadv_orig_node *curr_gw_orig; struct batadv_orig_node *curr_gw_orig;
struct batadv_neigh_node *router_gw = NULL, *router_orig = NULL; struct batadv_neigh_node *router_gw = NULL;
uint8_t gw_tq_avg, orig_tq_avg; struct batadv_neigh_node *router_orig = NULL;
u8 gw_tq_avg, orig_tq_avg;
curr_gw_orig = batadv_gw_get_selected_orig(bat_priv); curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
if (!curr_gw_orig) if (!curr_gw_orig)
...@@ -688,7 +691,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -688,7 +691,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
*/ */
enum batadv_dhcp_recipient enum batadv_dhcp_recipient
batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
uint8_t *chaddr) u8 *chaddr)
{ {
enum batadv_dhcp_recipient ret = BATADV_DHCP_NO; enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
...@@ -698,7 +701,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, ...@@ -698,7 +701,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
int chaddr_offset; int chaddr_offset;
__be16 proto; __be16 proto;
uint8_t *p; u8 *p;
/* check for ethernet header */ /* check for ethernet header */
if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) if (!pskb_may_pull(skb, *header_len + ETH_HLEN))
...@@ -808,13 +811,15 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, ...@@ -808,13 +811,15 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL; struct batadv_neigh_node *neigh_curr = NULL;
struct batadv_neigh_node *neigh_old = NULL;
struct batadv_orig_node *orig_dst_node = NULL; struct batadv_orig_node *orig_dst_node = NULL;
struct batadv_gw_node *gw_node = NULL, *curr_gw = NULL; struct batadv_gw_node *gw_node = NULL;
struct batadv_gw_node *curr_gw = NULL;
struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo; struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
bool out_of_range = false; bool out_of_range = false;
uint8_t curr_tq_avg; u8 curr_tq_avg;
unsigned short vid; unsigned short vid;
vid = batadv_get_vid(skb, 0); vid = batadv_get_vid(skb, 0);
......
...@@ -43,6 +43,6 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); ...@@ -43,6 +43,6 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb); bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
enum batadv_dhcp_recipient enum batadv_dhcp_recipient
batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
uint8_t *chaddr); u8 *chaddr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
#include "main.h" #include "main.h"
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/errno.h>
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/string.h> #include <linux/string.h>
...@@ -39,11 +41,11 @@ ...@@ -39,11 +41,11 @@
* Returns false on parse error and true otherwise. * Returns false on parse error and true otherwise.
*/ */
static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
uint32_t *down, uint32_t *up) u32 *down, u32 *up)
{ {
enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT; enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT;
char *slash_ptr, *tmp_ptr; char *slash_ptr, *tmp_ptr;
long ldown, lup; u64 ldown, lup;
int ret; int ret;
slash_ptr = strchr(buff, '/'); slash_ptr = strchr(buff, '/');
...@@ -61,7 +63,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -61,7 +63,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0'; *tmp_ptr = '\0';
} }
ret = kstrtol(buff, 10, &ldown); ret = kstrtou64(buff, 10, &ldown);
if (ret) { if (ret) {
batadv_err(net_dev, batadv_err(net_dev,
"Download speed of gateway mode invalid: %s\n", "Download speed of gateway mode invalid: %s\n",
...@@ -71,14 +73,31 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -71,14 +73,31 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
switch (bw_unit_type) { switch (bw_unit_type) {
case BATADV_BW_UNIT_MBIT: case BATADV_BW_UNIT_MBIT:
*down = ldown * 10; /* prevent overflow */
if (U64_MAX / 10 < ldown) {
batadv_err(net_dev,
"Download speed of gateway mode too large: %s\n",
buff);
return false;
}
ldown *= 10;
break; break;
case BATADV_BW_UNIT_KBIT: case BATADV_BW_UNIT_KBIT:
default: default:
*down = ldown / 100; ldown = div_u64(ldown, 100);
break; break;
} }
if (U32_MAX < ldown) {
batadv_err(net_dev,
"Download speed of gateway mode too large: %s\n",
buff);
return false;
}
*down = ldown;
/* we also got some upload info */ /* we also got some upload info */
if (slash_ptr) { if (slash_ptr) {
bw_unit_type = BATADV_BW_UNIT_KBIT; bw_unit_type = BATADV_BW_UNIT_KBIT;
...@@ -94,7 +113,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -94,7 +113,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0'; *tmp_ptr = '\0';
} }
ret = kstrtol(slash_ptr + 1, 10, &lup); ret = kstrtou64(slash_ptr + 1, 10, &lup);
if (ret) { if (ret) {
batadv_err(net_dev, batadv_err(net_dev,
"Upload speed of gateway mode invalid: %s\n", "Upload speed of gateway mode invalid: %s\n",
...@@ -104,13 +123,30 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -104,13 +123,30 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
switch (bw_unit_type) { switch (bw_unit_type) {
case BATADV_BW_UNIT_MBIT: case BATADV_BW_UNIT_MBIT:
*up = lup * 10; /* prevent overflow */
if (U64_MAX / 10 < lup) {
batadv_err(net_dev,
"Upload speed of gateway mode too large: %s\n",
slash_ptr + 1);
return false;
}
lup *= 10;
break; break;
case BATADV_BW_UNIT_KBIT: case BATADV_BW_UNIT_KBIT:
default: default:
*up = lup / 100; lup = div_u64(lup, 100);
break; break;
} }
if (U32_MAX < lup) {
batadv_err(net_dev,
"Upload speed of gateway mode too large: %s\n",
slash_ptr + 1);
return false;
}
*up = lup;
} }
return true; return true;
...@@ -124,7 +160,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff, ...@@ -124,7 +160,7 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv) void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv)
{ {
struct batadv_tvlv_gateway_data gw; struct batadv_tvlv_gateway_data gw;
uint32_t down, up; u32 down, up;
char gw_mode; char gw_mode;
gw_mode = atomic_read(&bat_priv->gw_mode); gw_mode = atomic_read(&bat_priv->gw_mode);
...@@ -149,7 +185,10 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -149,7 +185,10 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
size_t count) size_t count)
{ {
struct batadv_priv *bat_priv = netdev_priv(net_dev); struct batadv_priv *bat_priv = netdev_priv(net_dev);
uint32_t down_curr, up_curr, down_new = 0, up_new = 0; u32 down_curr;
u32 up_curr;
u32 down_new = 0;
u32 up_new = 0;
bool ret; bool ret;
down_curr = (unsigned int)atomic_read(&bat_priv->gw.bandwidth_down); down_curr = (unsigned int)atomic_read(&bat_priv->gw.bandwidth_down);
...@@ -157,7 +196,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -157,7 +196,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
ret = batadv_parse_gw_bandwidth(net_dev, buff, &down_new, &up_new); ret = batadv_parse_gw_bandwidth(net_dev, buff, &down_new, &up_new);
if (!ret) if (!ret)
goto end; return -EINVAL;
if (!down_new) if (!down_new)
down_new = 1; down_new = 1;
...@@ -181,7 +220,6 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -181,7 +220,6 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
atomic_set(&bat_priv->gw.bandwidth_up, up_new); atomic_set(&bat_priv->gw.bandwidth_up, up_new);
batadv_gw_tvlv_container_update(bat_priv); batadv_gw_tvlv_container_update(bat_priv);
end:
return count; return count;
} }
...@@ -195,9 +233,8 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -195,9 +233,8 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
*/ */
static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value, u16 tvlv_value_len)
uint16_t tvlv_value_len)
{ {
struct batadv_tvlv_gateway_data gateway, *gateway_ptr; struct batadv_tvlv_gateway_data gateway, *gateway_ptr;
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_priv;
struct net_device; struct net_device;
enum batadv_gw_modes { enum batadv_gw_modes {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
/* clears the hash */ /* clears the hash */
static void batadv_hash_init(struct batadv_hashtable *hash) static void batadv_hash_init(struct batadv_hashtable *hash)
{ {
uint32_t i; u32 i;
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
INIT_HLIST_HEAD(&hash->table[i]); INIT_HLIST_HEAD(&hash->table[i]);
...@@ -42,7 +42,7 @@ void batadv_hash_destroy(struct batadv_hashtable *hash) ...@@ -42,7 +42,7 @@ void batadv_hash_destroy(struct batadv_hashtable *hash)
} }
/* allocates and clears the hash */ /* allocates and clears the hash */
struct batadv_hashtable *batadv_hash_new(uint32_t size) struct batadv_hashtable *batadv_hash_new(u32 size)
{ {
struct batadv_hashtable *hash; struct batadv_hashtable *hash;
...@@ -73,7 +73,7 @@ struct batadv_hashtable *batadv_hash_new(uint32_t size) ...@@ -73,7 +73,7 @@ struct batadv_hashtable *batadv_hash_new(uint32_t size)
void batadv_hash_set_lock_class(struct batadv_hashtable *hash, void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
struct lock_class_key *key) struct lock_class_key *key)
{ {
uint32_t i; u32 i;
for (i = 0; i < hash->size; i++) for (i = 0; i < hash->size; i++)
lockdep_set_class(&hash->list_locks[i], key); lockdep_set_class(&hash->list_locks[i], key);
......
...@@ -39,17 +39,17 @@ typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *, ...@@ -39,17 +39,17 @@ typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,
* based on the key in the data of the first * based on the key in the data of the first
* argument and the size the second * argument and the size the second
*/ */
typedef uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t); typedef u32 (*batadv_hashdata_choose_cb)(const void *, u32);
typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *); typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
struct batadv_hashtable { struct batadv_hashtable {
struct hlist_head *table; /* the hashtable itself with the buckets */ struct hlist_head *table; /* the hashtable itself with the buckets */
spinlock_t *list_locks; /* spinlock for each hash list entry */ spinlock_t *list_locks; /* spinlock for each hash list entry */
uint32_t size; /* size of hashtable */ u32 size; /* size of hashtable */
}; };
/* allocates and clears the hash */ /* allocates and clears the hash */
struct batadv_hashtable *batadv_hash_new(uint32_t size); struct batadv_hashtable *batadv_hash_new(u32 size);
/* set class key for all locks */ /* set class key for all locks */
void batadv_hash_set_lock_class(struct batadv_hashtable *hash, void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
...@@ -69,7 +69,7 @@ static inline void batadv_hash_delete(struct batadv_hashtable *hash, ...@@ -69,7 +69,7 @@ static inline void batadv_hash_delete(struct batadv_hashtable *hash,
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node, *node_tmp; struct hlist_node *node, *node_tmp;
spinlock_t *list_lock; /* spinlock to protect write access */ spinlock_t *list_lock; /* spinlock to protect write access */
uint32_t i; u32 i;
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
...@@ -105,7 +105,7 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash, ...@@ -105,7 +105,7 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,
const void *data, const void *data,
struct hlist_node *data_node) struct hlist_node *data_node)
{ {
uint32_t index; u32 index;
int ret = -1; int ret = -1;
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node; struct hlist_node *node;
...@@ -149,7 +149,7 @@ static inline void *batadv_hash_remove(struct batadv_hashtable *hash, ...@@ -149,7 +149,7 @@ static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
batadv_hashdata_choose_cb choose, batadv_hashdata_choose_cb choose,
void *data) void *data)
{ {
uint32_t index; u32 index;
struct hlist_node *node; struct hlist_node *node;
struct hlist_head *head; struct hlist_head *head;
void *data_save = NULL; void *data_save = NULL;
......
...@@ -183,7 +183,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -183,7 +183,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
struct batadv_neigh_node *neigh_node = NULL; struct batadv_neigh_node *neigh_node = NULL;
size_t packet_len = sizeof(struct batadv_icmp_packet); size_t packet_len = sizeof(struct batadv_icmp_packet);
uint8_t *addr; u8 *addr;
if (len < sizeof(struct batadv_icmp_header)) { if (len < sizeof(struct batadv_icmp_header)) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
...@@ -337,8 +337,8 @@ int batadv_socket_setup(struct batadv_priv *bat_priv) ...@@ -337,8 +337,8 @@ int batadv_socket_setup(struct batadv_priv *bat_priv)
} }
/** /**
* batadv_socket_receive_packet - schedule an icmp packet to be sent to userspace * batadv_socket_receive_packet - schedule an icmp packet to be sent to
* on an icmp socket. * userspace on an icmp socket.
* @socket_client: the socket this packet belongs to * @socket_client: the socket this packet belongs to
* @icmph: pointer to the header of the icmp packet * @icmph: pointer to the header of the icmp packet
* @icmp_len: total length of the icmp packet * @icmp_len: total length of the icmp packet
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_icmp_header; struct batadv_icmp_header;
struct batadv_priv;
#define BATADV_ICMP_SOCKET "socket" #define BATADV_ICMP_SOCKET "socket"
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -148,7 +149,7 @@ int batadv_mesh_init(struct net_device *soft_iface) ...@@ -148,7 +149,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
INIT_HLIST_HEAD(&bat_priv->mcast.want_all_ipv6_list); INIT_HLIST_HEAD(&bat_priv->mcast.want_all_ipv6_list);
#endif #endif
INIT_LIST_HEAD(&bat_priv->tt.changes_list); INIT_LIST_HEAD(&bat_priv->tt.changes_list);
INIT_LIST_HEAD(&bat_priv->tt.req_list); INIT_HLIST_HEAD(&bat_priv->tt.req_list);
INIT_LIST_HEAD(&bat_priv->tt.roam_list); INIT_LIST_HEAD(&bat_priv->tt.roam_list);
#ifdef CONFIG_BATMAN_ADV_MCAST #ifdef CONFIG_BATMAN_ADV_MCAST
INIT_HLIST_HEAD(&bat_priv->mcast.mla_list); INIT_HLIST_HEAD(&bat_priv->mcast.mla_list);
...@@ -234,7 +235,7 @@ void batadv_mesh_free(struct net_device *soft_iface) ...@@ -234,7 +235,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
* *
* Returns 'true' if the mac address was found, false otherwise. * Returns 'true' if the mac address was found, false otherwise.
*/ */
bool batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr) bool batadv_is_my_mac(struct batadv_priv *bat_priv, const u8 *addr)
{ {
const struct batadv_hard_iface *hard_iface; const struct batadv_hard_iface *hard_iface;
bool is_my_mac = false; bool is_my_mac = false;
...@@ -387,7 +388,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -387,7 +388,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct batadv_priv *bat_priv; struct batadv_priv *bat_priv;
struct batadv_ogm_packet *batadv_ogm_packet; struct batadv_ogm_packet *batadv_ogm_packet;
struct batadv_hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
uint8_t idx; u8 idx;
int ret; int ret;
hard_iface = container_of(ptype, struct batadv_hard_iface, hard_iface = container_of(ptype, struct batadv_hard_iface,
...@@ -496,7 +497,7 @@ static void batadv_recv_handler_init(void) ...@@ -496,7 +497,7 @@ static void batadv_recv_handler_init(void)
} }
int int
batadv_recv_handler_register(uint8_t packet_type, batadv_recv_handler_register(u8 packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *)) struct batadv_hard_iface *))
{ {
...@@ -512,7 +513,7 @@ batadv_recv_handler_register(uint8_t packet_type, ...@@ -512,7 +513,7 @@ batadv_recv_handler_register(uint8_t packet_type,
return 0; return 0;
} }
void batadv_recv_handler_unregister(uint8_t packet_type) void batadv_recv_handler_unregister(u8 packet_type)
{ {
batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet; batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
} }
...@@ -583,7 +584,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) ...@@ -583,7 +584,7 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
seq_puts(seq, "Available routing algorithms:\n"); seq_puts(seq, "Available routing algorithms:\n");
hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) { hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) {
seq_printf(seq, "%s\n", bat_algo_ops->name); seq_printf(seq, " * %s\n", bat_algo_ops->name);
} }
return 0; return 0;
...@@ -642,8 +643,7 @@ batadv_tvlv_handler_free_ref(struct batadv_tvlv_handler *tvlv_handler) ...@@ -642,8 +643,7 @@ batadv_tvlv_handler_free_ref(struct batadv_tvlv_handler *tvlv_handler)
* Returns tvlv handler if found or NULL otherwise. * Returns tvlv handler if found or NULL otherwise.
*/ */
static struct batadv_tvlv_handler static struct batadv_tvlv_handler
*batadv_tvlv_handler_get(struct batadv_priv *bat_priv, *batadv_tvlv_handler_get(struct batadv_priv *bat_priv, u8 type, u8 version)
uint8_t type, uint8_t version)
{ {
struct batadv_tvlv_handler *tvlv_handler_tmp, *tvlv_handler = NULL; struct batadv_tvlv_handler *tvlv_handler_tmp, *tvlv_handler = NULL;
...@@ -691,8 +691,7 @@ static void batadv_tvlv_container_free_ref(struct batadv_tvlv_container *tvlv) ...@@ -691,8 +691,7 @@ static void batadv_tvlv_container_free_ref(struct batadv_tvlv_container *tvlv)
* Returns tvlv container if found or NULL otherwise. * Returns tvlv container if found or NULL otherwise.
*/ */
static struct batadv_tvlv_container static struct batadv_tvlv_container
*batadv_tvlv_container_get(struct batadv_priv *bat_priv, *batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
uint8_t type, uint8_t version)
{ {
struct batadv_tvlv_container *tvlv_tmp, *tvlv = NULL; struct batadv_tvlv_container *tvlv_tmp, *tvlv = NULL;
...@@ -723,10 +722,10 @@ static struct batadv_tvlv_container ...@@ -723,10 +722,10 @@ static struct batadv_tvlv_container
* *
* Returns size of all currently registered tvlv containers in bytes. * Returns size of all currently registered tvlv containers in bytes.
*/ */
static uint16_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv) static u16 batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
{ {
struct batadv_tvlv_container *tvlv; struct batadv_tvlv_container *tvlv;
uint16_t tvlv_len = 0; u16 tvlv_len = 0;
hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) { hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) {
tvlv_len += sizeof(struct batadv_tvlv_hdr); tvlv_len += sizeof(struct batadv_tvlv_hdr);
...@@ -739,13 +738,17 @@ static uint16_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv) ...@@ -739,13 +738,17 @@ static uint16_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
/** /**
* batadv_tvlv_container_remove - remove tvlv container from the tvlv container * batadv_tvlv_container_remove - remove tvlv container from the tvlv container
* list * list
* @bat_priv: the bat priv with all the soft interface information
* @tvlv: the to be removed tvlv container * @tvlv: the to be removed tvlv container
* *
* Has to be called with the appropriate locks being acquired * Has to be called with the appropriate locks being acquired
* (tvlv.container_list_lock). * (tvlv.container_list_lock).
*/ */
static void batadv_tvlv_container_remove(struct batadv_tvlv_container *tvlv) static void batadv_tvlv_container_remove(struct batadv_priv *bat_priv,
struct batadv_tvlv_container *tvlv)
{ {
lockdep_assert_held(&bat_priv->tvlv.handler_list_lock);
if (!tvlv) if (!tvlv)
return; return;
...@@ -764,13 +767,13 @@ static void batadv_tvlv_container_remove(struct batadv_tvlv_container *tvlv) ...@@ -764,13 +767,13 @@ static void batadv_tvlv_container_remove(struct batadv_tvlv_container *tvlv)
* @version: tvlv container type to unregister * @version: tvlv container type to unregister
*/ */
void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv, void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version) u8 type, u8 version)
{ {
struct batadv_tvlv_container *tvlv; struct batadv_tvlv_container *tvlv;
spin_lock_bh(&bat_priv->tvlv.container_list_lock); spin_lock_bh(&bat_priv->tvlv.container_list_lock);
tvlv = batadv_tvlv_container_get(bat_priv, type, version); tvlv = batadv_tvlv_container_get(bat_priv, type, version);
batadv_tvlv_container_remove(tvlv); batadv_tvlv_container_remove(bat_priv, tvlv);
spin_unlock_bh(&bat_priv->tvlv.container_list_lock); spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
} }
...@@ -787,8 +790,8 @@ void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv, ...@@ -787,8 +790,8 @@ void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
* content is going to replace the old one. * content is going to replace the old one.
*/ */
void batadv_tvlv_container_register(struct batadv_priv *bat_priv, void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version, u8 type, u8 version,
void *tvlv_value, uint16_t tvlv_value_len) void *tvlv_value, u16 tvlv_value_len)
{ {
struct batadv_tvlv_container *tvlv_old, *tvlv_new; struct batadv_tvlv_container *tvlv_old, *tvlv_new;
...@@ -809,7 +812,7 @@ void batadv_tvlv_container_register(struct batadv_priv *bat_priv, ...@@ -809,7 +812,7 @@ void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->tvlv.container_list_lock); spin_lock_bh(&bat_priv->tvlv.container_list_lock);
tvlv_old = batadv_tvlv_container_get(bat_priv, type, version); tvlv_old = batadv_tvlv_container_get(bat_priv, type, version);
batadv_tvlv_container_remove(tvlv_old); batadv_tvlv_container_remove(bat_priv, tvlv_old);
hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list); hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list);
spin_unlock_bh(&bat_priv->tvlv.container_list_lock); spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
} }
...@@ -861,14 +864,13 @@ static bool batadv_tvlv_realloc_packet_buff(unsigned char **packet_buff, ...@@ -861,14 +864,13 @@ static bool batadv_tvlv_realloc_packet_buff(unsigned char **packet_buff,
* *
* Returns size of all appended tvlv containers in bytes. * Returns size of all appended tvlv containers in bytes.
*/ */
uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
unsigned char **packet_buff, unsigned char **packet_buff,
int *packet_buff_len, int *packet_buff_len, int packet_min_len)
int packet_min_len)
{ {
struct batadv_tvlv_container *tvlv; struct batadv_tvlv_container *tvlv;
struct batadv_tvlv_hdr *tvlv_hdr; struct batadv_tvlv_hdr *tvlv_hdr;
uint16_t tvlv_value_len; u16 tvlv_value_len;
void *tvlv_value; void *tvlv_value;
bool ret; bool ret;
...@@ -893,7 +895,7 @@ uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, ...@@ -893,7 +895,7 @@ uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
tvlv_hdr->len = tvlv->tvlv_hdr.len; tvlv_hdr->len = tvlv->tvlv_hdr.len;
tvlv_value = tvlv_hdr + 1; tvlv_value = tvlv_hdr + 1;
memcpy(tvlv_value, tvlv + 1, ntohs(tvlv->tvlv_hdr.len)); memcpy(tvlv_value, tvlv + 1, ntohs(tvlv->tvlv_hdr.len));
tvlv_value = (uint8_t *)tvlv_value + ntohs(tvlv->tvlv_hdr.len); tvlv_value = (u8 *)tvlv_value + ntohs(tvlv->tvlv_hdr.len);
} }
end: end:
...@@ -920,8 +922,8 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv, ...@@ -920,8 +922,8 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv,
struct batadv_tvlv_handler *tvlv_handler, struct batadv_tvlv_handler *tvlv_handler,
bool ogm_source, bool ogm_source,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
uint8_t *src, uint8_t *dst, u8 *src, u8 *dst,
void *tvlv_value, uint16_t tvlv_value_len) void *tvlv_value, u16 tvlv_value_len)
{ {
if (!tvlv_handler) if (!tvlv_handler)
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
...@@ -972,13 +974,13 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv, ...@@ -972,13 +974,13 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv,
int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
bool ogm_source, bool ogm_source,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
uint8_t *src, uint8_t *dst, u8 *src, u8 *dst,
void *tvlv_value, uint16_t tvlv_value_len) void *tvlv_value, u16 tvlv_value_len)
{ {
struct batadv_tvlv_handler *tvlv_handler; struct batadv_tvlv_handler *tvlv_handler;
struct batadv_tvlv_hdr *tvlv_hdr; struct batadv_tvlv_hdr *tvlv_hdr;
uint16_t tvlv_value_cont_len; u16 tvlv_value_cont_len;
uint8_t cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND; u8 cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND;
int ret = NET_RX_SUCCESS; int ret = NET_RX_SUCCESS;
while (tvlv_value_len >= sizeof(*tvlv_hdr)) { while (tvlv_value_len >= sizeof(*tvlv_hdr)) {
...@@ -1000,7 +1002,7 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, ...@@ -1000,7 +1002,7 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
tvlv_value_cont_len); tvlv_value_cont_len);
if (tvlv_handler) if (tvlv_handler)
batadv_tvlv_handler_free_ref(tvlv_handler); batadv_tvlv_handler_free_ref(tvlv_handler);
tvlv_value = (uint8_t *)tvlv_value + tvlv_value_cont_len; tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len;
tvlv_value_len -= tvlv_value_cont_len; tvlv_value_len -= tvlv_value_cont_len;
} }
...@@ -1034,7 +1036,7 @@ void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv, ...@@ -1034,7 +1036,7 @@ void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node) struct batadv_orig_node *orig_node)
{ {
void *tvlv_value; void *tvlv_value;
uint16_t tvlv_value_len; u16 tvlv_value_len;
if (!batadv_ogm_packet) if (!batadv_ogm_packet)
return; return;
...@@ -1066,14 +1068,14 @@ void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv, ...@@ -1066,14 +1068,14 @@ void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
void (*optr)(struct batadv_priv *bat_priv, void (*optr)(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value,
uint16_t tvlv_value_len), u16 tvlv_value_len),
int (*uptr)(struct batadv_priv *bat_priv, int (*uptr)(struct batadv_priv *bat_priv,
uint8_t *src, uint8_t *dst, u8 *src, u8 *dst,
void *tvlv_value, void *tvlv_value,
uint16_t tvlv_value_len), u16 tvlv_value_len),
uint8_t type, uint8_t version, uint8_t flags) u8 type, u8 version, u8 flags)
{ {
struct batadv_tvlv_handler *tvlv_handler; struct batadv_tvlv_handler *tvlv_handler;
...@@ -1108,7 +1110,7 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, ...@@ -1108,7 +1110,7 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
* @version: tvlv handler version to be unregistered * @version: tvlv handler version to be unregistered
*/ */
void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv, void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version) u8 type, u8 version)
{ {
struct batadv_tvlv_handler *tvlv_handler; struct batadv_tvlv_handler *tvlv_handler;
...@@ -1134,9 +1136,9 @@ void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv, ...@@ -1134,9 +1136,9 @@ void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
* @tvlv_value: tvlv content * @tvlv_value: tvlv content
* @tvlv_value_len: tvlv content length * @tvlv_value_len: tvlv content length
*/ */
void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src, void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
uint8_t *dst, uint8_t type, uint8_t version, u8 *dst, u8 type, u8 version,
void *tvlv_value, uint16_t tvlv_value_len) void *tvlv_value, u16 tvlv_value_len)
{ {
struct batadv_unicast_tvlv_packet *unicast_tvlv_packet; struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
struct batadv_tvlv_hdr *tvlv_hdr; struct batadv_tvlv_hdr *tvlv_hdr;
......
...@@ -193,7 +193,7 @@ extern struct workqueue_struct *batadv_event_workqueue; ...@@ -193,7 +193,7 @@ extern struct workqueue_struct *batadv_event_workqueue;
int batadv_mesh_init(struct net_device *soft_iface); int batadv_mesh_init(struct net_device *soft_iface);
void batadv_mesh_free(struct net_device *soft_iface); void batadv_mesh_free(struct net_device *soft_iface);
bool batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr); bool batadv_is_my_mac(struct batadv_priv *bat_priv, const u8 *addr);
struct batadv_hard_iface * struct batadv_hard_iface *
batadv_seq_print_text_primary_if_get(struct seq_file *seq); batadv_seq_print_text_primary_if_get(struct seq_file *seq);
int batadv_max_header_len(void); int batadv_max_header_len(void);
...@@ -202,10 +202,10 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -202,10 +202,10 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct packet_type *ptype,
struct net_device *orig_dev); struct net_device *orig_dev);
int int
batadv_recv_handler_register(uint8_t packet_type, batadv_recv_handler_register(u8 packet_type,
int (*recv_handler)(struct sk_buff *, int (*recv_handler)(struct sk_buff *,
struct batadv_hard_iface *)); struct batadv_hard_iface *));
void batadv_recv_handler_unregister(uint8_t packet_type); void batadv_recv_handler_unregister(u8 packet_type);
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops); int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
int batadv_algo_select(struct batadv_priv *bat_priv, char *name); int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
...@@ -304,7 +304,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, ...@@ -304,7 +304,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
* they handle overflows/underflows and can correctly check for a * they handle overflows/underflows and can correctly check for a
* predecessor/successor unless the variable sequence number has grown by * predecessor/successor unless the variable sequence number has grown by
* more then 2**(bitwidth(x)-1)-1. * more then 2**(bitwidth(x)-1)-1.
* This means that for a uint8_t with the maximum value 255, it would think: * This means that for a u8 with the maximum value 255, it would think:
* - when adding nothing - it is neither a predecessor nor a successor * - when adding nothing - it is neither a predecessor nor a successor
* - before adding more than 127 to the starting value - it is a predecessor, * - before adding more than 127 to the starting value - it is a predecessor,
* - when adding 128 - it is neither a predecessor nor a successor, * - when adding 128 - it is neither a predecessor nor a successor,
...@@ -327,10 +327,9 @@ static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx, ...@@ -327,10 +327,9 @@ static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1) #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
/* Sum and return the cpu-local counters for index 'idx' */ /* Sum and return the cpu-local counters for index 'idx' */
static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv, static inline u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx)
size_t idx)
{ {
uint64_t *counters, sum = 0; u64 *counters, sum = 0;
int cpu; int cpu;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
...@@ -348,39 +347,38 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv, ...@@ -348,39 +347,38 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,
#define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0])) #define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0]))
void batadv_tvlv_container_register(struct batadv_priv *bat_priv, void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version, u8 type, u8 version,
void *tvlv_value, uint16_t tvlv_value_len); void *tvlv_value, u16 tvlv_value_len);
uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
unsigned char **packet_buff, unsigned char **packet_buff,
int *packet_buff_len, int *packet_buff_len, int packet_min_len);
int packet_min_len);
void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv, void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
struct batadv_ogm_packet *batadv_ogm_packet, struct batadv_ogm_packet *batadv_ogm_packet,
struct batadv_orig_node *orig_node); struct batadv_orig_node *orig_node);
void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv, void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version); u8 type, u8 version);
void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
void (*optr)(struct batadv_priv *bat_priv, void (*optr)(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value,
uint16_t tvlv_value_len), u16 tvlv_value_len),
int (*uptr)(struct batadv_priv *bat_priv, int (*uptr)(struct batadv_priv *bat_priv,
uint8_t *src, uint8_t *dst, u8 *src, u8 *dst,
void *tvlv_value, void *tvlv_value,
uint16_t tvlv_value_len), u16 tvlv_value_len),
uint8_t type, uint8_t version, uint8_t flags); u8 type, u8 version, u8 flags);
void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv, void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
uint8_t type, uint8_t version); u8 type, u8 version);
int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
bool ogm_source, bool ogm_source,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
uint8_t *src, uint8_t *dst, u8 *src, u8 *dst,
void *tvlv_buff, uint16_t tvlv_buff_len); void *tvlv_buff, u16 tvlv_buff_len);
void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src, void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
uint8_t *dst, uint8_t type, uint8_t version, u8 *dst, u8 type, u8 version,
void *tvlv_value, uint16_t tvlv_value_len); void *tvlv_value, u16 tvlv_value_len);
unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len); unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len);
bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid); bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/rculist.h> #include <linux/rculist.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
...@@ -89,7 +90,7 @@ static int batadv_mcast_mla_softif_get(struct net_device *dev, ...@@ -89,7 +90,7 @@ static int batadv_mcast_mla_softif_get(struct net_device *dev,
* Returns true if the given address is already in the given list. * Returns true if the given address is already in the given list.
* Otherwise returns false. * Otherwise returns false.
*/ */
static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr, static bool batadv_mcast_mla_is_duplicate(u8 *mcast_addr,
struct hlist_head *mcast_list) struct hlist_head *mcast_list)
{ {
struct batadv_hw_addr *mcast_entry; struct batadv_hw_addr *mcast_entry;
...@@ -103,15 +104,19 @@ static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr, ...@@ -103,15 +104,19 @@ static bool batadv_mcast_mla_is_duplicate(uint8_t *mcast_addr,
/** /**
* batadv_mcast_mla_list_free - free a list of multicast addresses * batadv_mcast_mla_list_free - free a list of multicast addresses
* @bat_priv: the bat priv with all the soft interface information
* @mcast_list: the list to free * @mcast_list: the list to free
* *
* Removes and frees all items in the given mcast_list. * Removes and frees all items in the given mcast_list.
*/ */
static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list) static void batadv_mcast_mla_list_free(struct batadv_priv *bat_priv,
struct hlist_head *mcast_list)
{ {
struct batadv_hw_addr *mcast_entry; struct batadv_hw_addr *mcast_entry;
struct hlist_node *tmp; struct hlist_node *tmp;
lockdep_assert_held(&bat_priv->tt.commit_lock);
hlist_for_each_entry_safe(mcast_entry, tmp, mcast_list, list) { hlist_for_each_entry_safe(mcast_entry, tmp, mcast_list, list) {
hlist_del(&mcast_entry->list); hlist_del(&mcast_entry->list);
kfree(mcast_entry); kfree(mcast_entry);
...@@ -134,6 +139,8 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv, ...@@ -134,6 +139,8 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
struct batadv_hw_addr *mcast_entry; struct batadv_hw_addr *mcast_entry;
struct hlist_node *tmp; struct hlist_node *tmp;
lockdep_assert_held(&bat_priv->tt.commit_lock);
hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list, hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list,
list) { list) {
if (mcast_list && if (mcast_list &&
...@@ -164,6 +171,8 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv, ...@@ -164,6 +171,8 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv,
struct batadv_hw_addr *mcast_entry; struct batadv_hw_addr *mcast_entry;
struct hlist_node *tmp; struct hlist_node *tmp;
lockdep_assert_held(&bat_priv->tt.commit_lock);
if (!mcast_list) if (!mcast_list)
return; return;
...@@ -268,7 +277,7 @@ void batadv_mcast_mla_update(struct batadv_priv *bat_priv) ...@@ -268,7 +277,7 @@ void batadv_mcast_mla_update(struct batadv_priv *bat_priv)
batadv_mcast_mla_tt_add(bat_priv, &mcast_list); batadv_mcast_mla_tt_add(bat_priv, &mcast_list);
out: out:
batadv_mcast_mla_list_free(&mcast_list); batadv_mcast_mla_list_free(bat_priv, &mcast_list);
} }
/** /**
...@@ -595,11 +604,13 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -595,11 +604,13 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
*/ */
static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv, static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t mcast_flags) u8 mcast_flags)
{ {
struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node; struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node;
struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list; struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list;
lockdep_assert_held(&orig->mcast_handler_lock);
/* switched from flag unset to set */ /* switched from flag unset to set */
if (mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && if (mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
!(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) { !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) {
...@@ -638,11 +649,13 @@ static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv, ...@@ -638,11 +649,13 @@ static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,
*/ */
static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv, static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t mcast_flags) u8 mcast_flags)
{ {
struct hlist_node *node = &orig->mcast_want_all_ipv4_node; struct hlist_node *node = &orig->mcast_want_all_ipv4_node;
struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list; struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list;
lockdep_assert_held(&orig->mcast_handler_lock);
/* switched from flag unset to set */ /* switched from flag unset to set */
if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV4 && if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV4 &&
!(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) { !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) {
...@@ -681,11 +694,13 @@ static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv, ...@@ -681,11 +694,13 @@ static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,
*/ */
static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv, static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t mcast_flags) u8 mcast_flags)
{ {
struct hlist_node *node = &orig->mcast_want_all_ipv6_node; struct hlist_node *node = &orig->mcast_want_all_ipv6_node;
struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list; struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list;
lockdep_assert_held(&orig->mcast_handler_lock);
/* switched from flag unset to set */ /* switched from flag unset to set */
if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV6 && if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV6 &&
!(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) { !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) {
...@@ -721,17 +736,17 @@ static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv, ...@@ -721,17 +736,17 @@ static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv,
*/ */
static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value,
uint16_t tvlv_value_len) u16 tvlv_value_len)
{ {
bool orig_mcast_enabled = !(flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND); bool orig_mcast_enabled = !(flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
uint8_t mcast_flags = BATADV_NO_FLAGS; u8 mcast_flags = BATADV_NO_FLAGS;
bool orig_initialized; bool orig_initialized;
if (orig_mcast_enabled && tvlv_value && if (orig_mcast_enabled && tvlv_value &&
(tvlv_value_len >= sizeof(mcast_flags))) (tvlv_value_len >= sizeof(mcast_flags)))
mcast_flags = *(uint8_t *)tvlv_value; mcast_flags = *(u8 *)tvlv_value;
spin_lock_bh(&orig->mcast_handler_lock); spin_lock_bh(&orig->mcast_handler_lock);
orig_initialized = test_bit(BATADV_ORIG_CAPA_HAS_MCAST, orig_initialized = test_bit(BATADV_ORIG_CAPA_HAS_MCAST,
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "main.h" #include "main.h"
struct batadv_orig_node;
struct batadv_priv;
struct sk_buff; struct sk_buff;
/** /**
......
...@@ -130,9 +130,8 @@ void batadv_nc_status_update(struct net_device *net_dev) ...@@ -130,9 +130,8 @@ void batadv_nc_status_update(struct net_device *net_dev)
*/ */
static void batadv_nc_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, static void batadv_nc_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig, struct batadv_orig_node *orig,
uint8_t flags, u8 flags,
void *tvlv_value, void *tvlv_value, u16 tvlv_value_len)
uint16_t tvlv_value_len)
{ {
if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND)
clear_bit(BATADV_ORIG_CAPA_HAS_NC, &orig->capabilities); clear_bit(BATADV_ORIG_CAPA_HAS_NC, &orig->capabilities);
...@@ -382,7 +381,7 @@ static void batadv_nc_purge_orig_hash(struct batadv_priv *bat_priv) ...@@ -382,7 +381,7 @@ static void batadv_nc_purge_orig_hash(struct batadv_priv *bat_priv)
struct batadv_hashtable *hash = bat_priv->orig_hash; struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head; struct hlist_head *head;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint32_t i; u32 i;
if (!hash) if (!hash)
return; return;
...@@ -418,7 +417,7 @@ static void batadv_nc_purge_paths(struct batadv_priv *bat_priv, ...@@ -418,7 +417,7 @@ static void batadv_nc_purge_paths(struct batadv_priv *bat_priv,
struct hlist_node *node_tmp; struct hlist_node *node_tmp;
struct batadv_nc_path *nc_path; struct batadv_nc_path *nc_path;
spinlock_t *lock; /* Protects lists in hash */ spinlock_t *lock; /* Protects lists in hash */
uint32_t i; u32 i;
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
head = &hash->table[i]; head = &hash->table[i];
...@@ -478,10 +477,10 @@ static void batadv_nc_hash_key_gen(struct batadv_nc_path *key, const char *src, ...@@ -478,10 +477,10 @@ static void batadv_nc_hash_key_gen(struct batadv_nc_path *key, const char *src,
* *
* Returns the selected index in the hash table for the given data. * Returns the selected index in the hash table for the given data.
*/ */
static uint32_t batadv_nc_hash_choose(const void *data, uint32_t size) static u32 batadv_nc_hash_choose(const void *data, u32 size)
{ {
const struct batadv_nc_path *nc_path = data; const struct batadv_nc_path *nc_path = data;
uint32_t hash = 0; u32 hash = 0;
hash = jhash(&nc_path->prev_hop, sizeof(nc_path->prev_hop), hash); hash = jhash(&nc_path->prev_hop, sizeof(nc_path->prev_hop), hash);
hash = jhash(&nc_path->next_hop, sizeof(nc_path->next_hop), hash); hash = jhash(&nc_path->next_hop, sizeof(nc_path->next_hop), hash);
...@@ -587,6 +586,8 @@ static bool batadv_nc_sniffed_purge(struct batadv_priv *bat_priv, ...@@ -587,6 +586,8 @@ static bool batadv_nc_sniffed_purge(struct batadv_priv *bat_priv,
unsigned long timeout = bat_priv->nc.max_buffer_time; unsigned long timeout = bat_priv->nc.max_buffer_time;
bool res = false; bool res = false;
lockdep_assert_held(&nc_path->packet_list_lock);
/* Packets are added to tail, so the remaining packets did not time /* Packets are added to tail, so the remaining packets did not time
* out and we can stop processing the current queue * out and we can stop processing the current queue
*/ */
...@@ -623,6 +624,8 @@ static bool batadv_nc_fwd_flush(struct batadv_priv *bat_priv, ...@@ -623,6 +624,8 @@ static bool batadv_nc_fwd_flush(struct batadv_priv *bat_priv,
{ {
unsigned long timeout = bat_priv->nc.max_fwd_delay; unsigned long timeout = bat_priv->nc.max_fwd_delay;
lockdep_assert_held(&nc_path->packet_list_lock);
/* Packets are added to tail, so the remaining packets did not time /* Packets are added to tail, so the remaining packets did not time
* out and we can stop processing the current queue * out and we can stop processing the current queue
*/ */
...@@ -744,8 +747,8 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv, ...@@ -744,8 +747,8 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv,
struct batadv_ogm_packet *ogm_packet) struct batadv_ogm_packet *ogm_packet)
{ {
struct batadv_orig_ifinfo *orig_ifinfo; struct batadv_orig_ifinfo *orig_ifinfo;
uint32_t last_real_seqno; u32 last_real_seqno;
uint8_t last_ttl; u8 last_ttl;
orig_ifinfo = batadv_orig_ifinfo_get(orig_node, BATADV_IF_DEFAULT); orig_ifinfo = batadv_orig_ifinfo_get(orig_node, BATADV_IF_DEFAULT);
if (!orig_ifinfo) if (!orig_ifinfo)
...@@ -873,8 +876,8 @@ static struct batadv_nc_node ...@@ -873,8 +876,8 @@ static struct batadv_nc_node
} }
/** /**
* batadv_nc_update_nc_node - updates stored incoming and outgoing nc node structs * batadv_nc_update_nc_node - updates stored incoming and outgoing nc node
* (best called on incoming OGMs) * structs (best called on incoming OGMs)
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @orig_node: orig node originating the ogm packet * @orig_node: orig node originating the ogm packet
* @orig_neigh_node: neighboring orig node from which we received the ogm packet * @orig_neigh_node: neighboring orig node from which we received the ogm packet
...@@ -888,7 +891,8 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, ...@@ -888,7 +891,8 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
struct batadv_ogm_packet *ogm_packet, struct batadv_ogm_packet *ogm_packet,
int is_single_hop_neigh) int is_single_hop_neigh)
{ {
struct batadv_nc_node *in_nc_node = NULL, *out_nc_node = NULL; struct batadv_nc_node *in_nc_node = NULL;
struct batadv_nc_node *out_nc_node = NULL;
/* Check if network coding is enabled */ /* Check if network coding is enabled */
if (!atomic_read(&bat_priv->network_coding)) if (!atomic_read(&bat_priv->network_coding))
...@@ -938,8 +942,8 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, ...@@ -938,8 +942,8 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
*/ */
static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv,
struct batadv_hashtable *hash, struct batadv_hashtable *hash,
uint8_t *src, u8 *src,
uint8_t *dst) u8 *dst)
{ {
int hash_added; int hash_added;
struct batadv_nc_path *nc_path, nc_path_key; struct batadv_nc_path *nc_path, nc_path_key;
...@@ -991,9 +995,9 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, ...@@ -991,9 +995,9 @@ static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv,
* selection of a receiver with slightly lower TQ than the other * selection of a receiver with slightly lower TQ than the other
* @tq: to be weighted tq value * @tq: to be weighted tq value
*/ */
static uint8_t batadv_nc_random_weight_tq(uint8_t tq) static u8 batadv_nc_random_weight_tq(u8 tq)
{ {
uint8_t rand_val, rand_tq; u8 rand_val, rand_tq;
get_random_bytes(&rand_val, sizeof(rand_val)); get_random_bytes(&rand_val, sizeof(rand_val));
...@@ -1038,7 +1042,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1038,7 +1042,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
struct batadv_nc_packet *nc_packet, struct batadv_nc_packet *nc_packet,
struct batadv_neigh_node *neigh_node) struct batadv_neigh_node *neigh_node)
{ {
uint8_t tq_weighted_neigh, tq_weighted_coding, tq_tmp; u8 tq_weighted_neigh, tq_weighted_coding, tq_tmp;
struct sk_buff *skb_dest, *skb_src; struct sk_buff *skb_dest, *skb_src;
struct batadv_unicast_packet *packet1; struct batadv_unicast_packet *packet1;
struct batadv_unicast_packet *packet2; struct batadv_unicast_packet *packet2;
...@@ -1047,7 +1051,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1047,7 +1051,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
struct batadv_neigh_node *router_coding = NULL; struct batadv_neigh_node *router_coding = NULL;
struct batadv_neigh_ifinfo *router_neigh_ifinfo = NULL; struct batadv_neigh_ifinfo *router_neigh_ifinfo = NULL;
struct batadv_neigh_ifinfo *router_coding_ifinfo = NULL; struct batadv_neigh_ifinfo *router_coding_ifinfo = NULL;
uint8_t *first_source, *first_dest, *second_source, *second_dest; u8 *first_source, *first_dest, *second_source, *second_dest;
__be32 packet_id1, packet_id2; __be32 packet_id1, packet_id2;
size_t count; size_t count;
bool res = false; bool res = false;
...@@ -1231,8 +1235,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1231,8 +1235,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
* *
* Returns true if coding of a decoded packet is allowed. * Returns true if coding of a decoded packet is allowed.
*/ */
static bool batadv_nc_skb_coding_possible(struct sk_buff *skb, static bool batadv_nc_skb_coding_possible(struct sk_buff *skb, u8 *dst, u8 *src)
uint8_t *dst, uint8_t *src)
{ {
if (BATADV_SKB_CB(skb)->decoded && !batadv_compare_eth(dst, src)) if (BATADV_SKB_CB(skb)->decoded && !batadv_compare_eth(dst, src))
return false; return false;
...@@ -1255,7 +1258,7 @@ batadv_nc_path_search(struct batadv_priv *bat_priv, ...@@ -1255,7 +1258,7 @@ batadv_nc_path_search(struct batadv_priv *bat_priv,
struct batadv_nc_node *in_nc_node, struct batadv_nc_node *in_nc_node,
struct batadv_nc_node *out_nc_node, struct batadv_nc_node *out_nc_node,
struct sk_buff *skb, struct sk_buff *skb,
uint8_t *eth_dst) u8 *eth_dst)
{ {
struct batadv_nc_path *nc_path, nc_path_key; struct batadv_nc_path *nc_path, nc_path_key;
struct batadv_nc_packet *nc_packet_out = NULL; struct batadv_nc_packet *nc_packet_out = NULL;
...@@ -1321,8 +1324,8 @@ batadv_nc_path_search(struct batadv_priv *bat_priv, ...@@ -1321,8 +1324,8 @@ batadv_nc_path_search(struct batadv_priv *bat_priv,
static struct batadv_nc_packet * static struct batadv_nc_packet *
batadv_nc_skb_src_search(struct batadv_priv *bat_priv, batadv_nc_skb_src_search(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
uint8_t *eth_dst, u8 *eth_dst,
uint8_t *eth_src, u8 *eth_src,
struct batadv_nc_node *in_nc_node) struct batadv_nc_node *in_nc_node)
{ {
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
...@@ -1362,7 +1365,7 @@ batadv_nc_skb_src_search(struct batadv_priv *bat_priv, ...@@ -1362,7 +1365,7 @@ batadv_nc_skb_src_search(struct batadv_priv *bat_priv,
*/ */
static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv, static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
uint8_t *eth_dst_new) u8 *eth_dst_new)
{ {
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
...@@ -1638,7 +1641,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -1638,7 +1641,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct batadv_coded_packet coded_packet_tmp; struct batadv_coded_packet coded_packet_tmp;
struct ethhdr *ethhdr, ethhdr_tmp; struct ethhdr *ethhdr, ethhdr_tmp;
uint8_t *orig_dest, ttl, ttvn; u8 *orig_dest, ttl, ttvn;
unsigned int coding_len; unsigned int coding_len;
int err; int err;
...@@ -1730,7 +1733,7 @@ batadv_nc_find_decoding_packet(struct batadv_priv *bat_priv, ...@@ -1730,7 +1733,7 @@ batadv_nc_find_decoding_packet(struct batadv_priv *bat_priv,
struct batadv_hashtable *hash = bat_priv->nc.decoding_hash; struct batadv_hashtable *hash = bat_priv->nc.decoding_hash;
struct batadv_nc_packet *tmp_nc_packet, *nc_packet = NULL; struct batadv_nc_packet *tmp_nc_packet, *nc_packet = NULL;
struct batadv_nc_path *nc_path, nc_path_key; struct batadv_nc_path *nc_path, nc_path_key;
uint8_t *dest, *source; u8 *dest, *source;
__be32 packet_id; __be32 packet_id;
int index; int index;
......
...@@ -22,11 +22,7 @@ ...@@ -22,11 +22,7 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_nc_node;
struct batadv_neigh_node;
struct batadv_ogm_packet; struct batadv_ogm_packet;
struct batadv_orig_node;
struct batadv_priv;
struct net_device; struct net_device;
struct seq_file; struct seq_file;
struct sk_buff; struct sk_buff;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/lockdep.h> #include <linux/lockdep.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/rculist.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -70,7 +71,7 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, ...@@ -70,7 +71,7 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
struct batadv_orig_node_vlan *vlan = NULL, *tmp; struct batadv_orig_node_vlan *vlan = NULL, *tmp;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) { hlist_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) {
if (tmp->vid != vid) if (tmp->vid != vid)
continue; continue;
...@@ -118,7 +119,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, ...@@ -118,7 +119,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
atomic_set(&vlan->refcount, 2); atomic_set(&vlan->refcount, 2);
vlan->vid = vid; vlan->vid = vid;
list_add_rcu(&vlan->list, &orig_node->vlan_list); hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list);
out: out:
spin_unlock_bh(&orig_node->vlan_list_lock); spin_unlock_bh(&orig_node->vlan_list_lock);
...@@ -452,8 +453,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh, ...@@ -452,8 +453,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
*/ */
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
const uint8_t *neigh_addr, const u8 *neigh_addr, struct batadv_orig_node *orig_node)
struct batadv_orig_node *orig_node)
{ {
struct batadv_neigh_node *neigh_node; struct batadv_neigh_node *neigh_node;
...@@ -489,7 +489,7 @@ batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, ...@@ -489,7 +489,7 @@ batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_neigh_node_get(const struct batadv_orig_node *orig_node, batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *hard_iface, const struct batadv_hard_iface *hard_iface,
const uint8_t *addr) const u8 *addr)
{ {
struct batadv_neigh_node *tmp_neigh_node, *res = NULL; struct batadv_neigh_node *tmp_neigh_node, *res = NULL;
...@@ -624,7 +624,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv) ...@@ -624,7 +624,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)
struct hlist_head *head; struct hlist_head *head;
spinlock_t *list_lock; /* spinlock to protect write access */ spinlock_t *list_lock; /* spinlock to protect write access */
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint32_t i; u32 i;
if (!hash) if (!hash)
return; return;
...@@ -659,7 +659,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv) ...@@ -659,7 +659,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)
* Returns the newly created object or NULL on failure. * Returns the newly created object or NULL on failure.
*/ */
struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
const uint8_t *addr) const u8 *addr)
{ {
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
struct batadv_orig_node_vlan *vlan; struct batadv_orig_node_vlan *vlan;
...@@ -674,7 +674,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, ...@@ -674,7 +674,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
return NULL; return NULL;
INIT_HLIST_HEAD(&orig_node->neigh_list); INIT_HLIST_HEAD(&orig_node->neigh_list);
INIT_LIST_HEAD(&orig_node->vlan_list); INIT_HLIST_HEAD(&orig_node->vlan_list);
INIT_HLIST_HEAD(&orig_node->ifinfo_list); INIT_HLIST_HEAD(&orig_node->ifinfo_list);
spin_lock_init(&orig_node->bcast_seqno_lock); spin_lock_init(&orig_node->bcast_seqno_lock);
spin_lock_init(&orig_node->neigh_list_lock); spin_lock_init(&orig_node->neigh_list_lock);
...@@ -981,7 +981,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv) ...@@ -981,7 +981,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)
struct hlist_head *head; struct hlist_head *head;
spinlock_t *list_lock; /* spinlock to protect write access */ spinlock_t *list_lock; /* spinlock to protect write access */
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint32_t i; u32 i;
if (!hash) if (!hash)
return; return;
...@@ -1115,7 +1115,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, ...@@ -1115,7 +1115,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
struct batadv_hashtable *hash = bat_priv->orig_hash; struct batadv_hashtable *hash = bat_priv->orig_hash;
struct hlist_head *head; struct hlist_head *head;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint32_t i; u32 i;
int ret; int ret;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on /* resize all orig nodes because orig_node->bcast_own(_sum) depend on
...@@ -1152,7 +1152,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, ...@@ -1152,7 +1152,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
struct batadv_hard_iface *hard_iface_tmp; struct batadv_hard_iface *hard_iface_tmp;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
uint32_t i; u32 i;
int ret; int ret;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on /* resize all orig nodes because orig_node->bcast_own(_sum) depend on
......
...@@ -40,15 +40,14 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv); ...@@ -40,15 +40,14 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node); void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node);
void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node); void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node);
struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
const uint8_t *addr); const u8 *addr);
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_neigh_node_get(const struct batadv_orig_node *orig_node, batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *hard_iface, const struct batadv_hard_iface *hard_iface,
const uint8_t *addr); const u8 *addr);
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
const uint8_t *neigh_addr, const u8 *neigh_addr, struct batadv_orig_node *orig_node);
struct batadv_orig_node *orig_node);
void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node); void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node);
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_orig_router_get(struct batadv_orig_node *orig_node, batadv_orig_router_get(struct batadv_orig_node *orig_node,
...@@ -86,9 +85,9 @@ void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan); ...@@ -86,9 +85,9 @@ void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan);
/* hashfunction to choose an entry in a hash table of given size /* hashfunction to choose an entry in a hash table of given size
* hash algorithm from http://en.wikipedia.org/wiki/Hash_table * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
*/ */
static inline uint32_t batadv_choose_orig(const void *data, uint32_t size) static inline u32 batadv_choose_orig(const void *data, u32 size)
{ {
uint32_t hash = 0; u32 hash = 0;
hash = jhash(data, ETH_ALEN, hash); hash = jhash(data, ETH_ALEN, hash);
return hash % size; return hash % size;
......
...@@ -197,8 +197,8 @@ enum batadv_tvlv_type { ...@@ -197,8 +197,8 @@ enum batadv_tvlv_type {
* transport the claim type and the group id * transport the claim type and the group id
*/ */
struct batadv_bla_claim_dst { struct batadv_bla_claim_dst {
uint8_t magic[3]; /* FF:43:05 */ u8 magic[3]; /* FF:43:05 */
uint8_t type; /* bla_claimframe */ u8 type; /* bla_claimframe */
__be16 group; /* group id */ __be16 group; /* group id */
}; };
...@@ -213,16 +213,16 @@ struct batadv_bla_claim_dst { ...@@ -213,16 +213,16 @@ struct batadv_bla_claim_dst {
* @tvlv_len: length of tvlv data following the ogm header * @tvlv_len: length of tvlv data following the ogm header
*/ */
struct batadv_ogm_packet { struct batadv_ogm_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; u8 version;
uint8_t ttl; u8 ttl;
uint8_t flags; u8 flags;
__be32 seqno; __be32 seqno;
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
uint8_t prev_sender[ETH_ALEN]; u8 prev_sender[ETH_ALEN];
uint8_t reserved; u8 reserved;
uint8_t tq; u8 tq;
__be16 tvlv_len; __be16 tvlv_len;
/* __packed is not needed as the struct size is divisible by 4, /* __packed is not needed as the struct size is divisible by 4,
* and the largest data type in this struct has a size of 4. * and the largest data type in this struct has a size of 4.
*/ */
...@@ -246,14 +246,14 @@ struct batadv_ogm_packet { ...@@ -246,14 +246,14 @@ struct batadv_ogm_packet {
* members are padded the same way as they are in real packets. * members are padded the same way as they are in real packets.
*/ */
struct batadv_icmp_header { struct batadv_icmp_header {
uint8_t packet_type; u8 packet_type;
uint8_t version; u8 version;
uint8_t ttl; u8 ttl;
uint8_t msg_type; /* see ICMP message types above */ u8 msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN]; u8 dst[ETH_ALEN];
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
uint8_t uid; u8 uid;
uint8_t align[3]; u8 align[3];
}; };
/** /**
...@@ -269,15 +269,15 @@ struct batadv_icmp_header { ...@@ -269,15 +269,15 @@ struct batadv_icmp_header {
* @seqno: ICMP sequence number * @seqno: ICMP sequence number
*/ */
struct batadv_icmp_packet { struct batadv_icmp_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; u8 version;
uint8_t ttl; u8 ttl;
uint8_t msg_type; /* see ICMP message types above */ u8 msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN]; u8 dst[ETH_ALEN];
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
uint8_t uid; u8 uid;
uint8_t reserved; u8 reserved;
__be16 seqno; __be16 seqno;
}; };
#define BATADV_RR_LEN 16 #define BATADV_RR_LEN 16
...@@ -296,16 +296,16 @@ struct batadv_icmp_packet { ...@@ -296,16 +296,16 @@ struct batadv_icmp_packet {
* @rr: route record array * @rr: route record array
*/ */
struct batadv_icmp_packet_rr { struct batadv_icmp_packet_rr {
uint8_t packet_type; u8 packet_type;
uint8_t version; u8 version;
uint8_t ttl; u8 ttl;
uint8_t msg_type; /* see ICMP message types above */ u8 msg_type; /* see ICMP message types above */
uint8_t dst[ETH_ALEN]; u8 dst[ETH_ALEN];
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
uint8_t uid; u8 uid;
uint8_t rr_cur; u8 rr_cur;
__be16 seqno; __be16 seqno;
uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; u8 rr[BATADV_RR_LEN][ETH_ALEN];
}; };
#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr) #define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
...@@ -331,11 +331,11 @@ struct batadv_icmp_packet_rr { ...@@ -331,11 +331,11 @@ struct batadv_icmp_packet_rr {
* @dest: originator destination of the unicast packet * @dest: originator destination of the unicast packet
*/ */
struct batadv_unicast_packet { struct batadv_unicast_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; u8 version;
uint8_t ttl; u8 ttl;
uint8_t ttvn; /* destination translation table version number */ u8 ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN]; u8 dest[ETH_ALEN];
/* "4 bytes boundary + 2 bytes" long to make the payload after the /* "4 bytes boundary + 2 bytes" long to make the payload after the
* following ethernet header again 4 bytes boundary aligned * following ethernet header again 4 bytes boundary aligned
*/ */
...@@ -349,9 +349,9 @@ struct batadv_unicast_packet { ...@@ -349,9 +349,9 @@ struct batadv_unicast_packet {
*/ */
struct batadv_unicast_4addr_packet { struct batadv_unicast_4addr_packet {
struct batadv_unicast_packet u; struct batadv_unicast_packet u;
uint8_t src[ETH_ALEN]; u8 src[ETH_ALEN];
uint8_t subtype; u8 subtype;
uint8_t reserved; u8 reserved;
/* "4 bytes boundary + 2 bytes" long to make the payload after the /* "4 bytes boundary + 2 bytes" long to make the payload after the
* following ethernet header again 4 bytes boundary aligned * following ethernet header again 4 bytes boundary aligned
*/ */
...@@ -370,22 +370,22 @@ struct batadv_unicast_4addr_packet { ...@@ -370,22 +370,22 @@ struct batadv_unicast_4addr_packet {
* @total_size: size of the merged packet * @total_size: size of the merged packet
*/ */
struct batadv_frag_packet { struct batadv_frag_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; /* batman version field */ u8 version; /* batman version field */
uint8_t ttl; u8 ttl;
#if defined(__BIG_ENDIAN_BITFIELD) #if defined(__BIG_ENDIAN_BITFIELD)
uint8_t no:4; u8 no:4;
uint8_t reserved:4; u8 reserved:4;
#elif defined(__LITTLE_ENDIAN_BITFIELD) #elif defined(__LITTLE_ENDIAN_BITFIELD)
uint8_t reserved:4; u8 reserved:4;
uint8_t no:4; u8 no:4;
#else #else
#error "unknown bitfield endianness" #error "unknown bitfield endianness"
#endif #endif
uint8_t dest[ETH_ALEN]; u8 dest[ETH_ALEN];
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
__be16 seqno; __be16 seqno;
__be16 total_size; __be16 total_size;
}; };
/** /**
...@@ -398,12 +398,12 @@ struct batadv_frag_packet { ...@@ -398,12 +398,12 @@ struct batadv_frag_packet {
* @orig: originator of the broadcast packet * @orig: originator of the broadcast packet
*/ */
struct batadv_bcast_packet { struct batadv_bcast_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; /* batman version field */ u8 version; /* batman version field */
uint8_t ttl; u8 ttl;
uint8_t reserved; u8 reserved;
__be32 seqno; __be32 seqno;
uint8_t orig[ETH_ALEN]; u8 orig[ETH_ALEN];
/* "4 bytes boundary + 2 bytes" long to make the payload after the /* "4 bytes boundary + 2 bytes" long to make the payload after the
* following ethernet header again 4 bytes boundary aligned * following ethernet header again 4 bytes boundary aligned
*/ */
...@@ -428,21 +428,21 @@ struct batadv_bcast_packet { ...@@ -428,21 +428,21 @@ struct batadv_bcast_packet {
* @coded_len: length of network coded part of the payload * @coded_len: length of network coded part of the payload
*/ */
struct batadv_coded_packet { struct batadv_coded_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; /* batman version field */ u8 version; /* batman version field */
uint8_t ttl; u8 ttl;
uint8_t first_ttvn; u8 first_ttvn;
/* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */ /* u8 first_dest[ETH_ALEN]; - saved in mac header destination */
uint8_t first_source[ETH_ALEN]; u8 first_source[ETH_ALEN];
uint8_t first_orig_dest[ETH_ALEN]; u8 first_orig_dest[ETH_ALEN];
__be32 first_crc; __be32 first_crc;
uint8_t second_ttl; u8 second_ttl;
uint8_t second_ttvn; u8 second_ttvn;
uint8_t second_dest[ETH_ALEN]; u8 second_dest[ETH_ALEN];
uint8_t second_source[ETH_ALEN]; u8 second_source[ETH_ALEN];
uint8_t second_orig_dest[ETH_ALEN]; u8 second_orig_dest[ETH_ALEN];
__be32 second_crc; __be32 second_crc;
__be16 coded_len; __be16 coded_len;
}; };
#pragma pack() #pragma pack()
...@@ -459,14 +459,14 @@ struct batadv_coded_packet { ...@@ -459,14 +459,14 @@ struct batadv_coded_packet {
* @align: 2 bytes to align the header to a 4 byte boundary * @align: 2 bytes to align the header to a 4 byte boundary
*/ */
struct batadv_unicast_tvlv_packet { struct batadv_unicast_tvlv_packet {
uint8_t packet_type; u8 packet_type;
uint8_t version; /* batman version field */ u8 version; /* batman version field */
uint8_t ttl; u8 ttl;
uint8_t reserved; u8 reserved;
uint8_t dst[ETH_ALEN]; u8 dst[ETH_ALEN];
uint8_t src[ETH_ALEN]; u8 src[ETH_ALEN];
__be16 tvlv_len; __be16 tvlv_len;
uint16_t align; u16 align;
}; };
/** /**
...@@ -476,9 +476,9 @@ struct batadv_unicast_tvlv_packet { ...@@ -476,9 +476,9 @@ struct batadv_unicast_tvlv_packet {
* @len: tvlv container length * @len: tvlv container length
*/ */
struct batadv_tvlv_hdr { struct batadv_tvlv_hdr {
uint8_t type; u8 type;
uint8_t version; u8 version;
__be16 len; __be16 len;
}; };
/** /**
...@@ -500,9 +500,9 @@ struct batadv_tvlv_gateway_data { ...@@ -500,9 +500,9 @@ struct batadv_tvlv_gateway_data {
* one batadv_tvlv_tt_vlan_data object per announced vlan * one batadv_tvlv_tt_vlan_data object per announced vlan
*/ */
struct batadv_tvlv_tt_data { struct batadv_tvlv_tt_data {
uint8_t flags; u8 flags;
uint8_t ttvn; u8 ttvn;
__be16 num_vlan; __be16 num_vlan;
}; };
/** /**
...@@ -513,9 +513,9 @@ struct batadv_tvlv_tt_data { ...@@ -513,9 +513,9 @@ struct batadv_tvlv_tt_data {
* @reserved: unused, useful for alignment purposes * @reserved: unused, useful for alignment purposes
*/ */
struct batadv_tvlv_tt_vlan_data { struct batadv_tvlv_tt_vlan_data {
__be32 crc; __be32 crc;
__be16 vid; __be16 vid;
uint16_t reserved; u16 reserved;
}; };
/** /**
...@@ -527,9 +527,9 @@ struct batadv_tvlv_tt_vlan_data { ...@@ -527,9 +527,9 @@ struct batadv_tvlv_tt_vlan_data {
* @vid: VLAN identifier * @vid: VLAN identifier
*/ */
struct batadv_tvlv_tt_change { struct batadv_tvlv_tt_change {
uint8_t flags; u8 flags;
uint8_t reserved[3]; u8 reserved[3];
uint8_t addr[ETH_ALEN]; u8 addr[ETH_ALEN];
__be16 vid; __be16 vid;
}; };
...@@ -539,7 +539,7 @@ struct batadv_tvlv_tt_change { ...@@ -539,7 +539,7 @@ struct batadv_tvlv_tt_change {
* @vid: VLAN identifier * @vid: VLAN identifier
*/ */
struct batadv_tvlv_roam_adv { struct batadv_tvlv_roam_adv {
uint8_t client[ETH_ALEN]; u8 client[ETH_ALEN];
__be16 vid; __be16 vid;
}; };
...@@ -549,8 +549,8 @@ struct batadv_tvlv_roam_adv { ...@@ -549,8 +549,8 @@ struct batadv_tvlv_roam_adv {
* @reserved: reserved field * @reserved: reserved field
*/ */
struct batadv_tvlv_mcast_data { struct batadv_tvlv_mcast_data {
uint8_t flags; u8 flags;
uint8_t reserved[3]; u8 reserved[3];
}; };
#endif /* _NET_BATMAN_ADV_PACKET_H_ */ #endif /* _NET_BATMAN_ADV_PACKET_H_ */
...@@ -145,7 +145,7 @@ void batadv_update_route(struct batadv_priv *bat_priv, ...@@ -145,7 +145,7 @@ void batadv_update_route(struct batadv_priv *bat_priv,
* 0 if the packet is to be accepted * 0 if the packet is to be accepted
* 1 if the packet is to be ignored. * 1 if the packet is to be ignored.
*/ */
int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff, int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff,
unsigned long *last_reset) unsigned long *last_reset)
{ {
if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
...@@ -653,19 +653,19 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ...@@ -653,19 +653,19 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
static bool static bool
batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
struct batadv_unicast_packet *unicast_packet, struct batadv_unicast_packet *unicast_packet,
uint8_t *dst_addr, unsigned short vid) u8 *dst_addr, unsigned short vid)
{ {
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
struct batadv_hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
bool ret = false; bool ret = false;
uint8_t *orig_addr, orig_ttvn; u8 *orig_addr, orig_ttvn;
if (batadv_is_my_client(bat_priv, dst_addr, vid)) { if (batadv_is_my_client(bat_priv, dst_addr, vid)) {
primary_if = batadv_primary_if_get_selected(bat_priv); primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if) if (!primary_if)
goto out; goto out;
orig_addr = primary_if->net_dev->dev_addr; orig_addr = primary_if->net_dev->dev_addr;
orig_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); orig_ttvn = (u8)atomic_read(&bat_priv->tt.vn);
} else { } else {
orig_node = batadv_transtable_search(bat_priv, NULL, dst_addr, orig_node = batadv_transtable_search(bat_priv, NULL, dst_addr,
vid); vid);
...@@ -676,7 +676,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, ...@@ -676,7 +676,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
goto out; goto out;
orig_addr = orig_node->orig; orig_addr = orig_node->orig;
orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); orig_ttvn = (u8)atomic_read(&orig_node->last_ttvn);
} }
/* update the packet header */ /* update the packet header */
...@@ -698,7 +698,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ...@@ -698,7 +698,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct batadv_hard_iface *primary_if; struct batadv_hard_iface *primary_if;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint8_t curr_ttvn, old_ttvn; u8 curr_ttvn, old_ttvn;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
unsigned short vid; unsigned short vid;
int is_old_ttvn; int is_old_ttvn;
...@@ -740,7 +740,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ...@@ -740,7 +740,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
* value is used later to check if the node which sent (or re-routed * value is used later to check if the node which sent (or re-routed
* last time) the packet had an updated information or not * last time) the packet had an updated information or not
*/ */
curr_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); curr_ttvn = (u8)atomic_read(&bat_priv->tt.vn);
if (!batadv_is_my_mac(bat_priv, unicast_packet->dest)) { if (!batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
orig_node = batadv_orig_hash_find(bat_priv, orig_node = batadv_orig_hash_find(bat_priv,
unicast_packet->dest); unicast_packet->dest);
...@@ -751,7 +751,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ...@@ -751,7 +751,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
if (!orig_node) if (!orig_node)
return 0; return 0;
curr_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); curr_ttvn = (u8)atomic_read(&orig_node->last_ttvn);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_free_ref(orig_node);
} }
...@@ -833,7 +833,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ...@@ -833,7 +833,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct batadv_unicast_4addr_packet *unicast_4addr_packet; struct batadv_unicast_4addr_packet *unicast_4addr_packet;
uint8_t *orig_addr; u8 *orig_addr;
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
int check, hdr_size = sizeof(*unicast_packet); int check, hdr_size = sizeof(*unicast_packet);
bool is4addr; bool is4addr;
...@@ -904,7 +904,7 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb, ...@@ -904,7 +904,7 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_tvlv_packet *unicast_tvlv_packet; struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
unsigned char *tvlv_buff; unsigned char *tvlv_buff;
uint16_t tvlv_buff_len; u16 tvlv_buff_len;
int hdr_size = sizeof(*unicast_tvlv_packet); int hdr_size = sizeof(*unicast_tvlv_packet);
int ret = NET_RX_DROP; int ret = NET_RX_DROP;
...@@ -1007,8 +1007,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1007,8 +1007,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
int hdr_size = sizeof(*bcast_packet); int hdr_size = sizeof(*bcast_packet);
int ret = NET_RX_DROP; int ret = NET_RX_DROP;
int32_t seq_diff; s32 seq_diff;
uint32_t seqno; u32 seqno;
/* drop packet if it has not necessary minimum size */ /* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, hdr_size))) if (unlikely(!pskb_may_pull(skb, hdr_size)))
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_hard_iface;
struct batadv_neigh_node;
struct batadv_orig_node;
struct batadv_priv;
struct sk_buff; struct sk_buff;
bool batadv_check_management_packet(struct sk_buff *skb, bool batadv_check_management_packet(struct sk_buff *skb,
...@@ -55,7 +51,7 @@ struct batadv_neigh_node * ...@@ -55,7 +51,7 @@ struct batadv_neigh_node *
batadv_find_router(struct batadv_priv *bat_priv, batadv_find_router(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_hard_iface *recv_if); struct batadv_hard_iface *recv_if);
int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff, int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff,
unsigned long *last_reset); unsigned long *last_reset);
#endif /* _NET_BATMAN_ADV_ROUTING_H_ */ #endif /* _NET_BATMAN_ADV_ROUTING_H_ */
...@@ -54,7 +54,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work); ...@@ -54,7 +54,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work);
*/ */
int batadv_send_skb_packet(struct sk_buff *skb, int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface, struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr) const u8 *dst_addr)
{ {
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
...@@ -172,7 +172,7 @@ batadv_send_skb_push_fill_unicast(struct sk_buff *skb, int hdr_size, ...@@ -172,7 +172,7 @@ batadv_send_skb_push_fill_unicast(struct sk_buff *skb, int hdr_size,
struct batadv_orig_node *orig_node) struct batadv_orig_node *orig_node)
{ {
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
uint8_t ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); u8 ttvn = (u8)atomic_read(&orig_node->last_ttvn);
if (batadv_skb_head_push(skb, hdr_size) < 0) if (batadv_skb_head_push(skb, hdr_size) < 0)
return false; return false;
...@@ -343,12 +343,12 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -343,12 +343,12 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
*/ */
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, uint8_t *dst_hint, int packet_subtype, u8 *dst_hint,
unsigned short vid) unsigned short vid)
{ {
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint8_t *src, *dst; u8 *src, *dst;
src = ethhdr->h_source; src = ethhdr->h_source;
dst = ethhdr->h_dest; dst = ethhdr->h_dest;
......
...@@ -25,15 +25,12 @@ ...@@ -25,15 +25,12 @@
#include "packet.h" #include "packet.h"
struct batadv_hard_iface;
struct batadv_orig_node;
struct batadv_priv;
struct sk_buff; struct sk_buff;
struct work_struct; struct work_struct;
int batadv_send_skb_packet(struct sk_buff *skb, int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface, struct batadv_hard_iface *hard_iface,
const uint8_t *dst_addr); const u8 *dst_addr);
int batadv_send_skb_to_orig(struct sk_buff *skb, int batadv_send_skb_to_orig(struct sk_buff *skb,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
struct batadv_hard_iface *recv_if); struct batadv_hard_iface *recv_if);
...@@ -56,7 +53,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -56,7 +53,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
unsigned short vid); unsigned short vid);
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, uint8_t *dst_hint, int packet_subtype, u8 *dst_hint,
unsigned short vid); unsigned short vid);
int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid); unsigned short vid);
...@@ -75,7 +72,7 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -75,7 +72,7 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
* Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/ */
static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
struct sk_buff *skb, uint8_t *dst_hint, struct sk_buff *skb, u8 *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0, return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
...@@ -100,7 +97,7 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, ...@@ -100,7 +97,7 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
int packet_subtype, int packet_subtype,
uint8_t *dst_hint, u8 *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, return batadv_send_skb_via_tt_generic(bat_priv, skb,
......
...@@ -131,7 +131,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -131,7 +131,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_priv *bat_priv = netdev_priv(dev);
struct batadv_softif_vlan *vlan; struct batadv_softif_vlan *vlan;
struct sockaddr *addr = p; struct sockaddr *addr = p;
uint8_t old_addr[ETH_ALEN]; u8 old_addr[ETH_ALEN];
if (!is_valid_ether_addr(addr->sa_data)) if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
...@@ -186,19 +186,19 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -186,19 +186,19 @@ static int batadv_interface_tx(struct sk_buff *skb,
struct batadv_hard_iface *primary_if = NULL; struct batadv_hard_iface *primary_if = NULL;
struct batadv_bcast_packet *bcast_packet; struct batadv_bcast_packet *bcast_packet;
__be16 ethertype = htons(ETH_P_BATMAN); __be16 ethertype = htons(ETH_P_BATMAN);
static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, static const u8 stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00,
0x00, 0x00}; 0x00, 0x00};
static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, static const u8 ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
0x00, 0x00}; 0x00, 0x00};
enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO; enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
uint8_t *dst_hint = NULL, chaddr[ETH_ALEN]; u8 *dst_hint = NULL, chaddr[ETH_ALEN];
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
unsigned int header_len = 0; unsigned int header_len = 0;
int data_len = skb->len, ret; int data_len = skb->len, ret;
unsigned long brd_delay = 1; unsigned long brd_delay = 1;
bool do_bcast = false, client_added; bool do_bcast = false, client_added;
unsigned short vid; unsigned short vid;
uint32_t seqno; u32 seqno;
int gw_mode; int gw_mode;
enum batadv_forw_mode forw_mode; enum batadv_forw_mode forw_mode;
struct batadv_orig_node *mcast_single_orig = NULL; struct batadv_orig_node *mcast_single_orig = NULL;
...@@ -750,9 +750,9 @@ static void batadv_softif_destroy_finish(struct work_struct *work) ...@@ -750,9 +750,9 @@ static void batadv_softif_destroy_finish(struct work_struct *work)
static int batadv_softif_init_late(struct net_device *dev) static int batadv_softif_init_late(struct net_device *dev)
{ {
struct batadv_priv *bat_priv; struct batadv_priv *bat_priv;
uint32_t random_seqno; u32 random_seqno;
int ret; int ret;
size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM; size_t cnt_len = sizeof(u64) * BATADV_CNT_NUM;
batadv_set_lockdep_class(dev); batadv_set_lockdep_class(dev);
...@@ -763,7 +763,7 @@ static int batadv_softif_init_late(struct net_device *dev) ...@@ -763,7 +763,7 @@ static int batadv_softif_init_late(struct net_device *dev)
/* batadv_interface_stats() needs to be available as soon as /* batadv_interface_stats() needs to be available as soon as
* register_netdevice() has been called * register_netdevice() has been called
*/ */
bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(u64));
if (!bat_priv->bat_counters) if (!bat_priv->bat_counters)
return -ENOMEM; return -ENOMEM;
...@@ -1117,8 +1117,7 @@ static const struct { ...@@ -1117,8 +1117,7 @@ static const struct {
#endif #endif
}; };
static void batadv_get_strings(struct net_device *dev, uint32_t stringset, static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
uint8_t *data)
{ {
if (stringset == ETH_SS_STATS) if (stringset == ETH_SS_STATS)
memcpy(data, batadv_counters_strings, memcpy(data, batadv_counters_strings,
...@@ -1126,8 +1125,7 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset, ...@@ -1126,8 +1125,7 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
} }
static void batadv_get_ethtool_stats(struct net_device *dev, static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, struct ethtool_stats *stats, u64 *data)
uint64_t *data)
{ {
struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_priv *bat_priv = netdev_priv(dev);
int i; int i;
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
struct batadv_hard_iface;
struct batadv_orig_node;
struct batadv_priv;
struct batadv_softif_vlan;
struct net_device; struct net_device;
struct sk_buff; struct sk_buff;
......
...@@ -457,7 +457,7 @@ static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, ...@@ -457,7 +457,7 @@ static ssize_t batadv_show_gw_bwidth(struct kobject *kobj,
struct attribute *attr, char *buff) struct attribute *attr, char *buff)
{ {
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
uint32_t down, up; u32 down, up;
down = atomic_read(&bat_priv->gw.bandwidth_down); down = atomic_read(&bat_priv->gw.bandwidth_down);
up = atomic_read(&bat_priv->gw.bandwidth_up); up = atomic_read(&bat_priv->gw.bandwidth_up);
...@@ -512,7 +512,7 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj, ...@@ -512,7 +512,7 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
{ {
struct net_device *net_dev = batadv_kobj_to_netdev(kobj); struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct batadv_priv *bat_priv = netdev_priv(net_dev); struct batadv_priv *bat_priv = netdev_priv(net_dev);
uint32_t mark, mask; u32 mark, mask;
char *mask_ptr; char *mask_ptr;
/* parse the mask if it has been specified, otherwise assume the mask is /* parse the mask if it has been specified, otherwise assume the mask is
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/types.h> #include <linux/types.h>
struct batadv_priv;
struct batadv_softif_vlan;
struct kobject; struct kobject;
struct net_device; struct net_device;
......
This diff is collapsed.
...@@ -22,44 +22,41 @@ ...@@ -22,44 +22,41 @@
#include <linux/types.h> #include <linux/types.h>
struct batadv_orig_node;
struct batadv_priv;
struct net_device; struct net_device;
struct seq_file; struct seq_file;
int batadv_tt_init(struct batadv_priv *bat_priv); int batadv_tt_init(struct batadv_priv *bat_priv);
bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
unsigned short vid, int ifindex, uint32_t mark); unsigned short vid, int ifindex, u32 mark);
uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid, const u8 *addr, unsigned short vid,
const char *message, bool roaming); const char *message, bool roaming);
int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
int32_t match_vid, const char *message); s32 match_vid, const char *message);
int batadv_tt_global_hash_count(struct batadv_priv *bat_priv, int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid); const u8 *addr, unsigned short vid);
struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
const uint8_t *src, const u8 *src, const u8 *addr,
const uint8_t *addr,
unsigned short vid); unsigned short vid);
void batadv_tt_free(struct batadv_priv *bat_priv); void batadv_tt_free(struct batadv_priv *bat_priv);
bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr, bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
unsigned short vid); unsigned short vid);
bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src, bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
uint8_t *dst, unsigned short vid); unsigned short vid);
void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv); void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv, bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
uint8_t *addr, unsigned short vid); u8 *addr, unsigned short vid);
bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv, bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
uint8_t *addr, unsigned short vid); u8 *addr, unsigned short vid);
void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface); void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface);
bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
const unsigned char *addr, const unsigned char *addr,
unsigned short vid); unsigned short vid);
bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv, bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid); const u8 *addr, unsigned short vid);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment