Skip to content

Commit

Permalink
batman-adv: use check_unicast_packet() in recv_roam_adv()
Browse files Browse the repository at this point in the history
To avoid code duplication and to simplify further changes,
check_unicast_packet() is now used in recv_roam_adv() to check for not
well formed packets and so discard them.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
  • Loading branch information
Antonio Quartulli committed Oct 29, 2012
1 parent a932657 commit d48ddb8
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,21 +687,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_roam_adv_packet *roam_adv_packet;
struct batadv_orig_node *orig_node;
struct ethhdr *ethhdr;

/* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb,
sizeof(struct batadv_roam_adv_packet))))
goto out;

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

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

/* packet with broadcast sender address */
if (is_broadcast_ether_addr(ethhdr->h_source))
if (batadv_check_unicast_packet(skb, sizeof(*roam_adv_packet)) < 0)
goto out;

batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
Expand Down

0 comments on commit d48ddb8

Please sign in to comment.