Skip to content

Commit

Permalink
Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-…
Browse files Browse the repository at this point in the history
…merge
  • Loading branch information
David S. Miller committed Jun 1, 2011
2 parents e11ec90 + bb899b8 commit 5bf74c9
Show file tree
Hide file tree
Showing 31 changed files with 284 additions and 276 deletions.
23 changes: 12 additions & 11 deletions net/batman-adv/aggregation.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
#include "hard-interface.h"

/* calculate the size of the tt information for a given packet */
static int tt_len(struct batman_packet *batman_packet)
static int tt_len(const struct batman_packet *batman_packet)
{
return batman_packet->num_tt * ETH_ALEN;
}

/* return true if new_packet can be aggregated with forw_packet */
static bool can_aggregate_with(struct batman_packet *new_batman_packet,
static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
int packet_len,
unsigned long send_time,
bool directlink,
struct hard_iface *if_incoming,
struct forw_packet *forw_packet)
const struct hard_iface *if_incoming,
const struct forw_packet *forw_packet)
{
struct batman_packet *batman_packet =
(struct batman_packet *)forw_packet->skb->data;
Expand Down Expand Up @@ -97,8 +97,9 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,
}

/* create a new aggregated packet and add this packet to it */
static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
unsigned long send_time, bool direct_link,
static void new_aggregated_packet(const unsigned char *packet_buff,
int packet_len, unsigned long send_time,
bool direct_link,
struct hard_iface *if_incoming,
int own_packet)
{
Expand All @@ -118,7 +119,7 @@ static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
}
}

forw_packet_aggr = kmalloc(sizeof(struct forw_packet), GFP_ATOMIC);
forw_packet_aggr = kmalloc(sizeof(*forw_packet_aggr), GFP_ATOMIC);
if (!forw_packet_aggr) {
if (!own_packet)
atomic_inc(&bat_priv->batman_queue_left);
Expand Down Expand Up @@ -176,8 +177,7 @@ static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,

/* aggregate a new packet into the existing aggregation */
static void aggregate(struct forw_packet *forw_packet_aggr,
unsigned char *packet_buff,
int packet_len,
const unsigned char *packet_buff, int packet_len,
bool direct_link)
{
unsigned char *skb_buff;
Expand Down Expand Up @@ -253,8 +253,9 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
}

/* unpack the aggregated packets and process them one by one */
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
int packet_len, struct hard_iface *if_incoming)
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
unsigned char *packet_buff, int packet_len,
struct hard_iface *if_incoming)
{
struct batman_packet *batman_packet;
int buff_pos = 0;
Expand Down
5 changes: 3 additions & 2 deletions net/batman-adv/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
unsigned char *packet_buff, int packet_len,
struct hard_iface *if_incoming, char own_packet,
unsigned long send_time);
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
int packet_len, struct hard_iface *if_incoming);
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
unsigned char *packet_buff, int packet_len,
struct hard_iface *if_incoming);

#endif /* _NET_BATMAN_ADV_AGGREGATION_H_ */
11 changes: 6 additions & 5 deletions net/batman-adv/bat_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ static void emit_log_char(struct debug_log *debug_log, char c)
debug_log->log_start = debug_log->log_end - log_buff_len;
}

static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
__printf(2, 3)
static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
{
va_list args;
static char debug_log_buf[256];
Expand All @@ -74,14 +75,14 @@ static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
return 0;
}

int debug_log(struct bat_priv *bat_priv, char *fmt, ...)
int debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
{
va_list args;
char tmp_log_buf[256];

va_start(args, fmt);
vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
fdebug_log(bat_priv->debug_log, "[%10u] %s",
fdebug_log(bat_priv->debug_log, "[%10lu] %s",
(jiffies / HZ), tmp_log_buf);
va_end(args);

Expand Down Expand Up @@ -114,7 +115,7 @@ static ssize_t log_read(struct file *file, char __user *buf,
!(debug_log->log_end - debug_log->log_start))
return -EAGAIN;

if ((!buf) || (count < 0))
if (!buf)
return -EINVAL;

if (count == 0)
Expand Down Expand Up @@ -184,7 +185,7 @@ static int debug_log_setup(struct bat_priv *bat_priv)
if (!bat_priv->debug_dir)
goto err;

bat_priv->debug_log = kzalloc(sizeof(struct debug_log), GFP_ATOMIC);
bat_priv->debug_log = kzalloc(sizeof(*bat_priv->debug_log), GFP_ATOMIC);
if (!bat_priv->debug_log)
goto err;

Expand Down
15 changes: 7 additions & 8 deletions net/batman-adv/bat_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ssize_t show_##_name(struct kobject *kobj, struct attribute *attr, \

static int store_bool_attr(char *buff, size_t count,
struct net_device *net_dev,
char *attr_name, atomic_t *attr)
const char *attr_name, atomic_t *attr)
{
int enabled = -1;

Expand Down Expand Up @@ -138,16 +138,15 @@ static inline ssize_t __store_bool_attr(char *buff, size_t count,
{
int ret;

ret = store_bool_attr(buff, count, net_dev, (char *)attr->name,
attr_store);
ret = store_bool_attr(buff, count, net_dev, attr->name, attr_store);
if (post_func && ret)
post_func(net_dev);

return ret;
}

static int store_uint_attr(char *buff, size_t count,
struct net_device *net_dev, char *attr_name,
static int store_uint_attr(const char *buff, size_t count,
struct net_device *net_dev, const char *attr_name,
unsigned int min, unsigned int max, atomic_t *attr)
{
unsigned long uint_val;
Expand Down Expand Up @@ -183,15 +182,15 @@ static int store_uint_attr(char *buff, size_t count,
return count;
}

static inline ssize_t __store_uint_attr(char *buff, size_t count,
static inline ssize_t __store_uint_attr(const char *buff, size_t count,
int min, int max,
void (*post_func)(struct net_device *),
struct attribute *attr,
const struct attribute *attr,
atomic_t *attr_store, struct net_device *net_dev)
{
int ret;

ret = store_uint_attr(buff, count, net_dev, (char *)attr->name,
ret = store_uint_attr(buff, count, net_dev, attr->name,
min, max, attr_store);
if (post_func && ret)
post_func(net_dev);
Expand Down
6 changes: 3 additions & 3 deletions net/batman-adv/bitarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */
uint8_t get_bit_status(unsigned long *seq_bits, uint32_t last_seqno,
uint8_t get_bit_status(const unsigned long *seq_bits, uint32_t last_seqno,
uint32_t curr_seqno)
{
int32_t diff, word_offset, word_num;
Expand Down Expand Up @@ -130,7 +130,7 @@ static void bit_reset_window(unsigned long *seq_bits)
char bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int8_t set_mark)
{
struct bat_priv *bat_priv = (struct bat_priv *)priv;
struct bat_priv *bat_priv = priv;

/* sequence number is slightly older. We already got a sequence number
* higher than this one, so we just mark it. */
Expand Down Expand Up @@ -190,7 +190,7 @@ char bit_get_packet(void *priv, unsigned long *seq_bits,
/* count the hamming weight, how many good packets did we receive? just count
* the 1's.
*/
int bit_packet_count(unsigned long *seq_bits)
int bit_packet_count(const unsigned long *seq_bits)
{
int i, hamming = 0;

Expand Down
6 changes: 3 additions & 3 deletions net/batman-adv/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

/* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno */
uint8_t get_bit_status(unsigned long *seq_bits, uint32_t last_seqno,
uint32_t curr_seqno);
uint8_t get_bit_status(const unsigned long *seq_bits, uint32_t last_seqno,
uint32_t curr_seqno);

/* turn corresponding bit on, so we can remember that we got the packet */
void bit_mark(unsigned long *seq_bits, int32_t n);
Expand All @@ -39,6 +39,6 @@ char bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int8_t set_mark);

/* count the hamming weight, how many good packets did we receive? */
int bit_packet_count(unsigned long *seq_bits);
int bit_packet_count(const unsigned long *seq_bits);

#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
19 changes: 9 additions & 10 deletions net/batman-adv/gateway_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void gw_select(struct bat_priv *bat_priv, struct gw_node *new_gw_node)
if (new_gw_node && !atomic_inc_not_zero(&new_gw_node->refcount))
new_gw_node = NULL;

curr_gw_node = bat_priv->curr_gw;
curr_gw_node = rcu_dereference_protected(bat_priv->curr_gw, 1);
rcu_assign_pointer(bat_priv->curr_gw, new_gw_node);

if (curr_gw_node)
Expand Down Expand Up @@ -273,11 +273,10 @@ static void gw_node_add(struct bat_priv *bat_priv,
struct gw_node *gw_node;
int down, up;

gw_node = kmalloc(sizeof(struct gw_node), GFP_ATOMIC);
gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
if (!gw_node)
return;

memset(gw_node, 0, sizeof(struct gw_node));
INIT_HLIST_NODE(&gw_node->list);
gw_node->orig_node = orig_node;
atomic_set(&gw_node->refcount, 1);
Expand Down Expand Up @@ -394,8 +393,8 @@ void gw_node_purge(struct bat_priv *bat_priv)
/**
* fails if orig_node has no router
*/
static int _write_buffer_text(struct bat_priv *bat_priv,
struct seq_file *seq, struct gw_node *gw_node)
static int _write_buffer_text(struct bat_priv *bat_priv, struct seq_file *seq,
const struct gw_node *gw_node)
{
struct gw_node *curr_gw;
struct neigh_node *router;
Expand Down Expand Up @@ -509,7 +508,7 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
/* check for ip header */
switch (ntohs(ethhdr->h_proto)) {
case ETH_P_IP:
if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr)))
if (!pskb_may_pull(skb, header_len + sizeof(*iphdr)))
return 0;
iphdr = (struct iphdr *)(skb->data + header_len);
header_len += iphdr->ihl * 4;
Expand All @@ -520,10 +519,10 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)

break;
case ETH_P_IPV6:
if (!pskb_may_pull(skb, header_len + sizeof(struct ipv6hdr)))
if (!pskb_may_pull(skb, header_len + sizeof(*ipv6hdr)))
return 0;
ipv6hdr = (struct ipv6hdr *)(skb->data + header_len);
header_len += sizeof(struct ipv6hdr);
header_len += sizeof(*ipv6hdr);

/* check for udp header */
if (ipv6hdr->nexthdr != IPPROTO_UDP)
Expand All @@ -534,10 +533,10 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
return 0;
}

if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr)))
if (!pskb_may_pull(skb, header_len + sizeof(*udphdr)))
return 0;
udphdr = (struct udphdr *)(skb->data + header_len);
header_len += sizeof(struct udphdr);
header_len += sizeof(*udphdr);

/* check for bootp port */
if ((ntohs(ethhdr->h_proto) == ETH_P_IP) &&
Expand Down
19 changes: 10 additions & 9 deletions net/batman-adv/gateway_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
}

static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
long *up, long *down)
int *up, int *down)
{
int ret, multi = 1;
char *slash_ptr, *tmp_ptr;
long ldown, lup;

slash_ptr = strchr(buff, '/');
if (slash_ptr)
Expand All @@ -96,15 +97,15 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0';
}

ret = strict_strtoul(buff, 10, down);
ret = strict_strtoul(buff, 10, &ldown);
if (ret) {
bat_err(net_dev,
"Download speed of gateway mode invalid: %s\n",
buff);
return false;
}

*down *= multi;
*down = ldown * multi;

/* we also got some upload info */
if (slash_ptr) {
Expand All @@ -121,15 +122,15 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0';
}

ret = strict_strtoul(slash_ptr + 1, 10, up);
ret = strict_strtoul(slash_ptr + 1, 10, &lup);
if (ret) {
bat_err(net_dev,
"Upload speed of gateway mode invalid: "
"%s\n", slash_ptr + 1);
return false;
}

*up *= multi;
*up = lup * multi;
}

return true;
Expand All @@ -138,7 +139,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
long gw_bandwidth_tmp = 0, up = 0, down = 0;
long gw_bandwidth_tmp = 0;
int up = 0, down = 0;
bool ret;

ret = parse_gw_bandwidth(net_dev, buff, &up, &down);
Expand All @@ -158,12 +160,11 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count)
* speeds, hence we need to calculate it back to show the number
* that is going to be propagated
**/
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp,
(int *)&down, (int *)&up);
gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up);

gw_deselect(bat_priv);
bat_info(net_dev, "Changing gateway bandwidth from: '%i' to: '%ld' "
"(propagating: %ld%s/%ld%s)\n",
"(propagating: %d%s/%d%s)\n",
atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
(down > 2048 ? down / 1024 : down),
(down > 2048 ? "MBit" : "KBit"),
Expand Down
Loading

0 comments on commit 5bf74c9

Please sign in to comment.