batman-adv: Replace C99 int types with kernel type
Sven Eckelmann
maintainerPATCH 1/2 batman-adv: Replace C99 int types with kernel type
(s|u)(8|16|32|64) are the preferred types in the kernel. The use of the standard C99 types u?int(8|16|32|64)_t are objected by some people and even checkpatch now warns about using them.
--- compat-include/linux/kernel.h | 2 +- compat-include/linux/percpu.h | 2 +- net/batman-adv/bat_iv_ogm.c | 94 +++++++------- net/batman-adv/bitarray.c | 6 +- net/batman-adv/bitarray.h | 10 +- net/batman-adv/bridge_loop_avoidance.c | 72 ++++++----- net/batman-adv/bridge_loop_avoidance.h | 5 +- net/batman-adv/distributed-arp-table.c | 59 +++++---- net/batman-adv/distributed-arp-table.h | 8 +- net/batman-adv/fragmentation.c | 10 +- net/batman-adv/gateway_client.c | 16 +-- net/batman-adv/gateway_client.h | 2 +- net/batman-adv/gateway_common.c | 11 +- net/batman-adv/hash.c | 6 +- net/batman-adv/hash.h | 12 +- net/batman-adv/icmp_socket.c | 2 +- net/batman-adv/main.c | 69 +++++----- net/batman-adv/main.h | 48 ++++--- net/batman-adv/multicast.c | 16 +-- net/batman-adv/network-coding.c | 44 ++++--- net/batman-adv/originator.c | 15 ++- net/batman-adv/originator.h | 11 +- net/batman-adv/packet.h | 204 +++++++++++++++--------------- net/batman-adv/routing.c | 24 ++-- net/batman-adv/routing.h | 2 +- net/batman-adv/send.c | 8 +- net/batman-adv/send.h | 8 +- net/batman-adv/soft-interface.c | 26 ++-- net/batman-adv/sysfs.c | 4 +- net/batman-adv/translation-table.c | 224 ++++++++++++++++----------------- net/batman-adv/translation-table.h | 29 +++-- net/batman-adv/types.h | 109 ++++++++-------- 32 files changed, 568 insertions(+), 590 deletions(-)
compat-include/linux/kernel.h +1 -1
@@ -31,7 +31,7 @@unsigned long _v;\int _r;\ _r =strict_strtoul (cp, base, &_v);\ - *(v) = (uint32_t )_v;\ + *(v) = (u32 )_v;\if ((unsigned long )*(v) != _v)\ _r = -ERANGE ;\ _r;\
compat-include/linux/percpu.h +1 -1
@@ -36,7 +36,7 @@#define this_cpu_add (x, c) batadv_this_cpu_add(&(x), c) -static inline void batadv_this_cpu_add (uint64_t *count_ptr,size_t count) +static inline void batadv_this_cpu_add (u64 *count_ptr,size_t count) {int cpu =get_cpu (); *per_cpu_ptr (count_ptr, cpu) += count;
net/batman-adv/bat_iv_ogm.c +46 -48
265 lines not on this page · raw message
net/batman-adv/bitarray.c +3 -3
@@ -21,7 +21,7 @@#include <linux/bitmap.h> /* 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 )return ;
@@ -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) * 0 if the window was not moved/shifted. */ -int batadv_bit_get_packet (void *priv,unsigned long *seq_bits, -int32_t seq_num_diff,int set_mark) +int batadv_bit_get_packet (void *priv,unsigned long *seq_bits,s32 seq_num_diff, +int set_mark) {struct batadv_priv *bat_priv = priv;
net/batman-adv/bitarray.h +5 -5
@@ -28,9 +28,9 @@* and curr_seqno is within range of last_seqno. Otherwise returns 0. */ 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;if (diff <0 || diff >=BATADV_TQ_LOCAL_WINDOW_SIZE )
@@ -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 */ -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 (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)/* receive and process one packet, returns 1 if received seq_num is considered * new, 0 if old */ -int batadv_bit_get_packet (void *priv,unsigned long *seq_bits, -int32_t seq_num_diff,int set_mark); +int batadv_bit_get_packet (void *priv,unsigned long *seq_bits,s32 seq_num_diff, +int set_mark);#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
net/batman-adv/bridge_loop_avoidance.c +35 -37
226 lines not on this page · raw message
net/batman-adv/bridge_loop_avoidance.h +2 -3
@@ -38,7 +38,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_backbone_table_seq_print_text (struct seq_file *seq,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);int batadv_bla_check_bcast_duplist (struct batadv_priv *bat_priv,struct sk_buff *skb);
@@ -84,8 +84,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, -uint8_t *orig, -unsigned short vid) +u8 *orig,unsigned short vid) {return false; }
net/batman-adv/distributed-arp-table.c +29 -30
171 lines not on this page · raw message
net/batman-adv/distributed-arp-table.h +4 -4
@@ -54,7 +54,7 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,static inline void 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 ); orig_node->dat_addr = (batadv_dat_addr_t )addr;
@@ -69,7 +69,7 @@ static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv, struct batadv_hard_iface *primary_if) { - uint32_t addr; + u32 addr; addr =batadv_choose_orig (primary_if->net_dev->dev_addr,BATADV_DAT_ADDR_MAX );
@@ -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 */ static inline void batadv_dat_inc_counter (struct batadv_priv *bat_priv, -uint8_t subtype) +u8 subtype) {switch (subtype) {case BATADV_P_DAT_DHT_GET :
@@ -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, -uint8_t subtype) +u8 subtype) { }
net/batman-adv/fragmentation.c +5 -5
@@ -66,7 +66,7 @@ void batadv_frag_purge_orig(struct batadv_orig_node *orig_node, bool (*check_cb)(struct batadv_frag_table_entry *)) {struct batadv_frag_table_entry *chain; -uint8_t i; +u8 i;for (i =0 ; i <BATADV_FRAG_BUFFER_COUNT ; i++) { chain = &orig_node->fragments[i];
@@ -110,7 +110,7 @@ static int batadv_frag_size_limit(void)* without searching for the right position. */ static bool batadv_frag_init_chain (struct batadv_frag_table_entry *chain, -uint16_t seqno) +u16 seqno) {if (chain->seqno == seqno)return false;
@@ -145,8 +145,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_last =NULL ;struct batadv_frag_packet *frag_packet; -uint8_t bucket; -uint16_t seqno, hdr_size =sizeof (struct batadv_frag_packet ); +u8 bucket; +u16 seqno, hdr_size =sizeof (struct batadv_frag_packet );bool ret = false;/* Linearize packet to avoid linearizing 16 packets in a row when doing
@@ -351,7 +351,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,struct batadv_orig_node *orig_node_dst =NULL ;struct batadv_neigh_node *neigh_node =NULL ;struct batadv_frag_packet *packet; -uint16_t total_size; +u16 total_size;bool ret = false; packet = (struct batadv_frag_packet *)skb->data;
net/batman-adv/gateway_client.c +8 -8
@@ -153,10 +153,10 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)struct batadv_neigh_node *router;struct batadv_neigh_ifinfo *router_ifinfo;struct batadv_gw_node *gw_node, *curr_gw =NULL ; -uint32_t max_gw_factor =0 , tmp_gw_factor =0 ; -uint32_t gw_divisor; -uint8_t max_tq =0 ; -uint8_t tq_avg; +u32 max_gw_factor =0 , tmp_gw_factor =0 ; +u32 gw_divisor; +u8 max_tq =0 ; +u8 tq_avg;struct batadv_orig_node *orig_node; gw_divisor =BATADV_TQ_LOCAL_WINDOW_SIZE *BATADV_TQ_LOCAL_WINDOW_SIZE ;
@@ -352,7 +352,7 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,struct batadv_neigh_ifinfo *router_gw_tq =NULL ;struct batadv_orig_node *curr_gw_orig;struct batadv_neigh_node *router_gw =NULL , *router_orig =NULL ; -uint8_t gw_tq_avg, orig_tq_avg; +u8 gw_tq_avg, orig_tq_avg; curr_gw_orig =batadv_gw_get_selected_orig (bat_priv);if (!curr_gw_orig)
@@ -690,7 +690,7 @@ out:*/ enum batadv_dhcp_recipient 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 ;struct ethhdr *ethhdr;
@@ -700,7 +700,7 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,struct vlan_ethhdr *vhdr;int chaddr_offset;__be16 proto; -uint8_t *p; +u8 *p;/* check for ethernet header */ if (!pskb_may_pull (skb, *header_len +ETH_HLEN ))
@@ -816,7 +816,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;struct ethhdr *ethhdr = (struct ethhdr *)skb->data;bool out_of_range = false; -uint8_t curr_tq_avg; +u8 curr_tq_avg;unsigned short vid; vid =batadv_get_vid (skb,0 );
net/batman-adv/gateway_client.h +1 -1
@@ -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);enum batadv_dhcp_recipient 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_ */
net/batman-adv/gateway_common.c +5 -6
@@ -39,7 +39,7 @@* Returns false on parse error and true otherwise. */ 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 ;char *slash_ptr, *tmp_ptr;
@@ -124,7 +124,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) {struct batadv_tvlv_gateway_data gw; -uint32_t down, up; +u32 down, up;char gw_mode; gw_mode =atomic_read (&bat_priv->gw_mode);
@@ -149,7 +149,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count) {struct batadv_priv *bat_priv =netdev_priv (net_dev); -uint32_t down_curr, up_curr, down_new =0 , up_new =0 ; +u32 down_curr, up_curr, down_new =0 , up_new =0 ;bool ret; down_curr = (unsigned int )atomic_read (&bat_priv->gw.bandwidth_down);
@@ -195,9 +195,8 @@ end:*/ static void batadv_gw_tvlv_ogm_handler_v1 (struct batadv_priv *bat_priv,struct batadv_orig_node *orig, -uint8_t flags, -void *tvlv_value, -uint16_t tvlv_value_len) +u8 flags, +void *tvlv_value,u16 tvlv_value_len) {struct batadv_tvlv_gateway_data gateway, *gateway_ptr;
net/batman-adv/hash.c +3 -3
@@ -25,7 +25,7 @@/* clears the hash */ static void batadv_hash_init (struct batadv_hashtable *hash) { -uint32_t i; +u32 i;for (i =0 ; i < hash->size; i++) {INIT_HLIST_HEAD (&hash->table[i]);
@@ -42,7 +42,7 @@ void batadv_hash_destroy(struct batadv_hashtable *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;
@@ -73,7 +73,7 @@ free_hash:void batadv_hash_set_lock_class (struct batadv_hashtable *hash,struct lock_class_key *key) { -uint32_t i; +u32 i;for (i =0 ; i < hash->size; i++)lockdep_set_class (&hash->list_locks[i], key);
net/batman-adv/hash.h +6 -6
@@ -39,17 +39,17 @@ typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *,* based on the key in the data of the first * 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 *);struct batadv_hashtable {struct hlist_head *table;/* the hashtable itself with the buckets */ 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 */ -struct batadv_hashtable *batadv_hash_new (uint32_t size); +struct batadv_hashtable *batadv_hash_new (u32 size);/* set class key for all locks */ void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
@@ -69,7 +69,7 @@ static inline void batadv_hash_delete(struct batadv_hashtable *hash,struct hlist_head *head;struct hlist_node *node, *node_tmp;spinlock_t *list_lock;/* spinlock to protect write access */ -uint32_t i; +u32 i;for (i =0 ; i < hash->size; i++) { head = &hash->table[i];
@@ -105,7 +105,7 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,const void *data, struct hlist_node *data_node) { - uint32_t index; + u32 index;int ret =-1 ;struct hlist_head *head;struct hlist_node *node;
@@ -149,7 +149,7 @@ static inline void *batadv_hash_remove(struct batadv_hashtable *hash,batadv_hashdata_choose_cb choose, void *data) { - uint32_t index; + u32 index;struct hlist_node *node;struct hlist_head *head;void *data_save =NULL ;
net/batman-adv/icmp_socket.c +1 -1
@@ -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_neigh_node *neigh_node =NULL ;size_t packet_len =sizeof (struct batadv_icmp_packet ); -uint8_t *addr; +u8 *addr;if (len <sizeof (struct batadv_icmp_header )) { batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
net/batman-adv/main.c +33 -36
188 lines not on this page · raw message
net/batman-adv/main.h +23 -25
96 lines not on this page · raw message
net/batman-adv/multicast.c +8 -8
@@ -87,7 +87,7 @@ static int batadv_mcast_mla_softif_get(struct net_device *dev,* Returns true if the given address is already in the given list. * 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 batadv_hw_addr *mcast_entry;
@@ -591,7 +591,7 @@ 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,struct batadv_orig_node *orig, -uint8_t mcast_flags) +u8 mcast_flags) {/* switched from flag unset to set */ if (mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES &&
@@ -624,7 +624,7 @@ static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,*/ static void batadv_mcast_want_ipv4_update (struct batadv_priv *bat_priv,struct batadv_orig_node *orig, -uint8_t mcast_flags) +u8 mcast_flags) {/* switched from flag unset to set */ if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV4 &&
@@ -657,7 +657,7 @@ static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,*/ static void batadv_mcast_want_ipv6_update (struct batadv_priv *bat_priv,struct batadv_orig_node *orig, -uint8_t mcast_flags) +u8 mcast_flags) {/* switched from flag unset to set */ if (mcast_flags & BATADV_MCAST_WANT_ALL_IPV6 &&
@@ -689,12 +689,12 @@ 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,struct batadv_orig_node *orig, -uint8_t flags, +u8 flags,void *tvlv_value, -uint16_t tvlv_value_len) +u16 tvlv_value_len) {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; orig_initialized = orig->capa_initialized &BATADV_ORIG_CAPA_HAS_MCAST ;
@@ -723,7 +723,7 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,if (orig_mcast_enabled && tvlv_value && (tvlv_value_len >=sizeof (mcast_flags))) - mcast_flags = *(uint8_t *)tvlv_value; + mcast_flags = *(u8 *)tvlv_value;batadv_mcast_want_unsnoop_update (bat_priv, orig, mcast_flags);batadv_mcast_want_ipv4_update (bat_priv, orig, mcast_flags);
net/batman-adv/network-coding.c +21 -23
137 lines not on this page · raw message
net/batman-adv/originator.c +7 -8
@@ -452,8 +452,7 @@ out:*/ struct batadv_neigh_node *batadv_neigh_node_new (struct batadv_hard_iface *hard_iface, -const uint8_t *neigh_addr, -struct batadv_orig_node *orig_node) +const u8 *neigh_addr,struct batadv_orig_node *orig_node) {struct batadv_neigh_node *neigh_node;
@@ -489,7 +488,7 @@ out:struct batadv_neigh_node *batadv_neigh_node_get (const struct batadv_orig_node *orig_node,const struct batadv_hard_iface *hard_iface, -const uint8_t *addr) +const u8 *addr) {struct batadv_neigh_node *tmp_neigh_node, *res =NULL ;
@@ -624,7 +623,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)struct hlist_head *head;spinlock_t *list_lock;/* spinlock to protect write access */ struct batadv_orig_node *orig_node; -uint32_t i; +u32 i;if (!hash)return ;
@@ -659,7 +658,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)* Returns the newly created object or NULL on failure. */ 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_vlan *vlan;
@@ -976,7 +975,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)struct hlist_head *head;spinlock_t *list_lock;/* spinlock to protect write access */ struct batadv_orig_node *orig_node; -uint32_t i; +u32 i;if (!hash)return ;
@@ -1110,7 +1109,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,struct batadv_hashtable *hash = bat_priv->orig_hash;struct hlist_head *head;struct batadv_orig_node *orig_node; -uint32_t i; +u32 i;int ret;/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
@@ -1147,7 +1146,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,struct batadv_hard_iface *hard_iface_tmp;struct batadv_orig_node *orig_node;struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; -uint32_t i; +u32 i;int ret;/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
net/batman-adv/originator.h +5 -6
@@ -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_now (struct batadv_orig_node *orig_node);struct batadv_orig_node *batadv_orig_node_new (struct batadv_priv *bat_priv, -const uint8_t *addr); +const u8 *addr);struct batadv_neigh_node *batadv_neigh_node_get (const struct batadv_orig_node *orig_node,const struct batadv_hard_iface *hard_iface, -const uint8_t *addr); +const u8 *addr);struct batadv_neigh_node *batadv_neigh_node_new (struct batadv_hard_iface *hard_iface, -const uint8_t *neigh_addr, -struct batadv_orig_node *orig_node); +const u8 *neigh_addr,struct batadv_orig_node *orig_node);void batadv_neigh_node_free_ref (struct batadv_neigh_node *neigh_node);struct batadv_neigh_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);/* hashfunction to choose an entry in a hash table of given size * 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);return hash % size;
net/batman-adv/packet.h +102 -102
311 lines not on this page · raw message
net/batman-adv/routing.c +12 -12
@@ -145,7 +145,7 @@ out:* 0 if the packet is to be accepted * 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) { if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
@@ -653,19 +653,19 @@ out:static bool batadv_reroute_unicast_packet (struct batadv_priv *bat_priv,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_hard_iface *primary_if =NULL ;bool ret = false; -uint8_t *orig_addr, orig_ttvn; +u8 *orig_addr, orig_ttvn;if (batadv_is_my_client (bat_priv, dst_addr, vid)) { primary_if =batadv_primary_if_get_selected (bat_priv);if (!primary_if) goto out; 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 { orig_node =batadv_transtable_search (bat_priv,NULL , dst_addr, vid);
@@ -676,7 +676,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, goto out; 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 */
@@ -698,7 +698,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,struct batadv_unicast_packet *unicast_packet;struct batadv_hard_iface *primary_if;struct batadv_orig_node *orig_node; -uint8_t curr_ttvn, old_ttvn; +u8 curr_ttvn, old_ttvn;struct ethhdr *ethhdr;unsigned short vid;int is_old_ttvn;
@@ -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 * 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)) { orig_node =batadv_orig_hash_find (bat_priv, unicast_packet->dest);
@@ -751,7 +751,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,if (!orig_node)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); }
@@ -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_unicast_packet *unicast_packet;struct batadv_unicast_4addr_packet *unicast_4addr_packet; -uint8_t *orig_addr; +u8 *orig_addr;struct batadv_orig_node *orig_node =NULL ;int check, hdr_size =sizeof (*unicast_packet);bool is4addr;
@@ -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_unicast_tvlv_packet *unicast_tvlv_packet;unsigned char *tvlv_buff; -uint16_t tvlv_buff_len; +u16 tvlv_buff_len;int hdr_size =sizeof (*unicast_tvlv_packet);int ret =NET_RX_DROP ;
@@ -1007,8 +1007,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,struct ethhdr *ethhdr;int hdr_size =sizeof (*bcast_packet);int ret =NET_RX_DROP ; -int32_t seq_diff; -uint32_t seqno; +s32 seq_diff; +u32 seqno;/* drop packet if it has not necessary minimum size */ if (unlikely (!pskb_may_pull (skb, hdr_size)))
net/batman-adv/routing.h +1 -1
@@ -55,7 +55,7 @@ struct batadv_neigh_node * batadv_find_router(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node, 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);#endif /* _NET_BATMAN_ADV_ROUTING_H_ */
net/batman-adv/send.c +4 -4
@@ -54,7 +54,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work);*/ int batadv_send_skb_packet (struct sk_buff *skb,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 ethhdr *ethhdr;
@@ -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_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 )return false;
@@ -343,12 +343,12 @@ out:*/ int batadv_send_skb_via_tt_generic (struct batadv_priv *bat_priv,struct sk_buff *skb,int packet_type, -int packet_subtype,uint8_t *dst_hint, +int packet_subtype,u8 *dst_hint,unsigned short vid) {struct ethhdr *ethhdr = (struct ethhdr *)skb->data;struct batadv_orig_node *orig_node; -uint8_t *src, *dst; +u8 *src, *dst; src = ethhdr->h_source; dst = ethhdr->h_dest;
net/batman-adv/send.h +4 -4
@@ -33,7 +33,7 @@ struct work_struct;int batadv_send_skb_packet (struct sk_buff *skb,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,struct batadv_orig_node *orig_node,struct batadv_hard_iface *recv_if);
@@ -56,7 +56,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, unsigned short vid);int batadv_send_skb_via_tt_generic (struct batadv_priv *bat_priv,struct sk_buff *skb,int packet_type, -int packet_subtype,uint8_t *dst_hint, +int packet_subtype,u8 *dst_hint,unsigned short vid);int batadv_send_skb_via_gw (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid);
@@ -75,7 +75,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. */ 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) { return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
@@ -100,7 +100,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,struct sk_buff *skb,int packet_subtype, -uint8_t *dst_hint, +u8 *dst_hint,unsigned short vid) { return batadv_send_skb_via_tt_generic(bat_priv, skb,
net/batman-adv/soft-interface.c +12 -14
@@ -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_softif_vlan *vlan;struct sockaddr *addr = p; -uint8_t old_addr[ETH_ALEN ]; +u8 old_addr[ETH_ALEN ];if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ;
@@ -186,19 +186,19 @@ static int batadv_interface_tx(struct sk_buff *skb,struct batadv_hard_iface *primary_if =NULL ;struct batadv_bcast_packet *bcast_packet;__be16 ethertype =htons (ETH_P_BATMAN ); -static const uint8_t stp_addr[ETH_ALEN ] = {0x01 ,0x80 ,0xC2 ,0x00 , -0x00 ,0x00 }; -static const uint8_t ectp_addr[ETH_ALEN ] = {0xCF ,0x00 ,0x00 ,0x00 , -0x00 ,0x00 }; +static const u8 stp_addr[ETH_ALEN ] = {0x01 ,0x80 ,0xC2 ,0x00 , +0x00 ,0x00 }; +static const u8 ectp_addr[ETH_ALEN ] = {0xCF ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 };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;unsigned int header_len =0 ;int data_len = skb->len, ret;unsigned long brd_delay =1 ;bool do_bcast = false, client_added;unsigned short vid; -uint32_t seqno; +u32 seqno;int gw_mode;enum batadv_forw_mode forw_mode;struct batadv_orig_node *mcast_single_orig =NULL ;
@@ -742,9 +742,9 @@ static void batadv_softif_destroy_finish(struct work_struct *work)static int batadv_softif_init_late (struct net_device *dev) {struct batadv_priv *bat_priv; -uint32_t random_seqno; +u32 random_seqno;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);
@@ -755,7 +755,7 @@ static int batadv_softif_init_late(struct net_device *dev)/* batadv_interface_stats() needs to be available as soon as * 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)return -ENOMEM ;
@@ -1109,8 +1109,7 @@ static const struct {#endif }; -static void batadv_get_strings (struct net_device *dev,uint32_t stringset, -uint8_t *data) +static void batadv_get_strings (struct net_device *dev,u32 stringset,u8 *data) {if (stringset ==ETH_SS_STATS ) memcpy(data, batadv_counters_strings,
@@ -1118,8 +1117,7 @@ static void batadv_get_strings(struct net_device *dev, uint32_t stringset, }static void batadv_get_ethtool_stats (struct net_device *dev, -struct ethtool_stats *stats, -uint64_t *data) +struct ethtool_stats *stats,u64 *data) {struct batadv_priv *bat_priv =netdev_priv (dev);int i;
net/batman-adv/sysfs.c +2 -2
@@ -457,7 +457,7 @@ static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, struct attribute *attr, char *buff) { 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); up =atomic_read (&bat_priv->gw.bandwidth_up);
@@ -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 batadv_priv *bat_priv =netdev_priv (net_dev); -uint32_t mark, mask; +u32 mark, mask;char *mask_ptr;/* parse the mask if it has been specified, otherwise assume the mask is
net/batman-adv/translation-table.c +111 -113
676 lines not on this page · raw message
net/batman-adv/translation-table.h +14 -15
@@ -28,38 +28,37 @@ struct net_device;struct seq_file ;int batadv_tt_init (struct batadv_priv *bat_priv); -bool batadv_tt_local_add (struct net_device *soft_iface,const uint8_t *addr, -unsigned short vid,int ifindex,uint32_t mark); -uint16_t batadv_tt_local_remove (struct batadv_priv *bat_priv, -const uint8_t *addr,unsigned short vid, -const char *message,bool roaming); +bool batadv_tt_local_add (struct net_device *soft_iface,const u8 *addr, +unsigned short vid,int ifindex,u32 mark); +u16 batadv_tt_local_remove (struct batadv_priv *bat_priv, +const u8 *addr,unsigned short vid, +const char *message,bool roaming);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);void batadv_tt_global_del_orig (struct batadv_priv *bat_priv,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, -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, -const uint8_t *src, -const uint8_t *addr, +const u8 *src,const u8 *addr,unsigned short vid);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); -bool batadv_is_ap_isolated (struct batadv_priv *bat_priv,uint8_t *src, -uint8_t *dst,unsigned short vid); +bool batadv_is_ap_isolated (struct batadv_priv *bat_priv,u8 *src,u8 *dst, +unsigned short vid);void batadv_tt_local_commit_changes (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, -uint8_t *addr,unsigned short vid); +u8 *addr,unsigned short vid);void batadv_tt_local_resize_to_mtu (struct net_device *soft_iface);bool batadv_tt_add_temporary_global_entry (struct batadv_priv *bat_priv,struct batadv_orig_node *orig_node,const unsigned char *addr,unsigned short vid);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_ */
net/batman-adv/types.h +54 -55
184 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.1.4
Part of the diff is not shown here. View the raw message.
Sven Eckelmann
maintainerPATCH 2/2 batman-adv: Avoid u32 overflow during gateway select
From: Ruben Wisniewski <[email protected]>
The gateway selection based on fast connections is using a single value calculated from the average tq (0-255) and the download bandwidth (in 100Kibit). The formula for the first step (tq ** 2 * 10000 * bandwidth) tends to overflow a u32 with low bandwidth settings like 50 [100KiBit] and a tq value of over 92.
Changing this to a 64 bit unsigned integer allows to support a bandwidth_down with up to ~2.8e10 [100KiBit] and a perfect tq of 255. This is ~6.6 times higher than the maximum possible value of the gateway announcement TVLV.
This problem only affects the non-default gw_sel_class 1.
---
I am sending this because Ruben Wisniewski didn't fix the commit message (yet) and my earlier patch broke his proposed one.
--- net/batman-adv/gateway_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/gateway_client.c +1 -1
@@ -153,7 +153,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)struct batadv_neigh_node *router;struct batadv_neigh_ifinfo *router_ifinfo;struct batadv_gw_node *gw_node, *curr_gw =NULL ; -u32 max_gw_factor =0 , tmp_gw_factor =0 ; +u64 max_gw_factor =0 , tmp_gw_factor =0 ;u32 gw_divisor;u8 max_tq =0 ;u8 tq_avg;
Signature · 1 line
2.1.4
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Avoid u32 overflow during gateway select
Quoted 18 lines · On Tuesday, May 26, 2015 18:34:27 Sven Eckelmann wrote:
From: Ruben Wisniewski <[email protected]>
The gateway selection based on fast connections is using a single value calculated from the average tq (0-255) and the download bandwidth (in 100Kibit). The formula for the first step (tq ** 2 * 10000 * bandwidth) tends to overflow a u32 with low bandwidth settings like 50 [100KiBit] and a tq value of over 92.
Changing this to a 64 bit unsigned integer allows to support a
bandwidth_downwith up to ~2.8e10 [100KiBit] and a perfect tq of 255. This is ~6.6 times higher than the maximum possible value of the gateway announcement TVLV.This problem only affects the non-default
gw_sel_class1.Signed-off-by Ruben Wisniewsi <[email protected]>[[email protected]: rewritten commit message, changed to kernel type]Signed-off-by Sven Eckelmann <[email protected]>
Quoted 6 lines
---
I am sending this because Ruben Wisniewski didn't fix the commit message (yet) and my earlier patch broke his proposed one.--- net/batman-adv/gateway_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision f63c54b.
Thanks,
Marek
Marek Lindner
AppliedQuoted 32 lines · On Tuesday, May 26, 2015 18:34:26 Sven Eckelmann wrote:
(s|u)(8|16|32|64) are the preferred types in the kernel. The use of the standard C99 types u?int(8|16|32|64)_t are objected by some people and even checkpatch now warns about using them.
Signed-off-by Sven Eckelmann <[email protected]>--- compat-include/linux/kernel.h | 2 +- compat-include/linux/percpu.h | 2 +- net/batman-adv/bat_iv_ogm.c | 94 +++++++------- net/batman-adv/bitarray.c | 6 +- net/batman-adv/bitarray.h | 10 +- net/batman-adv/bridge_loop_avoidance.c | 72 ++++++----- net/batman-adv/bridge_loop_avoidance.h | 5 +- net/batman-adv/distributed-arp-table.c | 59 +++++---- net/batman-adv/distributed-arp-table.h | 8 +- net/batman-adv/fragmentation.c | 10 +- net/batman-adv/gateway_client.c | 16 +-- net/batman-adv/gateway_client.h | 2 +- net/batman-adv/gateway_common.c | 11 +- net/batman-adv/hash.c | 6 +- net/batman-adv/hash.h | 12 +- net/batman-adv/icmp_socket.c | 2 +- net/batman-adv/main.c | 69 +++++----- net/batman-adv/main.h | 48 ++++--- net/batman-adv/multicast.c | 16 +-- net/batman-adv/network-coding.c | 44 ++++--- net/batman-adv/originator.c | 15 ++- net/batman-adv/originator.h | 11 +- net/batman-adv/packet.h | 204 +++++++++++++++--------------- net/batman-adv/routing.c | 24 ++-- net/batman-adv/routing.h | 2 +- net/batman-adv/send.c | 8 +-
Quoted 8 lines
net/batman-adv/send.h | 8 +- net/batman-adv/soft-interface.c | 26 ++-- net/batman-adv/sysfs.c | 4 +- net/batman-adv/translation-table.c | 224 ++++++++++++++++----------------- net/batman-adv/translation-table.h | 29 +++-- net/batman-adv/types.h | 109 ++++++++-------- 32 files changed, 568 insertions(+), 590 deletions(-)
Applied in revision dc0e68b.
Thanks,
Marek