Author: marek
Date: 2010-07-25 02:16:06 +0200 (Sun, 25 Jul 2010)
New Revision: 1748
Modified:
trunk/batman-adv/soft-interface.c
Log:
batman-adv: send fragmented packets with mac of primary interface
Fragmentated packets should use the primary mac in the 'orig' field
as the receiving end uses the global mac hash to store information.
If the mac address can't be found the packet is dropped.
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv/soft-interface.c
===================================================================
--- trunk/batman-adv/soft-interface.c 2010-07-25 00:16:05 UTC (rev 1747)
+++ trunk/batman-adv/soft-interface.c 2010-07-25 00:16:06 UTC (rev 1748)
@@ -224,6 +224,9 @@
data_len + sizeof(struct unicast_packet) >
batman_if->net_dev->mtu) {
+ if (!bat_priv->primary_if)
+ goto dropped;
+
hdr_len = sizeof(struct unicast_frag_packet);
frag_skb = dev_alloc_skb(data_len - (data_len / 2) +
@@ -245,7 +248,8 @@
ucast_frag1->packet_type = BAT_UNICAST_FRAG;
ucast_frag1->ttl = TTL;
memcpy(ucast_frag1->orig,
- batman_if->net_dev->dev_addr, ETH_ALEN);
+ bat_priv->primary_if->net_dev->dev_addr,
+ ETH_ALEN);
memcpy(ucast_frag1->dest, orig_node->orig, ETH_ALEN);
memcpy(ucast_frag2, ucast_frag1,
Author: marek
Date: 2010-07-25 02:16:05 +0200 (Sun, 25 Jul 2010)
New Revision: 1747
Modified:
trunk/batman-adv/routing.c
Log:
batman-adv: always reply batman icmp packets with primary mac
When receiving an batman icmp echo request or in case of a time-to-live
exceeded batman would reply with the mac address of the outgoing
interface which might be a secondary interface. Because secondary
interfaces are not globally known this might lead to confusion.
Now, replies are sent with the mac address of the primary interface.
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv/routing.c
===================================================================
--- trunk/batman-adv/routing.c 2010-07-25 00:16:04 UTC (rev 1746)
+++ trunk/batman-adv/routing.c 2010-07-25 00:16:05 UTC (rev 1747)
@@ -796,6 +796,8 @@
static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
{
+ /* FIXME: each batman_if will be attached to a softif */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
struct orig_node *orig_node;
struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
@@ -814,6 +816,9 @@
return NET_RX_DROP;
}
+ if (!bat_priv->primary_if)
+ return NET_RX_DROP;
+
/* answer echo request (ping) */
/* get routing information */
spin_lock_irqsave(&orig_hash_lock, flags);
@@ -843,7 +848,8 @@
}
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
- memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
+ memcpy(icmp_packet->orig,
+ bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = ECHO_REPLY;
icmp_packet->ttl = TTL;
@@ -858,6 +864,8 @@
static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
{
+ /* FIXME: each batman_if will be attached to a softif */
+ struct bat_priv *bat_priv = netdev_priv(soft_device);
struct orig_node *orig_node;
struct icmp_packet *icmp_packet;
struct ethhdr *ethhdr;
@@ -878,6 +886,9 @@
return NET_RX_DROP;
}
+ if (!bat_priv->primary_if)
+ return NET_RX_DROP;
+
/* get routing information */
spin_lock_irqsave(&orig_hash_lock, flags);
orig_node = ((struct orig_node *)
@@ -905,7 +916,8 @@
}
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
- memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
+ memcpy(icmp_packet->orig,
+ bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = TTL_EXCEEDED;
icmp_packet->ttl = TTL;
Author: marek
Date: 2010-07-25 02:16:04 +0200 (Sun, 25 Jul 2010)
New Revision: 1746
Modified:
trunk/batman-adv/icmp_socket.c
trunk/batman-adv/types.h
Log:
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(a)yahoo.de>
Modified: trunk/batman-adv/icmp_socket.c
===================================================================
--- trunk/batman-adv/icmp_socket.c 2010-07-24 17:52:55 UTC (rev 1745)
+++ trunk/batman-adv/icmp_socket.c 2010-07-25 00:16:04 UTC (rev 1746)
@@ -69,6 +69,7 @@
INIT_LIST_HEAD(&socket_client->queue_list);
socket_client->queue_len = 0;
socket_client->index = i;
+ socket_client->bat_priv = inode->i_private;
spin_lock_init(&socket_client->lock);
init_waitqueue_head(&socket_client->queue_wait);
@@ -153,9 +154,8 @@
static ssize_t bat_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off)
{
- /* FIXME: each orig_node->batman_if will be attached to a softif */
- struct bat_priv *bat_priv = netdev_priv(soft_device);
struct socket_client *socket_client = file->private_data;
+ struct bat_priv *bat_priv = socket_client->bat_priv;
struct sk_buff *skb;
struct icmp_packet_rr *icmp_packet;
struct orig_node *orig_node;
@@ -171,6 +171,9 @@
return -EINVAL;
}
+ if (!bat_priv->primary_if)
+ return -EFAULT;
+
if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
@@ -239,7 +242,8 @@
if (batman_if->if_status != IF_ACTIVE)
goto dst_unreach;
- memcpy(icmp_packet->orig, batman_if->net_dev->dev_addr, ETH_ALEN);
+ memcpy(icmp_packet->orig,
+ bat_priv->primary_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);
@@ -289,7 +293,7 @@
goto err;
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
- bat_priv->debug_dir, NULL, &fops);
+ bat_priv->debug_dir, bat_priv, &fops);
if (d)
goto err;
Modified: trunk/batman-adv/types.h
===================================================================
--- trunk/batman-adv/types.h 2010-07-24 17:52:55 UTC (rev 1745)
+++ trunk/batman-adv/types.h 2010-07-25 00:16:04 UTC (rev 1746)
@@ -142,6 +142,7 @@
unsigned char index;
spinlock_t lock;
wait_queue_head_t queue_wait;
+ struct bat_priv *bat_priv;
};
struct socket_packet {