Skip to content

Commit

Permalink
batman-adv: Move batadv_check_unicast_packet()
Browse files Browse the repository at this point in the history
batadv_check_unicast_packet() is needed in batadv_recv_tt_query(), so
move the former to before the latter.

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
  • Loading branch information
Martin Hundebøll authored and Antonio Quartulli committed Aug 23, 2012
1 parent 807736f commit ff51fd7
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,31 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig,
return router;
}

static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
{
struct ethhdr *ethhdr;

/* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, hdr_size)))
return -1;

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

/* packet with unicast indication but broadcast recipient */
if (is_broadcast_ether_addr(ethhdr->h_dest))
return -1;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
return -1;

/* not for me */
if (!batadv_is_my_mac(ethhdr->h_dest))
return -1;

return 0;
}

int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
Expand Down Expand Up @@ -819,31 +844,6 @@ batadv_find_router(struct batadv_priv *bat_priv,
return NULL;
}

static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size)
{
struct ethhdr *ethhdr;

/* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, hdr_size)))
return -1;

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

/* packet with unicast indication but broadcast recipient */
if (is_broadcast_ether_addr(ethhdr->h_dest))
return -1;

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
return -1;

/* not for me */
if (!batadv_is_my_mac(ethhdr->h_dest))
return -1;

return 0;
}

static int batadv_route_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if)
{
Expand Down

0 comments on commit ff51fd7

Please sign in to comment.