r1751 - branches/bmx-0.3.x
by postmaster@open-mesh.org
Author: axel
Date: 2010-07-31 19:21:13 +0200 (Sat, 31 Jul 2010)
New Revision: 1751
Modified:
branches/bmx-0.3.x/allocate.c
Log:
branches/bmx-0.3.x/allocate.c debugMalloc/Free/Realloc: quick arm9 fix changing trailing magicNumber to char
Modified: branches/bmx-0.3.x/allocate.c
===================================================================
--- branches/bmx-0.3.x/allocate.c 2010-07-25 02:53:39 UTC (rev 1750)
+++ branches/bmx-0.3.x/allocate.c 2010-07-31 17:21:13 UTC (rev 1751)
@@ -27,7 +27,8 @@
#include "os.h"
-#define MAGIC_NUMBER 0x12345678
+#define MAGIC_NUMBER_HEADER 0x12345678
+#define MAGIC_NUMBER_TRAILOR 0x12
#if defined DEBUG_MALLOC
@@ -39,16 +40,14 @@
struct chunkHeader *next;
uint32_t length;
int32_t tag;
- uint32_t magicNumber;
+ uint32_t magicNumberHeader;
};
-struct chunkTrailer
-{
- uint32_t magicNumber;
-};
+typedef unsigned char magicNumberTrailor;
+
#if defined MEMORY_USAGE
struct memoryUsage *memoryList = NULL;
@@ -152,32 +151,32 @@
void checkIntegrity(void)
{
struct chunkHeader *walker;
- struct chunkTrailer *chunkTrailer;
+ magicNumberTrailor *chunkTrailer;
unsigned char *memory;
for (walker = chunkList; walker != NULL; walker = walker->next)
{
- if (walker->magicNumber != MAGIC_NUMBER)
+ if (walker->magicNumberHeader != MAGIC_NUMBER_HEADER)
{
dbgf( DBGL_SYS, DBGT_ERR,
"invalid magic number in header: %08x, malloc tag = %d",
- walker->magicNumber, walker->tag );
+ walker->magicNumberHeader, walker->tag );
cleanup_all( -500073 );
}
memory = (unsigned char *)walker;
- chunkTrailer = (struct chunkTrailer *)(memory + sizeof(struct chunkHeader) + walker->length);
+ chunkTrailer = (magicNumberTrailor*)(memory + sizeof(struct chunkHeader) + walker->length);
- if (chunkTrailer->magicNumber != MAGIC_NUMBER)
- {
- dbgf( DBGL_SYS, DBGT_ERR,
- "invalid magic number in trailer: %08x, malloc tag = %d",
- chunkTrailer->magicNumber, walker->tag );
- cleanup_all( -500075 );
- }
- }
+ if (*chunkTrailer != MAGIC_NUMBER_TRAILOR)
+{
+ dbgf(DBGL_SYS, DBGT_ERR,
+ "invalid magic number in trailer: %08x, malloc tag = %d",
+ *chunkTrailer, walker->tag);
+ cleanup_all(-500075);
+ }
+ }
}
@@ -207,27 +206,27 @@
prof_start( PROF_debugMalloc );
unsigned char *memory;
struct chunkHeader *chunkHeader;
- struct chunkTrailer *chunkTrailer;
+ magicNumberTrailor *chunkTrailer;
unsigned char *chunk;
- memory = malloc(length + sizeof(struct chunkHeader) + sizeof(struct chunkTrailer));
+ memory = malloc(length + sizeof(struct chunkHeader) + sizeof(magicNumberTrailor));
if (memory == NULL)
{
dbg( DBGL_SYS, DBGT_ERR, "Cannot allocate %u bytes, malloc tag = %d",
- (unsigned int)(length + sizeof(struct chunkHeader) + sizeof(struct chunkTrailer)), tag );
+ (unsigned int)(length + sizeof(struct chunkHeader) + sizeof(magicNumberTrailor)), tag );
cleanup_all( -500076 );
}
chunkHeader = (struct chunkHeader *)memory;
chunk = memory + sizeof(struct chunkHeader);
- chunkTrailer = (struct chunkTrailer *)(memory + sizeof(struct chunkHeader) + length);
+ chunkTrailer = (magicNumberTrailor *) (memory + sizeof (struct chunkHeader) + length);
chunkHeader->length = length;
chunkHeader->tag = tag;
- chunkHeader->magicNumber = MAGIC_NUMBER;
+ chunkHeader->magicNumberHeader = MAGIC_NUMBER_HEADER;
- chunkTrailer->magicNumber = MAGIC_NUMBER;
+ *chunkTrailer = MAGIC_NUMBER_TRAILOR;
chunkHeader->next = chunkList;
chunkList = chunkHeader;
@@ -248,7 +247,7 @@
unsigned char *memory;
struct chunkHeader *chunkHeader=NULL;
- struct chunkTrailer *chunkTrailer;
+ magicNumberTrailor *chunkTrailer;
unsigned char *result;
uint32_t copyLength;
@@ -256,23 +255,23 @@
memory = memoryParameter;
chunkHeader = (struct chunkHeader *)(memory - sizeof(struct chunkHeader));
- if (chunkHeader->magicNumber != MAGIC_NUMBER)
+ if (chunkHeader->magicNumberHeader != MAGIC_NUMBER_HEADER)
{
dbgf( DBGL_SYS, DBGT_ERR,
"invalid magic number in header: %08x, malloc tag = %d",
- chunkHeader->magicNumber, chunkHeader->tag );
+ chunkHeader->magicNumberHeader, chunkHeader->tag );
cleanup_all( -500078 );
}
- chunkTrailer = (struct chunkTrailer *)(memory + chunkHeader->length);
+ chunkTrailer = (magicNumberTrailor *)(memory + chunkHeader->length);
- if (chunkTrailer->magicNumber != MAGIC_NUMBER)
+ if (*chunkTrailer != MAGIC_NUMBER_TRAILOR)
{
- dbgf( DBGL_SYS, DBGT_ERR,
- "invalid magic number in trailer: %08x, malloc tag = %d",
- chunkTrailer->magicNumber, chunkHeader->tag );
- cleanup_all( -500079 );
- }
+ dbgf( DBGL_SYS, DBGT_ERR,
+ "invalid magic number in trailer: %08x, malloc tag = %d",
+ *chunkTrailer, chunkHeader->tag);
+ cleanup_all(-500079);
+ }
}
@@ -297,18 +296,18 @@
unsigned char *memory;
struct chunkHeader *chunkHeader;
- struct chunkTrailer *chunkTrailer;
+ magicNumberTrailor *chunkTrailer;
struct chunkHeader *walker;
struct chunkHeader *previous;
memory = memoryParameter;
chunkHeader = (struct chunkHeader *)(memory - sizeof(struct chunkHeader));
- if (chunkHeader->magicNumber != MAGIC_NUMBER)
+ if (chunkHeader->magicNumberHeader != MAGIC_NUMBER_HEADER)
{
dbgf( DBGL_SYS, DBGT_ERR,
- "invalid magic number in header: %08x, malloc tag = %d, free tag = %d",
- chunkHeader->magicNumber, chunkHeader->tag, tag );
+ "invalid magic number in header: %08x, malloc tag = %d, free tag = %d, malloc size = %d",
+ chunkHeader->magicNumberHeader, chunkHeader->tag, tag, chunkHeader->length );
cleanup_all( -500080 );
}
@@ -324,8 +323,8 @@
if (walker == NULL)
{
- dbg( DBGL_SYS, DBGT_ERR, "Double free detected, malloc tag = %d, free tag = %d",
- chunkHeader->tag, tag );
+ dbg( DBGL_SYS, DBGT_ERR, "Double free detected, malloc tag = %d, free tag = %d, malloc size = %d",
+ chunkHeader->tag, tag, chunkHeader->length );
cleanup_all( -500081 );
}
@@ -336,14 +335,14 @@
previous->next = walker->next;
- chunkTrailer = (struct chunkTrailer *)(memory + chunkHeader->length);
+ chunkTrailer = (magicNumberTrailor *)(memory + chunkHeader->length);
- if (chunkTrailer->magicNumber != MAGIC_NUMBER)
- {
- dbgf( DBGL_SYS, DBGT_ERR,
- "invalid magic number in trailer: %08x, malloc tag = %d, free tag = %d",
- chunkTrailer->magicNumber, chunkHeader->tag, tag );
- cleanup_all( -500082 );
+ if (*chunkTrailer != MAGIC_NUMBER_TRAILOR)
+{
+ dbgf(DBGL_SYS, DBGT_ERR,
+ "invalid magic number in trailer: %08x, malloc tag = %d, free tag = %d, malloc size = %d",
+ *chunkTrailer, chunkHeader->tag, tag, chunkHeader->length);
+ cleanup_all(-500082);
}
#if defined MEMORY_USAGE
11 years, 11 months
r1750 - trunk/batctl
by postmaster@open-mesh.org
Author: marek
Date: 2010-07-25 04:53:39 +0200 (Sun, 25 Jul 2010)
New Revision: 1750
Modified:
trunk/batctl/tcpdump.c
Log:
batctl: tcpdump - print encapsulated payload even if DUMP_TYPE_NONBAT is not set
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batctl/tcpdump.c
===================================================================
--- trunk/batctl/tcpdump.c 2010-07-25 02:34:38 UTC (rev 1749)
+++ trunk/batctl/tcpdump.c 2010-07-25 02:53:39 UTC (rev 1750)
@@ -376,7 +376,7 @@
struct unicast_frag_packet *unicast_frag_packet;
LEN_CHECK((size_t)buff_len - ETH_HLEN, sizeof(struct unicast_frag_packet), "BAT FRAG");
- LEN_CHECK((size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), ETH_HLEN, "BAT FRAG (unpacked)");
+ LEN_CHECK((size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), (size_t)ETH_HLEN, "BAT FRAG (unpacked)");
ether_header = (struct ether_header *)packet_buff;
unicast_frag_packet = (struct unicast_frag_packet *)(packet_buff + ETH_HLEN);
@@ -385,7 +385,7 @@
time_printed = print_time();
printf("BAT %s > ",
- get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt));
+ get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->orig, read_opt));
printf("%s: FRAG, seq %hu, ttl %hu, flags [%c], ",
get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->dest, read_opt),
@@ -409,15 +409,15 @@
switch (ntohs(eth_hdr->ether_type)) {
case ETH_P_ARP:
- if (dump_level & DUMP_TYPE_NONBAT)
+ if ((dump_level & DUMP_TYPE_NONBAT) || (time_printed))
dump_arp(packet_buff + ETH_HLEN, buff_len - ETH_HLEN, time_printed);
break;
case ETH_P_IP:
- if (dump_level & DUMP_TYPE_NONBAT)
+ if ((dump_level & DUMP_TYPE_NONBAT) || (time_printed))
dump_ip(packet_buff + ETH_HLEN, buff_len - ETH_HLEN, time_printed);
break;
case ETH_P_8021Q:
- if (dump_level & DUMP_TYPE_NONBAT)
+ if ((dump_level & DUMP_TYPE_NONBAT) || (time_printed))
dump_vlan(packet_buff, buff_len, read_opt, time_printed);
break;
case ETH_P_BATMAN:
11 years, 11 months
r1749 - trunk/batman-adv
by postmaster@open-mesh.org
Author: marek
Date: 2010-07-25 04:34:38 +0200 (Sun, 25 Jul 2010)
New Revision: 1749
Added:
trunk/batman-adv/unicast.c
trunk/batman-adv/unicast.h
Removed:
trunk/batman-adv/fragmentation.c
trunk/batman-adv/fragmentation.h
Modified:
trunk/batman-adv/Makefile.kbuild
trunk/batman-adv/originator.c
trunk/batman-adv/routing.c
trunk/batman-adv/soft-interface.c
Log:
batman-adv: refactoring unicast payload code
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batman-adv/Makefile.kbuild
===================================================================
--- trunk/batman-adv/Makefile.kbuild 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/Makefile.kbuild 2010-07-25 02:34:38 UTC (rev 1749)
@@ -32,4 +32,4 @@
endif
obj-m += batman-adv.o
-batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o gateway_common.o gateway_client.o fragmentation.o $(shell [ "2" -eq "$(VERSION)" ] 2>&- && [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo bat_printk.o)
+batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o gateway_common.o gateway_client.o unicast.o $(shell [ "2" -eq "$(VERSION)" ] 2>&- && [ "6" -eq "$(PATCHLEVEL)" ] 2>&- && [ "$(SUBLEVEL)" -le "28" ] 2>&- && echo bat_printk.o)
Deleted: trunk/batman-adv/fragmentation.c
===================================================================
--- trunk/batman-adv/fragmentation.c 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/fragmentation.c 2010-07-25 02:34:38 UTC (rev 1749)
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2010 B.A.T.M.A.N. contributors:
- *
- * Andreas Langer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-#include "main.h"
-#include "fragmentation.h"
-
-
-struct sk_buff *merge_frag_packet(struct list_head *head,
- struct frag_packet_list_entry *tfp,
- struct sk_buff *skb)
-{
- struct unicast_frag_packet *up =
- (struct unicast_frag_packet *) skb->data;
- struct sk_buff *tmp_skb;
-
- /* set skb to the first part and tmp_skb to the second part */
- if (up->flags & UNI_FRAG_HEAD) {
- tmp_skb = tfp->skb;
- } else {
- tmp_skb = skb;
- skb = tfp->skb;
- }
-
- skb_pull(tmp_skb, sizeof(struct unicast_frag_packet));
- if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) {
- /* free buffered skb, skb will be freed later */
- kfree_skb(tfp->skb);
- return NULL;
- }
-
- /* move free entry to end */
- tfp->skb = NULL;
- tfp->seqno = 0;
- list_move_tail(&tfp->list, head);
-
- memcpy(skb_put(skb, tmp_skb->len), tmp_skb->data, tmp_skb->len);
- kfree_skb(tmp_skb);
- return skb;
-}
-
-void create_frag_entry(struct list_head *head, struct sk_buff *skb)
-{
- struct frag_packet_list_entry *tfp;
- struct unicast_frag_packet *up =
- (struct unicast_frag_packet *) skb->data;
-
- /* free and oldest packets stand at the end */
- tfp = list_entry((head)->prev, typeof(*tfp), list);
- kfree_skb(tfp->skb);
-
- tfp->seqno = ntohs(up->seqno);
- tfp->skb = skb;
- list_move(&tfp->list, head);
- return;
-}
-
-void create_frag_buffer(struct list_head *head)
-{
- int i;
- struct frag_packet_list_entry *tfp;
-
- for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
- tfp = kmalloc(sizeof(struct frag_packet_list_entry),
- GFP_ATOMIC);
- tfp->skb = NULL;
- tfp->seqno = 0;
- INIT_LIST_HEAD(&tfp->list);
- list_add(&tfp->list, head);
- }
-
- return;
-}
-
-struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
- struct unicast_frag_packet *up)
-{
- struct frag_packet_list_entry *tfp;
- struct unicast_frag_packet *tmp_up = NULL;
- uint16_t search_seqno;
-
- if (up->flags & UNI_FRAG_HEAD)
- search_seqno = ntohs(up->seqno)+1;
- else
- search_seqno = ntohs(up->seqno)-1;
-
- list_for_each_entry(tfp, head, list) {
-
- if (!tfp->skb)
- continue;
-
- if (tfp->seqno == ntohs(up->seqno))
- goto mov_tail;
-
- tmp_up = (struct unicast_frag_packet *) tfp->skb->data;
-
- if (tfp->seqno == search_seqno) {
-
- if ((tmp_up->flags & UNI_FRAG_HEAD) !=
- (up->flags & UNI_FRAG_HEAD))
- return tfp;
- else
- goto mov_tail;
- }
- }
- return NULL;
-
-mov_tail:
- list_move_tail(&tfp->list, head);
- return NULL;
-}
-
-void frag_list_free(struct list_head *head)
-{
- struct frag_packet_list_entry *pf, *tmp_pf;
-
- if (!list_empty(head)) {
-
- list_for_each_entry_safe(pf, tmp_pf, head, list) {
- kfree_skb(pf->skb);
- list_del(&pf->list);
- kfree(pf);
- }
- }
- return;
-}
Deleted: trunk/batman-adv/fragmentation.h
===================================================================
--- trunk/batman-adv/fragmentation.h 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/fragmentation.h 2010-07-25 02:34:38 UTC (rev 1749)
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 B.A.T.M.A.N. contributors:
- *
- * Andreas Langer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */
-#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
-
-struct sk_buff *merge_frag_packet(struct list_head *head,
- struct frag_packet_list_entry *tfp,
- struct sk_buff *skb);
-
-void create_frag_entry(struct list_head *head, struct sk_buff *skb);
-void create_frag_buffer(struct list_head *head);
-struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
- struct unicast_frag_packet *up);
-void frag_list_free(struct list_head *head);
Modified: trunk/batman-adv/originator.c
===================================================================
--- trunk/batman-adv/originator.c 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/originator.c 2010-07-25 02:34:38 UTC (rev 1749)
@@ -29,7 +29,7 @@
#include "compat.h"
#include "gateway_client.h"
#include "hard-interface.h"
-#include "fragmentation.h"
+#include "unicast.h"
static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
Modified: trunk/batman-adv/routing.c
===================================================================
--- trunk/batman-adv/routing.c 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/routing.c 2010-07-25 02:34:38 UTC (rev 1749)
@@ -34,7 +34,7 @@
#include "aggregation.h"
#include "compat.h"
#include "gateway_client.h"
-#include "fragmentation.h"
+#include "unicast.h"
static DECLARE_WAIT_QUEUE_HEAD(thread_wait);
Modified: trunk/batman-adv/soft-interface.c
===================================================================
--- trunk/batman-adv/soft-interface.c 2010-07-25 00:16:06 UTC (rev 1748)
+++ trunk/batman-adv/soft-interface.c 2010-07-25 02:34:38 UTC (rev 1749)
@@ -22,17 +22,14 @@
#include "main.h"
#include "soft-interface.h"
#include "hard-interface.h"
-#include "routing.h"
-#include "send.h"
#include "translation-table.h"
-#include "types.h"
-#include "hash.h"
-#include <linux/slab.h>
#include "gateway_client.h"
+#include "send.h"
+#include <linux/slab.h>
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include "compat.h"
-#include "fragmentation.h"
+#include "unicast.h"
static uint32_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid
* broadcast storms */
@@ -130,28 +127,15 @@
int interface_tx(struct sk_buff *skb, struct net_device *dev)
{
- struct unicast_packet *unicast_packet;
- struct unicast_frag_packet *ucast_frag1, *ucast_frag2;
- struct bcast_packet *bcast_packet;
- struct orig_node *orig_node;
- struct neigh_node *router;
struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
- struct bat_priv *priv = netdev_priv(dev);
- struct batman_if *batman_if;
- struct bat_priv *bat_priv;
- struct sk_buff *frag_skb;
- uint8_t dstaddr[6];
- int data_len = skb->len;
- unsigned long flags;
- int hdr_len;
+ struct bat_priv *bat_priv = netdev_priv(dev);
+ struct bcast_packet *bcast_packet;
+ int data_len = skb->len, ret;
bool bcast_dst = false, do_bcast = true;
if (atomic_read(&module_state) != MODULE_ACTIVE)
goto dropped;
- /* FIXME: each batman_if will be attached to a softif */
- bat_priv = netdev_priv(soft_device);
-
dev->trans_start = jiffies;
/* TODO: check this for locks */
hna_local_add(ethhdr->h_source);
@@ -191,109 +175,19 @@
/* unicast packet */
} else {
- spin_lock_irqsave(&orig_hash_lock, flags);
-
- /* get routing information */
- if (bcast_dst)
- orig_node = (struct orig_node *)gw_get_selected();
- else
- orig_node = ((struct orig_node *)hash_find(orig_hash,
- ethhdr->h_dest));
-
- /* check for hna host */
- if (!orig_node)
- orig_node = transtable_search(ethhdr->h_dest);
-
- router = find_router(orig_node, NULL);
-
- if (!router)
- goto unlock;
-
- /* don't lock while sending the packets ... we therefore
- * copy the required data before sending */
-
- batman_if = router->if_incoming;
- memcpy(dstaddr, router->addr, ETH_ALEN);
-
- spin_unlock_irqrestore(&orig_hash_lock, flags);
-
- if (batman_if->if_status != IF_ACTIVE)
- goto dropped;
-
- if (atomic_read(&bat_priv->frag_enabled) &&
- 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) +
- hdr_len);
- skb_split(skb, frag_skb, data_len / 2);
-
- if (my_skb_push(frag_skb, hdr_len) < 0 ||
- my_skb_push(skb, hdr_len) < 0) {
-
- kfree_skb(frag_skb);
- goto dropped;
- }
-
- ucast_frag1 = (struct unicast_frag_packet *)skb->data;
- ucast_frag2 =
- (struct unicast_frag_packet *)frag_skb->data;
-
- ucast_frag1->version = COMPAT_VERSION;
- ucast_frag1->packet_type = BAT_UNICAST_FRAG;
- ucast_frag1->ttl = TTL;
- memcpy(ucast_frag1->orig,
- bat_priv->primary_if->net_dev->dev_addr,
- ETH_ALEN);
- memcpy(ucast_frag1->dest, orig_node->orig, ETH_ALEN);
-
- memcpy(ucast_frag2, ucast_frag1,
- sizeof(struct unicast_frag_packet));
-
- ucast_frag1->flags |= UNI_FRAG_HEAD;
- ucast_frag2->flags &= ~UNI_FRAG_HEAD;
-
- ucast_frag1->seqno = htons((uint16_t)atomic_inc_return(
- &batman_if->frag_seqno));
-
- ucast_frag2->seqno = htons((uint16_t)atomic_inc_return(
- &batman_if->frag_seqno));
-
- send_skb_packet(skb, batman_if, dstaddr);
- send_skb_packet(frag_skb, batman_if, dstaddr);
-
- } else {
-
- if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
- goto dropped;
-
- unicast_packet = (struct unicast_packet *)skb->data;
-
- unicast_packet->version = COMPAT_VERSION;
- /* batman packet type: unicast */
- unicast_packet->packet_type = BAT_UNICAST;
- /* set unicast ttl */
- unicast_packet->ttl = TTL;
- /* copy the destination for faster routing */
- memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
-
- send_skb_packet(skb, batman_if, dstaddr);
+ ret = unicast_send_skb(skb, bat_priv);
+ if (ret != 0) {
+ bat_priv->stats.tx_dropped++;
+ goto end;
}
}
- priv->stats.tx_packets++;
- priv->stats.tx_bytes += data_len;
+ bat_priv->stats.tx_packets++;
+ bat_priv->stats.tx_bytes += data_len;
goto end;
-unlock:
- spin_unlock_irqrestore(&orig_hash_lock, flags);
dropped:
- priv->stats.tx_dropped++;
+ bat_priv->stats.tx_dropped++;
kfree_skb(skb);
end:
return NETDEV_TX_OK;
Added: trunk/batman-adv/unicast.c
===================================================================
--- trunk/batman-adv/unicast.c (rev 0)
+++ trunk/batman-adv/unicast.c 2010-07-25 02:34:38 UTC (rev 1749)
@@ -0,0 +1,269 @@
+/*
+ * Copyright (C) 2010 B.A.T.M.A.N. contributors:
+ *
+ * Andreas Langer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#include "main.h"
+#include "unicast.h"
+#include "send.h"
+#include "soft-interface.h"
+#include "gateway_client.h"
+#include "hash.h"
+#include "translation-table.h"
+#include "routing.h"
+#include "hard-interface.h"
+
+
+struct sk_buff *merge_frag_packet(struct list_head *head,
+ struct frag_packet_list_entry *tfp,
+ struct sk_buff *skb)
+{
+ struct unicast_frag_packet *up =
+ (struct unicast_frag_packet *) skb->data;
+ struct sk_buff *tmp_skb;
+
+ /* set skb to the first part and tmp_skb to the second part */
+ if (up->flags & UNI_FRAG_HEAD) {
+ tmp_skb = tfp->skb;
+ } else {
+ tmp_skb = skb;
+ skb = tfp->skb;
+ }
+
+ skb_pull(tmp_skb, sizeof(struct unicast_frag_packet));
+ if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) {
+ /* free buffered skb, skb will be freed later */
+ kfree_skb(tfp->skb);
+ return NULL;
+ }
+
+ /* move free entry to end */
+ tfp->skb = NULL;
+ tfp->seqno = 0;
+ list_move_tail(&tfp->list, head);
+
+ memcpy(skb_put(skb, tmp_skb->len), tmp_skb->data, tmp_skb->len);
+ kfree_skb(tmp_skb);
+ return skb;
+}
+
+void create_frag_entry(struct list_head *head, struct sk_buff *skb)
+{
+ struct frag_packet_list_entry *tfp;
+ struct unicast_frag_packet *up =
+ (struct unicast_frag_packet *) skb->data;
+
+ /* free and oldest packets stand at the end */
+ tfp = list_entry((head)->prev, typeof(*tfp), list);
+ kfree_skb(tfp->skb);
+
+ tfp->seqno = ntohs(up->seqno);
+ tfp->skb = skb;
+ list_move(&tfp->list, head);
+ return;
+}
+
+void create_frag_buffer(struct list_head *head)
+{
+ int i;
+ struct frag_packet_list_entry *tfp;
+
+ for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
+ tfp = kmalloc(sizeof(struct frag_packet_list_entry),
+ GFP_ATOMIC);
+ tfp->skb = NULL;
+ tfp->seqno = 0;
+ INIT_LIST_HEAD(&tfp->list);
+ list_add(&tfp->list, head);
+ }
+
+ return;
+}
+
+struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
+ struct unicast_frag_packet *up)
+{
+ struct frag_packet_list_entry *tfp;
+ struct unicast_frag_packet *tmp_up = NULL;
+ uint16_t search_seqno;
+
+ if (up->flags & UNI_FRAG_HEAD)
+ search_seqno = ntohs(up->seqno)+1;
+ else
+ search_seqno = ntohs(up->seqno)-1;
+
+ list_for_each_entry(tfp, head, list) {
+
+ if (!tfp->skb)
+ continue;
+
+ if (tfp->seqno == ntohs(up->seqno))
+ goto mov_tail;
+
+ tmp_up = (struct unicast_frag_packet *) tfp->skb->data;
+
+ if (tfp->seqno == search_seqno) {
+
+ if ((tmp_up->flags & UNI_FRAG_HEAD) !=
+ (up->flags & UNI_FRAG_HEAD))
+ return tfp;
+ else
+ goto mov_tail;
+ }
+ }
+ return NULL;
+
+mov_tail:
+ list_move_tail(&tfp->list, head);
+ return NULL;
+}
+
+void frag_list_free(struct list_head *head)
+{
+ struct frag_packet_list_entry *pf, *tmp_pf;
+
+ if (!list_empty(head)) {
+
+ list_for_each_entry_safe(pf, tmp_pf, head, list) {
+ kfree_skb(pf->skb);
+ list_del(&pf->list);
+ kfree(pf);
+ }
+ }
+ return;
+}
+
+int unicast_send_frag_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
+ struct batman_if *batman_if, uint8_t dstaddr[],
+ struct orig_node *orig_node)
+{
+ struct unicast_frag_packet *ucast_frag1, *ucast_frag2;
+ int hdr_len = sizeof(struct unicast_frag_packet);
+ struct sk_buff *frag_skb;
+ int data_len = skb->len;
+
+ if (!bat_priv->primary_if)
+ goto dropped;
+
+ frag_skb = dev_alloc_skb(data_len - (data_len / 2) + hdr_len);
+ skb_split(skb, frag_skb, data_len / 2);
+
+ if (my_skb_push(frag_skb, hdr_len) < 0 ||
+ my_skb_push(skb, hdr_len) < 0)
+ goto drop_frag;
+
+ ucast_frag1 = (struct unicast_frag_packet *)skb->data;
+ ucast_frag2 = (struct unicast_frag_packet *)frag_skb->data;
+
+ ucast_frag1->version = COMPAT_VERSION;
+ ucast_frag1->packet_type = BAT_UNICAST_FRAG;
+ ucast_frag1->ttl = TTL;
+ memcpy(ucast_frag1->orig,
+ bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
+ memcpy(ucast_frag1->dest, orig_node->orig, ETH_ALEN);
+
+ memcpy(ucast_frag2, ucast_frag1, sizeof(struct unicast_frag_packet));
+
+ ucast_frag1->flags |= UNI_FRAG_HEAD;
+ ucast_frag2->flags &= ~UNI_FRAG_HEAD;
+
+ ucast_frag1->seqno = htons((uint16_t)atomic_inc_return(
+ &batman_if->frag_seqno));
+
+ ucast_frag2->seqno = htons((uint16_t)atomic_inc_return(
+ &batman_if->frag_seqno));
+
+ send_skb_packet(skb, batman_if, dstaddr);
+ send_skb_packet(frag_skb, batman_if, dstaddr);
+ return 0;
+
+drop_frag:
+ kfree_skb(frag_skb);
+dropped:
+ kfree_skb(skb);
+ return 1;
+}
+
+int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
+{
+ struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
+ struct unicast_packet *unicast_packet;
+ struct orig_node *orig_node;
+ struct batman_if *batman_if;
+ struct neigh_node *router;
+ int data_len = skb->len;
+ uint8_t dstaddr[6];
+ unsigned long flags;
+
+ spin_lock_irqsave(&orig_hash_lock, flags);
+
+ /* get routing information */
+ if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest))
+ orig_node = (struct orig_node *)gw_get_selected();
+ else
+ orig_node = ((struct orig_node *)hash_find(orig_hash,
+ ethhdr->h_dest));
+
+ /* check for hna host */
+ if (!orig_node)
+ orig_node = transtable_search(ethhdr->h_dest);
+
+ router = find_router(orig_node, NULL);
+
+ if (!router)
+ goto unlock;
+
+ /* don't lock while sending the packets ... we therefore
+ * copy the required data before sending */
+
+ batman_if = router->if_incoming;
+ memcpy(dstaddr, router->addr, ETH_ALEN);
+
+ spin_unlock_irqrestore(&orig_hash_lock, flags);
+
+ if (batman_if->if_status != IF_ACTIVE)
+ goto dropped;
+
+ if (atomic_read(&bat_priv->frag_enabled) &&
+ data_len + sizeof(struct unicast_packet) > batman_if->net_dev->mtu)
+ return unicast_send_frag_skb(skb, bat_priv, batman_if,
+ dstaddr, orig_node);
+
+ if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
+ goto dropped;
+
+ unicast_packet = (struct unicast_packet *)skb->data;
+
+ unicast_packet->version = COMPAT_VERSION;
+ /* batman packet type: unicast */
+ unicast_packet->packet_type = BAT_UNICAST;
+ /* set unicast ttl */
+ unicast_packet->ttl = TTL;
+ /* copy the destination for faster routing */
+ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
+
+ send_skb_packet(skb, batman_if, dstaddr);
+ return 0;
+
+unlock:
+ spin_unlock_irqrestore(&orig_hash_lock, flags);
+dropped:
+ kfree_skb(skb);
+ return 1;
+}
Copied: trunk/batman-adv/unicast.h (from rev 1748, trunk/batman-adv/fragmentation.h)
===================================================================
--- trunk/batman-adv/unicast.h (rev 0)
+++ trunk/batman-adv/unicast.h 2010-07-25 02:34:38 UTC (rev 1749)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 B.A.T.M.A.N. contributors:
+ *
+ * Andreas Langer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */
+#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
+
+struct sk_buff *merge_frag_packet(struct list_head *head,
+ struct frag_packet_list_entry *tfp,
+ struct sk_buff *skb);
+
+void create_frag_entry(struct list_head *head, struct sk_buff *skb);
+void create_frag_buffer(struct list_head *head);
+struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
+ struct unicast_frag_packet *up);
+void frag_list_free(struct list_head *head);
+int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
11 years, 11 months
r1748 - trunk/batman-adv
by postmaster@open-mesh.org
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,
11 years, 11 months
r1747 - trunk/batman-adv
by postmaster@open-mesh.org
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;
11 years, 11 months
r1746 - trunk/batman-adv
by postmaster@open-mesh.org
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 {
11 years, 11 months
r1745 - trunk/batman-adv
by postmaster@open-mesh.org
Author: marek
Date: 2010-07-24 19:52:55 +0200 (Sat, 24 Jul 2010)
New Revision: 1745
Modified:
trunk/batman-adv/icmp_socket.c
Log:
batman-adv: Directly prepare icmp packets in socket buffer
It is unnecessary to generate an icmp packet in an extra memory region
and than copying it to a new allocated skb.
This also resolved the problem that we do inform the user that we
couldn't send the packet because we couldn't allocate the socket buffer.
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman-adv/icmp_socket.c
===================================================================
--- trunk/batman-adv/icmp_socket.c 2010-07-24 17:52:53 UTC (rev 1744)
+++ trunk/batman-adv/icmp_socket.c 2010-07-24 17:52:55 UTC (rev 1745)
@@ -156,7 +156,8 @@
/* 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 icmp_packet_rr icmp_packet;
+ struct sk_buff *skb;
+ struct icmp_packet_rr *icmp_packet;
struct orig_node *orig_node;
struct batman_if *batman_if;
size_t packet_len = sizeof(struct icmp_packet);
@@ -173,40 +174,53 @@
if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
- if (!access_ok(VERIFY_READ, buff, packet_len))
- return -EFAULT;
+ skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr));
+ if (!skb)
+ return -ENOMEM;
- if (__copy_from_user(&icmp_packet, buff, packet_len))
- return -EFAULT;
+ skb_reserve(skb, sizeof(struct ethhdr));
+ icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
- if (icmp_packet.packet_type != BAT_ICMP) {
+ if (!access_ok(VERIFY_READ, buff, packet_len)) {
+ len = -EFAULT;
+ goto free_skb;
+ }
+
+ if (__copy_from_user(icmp_packet, buff, packet_len)) {
+ len = -EFAULT;
+ goto free_skb;
+ }
+
+ if (icmp_packet->packet_type != BAT_ICMP) {
bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)\n");
- return -EINVAL;
+ len = -EINVAL;
+ goto free_skb;
}
- if (icmp_packet.msg_type != ECHO_REQUEST) {
+ if (icmp_packet->msg_type != ECHO_REQUEST) {
bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: "
"got bogus message type (expected: ECHO_REQUEST)\n");
- return -EINVAL;
+ len = -EINVAL;
+ goto free_skb;
}
- icmp_packet.uid = socket_client->index;
+ icmp_packet->uid = socket_client->index;
- if (icmp_packet.version != COMPAT_VERSION) {
- icmp_packet.msg_type = PARAMETER_PROBLEM;
- icmp_packet.ttl = COMPAT_VERSION;
- bat_socket_add_packet(socket_client, &icmp_packet, packet_len);
- goto out;
+ if (icmp_packet->version != COMPAT_VERSION) {
+ icmp_packet->msg_type = PARAMETER_PROBLEM;
+ icmp_packet->ttl = COMPAT_VERSION;
+ bat_socket_add_packet(socket_client, icmp_packet, packet_len);
+ goto free_skb;
}
if (atomic_read(&module_state) != MODULE_ACTIVE)
goto dst_unreach;
spin_lock_irqsave(&orig_hash_lock, flags);
- orig_node = ((struct orig_node *)hash_find(orig_hash, icmp_packet.dst));
+ orig_node = (struct orig_node *)hash_find(orig_hash, icmp_packet->dst);
if (!orig_node)
goto unlock;
@@ -225,21 +239,23 @@
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, 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);
+ memcpy(icmp_packet->rr, batman_if->net_dev->dev_addr, ETH_ALEN);
- send_raw_packet((unsigned char *)&icmp_packet,
- packet_len, batman_if, dstaddr);
+ send_skb_packet(skb, batman_if, dstaddr);
+
goto out;
unlock:
spin_unlock_irqrestore(&orig_hash_lock, flags);
dst_unreach:
- icmp_packet.msg_type = DESTINATION_UNREACHABLE;
- bat_socket_add_packet(socket_client, &icmp_packet, packet_len);
+ icmp_packet->msg_type = DESTINATION_UNREACHABLE;
+ bat_socket_add_packet(socket_client, icmp_packet, packet_len);
+free_skb:
+ kfree_skb(skb);
out:
return len;
}
11 years, 11 months
r1744 - trunk/batman-adv
by postmaster@open-mesh.org
Author: marek
Date: 2010-07-24 19:52:53 +0200 (Sat, 24 Jul 2010)
New Revision: 1744
Modified:
trunk/batman-adv/bat_debugfs.c
trunk/batman-adv/icmp_socket.c
Log:
batman-adv: Remove unnecessary casts of private_data
Signed-off-by: Joe Perches <joe(a)perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)suse.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann(a)gmx.de>
Modified: trunk/batman-adv/bat_debugfs.c
===================================================================
--- trunk/batman-adv/bat_debugfs.c 2010-07-22 15:32:03 UTC (rev 1743)
+++ trunk/batman-adv/bat_debugfs.c 2010-07-24 17:52:53 UTC (rev 1744)
@@ -107,7 +107,7 @@
static ssize_t log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
- struct bat_priv *bat_priv = (struct bat_priv *)file->private_data;
+ struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char c;
@@ -161,7 +161,7 @@
static unsigned int log_poll(struct file *file, poll_table *wait)
{
- struct bat_priv *bat_priv = (struct bat_priv *)file->private_data;
+ struct bat_priv *bat_priv = file->private_data;
struct debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait);
Modified: trunk/batman-adv/icmp_socket.c
===================================================================
--- trunk/batman-adv/icmp_socket.c 2010-07-22 15:32:03 UTC (rev 1743)
+++ trunk/batman-adv/icmp_socket.c 2010-07-24 17:52:53 UTC (rev 1744)
@@ -80,8 +80,7 @@
static int bat_socket_release(struct inode *inode, struct file *file)
{
- struct socket_client *socket_client =
- (struct socket_client *)file->private_data;
+ struct socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet;
struct list_head *list_pos, *list_pos_tmp;
unsigned long flags;
@@ -109,8 +108,7 @@
static ssize_t bat_socket_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
- struct socket_client *socket_client =
- (struct socket_client *)file->private_data;
+ struct socket_client *socket_client = file->private_data;
struct socket_packet *socket_packet;
size_t packet_len;
int error;
@@ -157,8 +155,7 @@
{
/* 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 =
- (struct socket_client *)file->private_data;
+ struct socket_client *socket_client = file->private_data;
struct icmp_packet_rr icmp_packet;
struct orig_node *orig_node;
struct batman_if *batman_if;
@@ -249,8 +246,7 @@
static unsigned int bat_socket_poll(struct file *file, poll_table *wait)
{
- struct socket_client *socket_client =
- (struct socket_client *)file->private_data;
+ struct socket_client *socket_client = file->private_data;
poll_wait(file, &socket_client->queue_wait, wait);
11 years, 11 months
[git] linux integration annotated tag, v2.6.35-rc6, created. v2.6.35-rc6
by postmaster@open-mesh.net
The annotated tag, v2.6.35-rc6 has been created
at 37a3bd34ba0892f0f1c1a0a03b06d61ed3c554c1 (tag)
tagging b37fa16e78d6f9790462b3181602a26b5af36260 (commit)
replaces v2.6.35-rc5
tagged by Linus Torvalds
on Thu Jul 22 12:13:49 2010 -0700
- Shortlog ------------------------------------------------------------
Linux 2.6.35-rc6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkxImHQACgkQF3YsRnbiHLtPQgCdE+ewjOaNkE/Vqv4f9iKoVepp
aWEAoK5vdfUS8q1MtTMx+feIzXmxoUYr
=4Nan
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
linux integration
11 years, 11 months
r1743 - trunk/batctl
by postmaster@open-mesh.org
Author: marek
Date: 2010-07-22 17:32:03 +0200 (Thu, 22 Jul 2010)
New Revision: 1743
Modified:
trunk/batctl/tcpdump.c
trunk/batctl/tcpdump.h
Log:
batctl: tcpdump - add support for fragmented packets
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
Modified: trunk/batctl/tcpdump.c
===================================================================
--- trunk/batctl/tcpdump.c 2010-07-22 15:32:02 UTC (rev 1742)
+++ trunk/batctl/tcpdump.c 2010-07-22 15:32:03 UTC (rev 1743)
@@ -51,7 +51,7 @@
}
static unsigned short dump_level = DUMP_TYPE_BATOGM | DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST |
- DUMP_TYPE_BATBCAST | DUMP_TYPE_BATVIS | DUMP_TYPE_NONBAT;
+ DUMP_TYPE_BATBCAST | DUMP_TYPE_BATVIS | DUMP_TYPE_BATFRAG | DUMP_TYPE_NONBAT;
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed);
@@ -67,6 +67,7 @@
printf(" \t\t%d - batman unicast packets\n", DUMP_TYPE_BATUCAST);
printf(" \t\t%d - batman broadcast packets\n", DUMP_TYPE_BATBCAST);
printf(" \t\t%d - batman vis packets\n", DUMP_TYPE_BATVIS);
+ printf(" \t\t%d - batman fragmented packets\n", DUMP_TYPE_BATFRAG);
printf(" \t\t%d - non batman packets\n", DUMP_TYPE_NONBAT);
printf(" \t\t%d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT);
}
@@ -261,7 +262,7 @@
printf("BAT %s: ",
get_name_by_macaddr((struct ether_addr *)batman_packet->orig, read_opt));
- printf("OGM via neigh %s, seqno %u, tq %3d, ttl %2d, v %d, flags [%c%c%c], length %zu\n",
+ printf("OGM via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c], length %zu\n",
get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt),
ntohl(batman_packet->seqno), batman_packet->tq,
batman_packet->ttl, batman_packet->version,
@@ -360,7 +361,7 @@
printf("BAT %s: ",
get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt));
- printf("BCAST, orig %s, seqno %u, ",
+ printf("BCAST, orig %s, seq %u, ",
get_name_by_macaddr((struct ether_addr *)bcast_packet->orig, read_opt),
ntohl(bcast_packet->seqno));
@@ -369,6 +370,36 @@
read_opt, time_printed);
}
+static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
+{
+ struct ether_header *ether_header;
+ struct unicast_frag_packet *unicast_frag_packet;
+
+ LEN_CHECK((size_t)buff_len - ETH_HLEN, sizeof(struct unicast_frag_packet), "BAT FRAG");
+ LEN_CHECK((size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), ETH_HLEN, "BAT FRAG (unpacked)");
+
+ ether_header = (struct ether_header *)packet_buff;
+ unicast_frag_packet = (struct unicast_frag_packet *)(packet_buff + ETH_HLEN);
+
+ if (!time_printed)
+ time_printed = print_time();
+
+ printf("BAT %s > ",
+ get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt));
+
+ printf("%s: FRAG, seq %hu, ttl %hu, flags [%c], ",
+ get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->dest, read_opt),
+ ntohs(unicast_frag_packet->seqno), unicast_frag_packet->ttl,
+ (unicast_frag_packet->flags & UNI_FRAG_HEAD ? 'H' : '.'));
+
+ if (unicast_frag_packet->flags & UNI_FRAG_HEAD)
+ parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct unicast_frag_packet),
+ buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet),
+ read_opt, time_printed);
+ else
+ printf("length %zu\n", (size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet));
+}
+
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed)
{
struct batman_packet *batman_packet;
@@ -379,20 +410,18 @@
switch (ntohs(eth_hdr->ether_type)) {
case ETH_P_ARP:
if (dump_level & DUMP_TYPE_NONBAT)
- dump_arp(packet_buff + sizeof(struct ether_header),
- buff_len - sizeof(struct ether_header), time_printed);
+ dump_arp(packet_buff + ETH_HLEN, buff_len - ETH_HLEN, time_printed);
break;
case ETH_P_IP:
if (dump_level & DUMP_TYPE_NONBAT)
- dump_ip(packet_buff + sizeof(struct ether_header),
- buff_len - sizeof(struct ether_header), time_printed);
+ dump_ip(packet_buff + ETH_HLEN, buff_len - ETH_HLEN, time_printed);
break;
case ETH_P_8021Q:
if (dump_level & DUMP_TYPE_NONBAT)
dump_vlan(packet_buff, buff_len, read_opt, time_printed);
break;
case ETH_P_BATMAN:
- batman_packet = (struct batman_packet *)(packet_buff + sizeof(struct ether_header));
+ batman_packet = (struct batman_packet *)(packet_buff + ETH_HLEN);
switch (batman_packet->packet_type) {
case BAT_PACKET:
@@ -415,6 +444,10 @@
if (dump_level & DUMP_TYPE_BATVIS)
printf("Warning - batman vis packet received: function not implemented yet\n");
break;
+ case BAT_UNICAST_FRAG:
+ if (dump_level & DUMP_TYPE_BATFRAG)
+ dump_batman_frag(packet_buff, buff_len, read_opt, time_printed);
+ break;
default:
printf("Warning - packet contains unknown batman packet type: 0x%02x\n", batman_packet->packet_type);
break;
Modified: trunk/batctl/tcpdump.h
===================================================================
--- trunk/batctl/tcpdump.h 2010-07-22 15:32:02 UTC (rev 1742)
+++ trunk/batctl/tcpdump.h 2010-07-22 15:32:03 UTC (rev 1743)
@@ -28,7 +28,8 @@
#define DUMP_TYPE_BATUCAST 4
#define DUMP_TYPE_BATBCAST 8
#define DUMP_TYPE_BATVIS 16
-#define DUMP_TYPE_NONBAT 32
+#define DUMP_TYPE_BATFRAG 32
+#define DUMP_TYPE_NONBAT 64
struct dump_if {
struct list_head list;
11 years, 11 months