summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAndreas Langer <an.langer@gmx.de>2010-11-22 00:55:50 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-29 11:09:10 -0800
commit225f7b0b950d141819a8d9694141571b349e563d (patch)
treeae77ea04c63496d8f41a11e3c583cb1a1976ab46 /drivers
parent9061109ab18352c73b5dda426043dbb6d5e2dae7 (diff)
Staging: batman-adv: reassemble fragmented skb if mtu allows it
Signed-off-by: Andreas Langer <an.langer@gmx.de> Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/batman-adv/routing.c21
-rw-r--r--drivers/staging/batman-adv/unicast.c8
2 files changed, 28 insertions, 1 deletions
diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c
index 1e101113b6ff..750cec708244 100644
--- a/drivers/staging/batman-adv/routing.c
+++ b/drivers/staging/batman-adv/routing.c
@@ -1128,6 +1128,8 @@ static int route_unicast_packet(struct sk_buff *skb,
unsigned long flags;
struct unicast_packet *unicast_packet;
struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+ int ret;
+ struct sk_buff *new_skb;
unicast_packet = (struct unicast_packet *)skb->data;
@@ -1171,6 +1173,22 @@ static int route_unicast_packet(struct sk_buff *skb,
return frag_send_skb(skb, bat_priv, batman_if,
dstaddr);
+ if (unicast_packet->packet_type == BAT_UNICAST_FRAG &&
+ 2 * skb->len - hdr_size <= batman_if->net_dev->mtu) {
+
+ ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
+
+ if (ret == NET_RX_DROP)
+ return NET_RX_DROP;
+
+ /* packet was buffered for late merge */
+ if (!new_skb)
+ return NET_RX_SUCCESS;
+
+ skb = new_skb;
+ unicast_packet = (struct unicast_packet *) skb->data;
+ }
+
/* decrement ttl */
unicast_packet->ttl--;
@@ -1224,7 +1242,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)
if (!new_skb)
return NET_RX_SUCCESS;
- interface_rx(recv_if->soft_iface, new_skb, hdr_size);
+ interface_rx(recv_if->soft_iface, new_skb,
+ sizeof(struct unicast_packet));
return NET_RX_SUCCESS;
}
diff --git a/drivers/staging/batman-adv/unicast.c b/drivers/staging/batman-adv/unicast.c
index 12afae618ce2..e58e634c2806 100644
--- a/drivers/staging/batman-adv/unicast.c
+++ b/drivers/staging/batman-adv/unicast.c
@@ -36,6 +36,9 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
struct unicast_frag_packet *up =
(struct unicast_frag_packet *)skb->data;
struct sk_buff *tmp_skb;
+ struct unicast_packet *unicast_packet;
+ int hdr_len = sizeof(struct unicast_packet),
+ uni_diff = sizeof(struct unicast_frag_packet) - hdr_len;
/* set skb to the first part and tmp_skb to the second part */
if (up->flags & UNI_FRAG_HEAD) {
@@ -59,6 +62,11 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
memcpy(skb_put(skb, tmp_skb->len), tmp_skb->data, tmp_skb->len);
kfree_skb(tmp_skb);
+
+ memmove(skb->data + uni_diff, skb->data, hdr_len);
+ unicast_packet = (struct unicast_packet *) skb_pull(skb, uni_diff);
+ unicast_packet->packet_type = BAT_UNICAST;
+
return skb;
}