diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2010-08-09 17:56:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-23 21:15:36 -0400 |
commit | 13334d4875dbaeeb44e7905463f07e236f80311f (patch) | |
tree | ce73f583ef4ca95348e62e1b93e266b6945a6234 | |
parent | 9abc10238e1df7ce81c58a441f65efd5e905b9e8 (diff) |
Staging: batman-adv: fix batman icmp originating from secondary interface
If a batman icmp packet had to be routed over a secondary interface
at the first hop, the mac address of that secondary interface would
be written in the 'orig' field of the icmp packet. A node which is
more than one hop away is not aware of the mac address because
secondary interfaces are not flooded through the whole mesh and
therefore can't send a reply.
This patch always sends the mac address of the primary interface
in the 'orig' field of the icmp packet.
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/batman-adv/icmp_socket.c | 12 | ||||
-rw-r--r-- | drivers/staging/batman-adv/types.h | 1 |
2 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/batman-adv/icmp_socket.c b/drivers/staging/batman-adv/icmp_socket.c index fc3d32c12729..3ae7dd2d2d4d 100644 --- a/drivers/staging/batman-adv/icmp_socket.c +++ b/drivers/staging/batman-adv/icmp_socket.c | |||
@@ -67,6 +67,7 @@ static int bat_socket_open(struct inode *inode, struct file *file) | |||
67 | INIT_LIST_HEAD(&socket_client->queue_list); | 67 | INIT_LIST_HEAD(&socket_client->queue_list); |
68 | socket_client->queue_len = 0; | 68 | socket_client->queue_len = 0; |
69 | socket_client->index = i; | 69 | socket_client->index = i; |
70 | socket_client->bat_priv = inode->i_private; | ||
70 | spin_lock_init(&socket_client->lock); | 71 | spin_lock_init(&socket_client->lock); |
71 | init_waitqueue_head(&socket_client->queue_wait); | 72 | init_waitqueue_head(&socket_client->queue_wait); |
72 | 73 | ||
@@ -151,9 +152,8 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf, | |||
151 | static ssize_t bat_socket_write(struct file *file, const char __user *buff, | 152 | static ssize_t bat_socket_write(struct file *file, const char __user *buff, |
152 | size_t len, loff_t *off) | 153 | size_t len, loff_t *off) |
153 | { | 154 | { |
154 | /* FIXME: each orig_node->batman_if will be attached to a softif */ | ||
155 | struct bat_priv *bat_priv = netdev_priv(soft_device); | ||
156 | struct socket_client *socket_client = file->private_data; | 155 | struct socket_client *socket_client = file->private_data; |
156 | struct bat_priv *bat_priv = socket_client->bat_priv; | ||
157 | struct icmp_packet_rr icmp_packet; | 157 | struct icmp_packet_rr icmp_packet; |
158 | struct orig_node *orig_node; | 158 | struct orig_node *orig_node; |
159 | struct batman_if *batman_if; | 159 | struct batman_if *batman_if; |
@@ -168,6 +168,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, | |||
168 | return -EINVAL; | 168 | return -EINVAL; |
169 | } | 169 | } |
170 | 170 | ||
171 | if (!bat_priv->primary_if) | ||
172 | return -EFAULT; | ||
173 | |||
171 | if (len >= sizeof(struct icmp_packet_rr)) | 174 | if (len >= sizeof(struct icmp_packet_rr)) |
172 | packet_len = sizeof(struct icmp_packet_rr); | 175 | packet_len = sizeof(struct icmp_packet_rr); |
173 | 176 | ||
@@ -223,7 +226,8 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, | |||
223 | if (batman_if->if_status != IF_ACTIVE) | 226 | if (batman_if->if_status != IF_ACTIVE) |
224 | goto dst_unreach; | 227 | goto dst_unreach; |
225 | 228 | ||
226 | memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN); | 229 | memcpy(icmp_packet.orig, |
230 | bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN); | ||
227 | 231 | ||
228 | if (packet_len == sizeof(struct icmp_packet_rr)) | 232 | if (packet_len == sizeof(struct icmp_packet_rr)) |
229 | memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN); | 233 | memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN); |
@@ -271,7 +275,7 @@ int bat_socket_setup(struct bat_priv *bat_priv) | |||
271 | goto err; | 275 | goto err; |
272 | 276 | ||
273 | d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, | 277 | d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, |
274 | bat_priv->debug_dir, NULL, &fops); | 278 | bat_priv->debug_dir, bat_priv, &fops); |
275 | if (d) | 279 | if (d) |
276 | goto err; | 280 | goto err; |
277 | 281 | ||
diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index 21d0717afb09..9aa9d369c752 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h | |||
@@ -126,6 +126,7 @@ struct socket_client { | |||
126 | unsigned char index; | 126 | unsigned char index; |
127 | spinlock_t lock; | 127 | spinlock_t lock; |
128 | wait_queue_head_t queue_wait; | 128 | wait_queue_head_t queue_wait; |
129 | struct bat_priv *bat_priv; | ||
129 | }; | 130 | }; |
130 | 131 | ||
131 | struct socket_packet { | 132 | struct socket_packet { |