diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-04-03 04:14:20 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-04-22 03:55:23 -0400 |
commit | dd981ab091cde09bb9eb23c8d81305ba615ee30c (patch) | |
tree | 7d055170b75f69c210ed0de8577c39b4b3dc30c7 /net/batman-adv | |
parent | 60d509fa6a9c4653a86ad830e4c4b30360b23f0e (diff) |
batman-adv: use the proper header len when checking the TTVN
Unicast packet might be of type either UNICAST or
UNICAST4ADDR.
In the two cases the header size is different, but the
mechanism checking the TTVN field was assuming it to be
always of the same type (UNICAST), so failing to access the
inner Ethernet header in case of UNICAST4ADDR.
Fix this by passing the real header length as argument.
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/routing.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 319f2906c71a..7de033667ebc 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -924,7 +924,7 @@ out: | |||
924 | } | 924 | } |
925 | 925 | ||
926 | static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | 926 | static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, |
927 | struct sk_buff *skb) { | 927 | struct sk_buff *skb, int hdr_len) { |
928 | uint8_t curr_ttvn, old_ttvn; | 928 | uint8_t curr_ttvn, old_ttvn; |
929 | struct batadv_orig_node *orig_node; | 929 | struct batadv_orig_node *orig_node; |
930 | struct ethhdr *ethhdr; | 930 | struct ethhdr *ethhdr; |
@@ -933,7 +933,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | |||
933 | int is_old_ttvn; | 933 | int is_old_ttvn; |
934 | 934 | ||
935 | /* check if there is enough data before accessing it */ | 935 | /* check if there is enough data before accessing it */ |
936 | if (pskb_may_pull(skb, sizeof(*unicast_packet) + ETH_HLEN) < 0) | 936 | if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0) |
937 | return 0; | 937 | return 0; |
938 | 938 | ||
939 | /* create a copy of the skb (in case of for re-routing) to modify it. */ | 939 | /* create a copy of the skb (in case of for re-routing) to modify it. */ |
@@ -941,7 +941,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | |||
941 | return 0; | 941 | return 0; |
942 | 942 | ||
943 | unicast_packet = (struct batadv_unicast_packet *)skb->data; | 943 | unicast_packet = (struct batadv_unicast_packet *)skb->data; |
944 | ethhdr = (struct ethhdr *)(skb->data + sizeof(*unicast_packet)); | 944 | ethhdr = (struct ethhdr *)(skb->data + hdr_len); |
945 | 945 | ||
946 | /* check if the destination client was served by this node and it is now | 946 | /* check if the destination client was served by this node and it is now |
947 | * roaming. In this case, it means that the node has got a ROAM_ADV | 947 | * roaming. In this case, it means that the node has got a ROAM_ADV |
@@ -1048,8 +1048,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, | |||
1048 | 1048 | ||
1049 | if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) | 1049 | if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) |
1050 | return NET_RX_DROP; | 1050 | return NET_RX_DROP; |
1051 | 1051 | if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size)) | |
1052 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) | ||
1053 | return NET_RX_DROP; | 1052 | return NET_RX_DROP; |
1054 | 1053 | ||
1055 | /* packet for me */ | 1054 | /* packet for me */ |
@@ -1093,7 +1092,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb, | |||
1093 | if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) | 1092 | if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) |
1094 | return NET_RX_DROP; | 1093 | return NET_RX_DROP; |
1095 | 1094 | ||
1096 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) | 1095 | if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size)) |
1097 | return NET_RX_DROP; | 1096 | return NET_RX_DROP; |
1098 | 1097 | ||
1099 | unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; | 1098 | unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; |