Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219756
b: refs/heads/master
c: aedbffc
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann authored and Greg Kroah-Hartman committed Sep 5, 2010
1 parent 08384f2 commit 1e2b5e3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 54 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: b411d498eeed97ed14a42abeffac2012dd10d971
refs/heads/master: aedbffc7774574de74563f350b363cbfb52984fd
77 changes: 24 additions & 53 deletions trunk/drivers/staging/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ int recv_bat_packet(struct sk_buff *skb,
{
struct ethhdr *ethhdr;
unsigned long flags;
struct sk_buff *skb_old;

/* drop packet if it has not necessary minimum size */
if (skb_headlen(skb) < sizeof(struct batman_packet))
Expand All @@ -758,18 +757,11 @@ int recv_bat_packet(struct sk_buff *skb,
if (is_bcast(ethhdr->h_source))
return NET_RX_DROP;

/* TODO: we use headlen instead of "length", because
* only this data is paged in. */

/* create a copy of the skb, if needed, to modify it. */
if (!skb_clone_writable(skb, skb_headlen(skb))) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
ethhdr = (struct ethhdr *)skb_mac_header(skb);
kfree_skb(skb_old);
}
if (skb_cow(skb, 0) < 0)
return NET_RX_DROP;

ethhdr = (struct ethhdr *)skb_mac_header(skb);

spin_lock_irqsave(&orig_hash_lock, flags);
receive_aggr_bat_packet(ethhdr,
Expand All @@ -789,7 +781,6 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
struct orig_node *orig_node;
struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
struct sk_buff *skb_old;
struct batman_if *batman_if;
int ret;
unsigned long flags;
Expand Down Expand Up @@ -824,16 +815,11 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
spin_unlock_irqrestore(&orig_hash_lock, flags);

/* create a copy of the skb, if needed, to modify it. */
skb_old = NULL;
if (!skb_clone_writable(skb, icmp_len)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
icmp_packet = (struct icmp_packet_rr *)skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);
kfree_skb(skb_old);
}
if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
return NET_RX_DROP;

icmp_packet = (struct icmp_packet_rr *)skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);

memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig,
Expand All @@ -857,7 +843,6 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
struct orig_node *orig_node;
struct icmp_packet *icmp_packet;
struct ethhdr *ethhdr;
struct sk_buff *skb_old;
struct batman_if *batman_if;
int ret;
unsigned long flags;
Expand Down Expand Up @@ -893,15 +878,11 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
spin_unlock_irqrestore(&orig_hash_lock, flags);

/* create a copy of the skb, if needed, to modify it. */
if (!skb_clone_writable(skb, icmp_len)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
icmp_packet = (struct icmp_packet *) skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);
kfree_skb(skb_old);
}
if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
return NET_RX_DROP;

icmp_packet = (struct icmp_packet *) skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);

memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig,
Expand All @@ -924,7 +905,6 @@ int recv_icmp_packet(struct sk_buff *skb)
struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
struct orig_node *orig_node;
struct sk_buff *skb_old;
struct batman_if *batman_if;
int hdr_size = sizeof(struct icmp_packet);
int ret;
Expand Down Expand Up @@ -990,15 +970,11 @@ int recv_icmp_packet(struct sk_buff *skb)
spin_unlock_irqrestore(&orig_hash_lock, flags);

/* create a copy of the skb, if needed, to modify it. */
if (!skb_clone_writable(skb, hdr_size)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
icmp_packet = (struct icmp_packet_rr *)skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);
kfree_skb(skb_old);
}
if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
return NET_RX_DROP;

icmp_packet = (struct icmp_packet_rr *)skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* decrement ttl */
icmp_packet->ttl--;
Expand Down Expand Up @@ -1137,7 +1113,6 @@ static int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,
struct orig_node *orig_node;
struct neigh_node *router;
struct batman_if *batman_if;
struct sk_buff *skb_old;
uint8_t dstaddr[ETH_ALEN];
unsigned long flags;
struct unicast_packet *unicast_packet =
Expand Down Expand Up @@ -1173,15 +1148,11 @@ static int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,
spin_unlock_irqrestore(&orig_hash_lock, flags);

/* create a copy of the skb, if needed, to modify it. */
if (!skb_clone_writable(skb, hdr_size)) {
skb_old = skb;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
unicast_packet = (struct unicast_packet *) skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);
kfree_skb(skb_old);
}
if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
return NET_RX_DROP;

unicast_packet = (struct unicast_packet *) skb->data;
ethhdr = (struct ethhdr *)skb_mac_header(skb);

/* decrement ttl */
unicast_packet->ttl--;
Expand Down

0 comments on commit 1e2b5e3

Please sign in to comment.