diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/gateway_client.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 1bce63aa5f5f..ac97ca7f4ad0 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -655,24 +655,29 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) | |||
655 | struct iphdr *iphdr; | 655 | struct iphdr *iphdr; |
656 | struct ipv6hdr *ipv6hdr; | 656 | struct ipv6hdr *ipv6hdr; |
657 | struct udphdr *udphdr; | 657 | struct udphdr *udphdr; |
658 | struct vlan_ethhdr *vhdr; | ||
659 | __be16 proto; | ||
658 | 660 | ||
659 | /* check for ethernet header */ | 661 | /* check for ethernet header */ |
660 | if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) | 662 | if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) |
661 | return false; | 663 | return false; |
662 | ethhdr = (struct ethhdr *)skb->data; | 664 | ethhdr = (struct ethhdr *)skb->data; |
665 | proto = ethhdr->h_proto; | ||
663 | *header_len += ETH_HLEN; | 666 | *header_len += ETH_HLEN; |
664 | 667 | ||
665 | /* check for initial vlan header */ | 668 | /* check for initial vlan header */ |
666 | if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { | 669 | if (proto == htons(ETH_P_8021Q)) { |
667 | if (!pskb_may_pull(skb, *header_len + VLAN_HLEN)) | 670 | if (!pskb_may_pull(skb, *header_len + VLAN_HLEN)) |
668 | return false; | 671 | return false; |
669 | ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN); | 672 | |
673 | vhdr = (struct vlan_ethhdr *)skb->data; | ||
674 | proto = vhdr->h_vlan_encapsulated_proto; | ||
670 | *header_len += VLAN_HLEN; | 675 | *header_len += VLAN_HLEN; |
671 | } | 676 | } |
672 | 677 | ||
673 | /* check for ip header */ | 678 | /* check for ip header */ |
674 | switch (ntohs(ethhdr->h_proto)) { | 679 | switch (proto) { |
675 | case ETH_P_IP: | 680 | case htons(ETH_P_IP): |
676 | if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr))) | 681 | if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr))) |
677 | return false; | 682 | return false; |
678 | iphdr = (struct iphdr *)(skb->data + *header_len); | 683 | iphdr = (struct iphdr *)(skb->data + *header_len); |
@@ -683,7 +688,7 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) | |||
683 | return false; | 688 | return false; |
684 | 689 | ||
685 | break; | 690 | break; |
686 | case ETH_P_IPV6: | 691 | case htons(ETH_P_IPV6): |
687 | if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr))) | 692 | if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr))) |
688 | return false; | 693 | return false; |
689 | ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len); | 694 | ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len); |
@@ -710,11 +715,11 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) | |||
710 | *header_len += sizeof(*udphdr); | 715 | *header_len += sizeof(*udphdr); |
711 | 716 | ||
712 | /* check for bootp port */ | 717 | /* check for bootp port */ |
713 | if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && | 718 | if ((proto == htons(ETH_P_IP)) && |
714 | (ntohs(udphdr->dest) != 67)) | 719 | (ntohs(udphdr->dest) != 67)) |
715 | return false; | 720 | return false; |
716 | 721 | ||
717 | if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) && | 722 | if ((proto == htons(ETH_P_IPV6)) && |
718 | (ntohs(udphdr->dest) != 547)) | 723 | (ntohs(udphdr->dest) != 547)) |
719 | return false; | 724 | return false; |
720 | 725 | ||