r1578 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-27 06:56:18 +0100 (Sat, 27 Feb 2010)
New Revision: 1578
Modified:
trunk/batman-adv-kernelland/soft-interface.c
Log:
batman-adv: only modify hna-table on active module
If we haven't set the module to MODULE_ACTIVE state before (in general,
no interface has yet been added to batman-adv) then the hna table is not
initialised yet. If the kernel changes the mac address of the bat0
interface at this moment then an hna_local_add() called by interface_set_mac_addr()
then resulted in a null pointer derefernce. With this patch we are now
explicitly checking before if the state is MODULE_ACTIVE right now so
that we can assume having an initialised hna table.
Signed-off-by: Linus L?\195?\188ssing <linus.luessing(a)web.de>
Modified: trunk/batman-adv-kernelland/soft-interface.c
===================================================================
--- trunk/batman-adv-kernelland/soft-interface.c 2010-02-26 06:02:34 UTC (rev 1577)
+++ trunk/batman-adv-kernelland/soft-interface.c 2010-02-27 05:56:18 UTC (rev 1578)
@@ -154,9 +154,13 @@
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
- hna_local_remove(dev->dev_addr, "mac address changed");
+ /* only modify hna-table if it has been initialised before */
+ if (atomic_read(&module_state) == MODULE_ACTIVE) {
+ hna_local_remove(dev->dev_addr, "mac address changed");
+ hna_local_add(addr->sa_data);
+ }
+
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
- hna_local_add(dev->dev_addr);
return 0;
}
12 years, 4 months
r1577 - branches/batctl-0.2.x
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-26 07:02:34 +0100 (Fri, 26 Feb 2010)
New Revision: 1577
Modified:
branches/batctl-0.2.x/packet.h
Log:
batctl-0.2.x: fix incompatible batctl-0.2.x/batman-adv maint COMPAT_VERSION
Modified: branches/batctl-0.2.x/packet.h
===================================================================
--- branches/batctl-0.2.x/packet.h 2010-02-24 10:51:16 UTC (rev 1576)
+++ branches/batctl-0.2.x/packet.h 2010-02-26 06:02:34 UTC (rev 1577)
@@ -28,7 +28,7 @@
#define BAT_VIS 0x05
/* this file is included by batctl which needs these defines */
-#define COMPAT_VERSION 9
+#define COMPAT_VERSION 8
#define DIRECTLINK 0x40
#define VIS_SERVER 0x20
@@ -53,8 +53,6 @@
uint8_t prev_sender[6];
uint8_t ttl;
uint8_t num_hna;
- uint8_t gw_flags; /* flags related to gateway class */
- uint8_t align;
} __attribute__((packed));
#define BAT_PACKET_LEN sizeof(struct batman_packet)
12 years, 4 months
r1576 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-24 11:51:16 +0100 (Wed, 24 Feb 2010)
New Revision: 1576
Modified:
trunk/batman-adv-kernelland/device.c
Log:
batman-adv: Convert driver-staging to use spin_lock_init()
This fixes some RT-triggered compile errors and typos.
Signed-off-by: Sven-Thorsten Dietrich <sdietrich(a)novell.com>
Modified: trunk/batman-adv-kernelland/device.c
===================================================================
--- trunk/batman-adv-kernelland/device.c 2010-02-16 15:44:17 UTC (rev 1575)
+++ trunk/batman-adv-kernelland/device.c 2010-02-24 10:51:16 UTC (rev 1576)
@@ -120,7 +120,7 @@
INIT_LIST_HEAD(&device_client->queue_list);
device_client->queue_len = 0;
device_client->index = i;
- device_client->lock = __SPIN_LOCK_UNLOCKED(device_client->lock);
+ spin_lock_init(&device_client->lock);
init_waitqueue_head(&device_client->queue_wait);
file->private_data = device_client;
12 years, 4 months
[git] batman-adv tag, GregKH-20100216, created. v0.2-33-g2f51b1c
by postmaster@open-mesh.net
The tag, GregKH-20100216 has been created
at 2f51b1c529d9f3d5654e41e6e08b8ba769e786f7 (commit)
- Shortlog ------------------------------------------------------------
commit 2f51b1c529d9f3d5654e41e6e08b8ba769e786f7
Author: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Date: Fri Jan 1 20:09:34 2010 +0000
Staging: batman-adv: fix unlock, make code sparse clean
If the skb failed to copy in the (batman) icmp receive handlers, the function
returned without unlocking the orig_hash_lock first. To prevent this,
the fields needed from the orig_node are now copied, and the copies are
used for sending (just like in other handlers).
Furthermore, find_batman_if() was declared static. The code now appears
to be clean in 'sparse' [1].
Thanks to Andrew Lunn for pointing that out.
[1] http://sparse.wiki.kernel.org/index.php/Main_Page
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
-----------------------------------------------------------------------
--
batman-adv
12 years, 4 months
r1575 - trunk/batctl
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-16 16:44:17 +0100 (Tue, 16 Feb 2010)
New Revision: 1575
Modified:
trunk/batctl/ping.c
Log:
batctl: record route for ICMP messages
batctl is extended to recognize the -R option for the ping subcommand.
The output should be the same as for the standard iputils ping program.
For this, the destination host is printed twice.
Signed-off-by: Daniel Seither <post(a)tiwoc.de>
Modified: trunk/batctl/ping.c
===================================================================
--- trunk/batctl/ping.c 2010-02-16 15:44:12 UTC (rev 1574)
+++ trunk/batctl/ping.c 2010-02-16 15:44:17 UTC (rev 1575)
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2007-2009 B.A.T.M.A.N. contributors:
*
* Andreas Langer <a.langer(a)q-dsl.de>, Marek Lindner <lindner_marek(a)yahoo.de>
@@ -48,6 +48,7 @@
printf(" \t -h print this help\n");
printf(" \t -i interval in seconds\n");
printf(" \t -t timeout in seconds\n");
+ printf(" \t -R record route\n");
}
void sig_handler(int sig)
@@ -64,20 +65,22 @@
int ping(int argc, char **argv)
{
- struct icmp_packet icmp_packet_out, icmp_packet_in;
+ struct icmp_packet_rr icmp_packet_out, icmp_packet_in;
struct timeval tv;
- struct ether_addr *dst_mac = NULL;
- struct bat_host *bat_host;
+ struct ether_addr *dst_mac = NULL, *rr_mac = NULL;
+ struct bat_host *bat_host, *rr_host;
ssize_t read_len;
fd_set read_socket;
int ret = EXIT_FAILURE, ping_fd = 0, res, optchar, found_args = 1;
- int loop_count = -1, loop_interval = 1, timeout = 1;
+ int loop_count = -1, loop_interval = 1, timeout = 1, rr = 0, i;
unsigned int seq_counter = 0, packets_out = 0, packets_in = 0, packets_loss;
- char *dst_string, *mac_string;
+ char *dst_string, *mac_string, *rr_string;
double time_delta;
float min = 0.0, max = 0.0, avg = 0.0;
+ uint8_t last_rr_cur = 0, last_rr[BAT_RR_LEN][ETH_ALEN];
+ size_t packet_len;
- while ((optchar = getopt(argc, argv, "hc:i:t:")) != -1) {
+ while ((optchar = getopt(argc, argv, "hc:i:t:R")) != -1) {
switch (optchar) {
case 'c':
loop_count = strtol(optarg, NULL , 10);
@@ -100,6 +103,10 @@
timeout = 1;
found_args += ((*((char*)(optarg - 1)) == optchar ) ? 1 : 2);
break;
+ case 'R':
+ rr = 1;
+ found_args++;
+ break;
default:
ping_usage();
return EXIT_FAILURE;
@@ -141,6 +148,8 @@
goto out;
}
+ packet_len = sizeof(struct icmp_packet);
+
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN);
icmp_packet_out.packet_type = BAT_ICMP;
icmp_packet_out.version = COMPAT_VERSION;
@@ -148,8 +157,15 @@
icmp_packet_out.ttl = 50;
icmp_packet_out.seqno = 0;
+ if (rr) {
+ packet_len = sizeof(struct icmp_packet_rr);
+ icmp_packet_out.rr_cur = 1;
+ memset(&icmp_packet_out.rr, 0, BAT_RR_LEN * ETH_ALEN);
+ memset(last_rr, 0, BAT_RR_LEN * ETH_ALEN);
+ }
+
printf("PING %s (%s) %zu(%zu) bytes of data\n", dst_string, mac_string,
- sizeof(icmp_packet_out), sizeof(icmp_packet_out) + 28);
+ packet_len, packet_len + 28);
while (!is_aborted) {
if (loop_count == 0)
@@ -160,7 +176,7 @@
icmp_packet_out.seqno = htons(++seq_counter);
- if (write(ping_fd, (char *)&icmp_packet_out, sizeof(icmp_packet_out)) < 0) {
+ if (write(ping_fd, (char *)&icmp_packet_out, packet_len) < 0) {
printf("Error - can't write to batman adv kernel file '%s': %s\n", BAT_DEVICE, strerror(errno));
goto sleep;
}
@@ -188,26 +204,57 @@
if (res < 0)
goto sleep;
- read_len = read(ping_fd, (char *)&icmp_packet_in, sizeof(icmp_packet_in));
+ read_len = read(ping_fd, (char *)&icmp_packet_in, packet_len);
if (read_len < 0) {
printf("Error - can't read from batman adv kernel file '%s': %s\n", BAT_DEVICE, strerror(errno));
goto sleep;
}
- if ((size_t)read_len < sizeof(icmp_packet_in)) {
+ if ((size_t)read_len < packet_len) {
printf("Warning - dropping received packet as it is smaller than expected (%zu): %zd\n",
- sizeof(icmp_packet_in), read_len);
+ packet_len, read_len);
goto sleep;
}
switch (icmp_packet_in.msg_type) {
case ECHO_REPLY:
time_delta = end_timer();
- printf("%zd bytes from %s icmp_seq=%hu ttl=%d time=%.2f ms\n",
+ printf("%zd bytes from %s icmp_seq=%hu ttl=%d time=%.2f ms",
read_len, dst_string, ntohs(icmp_packet_in.seqno),
icmp_packet_in.ttl, time_delta);
+ if (read_len == sizeof(struct icmp_packet_rr)) {
+ if (last_rr_cur == icmp_packet_in.rr_cur
+ && !memcmp(last_rr, icmp_packet_in.rr, BAT_RR_LEN * ETH_ALEN)) {
+
+ printf("\t(same route)");
+
+ } else {
+ printf("\nRR: ");
+
+ for (i = 0; i < BAT_RR_LEN
+ && i < icmp_packet_in.rr_cur; i++) {
+
+ rr_mac = (struct ether_addr *)&icmp_packet_in.rr[i];
+ rr_host = bat_hosts_find_by_mac((char *)rr_mac);
+ if (rr_host)
+ rr_string = rr_host->name;
+ else
+ rr_string = ether_ntoa_long(rr_mac);
+ printf("\t%s\n", rr_string);
+
+ if (memcmp(rr_mac, dst_mac, ETH_ALEN) == 0)
+ printf("\t%s\n", rr_string);
+ }
+
+ last_rr_cur = icmp_packet_in.rr_cur;
+ memcpy(last_rr, icmp_packet_in.rr, BAT_RR_LEN * ETH_ALEN);
+ }
+ }
+
+ printf("\n");
+
if ((time_delta < min) || (min == 0.0))
min = time_delta;
if (time_delta > max)
12 years, 4 months
r1574 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-16 16:44:12 +0100 (Tue, 16 Feb 2010)
New Revision: 1574
Modified:
trunk/batman-adv-kernelland/device.c
trunk/batman-adv-kernelland/device.h
trunk/batman-adv-kernelland/packet.h
trunk/batman-adv-kernelland/routing.c
trunk/batman-adv-kernelland/types.h
Log:
batman-adv: record route for ICMP messages
The standard layer 3 ping utility can use the record route (RR) option
of IP to collect route data for sent ping messages (ping -R). This
patch introduces comparable functionality for batman-adv ICMP messages.
The patch adds a second batman ICMP packet format (icmp_packet_rr) such
that up to 17 MAC addresses can be recorded (sufficient for up to 8
hops per direction). When no RR is wanted, the old icmp_packet without
the RR overhead can be sent.
Signed-off-by: Daniel Seither <post(a)tiwoc.de>
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv-kernelland/device.c
===================================================================
--- trunk/batman-adv-kernelland/device.c 2010-02-14 17:18:29 UTC (rev 1573)
+++ trunk/batman-adv-kernelland/device.c 2010-02-16 15:44:12 UTC (rev 1574)
@@ -163,6 +163,7 @@
struct device_client *device_client =
(struct device_client *)file->private_data;
struct device_packet *device_packet;
+ size_t packet_len;
int error;
unsigned long flags;
@@ -191,14 +192,15 @@
spin_unlock_irqrestore(&device_client->lock, flags);
error = __copy_to_user(buf, &device_packet->icmp_packet,
- sizeof(struct icmp_packet));
+ device_packet->icmp_len);
+ packet_len = device_packet->icmp_len;
kfree(device_packet);
if (error)
return error;
- return sizeof(struct icmp_packet);
+ return packet_len;
}
ssize_t bat_device_write(struct file *file, const char __user *buff,
@@ -206,9 +208,10 @@
{
struct device_client *device_client =
(struct device_client *)file->private_data;
- struct icmp_packet icmp_packet;
+ struct icmp_packet_rr icmp_packet;
struct orig_node *orig_node;
struct batman_if *batman_if;
+ size_t packet_len = sizeof(struct icmp_packet);
uint8_t dstaddr[ETH_ALEN];
unsigned long flags;
@@ -217,10 +220,13 @@
return -EINVAL;
}
- if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet)))
+ if (len >= sizeof(struct icmp_packet_rr))
+ packet_len = sizeof(struct icmp_packet_rr);
+
+ if (!access_ok(VERIFY_READ, buff, packet_len))
return -EFAULT;
- if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet)))
+ if (__copy_from_user(&icmp_packet, buff, packet_len))
return -EFAULT;
if (icmp_packet.packet_type != BAT_ICMP) {
@@ -238,7 +244,7 @@
if (icmp_packet.version != COMPAT_VERSION) {
icmp_packet.msg_type = PARAMETER_PROBLEM;
icmp_packet.ttl = COMPAT_VERSION;
- bat_device_add_packet(device_client, &icmp_packet);
+ bat_device_add_packet(device_client, &icmp_packet, packet_len);
goto out;
}
@@ -265,13 +271,13 @@
if (batman_if->if_active != IF_ACTIVE)
goto dst_unreach;
- memcpy(icmp_packet.orig,
- batman_if->net_dev->dev_addr,
- ETH_ALEN);
+ memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN);
+ if (packet_len == sizeof(struct icmp_packet_rr))
+ memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN);
+
send_raw_packet((unsigned char *)&icmp_packet,
- sizeof(struct icmp_packet),
- batman_if, dstaddr);
+ packet_len, batman_if, dstaddr);
goto out;
@@ -279,7 +285,7 @@
spin_unlock_irqrestore(&orig_hash_lock, flags);
dst_unreach:
icmp_packet.msg_type = DESTINATION_UNREACHABLE;
- bat_device_add_packet(device_client, &icmp_packet);
+ bat_device_add_packet(device_client, &icmp_packet, packet_len);
out:
return len;
}
@@ -298,7 +304,8 @@
}
void bat_device_add_packet(struct device_client *device_client,
- struct icmp_packet *icmp_packet)
+ struct icmp_packet_rr *icmp_packet,
+ size_t icmp_len)
{
struct device_packet *device_packet;
unsigned long flags;
@@ -309,8 +316,8 @@
return;
INIT_LIST_HEAD(&device_packet->list);
- memcpy(&device_packet->icmp_packet, icmp_packet,
- sizeof(struct icmp_packet));
+ memcpy(&device_packet->icmp_packet, icmp_packet, icmp_len);
+ device_packet->icmp_len = icmp_len;
spin_lock_irqsave(&device_client->lock, flags);
@@ -339,10 +346,11 @@
wake_up(&device_client->queue_wait);
}
-void bat_device_receive_packet(struct icmp_packet *icmp_packet)
+void bat_device_receive_packet(struct icmp_packet_rr *icmp_packet,
+ size_t icmp_len)
{
struct device_client *hash = device_client_hash[icmp_packet->uid];
if (hash)
- bat_device_add_packet(hash, icmp_packet);
+ bat_device_add_packet(hash, icmp_packet, icmp_len);
}
Modified: trunk/batman-adv-kernelland/device.h
===================================================================
--- trunk/batman-adv-kernelland/device.h 2010-02-14 17:18:29 UTC (rev 1573)
+++ trunk/batman-adv-kernelland/device.h 2010-02-16 15:44:12 UTC (rev 1574)
@@ -32,5 +32,7 @@
size_t len, loff_t *off);
unsigned int bat_device_poll(struct file *file, poll_table *wait);
void bat_device_add_packet(struct device_client *device_client,
- struct icmp_packet *icmp_packet);
-void bat_device_receive_packet(struct icmp_packet *icmp_packet);
+ struct icmp_packet_rr *icmp_packet,
+ size_t icmp_len);
+void bat_device_receive_packet(struct icmp_packet_rr *icmp_packet,
+ size_t icmp_len);
Modified: trunk/batman-adv-kernelland/packet.h
===================================================================
--- trunk/batman-adv-kernelland/packet.h 2010-02-14 17:18:29 UTC (rev 1573)
+++ trunk/batman-adv-kernelland/packet.h 2010-02-16 15:44:12 UTC (rev 1574)
@@ -71,6 +71,23 @@
uint8_t uid;
} __attribute__((packed));
+#define BAT_RR_LEN 16
+
+/* icmp_packet_rr must start with all fields from imcp_packet
+ as this is assumed by code that handles ICMP packets */
+struct icmp_packet_rr {
+ uint8_t packet_type;
+ uint8_t version; /* batman version field */
+ uint8_t msg_type; /* see ICMP message types above */
+ uint8_t ttl;
+ uint8_t dst[6];
+ uint8_t orig[6];
+ uint16_t seqno;
+ uint8_t uid;
+ uint8_t rr_cur;
+ uint8_t rr[BAT_RR_LEN][ETH_ALEN];
+} __attribute__((packed));
+
struct unicast_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
Modified: trunk/batman-adv-kernelland/routing.c
===================================================================
--- trunk/batman-adv-kernelland/routing.c 2010-02-14 17:18:29 UTC (rev 1573)
+++ trunk/batman-adv-kernelland/routing.c 2010-02-16 15:44:12 UTC (rev 1574)
@@ -706,10 +706,10 @@
return NET_RX_SUCCESS;
}
-static int recv_my_icmp_packet(struct sk_buff *skb)
+static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
{
struct orig_node *orig_node;
- struct icmp_packet *icmp_packet;
+ struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
struct sk_buff *skb_old;
struct batman_if *batman_if;
@@ -717,12 +717,12 @@
unsigned long flags;
uint8_t dstaddr[ETH_ALEN];
- icmp_packet = (struct icmp_packet *) skb->data;
- ethhdr = (struct ethhdr *) skb_mac_header(skb);
+ icmp_packet = (struct icmp_packet_rr *)skb->data;
+ ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* add data to device queue */
if (icmp_packet->msg_type != ECHO_REQUEST) {
- bat_device_receive_packet(icmp_packet);
+ bat_device_receive_packet(icmp_packet, icmp_len);
return NET_RX_DROP;
}
@@ -745,12 +745,12 @@
/* create a copy of the skb, if needed, to modify it. */
skb_old = NULL;
- if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) {
+ if (!skb_clone_writable(skb, icmp_len)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
- icmp_packet = (struct icmp_packet *) skb->data;
+ icmp_packet = (struct icmp_packet_rr *)skb->data;
kfree_skb(skb_old);
}
@@ -768,7 +768,7 @@
return ret;
}
-static int recv_icmp_ttl_exceeded(struct sk_buff *skb)
+static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
{
struct orig_node *orig_node;
struct icmp_packet *icmp_packet;
@@ -806,7 +806,7 @@
spin_unlock_irqrestore(&orig_hash_lock, flags);
/* create a copy of the skb, if needed, to modify it. */
- if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) {
+ if (!skb_clone_writable(skb, icmp_len)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
@@ -832,7 +832,7 @@
int recv_icmp_packet(struct sk_buff *skb)
{
- struct icmp_packet *icmp_packet;
+ struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
struct orig_node *orig_node;
struct sk_buff *skb_old;
@@ -842,6 +842,12 @@
unsigned long flags;
uint8_t dstaddr[ETH_ALEN];
+ /**
+ * we truncate all incoming icmp packets if they don't match our size
+ */
+ if (skb_headlen(skb) >= sizeof(struct icmp_packet_rr))
+ hdr_size = sizeof(struct icmp_packet_rr);
+
/* drop packet if it has not necessary minimum size */
if (skb_headlen(skb) < hdr_size)
return NET_RX_DROP;
@@ -860,15 +866,23 @@
if (!is_my_mac(ethhdr->h_dest))
return NET_RX_DROP;
- icmp_packet = (struct icmp_packet *) skb->data;
+ icmp_packet = (struct icmp_packet_rr *)skb->data;
+ /* add record route information if not full */
+ if ((hdr_size == sizeof(struct icmp_packet_rr)) &&
+ (icmp_packet->rr_cur < BAT_RR_LEN)) {
+ memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]),
+ ethhdr->h_dest, ETH_ALEN);
+ icmp_packet->rr_cur++;
+ }
+
/* packet for me */
if (is_my_mac(icmp_packet->dst))
- return recv_my_icmp_packet(skb);
+ return recv_my_icmp_packet(skb, hdr_size);
/* TTL exceeded */
if (icmp_packet->ttl < 2)
- return recv_icmp_ttl_exceeded(skb);
+ return recv_icmp_ttl_exceeded(skb, hdr_size);
ret = NET_RX_DROP;
@@ -888,12 +902,12 @@
spin_unlock_irqrestore(&orig_hash_lock, flags);
/* create a copy of the skb, if needed, to modify it. */
- if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) {
+ if (!skb_clone_writable(skb, hdr_size)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
- icmp_packet = (struct icmp_packet *) skb->data;
+ icmp_packet = (struct icmp_packet_rr *)skb->data;
kfree_skb(skb_old);
}
Modified: trunk/batman-adv-kernelland/types.h
===================================================================
--- trunk/batman-adv-kernelland/types.h 2010-02-14 17:18:29 UTC (rev 1573)
+++ trunk/batman-adv-kernelland/types.h 2010-02-16 15:44:12 UTC (rev 1574)
@@ -106,7 +106,8 @@
struct device_packet {
struct list_head list;
- struct icmp_packet icmp_packet;
+ size_t icmp_len;
+ struct icmp_packet_rr icmp_packet;
};
struct hna_local_entry {
12 years, 4 months
r1573 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: simon
Date: 2010-02-14 18:18:29 +0100 (Sun, 14 Feb 2010)
New Revision: 1573
Modified:
trunk/batman-adv-kernelland/hard-interface.c
trunk/batman-adv-kernelland/proc.c
Log:
batman-adv: fix module initialization
Mareks patch to make sure that batman-adv does not process packets before its
initialization is complete. Some sanity checks added to the receiver function.
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Modified: trunk/batman-adv-kernelland/hard-interface.c
===================================================================
--- trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 16:30:15 UTC (rev 1572)
+++ trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 17:18:29 UTC (rev 1573)
@@ -433,6 +433,9 @@
if (!skb)
goto err_out;
+ if (atomic_read(&module_state) != MODULE_ACTIVE)
+ goto err_free;
+
/* packet should hold at least type and version */
if (unlikely(skb_headlen(skb) < 2))
goto err_free;
@@ -446,6 +449,10 @@
if (!batman_if)
goto err_free;
+ /* discard frames on not active interfaces */
+ if (batman_if->if_active != IF_ACTIVE)
+ goto err_free;
+
stats = (struct net_device_stats *)dev_get_stats(skb->dev);
if (stats) {
stats->rx_packets++;
Modified: trunk/batman-adv-kernelland/proc.c
===================================================================
--- trunk/batman-adv-kernelland/proc.c 2010-02-14 16:30:15 UTC (rev 1572)
+++ trunk/batman-adv-kernelland/proc.c 2010-02-14 17:18:29 UTC (rev 1573)
@@ -67,7 +67,7 @@
size_t count, loff_t *data)
{
char *if_string, *colon_ptr = NULL, *cr_ptr = NULL;
- int not_copied = 0, if_num = 0;
+ int not_copied = 0, if_num = 0, add_success;
struct batman_if *batman_if = NULL;
if_string = kmalloc(count, GFP_KERNEL);
@@ -113,22 +113,17 @@
}
rcu_read_unlock();
- hardif_add_interface(if_string, if_num);
+ add_success = hardif_add_interface(if_string, if_num);
+ if (add_success < 0)
+ goto end;
+ num_ifs = if_num + 1;
+
if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
(hardif_get_active_if_num() > 0))
activate_module();
- rcu_read_lock();
- if (list_empty(&if_list)) {
- rcu_read_unlock();
- goto end;
- }
- rcu_read_unlock();
-
- num_ifs = if_num + 1;
return count;
-
end:
kfree(if_string);
return count;
12 years, 4 months
r1572 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-14 17:30:15 +0100 (Sun, 14 Feb 2010)
New Revision: 1572
Modified:
trunk/batman-adv-kernelland/hard-interface.c
Log:
batman-adv: avoid crash on memory allocation error
skb_share_check() returns NULL if it can't allocate more memory but
it still frees the skbuff.
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv-kernelland/hard-interface.c
===================================================================
--- trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 15:05:18 UTC (rev 1571)
+++ trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 16:30:15 UTC (rev 1572)
@@ -427,10 +427,11 @@
struct net_device_stats *stats;
int ret;
- skb = skb_share_check(skb, GFP_ATOMIC);
+ skb = skb_share_check(skb, GFP_ATOMIC);
- if (skb == NULL)
- goto err_free;
+ /* skb was released by skb_share_check() */
+ if (!skb)
+ goto err_out;
/* packet should hold at least type and version */
if (unlikely(skb_headlen(skb) < 2))
@@ -445,7 +446,7 @@
if (!batman_if)
goto err_free;
- stats = (struct net_device_stats *) dev_get_stats(skb->dev);
+ stats = (struct net_device_stats *)dev_get_stats(skb->dev);
if (stats) {
stats->rx_packets++;
stats->rx_bytes += skb->len;
@@ -491,6 +492,7 @@
default:
ret = NET_RX_DROP;
}
+
if (ret == NET_RX_DROP)
kfree_skb(skb);
@@ -501,9 +503,9 @@
return NET_RX_SUCCESS;
err_free:
- kfree_skb(skb);
- return NET_RX_DROP;
-
+ kfree_skb(skb);
+err_out:
+ return NET_RX_DROP;
}
12 years, 4 months
r1571 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: simon
Date: 2010-02-14 16:05:18 +0100 (Sun, 14 Feb 2010)
New Revision: 1571
Modified:
trunk/batman-adv-kernelland/routing.c
Log:
batman-adv: bonding: don't ask hash when already found primary router
The probability is very high that we are already dealing with the primary
router when searching for a bonding candidate, so check if we are already found
it before searching with hash_find().
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Modified: trunk/batman-adv-kernelland/routing.c
===================================================================
--- trunk/batman-adv-kernelland/routing.c 2010-02-13 14:55:59 UTC (rev 1570)
+++ trunk/batman-adv-kernelland/routing.c 2010-02-14 15:05:18 UTC (rev 1571)
@@ -937,11 +937,17 @@
return orig_node->router;
/* find the orig_node which has the primary interface. might
- * even be the same as our orig_node in many cases */
+ * even be the same as our router_orig in many cases */
- primary_orig_node = hash_find(orig_hash, router_orig->primary_addr);
- if (!primary_orig_node)
- return orig_node->router;
+ if (memcmp(router_orig->primary_addr,
+ router_orig->orig, ETH_ALEN) == 0) {
+ primary_orig_node = router_orig;
+ } else {
+ primary_orig_node = hash_find(orig_hash,
+ router_orig->primary_addr);
+ if (!primary_orig_node)
+ return orig_node->router;
+ }
/* with less than 2 candidates, we can't do any
* bonding and prefer the original router. */
12 years, 4 months
r1570 - trunk/batman-adv-kernelland
by postmaster@open-mesh.net
Author: marek
Date: 2010-02-13 15:55:59 +0100 (Sat, 13 Feb 2010)
New Revision: 1570
Modified:
trunk/batman-adv-kernelland/bat_printk.c
Log:
batman-adv: Some missed debug output, removing it.
Signed-off-by: Linus L?\195?\188ssing <linus.luessing(a)web.de>
Signed-off-by: Andrew Lunn <andrew(a)lunn.ch>
Modified: trunk/batman-adv-kernelland/bat_printk.c
===================================================================
--- trunk/batman-adv-kernelland/bat_printk.c 2010-02-13 14:55:55 UTC (rev 1569)
+++ trunk/batman-adv-kernelland/bat_printk.c 2010-02-13 14:55:59 UTC (rev 1570)
@@ -857,5 +857,5 @@
r = bat_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- return printk("foo:%s", buf);
+ return printk("%s", buf);
}
12 years, 4 months