Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197372
b: refs/heads/master
c: 6d45d8d
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann authored and Greg Kroah-Hartman committed May 11, 2010
1 parent 8722bf3 commit 18e541b
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 89 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9ab70e787c3b94ce7c56324b4afbc8051e99424
refs/heads/master: 6d45d8df243054614d795901c03817e21bfde964
22 changes: 16 additions & 6 deletions trunk/drivers/staging/batman-adv/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ int bat_device_setup(void)
/* register our device - kernel assigns a free major number */
tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
if (tmp_major < 0) {
printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
printk(KERN_ERR "batman-adv:"
"Registering the character device failed with %d\n",
tmp_major);
return 0;
}

batman_class = class_create(THIS_MODULE, "batman-adv");

if (IS_ERR(batman_class)) {
printk(KERN_ERR "batman-adv:Could not register class 'batman-adv'\n");
printk(KERN_ERR "batman-adv:"
"Could not register class 'batman-adv'\n");
return 0;
}

Expand Down Expand Up @@ -108,7 +110,9 @@ int bat_device_open(struct inode *inode, struct file *file)
}

if (i == ARRAY_SIZE(device_client_hash)) {
printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
printk(KERN_ERR "batman-adv:"
"Error - can't add another packet client: "
"maximum number of clients reached\n");
kfree(device_client);
return -EXFULL;
}
Expand Down Expand Up @@ -209,7 +213,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
unsigned long flags;

if (len < sizeof(struct icmp_packet)) {
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
bat_dbg(DBG_BATMAN, "batman-adv:"
"Error - can't send packet from char device: "
"invalid packet size\n");
return -EINVAL;
}

Expand All @@ -220,12 +226,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
return -EFAULT;

if (icmp_packet.packet_type != BAT_ICMP) {
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
bat_dbg(DBG_BATMAN, "batman-adv:"
"Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)\n");
return -EINVAL;
}

if (icmp_packet.msg_type != ECHO_REQUEST) {
bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
bat_dbg(DBG_BATMAN, "batman-adv:"
"Error - can't send packet from char device: "
"got bogus message type (expected: ECHO_REQUEST)\n");
return -EINVAL;
}

Expand Down
20 changes: 14 additions & 6 deletions trunk/drivers/staging/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ static void check_known_mac_addr(uint8_t *addr)
if (!compare_orig(batman_if->net_dev->dev_addr, addr))
continue;

printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
addr, batman_if->dev);
printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
printk(KERN_WARNING "batman-adv:"
"The newly added mac address (%pM) already exists on: %s\n",
addr, batman_if->dev);
printk(KERN_WARNING "batman-adv:"
"It is strongly recommended to keep mac addresses unique"
"to avoid problems!\n");
}
rcu_read_unlock();
}
Expand Down Expand Up @@ -242,7 +245,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);

if (!batman_if->packet_buff) {
printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n",
printk(KERN_ERR "batman-adv:"
"Can't add interface packet (%s): out of memory\n",
batman_if->dev);
goto err;
}
Expand All @@ -266,7 +270,10 @@ int hardif_enable_interface(struct batman_if *batman_if)
if (hardif_is_iface_up(batman_if))
hardif_activate_interface(bat_priv, batman_if);
else
printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
printk(KERN_ERR "batman-adv:"
"Not using interface %s "
"(retrying later): interface not active\n",
batman_if->dev);

/* begin scheduling originator messages on that interface */
schedule_own_packet(batman_if);
Expand Down Expand Up @@ -316,7 +323,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)

batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
if (!batman_if) {
printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n",
printk(KERN_ERR "batman-adv:"
"Can't add interface (%s): out of memory\n",
net_dev->name);
goto out;
}
Expand Down
17 changes: 11 additions & 6 deletions trunk/drivers/staging/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ int init_module(void)
interface_setup);

if (!soft_device) {
printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
printk(KERN_ERR "batman-adv:"
"Unable to allocate the batman interface\n");
goto end;
}

retval = register_netdev(soft_device);

if (retval < 0) {
printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
printk(KERN_ERR "batman-adv:"
"Unable to register the batman interface: %i\n", retval);
goto free_soft_device;
}

Expand All @@ -118,8 +120,9 @@ int init_module(void)
register_netdevice_notifier(&hard_if_notifier);
dev_add_pack(&batman_adv_packet_type);

printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
printk(KERN_INFO "batman-adv:"
"B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);

return 0;

Expand Down Expand Up @@ -176,7 +179,9 @@ void activate_module(void)
goto end;

err:
printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
printk(KERN_ERR "batman-adv:"
"Unable to allocate memory for mesh information structures: "
"out of mem ?\n");
deactivate_module();
end:
return;
Expand Down Expand Up @@ -218,7 +223,7 @@ void dec_module_count(void)

int addr_to_string(char *buff, uint8_t *addr)
{
return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x",
return sprintf(buff, MAC_FMT,
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
}

Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/staging/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
/* Kernel Programming */
#define LINUX

#define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
#define DRIVER_AUTHOR "Marek Lindner <lindner_marek@yahoo.de>, " \
"Simon Wunderlich <siwu@hrz.tu-chemnitz.de>"
#define DRIVER_DESC "B.A.T.M.A.N. advanced"
#define DRIVER_DEVICE "batman-adv"

Expand Down
47 changes: 29 additions & 18 deletions trunk/drivers/staging/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ struct orig_node *get_orig_node(uint8_t *addr)
memcpy(orig_node->orig, addr, ETH_ALEN);
orig_node->router = NULL;
orig_node->hna_buff = NULL;
orig_node->bcast_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
orig_node->batman_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
orig_node->bcast_seqno_reset = jiffies - 1
- msecs_to_jiffies(RESET_PROTECTION_MS);
orig_node->batman_seqno_reset = jiffies - 1
- msecs_to_jiffies(RESET_PROTECTION_MS);

size = bat_priv->num_ifaces * sizeof(TYPE_OF_WORD) * NUM_WORDS;

Expand Down Expand Up @@ -198,11 +200,15 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,

if (neigh_node->if_incoming->if_status ==
IF_TO_BE_REMOVED)
bat_dbg(DBG_BATMAN, "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
bat_dbg(DBG_BATMAN,
"neighbor purge: originator %pM, "
"neighbor: %pM, iface: %s\n",
orig_node->orig, neigh_node->addr,
neigh_node->if_incoming->dev);
else
bat_dbg(DBG_BATMAN, "neighbor timeout: originator %pM, neighbor: %pM, last_valid: %lu\n",
bat_dbg(DBG_BATMAN,
"neighbor timeout: originator %pM, "
"neighbor: %pM, last_valid: %lu\n",
orig_node->orig, neigh_node->addr,
(neigh_node->last_valid / HZ));

Expand Down Expand Up @@ -280,24 +286,25 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
if (!bat_priv->primary_if) {
if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
net_dev->name);
"BATMAN mesh %s disabled - "
"please specify interfaces to enable it\n",
net_dev->name);

return 0;
}

if (bat_priv->primary_if->if_status != IF_ACTIVE) {
if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name);

if (bat_priv->primary_if->if_status != IF_ACTIVE && off == 0)
return sprintf(buff,
"BATMAN mesh %s "
"disabled - primary interface not active\n",
net_dev->name);
else if (bat_priv->primary_if->if_status != IF_ACTIVE)
return 0;
}

rcu_read_lock();
hdr_len = sprintf(buff,
" %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
" %-14s (%s/%i) %17s [%10s]: %20s "
"... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
"Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
"Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
Expand Down Expand Up @@ -366,7 +373,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
GFP_ATOMIC);
if (!data_ptr) {
printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
printk(KERN_ERR
"batman-adv:Can't resize orig: out of memory\n");
return -1;
}

Expand All @@ -377,7 +385,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)

data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) {
printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
printk(KERN_ERR
"batman-adv:Can't resize orig: out of memory\n");
return -1;
}

Expand Down Expand Up @@ -426,7 +435,8 @@ static int orig_node_del_if(struct orig_node *orig_node,
chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
if (!data_ptr) {
printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
printk(KERN_ERR
"batman-adv:Can't resize orig: out of memory\n");
return -1;
}

Expand All @@ -447,7 +457,8 @@ static int orig_node_del_if(struct orig_node *orig_node,

data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
if (!data_ptr) {
printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
printk(KERN_ERR
"batman-adv:Can't resize orig: out of memory\n");
return -1;
}

Expand Down
Loading

0 comments on commit 18e541b

Please sign in to comment.