Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 228191
b: refs/heads/master
c: 003db3b
h: refs/heads/master
i:
  228189: 54e3938
  228187: 2d95200
  228183: 7dd716d
  228175: 8fa7136
  228159: 3581b4f
v: v3
  • Loading branch information
Marek Lindner authored and Greg Kroah-Hartman committed Nov 29, 2010
1 parent a29adc0 commit 6aacaa5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 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: c9c556b63b19c8b52de5c5ea6f47ab16fc540e47
refs/heads/master: 003db3b2ad61c2964d624b0786cf8202e9a92c8e
40 changes: 31 additions & 9 deletions trunk/drivers/staging/batman-adv/gateway_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "gateway_common.h"
#include "hard-interface.h"
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/udp.h>
#include <linux/if_vlan.h>

Expand Down Expand Up @@ -403,6 +404,7 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
{
struct ethhdr *ethhdr;
struct iphdr *iphdr;
struct ipv6hdr *ipv6hdr;
struct udphdr *udphdr;
unsigned int header_len = 0;

Expand All @@ -424,25 +426,45 @@ int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb)
}

/* check for ip header */
if (ntohs(ethhdr->h_proto) != ETH_P_IP)
return 0;
switch (ntohs(ethhdr->h_proto)) {
case ETH_P_IP:
if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr)))
return 0;
iphdr = (struct iphdr *)(skb->data + header_len);
header_len += iphdr->ihl * 4;

if (!pskb_may_pull(skb, header_len + sizeof(struct iphdr)))
return 0;
iphdr = (struct iphdr *)(skb->data + header_len);
header_len += iphdr->ihl * 4;
/* check for udp header */
if (iphdr->protocol != IPPROTO_UDP)
return 0;

break;
case ETH_P_IPV6:
if (!pskb_may_pull(skb, header_len + sizeof(struct ipv6hdr)))
return 0;
ipv6hdr = (struct ipv6hdr *)(skb->data + header_len);
header_len += sizeof(struct ipv6hdr);

/* check for udp header */
if (iphdr->protocol != IPPROTO_UDP)
/* check for udp header */
if (ipv6hdr->nexthdr != IPPROTO_UDP)
return 0;

break;
default:
return 0;
}

if (!pskb_may_pull(skb, header_len + sizeof(struct udphdr)))
return 0;
udphdr = (struct udphdr *)(skb->data + header_len);
header_len += sizeof(struct udphdr);

/* check for bootp port */
if (ntohs(udphdr->dest) != 67)
if ((ntohs(ethhdr->h_proto) == ETH_P_IP) &&
(ntohs(udphdr->dest) != 67))
return 0;

if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) &&
(ntohs(udphdr->dest) != 547))
return 0;

if (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)
Expand Down

0 comments on commit 6aacaa5

Please sign in to comment.