Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 236822
b: refs/heads/master
c: ae361ce
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann committed Jan 31, 2011
1 parent 4ff29de commit 4451b27
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c77d8bb8aeb4ec6804b6c32061109ba2ea6988d
refs/heads/master: ae361ce19fa135035c6b83ac1f07090b72fd4b8f
1 change: 1 addition & 0 deletions trunk/net/batman-adv/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

/* fragmentation defines */
#define UNI_FRAG_HEAD 0x01
#define UNI_FRAG_LARGETAIL 0x02

struct batman_packet {
uint8_t packet_type;
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,
dstaddr);

if (unicast_packet->packet_type == BAT_UNICAST_FRAG &&
2 * skb->len - hdr_size <= batman_if->net_dev->mtu) {
frag_can_reassemble(skb, batman_if->net_dev->mtu)) {

ret = frag_reassemble_skb(skb, bat_priv, &new_skb);

Expand Down
8 changes: 6 additions & 2 deletions trunk/net/batman-adv/unicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
int uc_hdr_len = sizeof(struct unicast_packet);
int ucf_hdr_len = sizeof(struct unicast_frag_packet);
int data_len = skb->len - uc_hdr_len;
int large_tail = 0;

if (!bat_priv->primary_if)
goto dropped;
Expand Down Expand Up @@ -254,8 +255,11 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
memcpy(frag1->orig, bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
memcpy(frag2, frag1, sizeof(struct unicast_frag_packet));

frag1->flags |= UNI_FRAG_HEAD;
frag2->flags &= ~UNI_FRAG_HEAD;
if (data_len & 1)
large_tail = UNI_FRAG_LARGETAIL;

frag1->flags = UNI_FRAG_HEAD | large_tail;
frag2->flags = large_tail;

frag1->seqno = htons((uint16_t)atomic_inc_return(
&batman_if->frag_seqno));
Expand Down
23 changes: 23 additions & 0 deletions trunk/net/batman-adv/unicast.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _NET_BATMAN_ADV_UNICAST_H_
#define _NET_BATMAN_ADV_UNICAST_H_

#include "packet.h"

#define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */
#define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */

Expand All @@ -32,4 +34,25 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
struct batman_if *batman_if, uint8_t dstaddr[]);

static inline int frag_can_reassemble(struct sk_buff *skb, int mtu)
{
struct unicast_frag_packet *unicast_packet;
int uneven_correction = 0;
unsigned int merged_size;

unicast_packet = (struct unicast_frag_packet *)skb->data;

if (unicast_packet->flags & UNI_FRAG_LARGETAIL) {
if (unicast_packet->flags & UNI_FRAG_HEAD)
uneven_correction = 1;
else
uneven_correction = -1;
}

merged_size = (skb->len - sizeof(struct unicast_frag_packet)) * 2;
merged_size += sizeof(struct unicast_packet) + uneven_correction;

return merged_size <= mtu;
}

#endif /* _NET_BATMAN_ADV_UNICAST_H_ */

0 comments on commit 4451b27

Please sign in to comment.