Deleted Added
full compact
if_llatbl.c (238989) if_llatbl.c (238990)
1/*
2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
3 * Copyright (c) 2004-2008 Qing Li. All rights reserved.
4 * Copyright (c) 2008 Kip Macy. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
3 * Copyright (c) 2004-2008 Qing Li. All rights reserved.
4 * Copyright (c) 2008 Kip Macy. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.c 238989 2012-08-02 13:20:44Z glebius $");
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.c 238990 2012-08-02 13:57:49Z glebius $");
29
30#include "opt_ddb.h"
31#include "opt_inet.h"
32#include "opt_inet6.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>

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

101 * Returns the number of held packets, if any, that were dropped.
102 */
103size_t
104llentry_free(struct llentry *lle)
105{
106 size_t pkts_dropped;
107 struct mbuf *next;
108
29
30#include "opt_ddb.h"
31#include "opt_inet.h"
32#include "opt_inet6.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>

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

101 * Returns the number of held packets, if any, that were dropped.
102 */
103size_t
104llentry_free(struct llentry *lle)
105{
106 size_t pkts_dropped;
107 struct mbuf *next;
108
109 pkts_dropped = 0;
109 IF_AFDATA_WLOCK_ASSERT(lle->lle_tbl->llt_ifp);
110 LLE_WLOCK_ASSERT(lle);
110 LLE_WLOCK_ASSERT(lle);
111
112 /* XXX: guard against race with other llentry_free(). */
113 if (!(lle->la_flags & LLE_LINKED)) {
114 LLE_FREE_LOCKED(lle);
115 return (0);
116 }
117
111 LIST_REMOVE(lle, lle_next);
118 LIST_REMOVE(lle, lle_next);
119 lle->la_flags &= ~(LLE_VALID | LLE_LINKED);
112
120
121 pkts_dropped = 0;
113 while ((lle->la_numheld > 0) && (lle->la_hold != NULL)) {
114 next = lle->la_hold->m_nextpkt;
115 m_freem(lle->la_hold);
116 lle->la_hold = next;
117 lle->la_numheld--;
118 pkts_dropped++;
119 }
120
121 KASSERT(lle->la_numheld == 0,
122 ("%s: la_numheld %d > 0, pkts_droped %zd", __func__,
123 lle->la_numheld, pkts_dropped));
124
122 while ((lle->la_numheld > 0) && (lle->la_hold != NULL)) {
123 next = lle->la_hold->m_nextpkt;
124 m_freem(lle->la_hold);
125 lle->la_hold = next;
126 lle->la_numheld--;
127 pkts_dropped++;
128 }
129
130 KASSERT(lle->la_numheld == 0,
131 ("%s: la_numheld %d > 0, pkts_droped %zd", __func__,
132 lle->la_numheld, pkts_dropped));
133
125 lle->la_flags &= ~LLE_VALID;
126 LLE_FREE_LOCKED(lle);
127
128 return (pkts_dropped);
129}
130
131/*
132 * (al)locate an llentry for address dst (equivalent to rtalloc for new-arp).
133 *

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

168 int i;
169
170 KASSERT(llt != NULL, ("%s: llt is NULL", __func__));
171
172 LLTABLE_WLOCK();
173 SLIST_REMOVE(&V_lltables, llt, lltable, llt_link);
174 LLTABLE_WUNLOCK();
175
134 LLE_FREE_LOCKED(lle);
135
136 return (pkts_dropped);
137}
138
139/*
140 * (al)locate an llentry for address dst (equivalent to rtalloc for new-arp).
141 *

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

176 int i;
177
178 KASSERT(llt != NULL, ("%s: llt is NULL", __func__));
179
180 LLTABLE_WLOCK();
181 SLIST_REMOVE(&V_lltables, llt, lltable, llt_link);
182 LLTABLE_WUNLOCK();
183
184 IF_AFDATA_WLOCK(llt->llt_ifp);
176 for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) {
177 LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) {
185 for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) {
186 LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) {
178 int canceled;
179
180 canceled = callout_drain(&lle->la_timer);
181 LLE_WLOCK(lle);
187 LLE_WLOCK(lle);
182 if (canceled)
188 if (callout_stop(&lle->la_timer))
183 LLE_REMREF(lle);
184 llentry_free(lle);
185 }
186 }
189 LLE_REMREF(lle);
190 llentry_free(lle);
191 }
192 }
193 IF_AFDATA_WUNLOCK(llt->llt_ifp);
187
188 free(llt, M_LLTABLE);
189}
190
191#if 0
192void
193lltable_drain(int af)
194{

--- 339 unchanged lines hidden ---
194
195 free(llt, M_LLTABLE);
196}
197
198#if 0
199void
200lltable_drain(int af)
201{

--- 339 unchanged lines hidden ---