batman-adv: avoid skb_linearise() if not needed

Message ID 1331895151-22510-1-git-send-email-ordex@autistici.org (mailing list archive)
State Accepted, archived
Commit 782b0f4b7f175e639299e9bd15e6c5064d39ed67
Headers

Commit Message

Antonio Quartulli March 16, 2012, 10:52 a.m. UTC
  Whenever we want to access headers only, we do not need to linearise the whole
packet. Instead we can use pskb_may_pull()

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 routing.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Marek Lindner March 20, 2012, 12:59 p.m. UTC | #1
On Friday, March 16, 2012 11:52:31 Antonio Quartulli wrote:
> Whenever we want to access headers only, we do not need to linearise the
> whole packet. Instead we can use pskb_may_pull()

Applied in revision 782b0f4.

Thanks,
Marek
  

Patch

diff --git a/routing.c b/routing.c
index 962a315..576ffb1 100644
--- a/routing.c
+++ b/routing.c
@@ -915,8 +915,9 @@  static int check_unicast_ttvn(struct bat_priv *bat_priv,
 
 	/* Check whether I have to reroute the packet */
 	if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) {
-		/* Linearize the skb before accessing it */
-		if (skb_linearize(skb) < 0)
+		/* check if there is enough data before accessing it */
+		if (pskb_may_pull(skb, sizeof(struct unicast_packet) +
+				  ETH_HLEN) < 0)
 			return 0;
 
 		ethhdr = (struct ethhdr *)(skb->data +