On Thu, Mar 01, 2012 at 03:35:18PM +0800, Marek Lindner wrote: > -static void bat_iv_ogm_receive(struct hard_iface *if_incoming, > - struct sk_buff *skb) > +static void _bat_iv_ogm_receive(struct sk_buff *skb, > + struct hard_iface *if_incoming)
<rant> Personally, I don't like underscore functions. They are usually created because of a lack of creativity, but are later called from different places, do different jobs and in the end everyone is confused. :) Is it possibble to change the name, e.g. to bat_iv_ogm_handle()? </rant> > { > struct batman_ogm_packet *batman_ogm_packet; > struct ethhdr *ethhdr; > @@ -1200,6 +1200,39 @@ static void bat_iv_ogm_receive(struct hard_iface > *if_incoming, > batman_ogm_packet->tt_num_changes)); > } > > +static int bat_iv_ogm_receive(struct sk_buff *skb, > + struct hard_iface *hard_iface) > +{ > + struct ethhdr *ethhdr; > + > + /* drop packet if it has not necessary minimum size */ > + if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN))) > + return NET_RX_DROP; > + > + ethhdr = (struct ethhdr *)skb_mac_header(skb); > + > + /* packet with broadcast indication but unicast recipient */ > + if (!is_broadcast_ether_addr(ethhdr->h_dest)) > + return NET_RX_DROP; > + > + /* packet with broadcast sender address */ > + if (is_broadcast_ether_addr(ethhdr->h_source)) > + return NET_RX_DROP; > + > + /* create a copy of the skb, if needed, to modify it. */ > + if (skb_cow(skb, 0) < 0) > + return NET_RX_DROP; > + > + /* keep skb linear */ > + if (skb_linearize(skb) < 0) > + return NET_RX_DROP; > + > + _bat_iv_ogm_receive(skb, hard_iface); > + > + kfree_skb(skb); > + return NET_RX_SUCCESS; > +} > + We should somewhere add a check whether the hard_iface is actually assigned to a mesh using the BATMAN IV algorithm. When more algorithms are added, we only want the assigned protocol to be handled, others should be ignored. Cheers, Simon
signature.asc
Description: Digital signature