Lines Matching refs:fl
67 struct ip6_flowlabel *fl; in __fl_lookup() local
69 for (fl=fl_ht[FL_HASH(label)]; fl; fl = fl->next) { in __fl_lookup()
70 if (fl->label == label && fl->fl_net == net) in __fl_lookup()
71 return fl; in __fl_lookup()
78 struct ip6_flowlabel *fl; in fl_lookup() local
81 fl = __fl_lookup(net, label); in fl_lookup()
82 if (fl) in fl_lookup()
83 atomic_inc(&fl->users); in fl_lookup()
85 return fl; in fl_lookup()
89 static void fl_free(struct ip6_flowlabel *fl) in fl_free() argument
91 if (fl) { in fl_free()
92 release_net(fl->fl_net); in fl_free()
93 kfree(fl->opt); in fl_free()
95 kfree(fl); in fl_free()
98 static void fl_release(struct ip6_flowlabel *fl) in fl_release() argument
102 fl->lastuse = jiffies; in fl_release()
103 if (atomic_dec_and_test(&fl->users)) { in fl_release()
104 unsigned long ttd = fl->lastuse + fl->linger; in fl_release()
105 if (time_after(ttd, fl->expires)) in fl_release()
106 fl->expires = ttd; in fl_release()
107 ttd = fl->expires; in fl_release()
108 if (fl->opt && fl->share == IPV6_FL_S_EXCL) { in fl_release()
109 struct ipv6_txoptions *opt = fl->opt; in fl_release()
110 fl->opt = NULL; in fl_release()
129 struct ip6_flowlabel *fl, **flp; in ip6_fl_gc() local
131 while ((fl=*flp) != NULL) { in ip6_fl_gc()
132 if (atomic_read(&fl->users) == 0) { in ip6_fl_gc()
133 unsigned long ttd = fl->lastuse + fl->linger; in ip6_fl_gc()
134 if (time_after(ttd, fl->expires)) in ip6_fl_gc()
135 fl->expires = ttd; in ip6_fl_gc()
136 ttd = fl->expires; in ip6_fl_gc()
138 *flp = fl->next; in ip6_fl_gc()
139 fl_free(fl); in ip6_fl_gc()
146 flp = &fl->next; in ip6_fl_gc()
163 struct ip6_flowlabel *fl, **flp; in ip6_fl_purge() local
165 while ((fl = *flp) != NULL) { in ip6_fl_purge()
166 if (fl->fl_net == net && atomic_read(&fl->users) == 0) { in ip6_fl_purge()
167 *flp = fl->next; in ip6_fl_purge()
168 fl_free(fl); in ip6_fl_purge()
172 flp = &fl->next; in ip6_fl_purge()
179 struct ip6_flowlabel *fl, __be32 label) in fl_intern()
183 fl->label = label & IPV6_FLOWLABEL_MASK; in fl_intern()
188 fl->label = htonl(net_random())&IPV6_FLOWLABEL_MASK; in fl_intern()
189 if (fl->label) { in fl_intern()
190 lfl = __fl_lookup(net, fl->label); in fl_intern()
204 lfl = __fl_lookup(net, fl->label); in fl_intern()
212 fl->lastuse = jiffies; in fl_intern()
213 fl->next = fl_ht[FL_HASH(fl->label)]; in fl_intern()
214 fl_ht[FL_HASH(fl->label)] = fl; in fl_intern()
233 struct ip6_flowlabel *fl = sfl->fl; in fl6_sock_lookup() local
234 if (fl->label == label) { in fl6_sock_lookup()
235 fl->lastuse = jiffies; in fl6_sock_lookup()
236 atomic_inc(&fl->users); in fl6_sock_lookup()
238 return fl; in fl6_sock_lookup()
254 fl_release(sfl->fl); in fl6_free_socklist()
269 struct ip6_flowlabel * fl, in fl6_merge_options() argument
272 struct ipv6_txoptions * fl_opt = fl->opt; in fl6_merge_options()
304 static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned long expires) in fl6_renew() argument
312 fl->lastuse = jiffies; in fl6_renew()
313 if (time_before(fl->linger, linger)) in fl6_renew()
314 fl->linger = linger; in fl6_renew()
315 if (time_before(expires, fl->linger)) in fl6_renew()
316 expires = fl->linger; in fl6_renew()
317 if (time_before(fl->expires, fl->lastuse + expires)) in fl6_renew()
318 fl->expires = fl->lastuse + expires; in fl6_renew()
326 struct ip6_flowlabel *fl = NULL; in fl_create() local
337 fl = kzalloc(sizeof(*fl), GFP_KERNEL); in fl_create()
338 if (fl == NULL) in fl_create()
347 fl->opt = kmalloc(sizeof(*fl->opt) + olen, GFP_KERNEL); in fl_create()
348 if (fl->opt == NULL) in fl_create()
351 memset(fl->opt, 0, sizeof(*fl->opt)); in fl_create()
352 fl->opt->tot_len = sizeof(*fl->opt) + olen; in fl_create()
354 if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) in fl_create()
358 msg.msg_control = (void*)(fl->opt+1); in fl_create()
361 err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk, &junk); in fl_create()
365 if (fl->opt->opt_flen) in fl_create()
367 if (fl->opt->opt_nflen == 0) { in fl_create()
368 kfree(fl->opt); in fl_create()
369 fl->opt = NULL; in fl_create()
373 fl->fl_net = hold_net(net); in fl_create()
374 fl->expires = jiffies; in fl_create()
375 err = fl6_renew(fl, freq->flr_linger, freq->flr_expires); in fl_create()
378 fl->share = freq->flr_share; in fl_create()
385 ipv6_addr_copy(&fl->dst, &freq->flr_dst); in fl_create()
386 atomic_set(&fl->users, 1); in fl_create()
387 switch (fl->share) { in fl_create()
392 fl->owner = current->pid; in fl_create()
395 fl->owner = current_euid(); in fl_create()
401 return fl; in fl_create()
404 fl_free(fl); in fl_create()
460 struct ip6_flowlabel *fl) in fl_link() argument
463 sfl->fl = fl; in fl_link()
477 struct ip6_flowlabel *fl, *fl1 = NULL; in ipv6_flowlabel_opt() local
490 if (sfl->fl->label == freq.flr_label) { in ipv6_flowlabel_opt()
495 fl_release(sfl->fl); in ipv6_flowlabel_opt()
506 if (sfl->fl->label == freq.flr_label) { in ipv6_flowlabel_opt()
507 err = fl6_renew(sfl->fl, freq.flr_linger, freq.flr_expires); in ipv6_flowlabel_opt()
515 fl = fl_lookup(net, freq.flr_label); in ipv6_flowlabel_opt()
516 if (fl) { in ipv6_flowlabel_opt()
517 err = fl6_renew(fl, freq.flr_linger, freq.flr_expires); in ipv6_flowlabel_opt()
518 fl_release(fl); in ipv6_flowlabel_opt()
528 fl = fl_create(net, &freq, optval, optlen, &err); in ipv6_flowlabel_opt()
529 if (fl == NULL) in ipv6_flowlabel_opt()
537 if (sfl->fl->label == freq.flr_label) { in ipv6_flowlabel_opt()
542 fl1 = sfl->fl; in ipv6_flowlabel_opt()
558 fl1->share != fl->share || in ipv6_flowlabel_opt()
559 fl1->owner != fl->owner) in ipv6_flowlabel_opt()
563 if (!ipv6_addr_equal(&fl1->dst, &fl->dst) || in ipv6_flowlabel_opt()
564 ipv6_opt_cmp(fl1->opt, fl->opt)) in ipv6_flowlabel_opt()
570 if (fl->linger > fl1->linger) in ipv6_flowlabel_opt()
571 fl1->linger = fl->linger; in ipv6_flowlabel_opt()
572 if ((long)(fl->expires - fl1->expires) > 0) in ipv6_flowlabel_opt()
573 fl1->expires = fl->expires; in ipv6_flowlabel_opt()
575 fl_free(fl); in ipv6_flowlabel_opt()
591 fl1 = fl_intern(net, fl, freq.flr_label); in ipv6_flowlabel_opt()
597 &fl->label, sizeof(fl->label))) { in ipv6_flowlabel_opt()
602 fl_link(np, sfl1, fl); in ipv6_flowlabel_opt()
610 fl_free(fl); in ipv6_flowlabel_opt()
626 struct ip6_flowlabel *fl = NULL; in ip6fl_get_first() local
631 fl = fl_ht[state->bucket]; in ip6fl_get_first()
633 while (fl && fl->fl_net != net) in ip6fl_get_first()
634 fl = fl->next; in ip6fl_get_first()
635 if (fl) in ip6fl_get_first()
638 return fl; in ip6fl_get_first()
641 static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flowlabel *fl) in ip6fl_get_next() argument
646 fl = fl->next; in ip6fl_get_next()
648 while (fl && fl->fl_net != net) in ip6fl_get_next()
649 fl = fl->next; in ip6fl_get_next()
651 while (!fl) { in ip6fl_get_next()
653 fl = fl_ht[state->bucket]; in ip6fl_get_next()
658 return fl; in ip6fl_get_next()
663 struct ip6_flowlabel *fl = ip6fl_get_first(seq); in ip6fl_get_idx() local
664 if (fl) in ip6fl_get_idx()
665 while (pos && (fl = ip6fl_get_next(seq, fl)) != NULL) in ip6fl_get_idx()
667 return pos ? NULL : fl; in ip6fl_get_idx()
679 struct ip6_flowlabel *fl; in ip6fl_seq_next() local
682 fl = ip6fl_get_first(seq); in ip6fl_seq_next()
684 fl = ip6fl_get_next(seq, v); in ip6fl_seq_next()
686 return fl; in ip6fl_seq_next()
701 struct ip6_flowlabel *fl = v; in ip6fl_seq_show() local
704 (unsigned)ntohl(fl->label), in ip6fl_seq_show()
705 fl->share, in ip6fl_seq_show()
706 (unsigned)fl->owner, in ip6fl_seq_show()
707 atomic_read(&fl->users), in ip6fl_seq_show()
708 fl->linger/HZ, in ip6fl_seq_show()
709 (long)(fl->expires - jiffies)/HZ, in ip6fl_seq_show()
710 &fl->dst, in ip6fl_seq_show()
711 fl->opt ? fl->opt->opt_nflen : 0); in ip6fl_seq_show()