Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *	6LoWPAN next header compression
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Alexander Aring		<aar@pengutronix.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <net/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "nhc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static struct rb_root rb_root = RB_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static DEFINE_SPINLOCK(lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct rb_node **new = &rb_root.rb_node, *parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	/* Figure out where to put new node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	while (*new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		struct lowpan_nhc *this = rb_entry(*new, struct lowpan_nhc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 						   node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		int result, len_dif, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		len_dif = nhc->idlen - this->idlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		if (nhc->idlen < this->idlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			len = nhc->idlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 			len = this->idlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		result = memcmp(nhc->id, this->id, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		if (!result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			result = len_dif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		parent = *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			new = &((*new)->rb_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		else if (result > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			new = &((*new)->rb_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			return -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	/* Add new node and rebalance tree. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	rb_link_node(&nhc->node, parent, new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	rb_insert_color(&nhc->node, &rb_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static void lowpan_nhc_remove(struct lowpan_nhc *nhc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	rb_erase(&nhc->node, &rb_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct rb_node *node = rb_root.rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	const u8 *nhcid_skb_ptr = skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	while (node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		struct lowpan_nhc *nhc = rb_entry(node, struct lowpan_nhc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 						  node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		u8 nhcid_skb_ptr_masked[LOWPAN_NHC_MAX_ID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		int result, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		if (nhcid_skb_ptr + nhc->idlen > skb->data + skb->len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		/* copy and mask afterwards the nhid value from skb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		memcpy(nhcid_skb_ptr_masked, nhcid_skb_ptr, nhc->idlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		for (i = 0; i < nhc->idlen; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			nhcid_skb_ptr_masked[i] &= nhc->idmask[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		result = memcmp(nhcid_skb_ptr_masked, nhc->id, nhc->idlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			node = node->rb_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		else if (result > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			node = node->rb_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			return nhc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) int lowpan_nhc_check_compression(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				 const struct ipv6hdr *hdr, u8 **hc_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	struct lowpan_nhc *nhc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	spin_lock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	nhc = lowpan_nexthdr_nhcs[hdr->nexthdr];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (!(nhc && nhc->compress))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		ret = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			      u8 **hc_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct lowpan_nhc *nhc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	spin_lock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	nhc = lowpan_nexthdr_nhcs[hdr->nexthdr];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/* check if the nhc module was removed in unlocked part.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	 * TODO: this is a workaround we should prevent unloading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	 * of nhc modules while unlocked part, this will always drop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 * the lowpan packet but it's very unlikely.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 * Solution isn't easy because we need to decide at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 * lowpan_nhc_check_compression if we do a compression or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 * Because the inline data which is added to skb, we can't move this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	 * handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (unlikely(!nhc || !nhc->compress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/* In the case of RAW sockets the transport header is not set by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 * the ip6 stack so we must set it ourselves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (skb->transport_header == skb->network_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		skb_set_transport_header(skb, sizeof(struct ipv6hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	ret = nhc->compress(skb, hc_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	/* skip the transport header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	skb_pull(skb, nhc->nexthdrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int lowpan_nhc_do_uncompression(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 				struct ipv6hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct lowpan_nhc *nhc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	spin_lock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	nhc = lowpan_nhc_by_nhcid(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (nhc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		if (nhc->uncompress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			ret = nhc->uncompress(skb, sizeof(struct ipv6hdr) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 					      nhc->nexthdrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 				return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			netdev_warn(dev, "received nhc id for %s which is not implemented.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 				    nhc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		netdev_warn(dev, "received unknown nhc id which was not found.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	hdr->nexthdr = nhc->nexthdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	skb_reset_transport_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	raw_dump_table(__func__, "raw transport header dump",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		       skb_transport_header(skb), nhc->nexthdrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int lowpan_nhc_add(struct lowpan_nhc *nhc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (!nhc->idlen || !nhc->idsetup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	WARN_ONCE(nhc->idlen > LOWPAN_NHC_MAX_ID_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		  "LOWPAN_NHC_MAX_ID_LEN should be updated to %zd.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		  nhc->idlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	nhc->idsetup(nhc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	spin_lock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (lowpan_nexthdr_nhcs[nhc->nexthdr]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		ret = -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	ret = lowpan_nhc_insert(nhc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	lowpan_nexthdr_nhcs[nhc->nexthdr] = nhc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) EXPORT_SYMBOL(lowpan_nhc_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) void lowpan_nhc_del(struct lowpan_nhc *nhc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	spin_lock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	lowpan_nhc_remove(nhc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	lowpan_nexthdr_nhcs[nhc->nexthdr] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	spin_unlock_bh(&lowpan_nhc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	synchronize_net();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) EXPORT_SYMBOL(lowpan_nhc_del);