Lines Matching +full:high +full:- +full:end
1 // SPDX-License-Identifier: GPL-2.0-or-later
29 static const char lowpan_frags_cache_name[] = "lowpan-frags";
41 BUILD_BUG_ON(sizeof(*key) > sizeof(q->key)); in lowpan_frag_init()
42 memcpy(&q->key, key, sizeof(*key)); in lowpan_frag_init()
53 spin_lock(&fq->q.lock); in lowpan_frag_expire()
55 if (fq->q.flags & INET_FRAG_COMPLETE) in lowpan_frag_expire()
58 inet_frag_kill(&fq->q, &refs); in lowpan_frag_expire()
60 spin_unlock(&fq->q.lock); in lowpan_frag_expire()
61 inet_frag_putn(&fq->q, refs); in lowpan_frag_expire()
74 key.tag = cb->d_tag; in fq_find()
75 key.d_size = cb->d_size; in fq_find()
79 q = inet_frag_find(ieee802154_lowpan->fqdir, &key); in fq_find()
92 int end, offset, err; in lowpan_frag_queue() local
94 /* inet_frag_queue_* functions use skb->cb; see struct ipfrag_skb_cb in lowpan_frag_queue()
100 if (fq->q.flags & INET_FRAG_COMPLETE) in lowpan_frag_queue()
103 offset = lowpan_802154_cb(skb)->d_offset << 3; in lowpan_frag_queue()
104 end = lowpan_802154_cb(skb)->d_size; in lowpan_frag_queue()
107 if (offset + skb->len == end) { in lowpan_frag_queue()
108 /* If we already have some bits beyond end in lowpan_frag_queue()
109 * or have different end, the segment is corrupted. in lowpan_frag_queue()
111 if (end < fq->q.len || in lowpan_frag_queue()
112 ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len)) in lowpan_frag_queue()
114 fq->q.flags |= INET_FRAG_LAST_IN; in lowpan_frag_queue()
115 fq->q.len = end; in lowpan_frag_queue()
117 if (end > fq->q.len) { in lowpan_frag_queue()
118 /* Some bits beyond end -> corruption. */ in lowpan_frag_queue()
119 if (fq->q.flags & INET_FRAG_LAST_IN) in lowpan_frag_queue()
121 fq->q.len = end; in lowpan_frag_queue()
125 ldev = skb->dev; in lowpan_frag_queue()
127 skb->dev = NULL; in lowpan_frag_queue()
130 prev_tail = fq->q.fragments_tail; in lowpan_frag_queue()
131 err = inet_frag_queue_insert(&fq->q, skb, offset, end); in lowpan_frag_queue()
135 fq->q.stamp = skb->tstamp; in lowpan_frag_queue()
136 fq->q.tstamp_type = skb->tstamp_type; in lowpan_frag_queue()
138 fq->q.flags |= INET_FRAG_FIRST_IN; in lowpan_frag_queue()
140 fq->q.meat += skb->len; in lowpan_frag_queue()
141 add_frag_mem_limit(fq->q.fqdir, skb->truesize); in lowpan_frag_queue()
143 if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && in lowpan_frag_queue()
144 fq->q.meat == fq->q.len) { in lowpan_frag_queue()
146 unsigned long orefdst = skb->_skb_refdst; in lowpan_frag_queue()
148 skb->_skb_refdst = 0UL; in lowpan_frag_queue()
150 skb->_skb_refdst = orefdst; in lowpan_frag_queue()
155 return -1; in lowpan_frag_queue()
158 return -1; in lowpan_frag_queue()
173 inet_frag_kill(&fq->q, refs); in lowpan_frag_reasm()
175 reasm_data = inet_frag_reasm_prepare(&fq->q, skb, prev_tail); in lowpan_frag_reasm()
178 inet_frag_reasm_finish(&fq->q, skb, reasm_data, false); in lowpan_frag_reasm()
180 skb->dev = ldev; in lowpan_frag_reasm()
181 skb->tstamp = fq->q.stamp; in lowpan_frag_reasm()
182 fq->q.rb_fragments = RB_ROOT; in lowpan_frag_reasm()
183 fq->q.fragments_tail = NULL; in lowpan_frag_reasm()
184 fq->q.last_run_head = NULL; in lowpan_frag_reasm()
189 return -1; in lowpan_frag_reasm()
251 u8 high = 0, low = 0; in lowpan_get_cb() local
254 fail = lowpan_fetch_skb(skb, &high, 1); in lowpan_get_cb()
256 /* remove the dispatch value and use first three bits as high value in lowpan_get_cb()
259 cb->d_size = (high & LOWPAN_FRAG_DGRAM_SIZE_HIGH_MASK) << in lowpan_get_cb()
262 cb->d_tag = ntohs(d_tag); in lowpan_get_cb()
265 fail |= lowpan_fetch_skb(skb, &cb->d_offset, 1); in lowpan_get_cb()
268 cb->d_offset = 0; in lowpan_get_cb()
270 fail |= cb->d_size < sizeof(struct ipv6hdr); in lowpan_get_cb()
272 fail |= !skb->len; in lowpan_get_cb()
276 return -EIO; in lowpan_get_cb()
284 struct net *net = dev_net(skb->dev); in lowpan_frag_rcv()
302 if (cb->d_size > IPV6_MIN_MTU) { in lowpan_frag_rcv()
312 spin_lock(&fq->q.lock); in lowpan_frag_rcv()
314 spin_unlock(&fq->q.lock); in lowpan_frag_rcv()
317 inet_frag_putn(&fq->q, refs); in lowpan_frag_rcv()
324 return -1; in lowpan_frag_rcv()
378 if (net->user_ns != &init_user_ns) in lowpan_frags_ns_sysctl_register()
382 table[0].data = &ieee802154_lowpan->fqdir->high_thresh; in lowpan_frags_ns_sysctl_register()
383 table[0].extra1 = &ieee802154_lowpan->fqdir->low_thresh; in lowpan_frags_ns_sysctl_register()
384 table[1].data = &ieee802154_lowpan->fqdir->low_thresh; in lowpan_frags_ns_sysctl_register()
385 table[1].extra2 = &ieee802154_lowpan->fqdir->high_thresh; in lowpan_frags_ns_sysctl_register()
386 table[2].data = &ieee802154_lowpan->fqdir->timeout; in lowpan_frags_ns_sysctl_register()
393 ieee802154_lowpan->sysctl.frags_hdr = hdr; in lowpan_frags_ns_sysctl_register()
400 return -ENOMEM; in lowpan_frags_ns_sysctl_register()
409 table = ieee802154_lowpan->sysctl.frags_hdr->ctl_table_arg; in lowpan_frags_ns_sysctl_unregister()
410 unregister_net_sysctl_table(ieee802154_lowpan->sysctl.frags_hdr); in lowpan_frags_ns_sysctl_unregister()
422 return lowpan_ctl_header == NULL ? -ENOMEM : 0; in lowpan_frags_sysctl_register()
456 res = fqdir_init(&ieee802154_lowpan->fqdir, &lowpan_frags, net); in lowpan_frags_init_net()
460 ieee802154_lowpan->fqdir->high_thresh = IPV6_FRAG_HIGH_THRESH; in lowpan_frags_init_net()
461 ieee802154_lowpan->fqdir->low_thresh = IPV6_FRAG_LOW_THRESH; in lowpan_frags_init_net()
462 ieee802154_lowpan->fqdir->timeout = IPV6_FRAG_TIMEOUT; in lowpan_frags_init_net()
466 fqdir_exit(ieee802154_lowpan->fqdir); in lowpan_frags_init_net()
475 fqdir_pre_exit(ieee802154_lowpan->fqdir); in lowpan_frags_pre_exit_net()
484 fqdir_exit(ieee802154_lowpan->fqdir); in lowpan_frags_exit_net()
503 return jhash2((const u32 *)&fq->key, in lowpan_obj_hashfn()
509 const struct frag_lowpan_compare_key *key = arg->key; in lowpan_obj_cmpfn()
512 return !!memcmp(&fq->key, key, sizeof(*key)); in lowpan_obj_cmpfn()