Hi Werner, On Wed, Aug 07, 2013 at 05:28:39PM -0300, Werner Almesberger wrote: > Alexander Aring wrote: > > To uncompress a multicast address is different than a other > > non-multicasts addresses according to rfc6282. > > The uncompression looks fine. But you should check skb->len before > trying to access the data. This also means that you can simplify > some of the skb_pull. > > Maybe a little helper function like this could be useful: > > static inline unsigned char *fetch(struct sk_buff *skb, unsigned int len) > { > unsigned char *tmp = skb->data; > > if (unlikely(len > skb->len)) > return NULL; > skb_pull(skb, len); > return tmp; > } > Yea, we thinking in the same way, I have already a function for this in my dirty branch.
It looks like: static inline int lowpan_fetch_skb(struct sk_buff *skb, void *data, const unsigned int len) { if (unlikely(!pskb_may_pull(skb, len))) return -EINVAL; skb_copy_from_linear_data(skb, data, len); skb_pull(skb, len); return 0; } Then we can drop these lowpan_fetch_skb_u8 lowpan_fetch_skb_u16 things. Important is that we make a ntohs on lowpan_fetch_skb_u16 afterwards. (It's only one case... for the tag information in fragmentation header) This function looks others than yours, it copy the data to a destination pointer. We can drop all things with that in this case: memcpy(d, skb->data..., 2); skb_pull(skb, 2); to: err = lowpan_fetch_skb(skb, d, 2); ... and for example: memcpy(d, skb->data[0], 2); memcpy(d2, skb->data[xy], 2); /* Need calculate here because we run no skb_pull before */ skb_pull(skb, 2); becomes to: err = lowpan_fetch_skb(skb, d, 2); .. err = lowpan_fetch_skb(skb, d2, 2); .. So we are more in "streaming data"..., because we run skb_pull after each fetch. What's your opinion with this function. I can make a patch before to introduce this function and then I will use it for this patch... But I don't make a full cleanup patch to drop the lowpan_fetch_skb_u8 and lowpan_fetch_skb_u16 function... That's one of the main goal for the end of the patch series. - Alex ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel