frag6.c (5e9510e3b63d993617a688166ffa1cb471b15ac1) frag6.c (1272577e22d8f1c1c5b5e88f2624836e93aecb17)
1/* $FreeBSD$ */
2/* $KAME: frag6.c,v 1.33 2002/01/07 11:34:48 kjc Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 80 unchanged lines hidden (view full) ---

89frag6_change(void *tag)
90{
91
92 ip6_maxfragpackets = nmbclusters / 4;
93 ip6_maxfrags = nmbclusters / 4;
94}
95
96void
1/* $FreeBSD$ */
2/* $KAME: frag6.c,v 1.33 2002/01/07 11:34:48 kjc Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 80 unchanged lines hidden (view full) ---

89frag6_change(void *tag)
90{
91
92 ip6_maxfragpackets = nmbclusters / 4;
93 ip6_maxfrags = nmbclusters / 4;
94}
95
96void
97frag6_init()
97frag6_init(void)
98{
99
100 ip6_maxfragpackets = nmbclusters / 4;
101 ip6_maxfrags = nmbclusters / 4;
102 EVENTHANDLER_REGISTER(nmbclusters_change,
103 frag6_change, NULL, EVENTHANDLER_PRI_ANY);
104
105 IP6Q_LOCK_INIT();

--- 29 unchanged lines hidden (view full) ---

135 * -> should grab it from the first fragment only
136 *
137 * There is no explicit reason given in the RFC. Historical reason maybe?
138 */
139/*
140 * Fragment input
141 */
142int
98{
99
100 ip6_maxfragpackets = nmbclusters / 4;
101 ip6_maxfrags = nmbclusters / 4;
102 EVENTHANDLER_REGISTER(nmbclusters_change,
103 frag6_change, NULL, EVENTHANDLER_PRI_ANY);
104
105 IP6Q_LOCK_INIT();

--- 29 unchanged lines hidden (view full) ---

135 * -> should grab it from the first fragment only
136 *
137 * There is no explicit reason given in the RFC. Historical reason maybe?
138 */
139/*
140 * Fragment input
141 */
142int
143frag6_input(mp, offp, proto)
144 struct mbuf **mp;
145 int *offp, proto;
143frag6_input(struct mbuf **mp, int *offp, int proto)
146{
147 struct mbuf *m = *mp, *t;
148 struct ip6_hdr *ip6;
149 struct ip6_frag *ip6f;
150 struct ip6q *q6;
151 struct ip6asfrag *af6, *ip6af, *af6dwn;
152#ifdef IN6_IFSTAT_STRICT
153 struct in6_ifaddr *ia;

--- 424 unchanged lines hidden (view full) ---

578 return IPPROTO_DONE;
579}
580
581/*
582 * Free a fragment reassembly header and all
583 * associated datagrams.
584 */
585void
144{
145 struct mbuf *m = *mp, *t;
146 struct ip6_hdr *ip6;
147 struct ip6_frag *ip6f;
148 struct ip6q *q6;
149 struct ip6asfrag *af6, *ip6af, *af6dwn;
150#ifdef IN6_IFSTAT_STRICT
151 struct in6_ifaddr *ia;

--- 424 unchanged lines hidden (view full) ---

576 return IPPROTO_DONE;
577}
578
579/*
580 * Free a fragment reassembly header and all
581 * associated datagrams.
582 */
583void
586frag6_freef(q6)
587 struct ip6q *q6;
584frag6_freef(struct ip6q *q6)
588{
589 struct ip6asfrag *af6, *down6;
590
591 IP6Q_LOCK_ASSERT();
592
593 for (af6 = q6->ip6q_down; af6 != (struct ip6asfrag *)q6;
594 af6 = down6) {
595 struct mbuf *m = IP6_REASS_MBUF(af6);

--- 27 unchanged lines hidden (view full) ---

623 frag6_nfragpackets--;
624}
625
626/*
627 * Put an ip fragment on a reassembly chain.
628 * Like insque, but pointers in middle of structure.
629 */
630void
585{
586 struct ip6asfrag *af6, *down6;
587
588 IP6Q_LOCK_ASSERT();
589
590 for (af6 = q6->ip6q_down; af6 != (struct ip6asfrag *)q6;
591 af6 = down6) {
592 struct mbuf *m = IP6_REASS_MBUF(af6);

--- 27 unchanged lines hidden (view full) ---

620 frag6_nfragpackets--;
621}
622
623/*
624 * Put an ip fragment on a reassembly chain.
625 * Like insque, but pointers in middle of structure.
626 */
627void
631frag6_enq(af6, up6)
632 struct ip6asfrag *af6, *up6;
628frag6_enq(struct ip6asfrag *af6, struct ip6asfrag *up6)
633{
634
635 IP6Q_LOCK_ASSERT();
636
637 af6->ip6af_up = up6;
638 af6->ip6af_down = up6->ip6af_down;
639 up6->ip6af_down->ip6af_up = af6;
640 up6->ip6af_down = af6;
641}
642
643/*
644 * To frag6_enq as remque is to insque.
645 */
646void
629{
630
631 IP6Q_LOCK_ASSERT();
632
633 af6->ip6af_up = up6;
634 af6->ip6af_down = up6->ip6af_down;
635 up6->ip6af_down->ip6af_up = af6;
636 up6->ip6af_down = af6;
637}
638
639/*
640 * To frag6_enq as remque is to insque.
641 */
642void
647frag6_deq(af6)
648 struct ip6asfrag *af6;
643frag6_deq(struct ip6asfrag *af6)
649{
650
651 IP6Q_LOCK_ASSERT();
652
653 af6->ip6af_up->ip6af_down = af6->ip6af_down;
654 af6->ip6af_down->ip6af_up = af6->ip6af_up;
655}
656
657void
644{
645
646 IP6Q_LOCK_ASSERT();
647
648 af6->ip6af_up->ip6af_down = af6->ip6af_down;
649 af6->ip6af_down->ip6af_up = af6->ip6af_up;
650}
651
652void
658frag6_insque(new, old)
659 struct ip6q *new, *old;
653frag6_insque(struct ip6q *new, struct ip6q *old)
660{
661
662 IP6Q_LOCK_ASSERT();
663
664 new->ip6q_prev = old;
665 new->ip6q_next = old->ip6q_next;
666 old->ip6q_next->ip6q_prev= new;
667 old->ip6q_next = new;
668}
669
670void
654{
655
656 IP6Q_LOCK_ASSERT();
657
658 new->ip6q_prev = old;
659 new->ip6q_next = old->ip6q_next;
660 old->ip6q_next->ip6q_prev= new;
661 old->ip6q_next = new;
662}
663
664void
671frag6_remque(p6)
672 struct ip6q *p6;
665frag6_remque(struct ip6q *p6)
673{
674
675 IP6Q_LOCK_ASSERT();
676
677 p6->ip6q_prev->ip6q_next = p6->ip6q_next;
678 p6->ip6q_next->ip6q_prev = p6->ip6q_prev;
679}
680
681/*
682 * IPv6 reassembling timer processing;
683 * if a timer expires on a reassembly
684 * queue, discard it.
685 */
686void
666{
667
668 IP6Q_LOCK_ASSERT();
669
670 p6->ip6q_prev->ip6q_next = p6->ip6q_next;
671 p6->ip6q_next->ip6q_prev = p6->ip6q_prev;
672}
673
674/*
675 * IPv6 reassembling timer processing;
676 * if a timer expires on a reassembly
677 * queue, discard it.
678 */
679void
687frag6_slowtimo()
680frag6_slowtimo(void)
688{
689 struct ip6q *q6;
690
691#if 0
692 GIANT_REQUIRED; /* XXX bz: ip6_forward_rt */
693#endif
694
695 IP6Q_LOCK();

--- 37 unchanged lines hidden (view full) ---

733 }
734#endif
735}
736
737/*
738 * Drain off all datagram fragments.
739 */
740void
681{
682 struct ip6q *q6;
683
684#if 0
685 GIANT_REQUIRED; /* XXX bz: ip6_forward_rt */
686#endif
687
688 IP6Q_LOCK();

--- 37 unchanged lines hidden (view full) ---

726 }
727#endif
728}
729
730/*
731 * Drain off all datagram fragments.
732 */
733void
741frag6_drain()
734frag6_drain(void)
742{
743
744 if (IP6Q_TRYLOCK() == 0)
745 return;
746 while (ip6q.ip6q_next != &ip6q) {
747 ip6stat.ip6s_fragdropped++;
748 /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
749 frag6_freef(ip6q.ip6q_next);
750 }
751 IP6Q_UNLOCK();
752}
735{
736
737 if (IP6Q_TRYLOCK() == 0)
738 return;
739 while (ip6q.ip6q_next != &ip6q) {
740 ip6stat.ip6s_fragdropped++;
741 /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
742 frag6_freef(ip6q.ip6q_next);
743 }
744 IP6Q_UNLOCK();
745}