Hi again,
things that changed since the last patch: - add support to fragment packets on every node, if outgoing iface mtu is smaller as the packet - add support to defragment packets on every node, if outgoing iface mtu is >= original size - rename some functions
In this patch every node defragment packets if it can. Do you think it is better to add an option to enable/disable this ?
Sven, any idea why checkpatch (0.31)b do this ?
ERROR: space prohibited after that '-' (ctx:WxW) #10: FILE: batman-adv/routing.c:1146: + uni_diff = sizeof(struct unicast_frag_packet) - hdr_len; ^
regards, Andreas
The unicast_frag_send_skb() function expected 'raw' packets (without any batman-adv header) to fragment them. This needs to be changed, so that this function is able to fragment packets that already traveled inside the mesh but need to be fragmented now.
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/unicast.c | 66 +++++++++++++++++++++++++++---------------------- 1 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/batman-adv/unicast.c b/batman-adv/unicast.c index ee85c7c..750f10e 100644 --- a/batman-adv/unicast.c +++ b/batman-adv/unicast.c @@ -153,55 +153,58 @@ void frag_list_free(struct list_head *head) return; }
-static 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) +int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, + struct batman_if *batman_if, uint8_t dstaddr[]) { - struct unicast_frag_packet *ucast_frag1, *ucast_frag2; - int hdr_len = sizeof(struct unicast_frag_packet); + struct unicast_packet tmp_uc, *unicast_packet; struct sk_buff *frag_skb; + struct unicast_frag_packet *frag1, *frag2; + int uc_hdr_len = sizeof(struct unicast_packet); + int ucf_hdr_len = sizeof(struct unicast_frag_packet); int data_len = skb->len;
if (!bat_priv->primary_if) goto dropped;
- frag_skb = dev_alloc_skb(data_len - (data_len / 2) + hdr_len); + unicast_packet = (struct unicast_packet *) skb->data; + + memcpy(&tmp_uc, unicast_packet, uc_hdr_len); + frag_skb = dev_alloc_skb(data_len - (data_len / 2) + ucf_hdr_len); skb_split(skb, frag_skb, data_len / 2);
- if (my_skb_head_push(frag_skb, hdr_len) < 0 || - my_skb_head_push(skb, hdr_len) < 0) + if (my_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 || + my_skb_head_push(frag_skb, ucf_hdr_len) < 0) goto drop_frag;
- ucast_frag1 = (struct unicast_frag_packet *)skb->data; - ucast_frag2 = (struct unicast_frag_packet *)frag_skb->data; + frag1 = (struct unicast_frag_packet *)skb->data; + 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(frag1, &tmp_uc, sizeof(struct unicast_packet));
- memcpy(ucast_frag2, ucast_frag1, sizeof(struct unicast_frag_packet)); + frag1->ttl--; + frag1->version = COMPAT_VERSION; + frag1->packet_type = BAT_UNICAST_FRAG;
- ucast_frag1->flags |= UNI_FRAG_HEAD; - ucast_frag2->flags &= ~UNI_FRAG_HEAD; + memcpy(frag1->orig, bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN); + memcpy(frag2, frag1, sizeof(struct unicast_frag_packet));
- ucast_frag1->seqno = htons((uint16_t)atomic_inc_return( - &batman_if->frag_seqno)); + frag1->flags |= UNI_FRAG_HEAD; + frag2->flags &= ~UNI_FRAG_HEAD;
- ucast_frag2->seqno = htons((uint16_t)atomic_inc_return( - &batman_if->frag_seqno)); + frag1->seqno = htons((uint16_t)atomic_inc_return( + &batman_if->frag_seqno)); + 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; + return NET_RX_SUCCESS;
drop_frag: kfree_skb(frag_skb); dropped: kfree_skb(skb); - return 1; + return NET_RX_DROP; }
int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) @@ -244,11 +247,6 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) 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_head_push(skb, sizeof(struct unicast_packet)) < 0) goto dropped;
@@ -262,6 +260,14 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) /* copy the destination for faster routing */ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
+ if (atomic_read(&bat_priv->frag_enabled) && + data_len + sizeof(struct unicast_packet) > + batman_if->net_dev->mtu) { + /* send frag skb decreases ttl */ + unicast_packet->ttl++; + return frag_send_skb(skb, bat_priv, batman_if, + dstaddr); + } send_skb_packet(skb, batman_if, dstaddr); return 0;
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 8 ++++---- batman-adv/unicast.c | 12 ++++++------ batman-adv/unicast.h | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index 603a932..a0936ca 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1245,24 +1245,24 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) orig_node->last_frag_packet = jiffies;
if (list_empty(&orig_node->frag_list) && - create_frag_buffer(&orig_node->frag_list)) { + frag_create_buffer(&orig_node->frag_list)) { spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags); return NET_RX_DROP; }
tmp_frag_entry = - search_frag_packet(&orig_node->frag_list, + frag_search_packet(&orig_node->frag_list, unicast_packet);
if (!tmp_frag_entry) { - create_frag_entry(&orig_node->frag_list, skb); + frag_create_entry(&orig_node->frag_list, skb); spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags); return NET_RX_SUCCESS; }
- skb = merge_frag_packet(&orig_node->frag_list, + skb = frag_merge_packet(&orig_node->frag_list, tmp_frag_entry, skb); spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags); if (!skb) diff --git a/batman-adv/unicast.c b/batman-adv/unicast.c index 750f10e..23a9373 100644 --- a/batman-adv/unicast.c +++ b/batman-adv/unicast.c @@ -30,9 +30,9 @@ #include "hard-interface.h"
-struct sk_buff *merge_frag_packet(struct list_head *head, - struct frag_packet_list_entry *tfp, - struct sk_buff *skb) +static struct sk_buff *frag_merge_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; @@ -63,7 +63,7 @@ struct sk_buff *merge_frag_packet(struct list_head *head, return skb; }
-void create_frag_entry(struct list_head *head, struct sk_buff *skb) +void frag_create_entry(struct list_head *head, struct sk_buff *skb) { struct frag_packet_list_entry *tfp; struct unicast_frag_packet *up = @@ -79,7 +79,7 @@ void create_frag_entry(struct list_head *head, struct sk_buff *skb) return; }
-int create_frag_buffer(struct list_head *head) +int frag_create_buffer(struct list_head *head) { int i; struct frag_packet_list_entry *tfp; @@ -100,7 +100,7 @@ int create_frag_buffer(struct list_head *head) return 0; }
-struct frag_packet_list_entry *search_frag_packet(struct list_head *head, +struct frag_packet_list_entry *frag_search_packet(struct list_head *head, struct unicast_frag_packet *up) { struct frag_packet_list_entry *tfp; diff --git a/batman-adv/unicast.h b/batman-adv/unicast.h index 7973697..b50d61b 100644 --- a/batman-adv/unicast.h +++ b/batman-adv/unicast.h @@ -25,13 +25,13 @@ #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 sk_buff *frag_merge_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); -int create_frag_buffer(struct list_head *head); -struct frag_packet_list_entry *search_frag_packet(struct list_head *head, +void frag_create_entry(struct list_head *head, struct sk_buff *skb); +int frag_create_buffer(struct list_head *head); +struct frag_packet_list_entry *frag_search_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);
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 43 +++++------------------------------ batman-adv/unicast.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- batman-adv/unicast.h | 10 +------ 3 files changed, 66 insertions(+), 47 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index a0936ca..c1e32e6 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1218,10 +1218,9 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) { struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct unicast_frag_packet *unicast_packet; - struct orig_node *orig_node; - struct frag_packet_list_entry *tmp_frag_entry; int hdr_size = sizeof(struct unicast_frag_packet); - unsigned long flags; + struct sk_buff *new_skb = NULL; + int ret;
if (check_unicast_packet(skb, hdr_size) < 0) return NET_RX_DROP; @@ -1231,44 +1230,16 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if) /* packet for me */ if (is_my_mac(unicast_packet->dest)) {
- spin_lock_irqsave(&bat_priv->orig_hash_lock, flags); - orig_node = ((struct orig_node *) - hash_find(bat_priv->orig_hash, unicast_packet->orig)); - - if (!orig_node) { - pr_debug("couldn't find orig node for fragmentation\n"); - spin_unlock_irqrestore(&bat_priv->orig_hash_lock, - flags); - return NET_RX_DROP; - } - - orig_node->last_frag_packet = jiffies; + ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
- if (list_empty(&orig_node->frag_list) && - frag_create_buffer(&orig_node->frag_list)) { - spin_unlock_irqrestore(&bat_priv->orig_hash_lock, - flags); + if (ret == NET_RX_DROP) return NET_RX_DROP; - } - - tmp_frag_entry = - frag_search_packet(&orig_node->frag_list, - unicast_packet);
- if (!tmp_frag_entry) { - frag_create_entry(&orig_node->frag_list, skb); - spin_unlock_irqrestore(&bat_priv->orig_hash_lock, - flags); + /* packet was buffered for late merge */ + if (!new_skb) return NET_RX_SUCCESS; - }
- skb = frag_merge_packet(&orig_node->frag_list, - tmp_frag_entry, skb); - spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags); - if (!skb) - return NET_RX_DROP; - - interface_rx(recv_if->soft_iface, skb, hdr_size); + interface_rx(recv_if->soft_iface, new_skb, hdr_size); return NET_RX_SUCCESS; }
diff --git a/batman-adv/unicast.c b/batman-adv/unicast.c index 23a9373..25284d8 100644 --- a/batman-adv/unicast.c +++ b/batman-adv/unicast.c @@ -63,7 +63,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, return skb; }
-void frag_create_entry(struct list_head *head, struct sk_buff *skb) +static void frag_create_entry(struct list_head *head, struct sk_buff *skb) { struct frag_packet_list_entry *tfp; struct unicast_frag_packet *up = @@ -79,7 +79,7 @@ void frag_create_entry(struct list_head *head, struct sk_buff *skb) return; }
-int frag_create_buffer(struct list_head *head) +static int frag_create_buffer(struct list_head *head) { int i; struct frag_packet_list_entry *tfp; @@ -100,7 +100,7 @@ int frag_create_buffer(struct list_head *head) return 0; }
-struct frag_packet_list_entry *frag_search_packet(struct list_head *head, +static struct frag_packet_list_entry *frag_search_packet(struct list_head *head, struct unicast_frag_packet *up) { struct frag_packet_list_entry *tfp; @@ -153,6 +153,60 @@ void frag_list_free(struct list_head *head) return; }
+/* frag_reassemble_skb(): + * returns NET_RX_DROP if the operation failed - skb is left intact + * returns NET_RX_SUCCESS if the fragment was buffered (skb_new will be NULL) + * or the skb could be reassembled (skb_new will point to the new packet and + * skb was freed) + */ +int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, + struct sk_buff **new_skb) +{ + unsigned long flags; + struct orig_node *orig_node; + struct frag_packet_list_entry *tmp_frag_entry; + int ret = NET_RX_DROP; + struct unicast_frag_packet *unicast_packet = + (struct unicast_frag_packet *)skb->data; + + *new_skb = NULL; + spin_lock_irqsave(&bat_priv->orig_hash_lock, flags); + orig_node = ((struct orig_node *) + hash_find(bat_priv->orig_hash, unicast_packet->orig)); + + if (!orig_node) { + pr_debug("couldn't find originator in orig_hash\n"); + goto out; + } + + orig_node->last_frag_packet = jiffies; + + if (list_empty(&orig_node->frag_list) && + frag_create_buffer(&orig_node->frag_list)) { + pr_debug("couldn't create frag buffer\n"); + goto out; + } + + tmp_frag_entry = frag_search_packet(&orig_node->frag_list, + unicast_packet); + + if (!tmp_frag_entry) { + frag_create_entry(&orig_node->frag_list, skb); + ret = NET_RX_SUCCESS; + goto out; + } + + *new_skb = frag_merge_packet(&orig_node->frag_list, tmp_frag_entry, + skb); + /* if not, merge failed */ + if (*new_skb) + ret = NET_RX_SUCCESS; +out: + spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags); + + return ret; +} + int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, struct batman_if *batman_if, uint8_t dstaddr[]) { diff --git a/batman-adv/unicast.h b/batman-adv/unicast.h index b50d61b..5908b01 100644 --- a/batman-adv/unicast.h +++ b/batman-adv/unicast.h @@ -25,14 +25,8 @@ #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 *frag_merge_packet(struct list_head *head, - struct frag_packet_list_entry *tfp, - struct sk_buff *skb); - -void frag_create_entry(struct list_head *head, struct sk_buff *skb); -int frag_create_buffer(struct list_head *head); -struct frag_packet_list_entry *frag_search_packet(struct list_head *head, - struct unicast_frag_packet *up); +int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, + struct sk_buff **new_skb); void frag_list_free(struct list_head *head); int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv);
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index c1e32e6..5d17597 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1145,12 +1145,6 @@ static int route_unicast_packet(struct sk_buff *skb,
unicast_packet = (struct unicast_packet *)skb->data;
- /* packet for me */ - if (is_my_mac(unicast_packet->dest)) { - interface_rx(recv_if->soft_iface, skb, hdr_size); - return NET_RX_SUCCESS; - } - /* TTL exceeded */ if (unicast_packet->ttl < 2) { pr_debug("Warning - can't forward unicast packet from %pM to " @@ -1184,7 +1178,6 @@ static int route_unicast_packet(struct sk_buff *skb, return NET_RX_DROP;
unicast_packet = (struct unicast_packet *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb);
/* decrement ttl */ unicast_packet->ttl--;
If a packet is too big to be forwarded over an interface it will be fragmented on-the-fly (if fragmentation is enabled).
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 6 ++++++ batman-adv/unicast.h | 2 ++ 2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index 5d17597..c763121 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1179,6 +1179,12 @@ static int route_unicast_packet(struct sk_buff *skb,
unicast_packet = (struct unicast_packet *)skb->data;
+ if (unicast_packet->packet_type == BAT_UNICAST && + atomic_read(&bat_priv->frag_enabled) && + skb->len > batman_if->net_dev->mtu) + return frag_send_skb(skb, bat_priv, batman_if, + dstaddr); + /* decrement ttl */ unicast_packet->ttl--;
diff --git a/batman-adv/unicast.h b/batman-adv/unicast.h index 5908b01..e32b786 100644 --- a/batman-adv/unicast.h +++ b/batman-adv/unicast.h @@ -29,5 +29,7 @@ int frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, struct sk_buff **new_skb); void frag_list_free(struct list_head *head); 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[]);
#endif /* _NET_BATMAN_ADV_UNICAST_H_ */
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 21 ++++++++++++++++++++- batman-adv/unicast.c | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index c763121..236ce96 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1142,6 +1142,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;
@@ -1185,6 +1187,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--;
@@ -1238,7 +1256,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/batman-adv/unicast.c b/batman-adv/unicast.c index 25284d8..4a49a4d 100644 --- a/batman-adv/unicast.c +++ b/batman-adv/unicast.c @@ -37,6 +37,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) { @@ -60,6 +63,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; }
Signed-off-by: Andreas Langer <an.langer at gmx.de> --- batman-adv/routing.c | 21 ++++++++++++++++++++- batman-adv/unicast.c | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/batman-adv/routing.c b/batman-adv/routing.c index c763121..236ce96 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -1142,6 +1142,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;
@@ -1185,6 +1187,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--;
@@ -1238,7 +1256,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/batman-adv/unicast.c b/batman-adv/unicast.c index 25284d8..bca69f6 100644 --- a/batman-adv/unicast.c +++ b/batman-adv/unicast.c @@ -37,6 +37,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) { @@ -60,6 +63,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; }
Andreas Langer wrote:
Sven, any idea why checkpatch (0.31)b do this ?
ERROR: space prohibited after that '-' (ctx:WxW) #10: FILE: batman-adv/routing.c:1146:
uni_diff = sizeof(struct unicast_frag_packet) - hdr_len;
Because... what the heck? Usually it says that you should use consistent spaces around '-'. So better use spaces in patch 1 and 6 and don't remove the space before hdr_len as you did now.
My version from linux-next (today) is 0.30 and doesn't have a problem with spaces around those '-' (but with your version of the patches). The checkpatch.pl-testing also don't have the problem.
I would guess that it was a regression in checkpatch.pl. Maybe Andy Whitcroft knows more about it
Best regards, Sven
On Fri, Sep 17, 2010 at 12:27:13AM +0200, Sven Eckelmann wrote:
Andreas Langer wrote:
Sven, any idea why checkpatch (0.31)b do this ?
ERROR: space prohibited after that '-' (ctx:WxW) #10: FILE: batman-adv/routing.c:1146:
uni_diff = sizeof(struct unicast_frag_packet) - hdr_len;
Because... what the heck? Usually it says that you should use consistent spaces around '-'. So better use spaces in patch 1 and 6 and don't remove the space before hdr_len as you did now.
Because it is wrong. I believe that I've fixed that one up in my development tree. Could you confirm it is correctly left alone with the version below:
http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-t...
My version from linux-next (today) is 0.30 and doesn't have a problem with spaces around those '-' (but with your version of the patches). The checkpatch.pl-testing also don't have the problem.
I would guess that it was a regression in checkpatch.pl. Maybe Andy Whitcroft knows more about it
-apw
Andy Whitcroft wrote:
On Fri, Sep 17, 2010 at 12:27:13AM +0200, Sven Eckelmann wrote:
Andreas Langer wrote:
Sven, any idea why checkpatch (0.31)b do this ?
ERROR: space prohibited after that '-' (ctx:WxW) #10: FILE: batman-adv/routing.c:1146:
uni_diff = sizeof(struct unicast_frag_packet) - hdr_len;
Because... what the heck? Usually it says that you should use consistent spaces around '-'. So better use spaces in patch 1 and 6 and don't remove the space before hdr_len as you did now.
Because it is wrong. I believe that I've fixed that one up in my development tree. Could you confirm it is correctly left alone with the version below:
http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl -testing
Yes, the testing version doesn't show that behavior.
thanks, Sven
Hi,
things that changed since the last patch:
- add support to fragment packets on every node, if outgoing iface mtu is smaller as the packet
- add support to defragment packets on every node, if outgoing iface mtu is >= original size
- rename some functions
I just merged your patchset (revision 1810-1815) into the trunk since everybody seemed to be happy with it. :-)
Thanks for your work on the fragmentation, Marek
b.a.t.m.a.n@lists.open-mesh.org