We introduced the lowpan_fetch_skb function in some previous patches for 6lowpan to have a generic fetch function. This patch drops the old function and use the generic lowpan_fetch_skb one.
Signed-off-by: Alexander Aring <alex.ar...@gmail.com> --- include/net/6lowpan.h | 22 ---------------------- net/bluetooth/6lowpan.c | 4 ++-- net/ieee802154/6lowpan_iphc.c | 13 +++++++------ net/ieee802154/6lowpan_rtnl.c | 4 ++-- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h index e940abb..e4eb36d 100644 --- a/include/net/6lowpan.h +++ b/include/net/6lowpan.h @@ -257,28 +257,6 @@ static inline void raw_dump_inline(const char *caller, char *msg, unsigned char *buf, int len) { } #endif -static inline int lowpan_fetch_skb_u8(struct sk_buff *skb, u8 *val) -{ - if (unlikely(!pskb_may_pull(skb, 1))) - return -EINVAL; - - *val = skb->data[0]; - skb_pull(skb, 1); - - return 0; -} - -static inline int lowpan_fetch_skb_u16(struct sk_buff *skb, u16 *val) -{ - if (unlikely(!pskb_may_pull(skb, 2))) - return -EINVAL; - - *val = (skb->data[0] << 8) | skb->data[1]; - skb_pull(skb, 2); - - return 0; -} - static inline bool lowpan_fetch_skb(struct sk_buff *skb, void *data, const unsigned int len) { diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 73492b9..693098e 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -208,10 +208,10 @@ static int process_data(struct sk_buff *skb, struct net_device *netdev, if (skb->len < 2) goto drop; - if (lowpan_fetch_skb_u8(skb, &iphc0)) + if (lowpan_fetch_skb(skb, &iphc0, sizeof(iphc0))) goto drop; - if (lowpan_fetch_skb_u8(skb, &iphc1)) + if (lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1))) goto drop; return lowpan_process_data(skb, netdev, diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c index b63a6e1..fa5095a 100644 --- a/net/ieee802154/6lowpan_iphc.c +++ b/net/ieee802154/6lowpan_iphc.c @@ -357,7 +357,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, /* another if the CID flag is set */ if (iphc1 & LOWPAN_IPHC_CID) { pr_debug("CID flag is set, increase header with one\n"); - if (lowpan_fetch_skb_u8(skb, &num_context)) + if (lowpan_fetch_skb(skb, &num_context, sizeof(num_context))) goto drop; } @@ -370,7 +370,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, * ECN + DSCP + 4-bit Pad + Flow Label (4 bytes) */ case 0: /* 00b */ - if (lowpan_fetch_skb_u8(skb, &tmp)) + if (lowpan_fetch_skb(skb, &tmp, sizeof(tmp))) goto drop; memcpy(&hdr.flow_lbl, &skb->data[0], 3); @@ -384,7 +384,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, * ECN + DSCP (1 byte), Flow Label is elided */ case 2: /* 10b */ - if (lowpan_fetch_skb_u8(skb, &tmp)) + if (lowpan_fetch_skb(skb, &tmp, sizeof(tmp))) goto drop; hdr.priority = ((tmp >> 2) & 0x0f); @@ -395,7 +395,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, * ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided */ case 1: /* 01b */ - if (lowpan_fetch_skb_u8(skb, &tmp)) + if (lowpan_fetch_skb(skb, &tmp, sizeof(tmp))) goto drop; hdr.flow_lbl[0] = (skb->data[0] & 0x0F) | ((tmp >> 2) & 0x30); @@ -412,7 +412,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, /* Next Header */ if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) { /* Next header is carried inline */ - if (lowpan_fetch_skb_u8(skb, &(hdr.nexthdr))) + if (lowpan_fetch_skb(skb, &hdr.nexthdr, sizeof(hdr.nexthdr))) goto drop; pr_debug("NH flag is set, next header carried inline: %02x\n", @@ -423,7 +423,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, if ((iphc0 & 0x03) != LOWPAN_IPHC_TTL_I) hdr.hop_limit = lowpan_ttl_values[iphc0 & 0x03]; else { - if (lowpan_fetch_skb_u8(skb, &(hdr.hop_limit))) + if (lowpan_fetch_skb(skb, &hdr.hop_limit, + sizeof(hdr.hop_limit))) goto drop; } diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c index c35e63e..2a146fb 100644 --- a/net/ieee802154/6lowpan_rtnl.c +++ b/net/ieee802154/6lowpan_rtnl.c @@ -173,10 +173,10 @@ static int process_data(struct sk_buff *skb) if (skb->len < 2) goto drop; - if (lowpan_fetch_skb_u8(skb, &iphc0)) + if (lowpan_fetch_skb(skb, &iphc0, sizeof(iphc0))) goto drop; - if (lowpan_fetch_skb_u8(skb, &iphc1)) + if (lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1))) goto drop; _saddr = &mac_cb(skb)->sa; -- 1.9.0 ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel