Deleted Added
full compact
if_llatbl.c (230598) if_llatbl.c (238945)
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 230598 2012-01-26 20:02:40Z kmacy $");
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.c 238945 2012-07-31 11:31:12Z 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>

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

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
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>

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

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__,
121 KASSERT(lle->la_numheld == 0,
122 ("%s: la_numheld %d > 0, pkts_droped %zd", __func__,
123 lle->la_numheld, pkts_dropped));
124
125 lle->la_flags &= ~LLE_VALID;
126 LLE_FREE_LOCKED(lle);
127
128 return (pkts_dropped);
129}
130

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

139 struct sockaddr_storage *dst, struct ifnet *ifp)
140{
141 struct llentry *la;
142
143 IF_AFDATA_RLOCK(ifp);
144 la = lla_lookup(lt, LLE_EXCLUSIVE,
145 (struct sockaddr *)dst);
146 IF_AFDATA_RUNLOCK(ifp);
123 lle->la_numheld, pkts_dropped));
124
125 lle->la_flags &= ~LLE_VALID;
126 LLE_FREE_LOCKED(lle);
127
128 return (pkts_dropped);
129}
130

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

139 struct sockaddr_storage *dst, struct ifnet *ifp)
140{
141 struct llentry *la;
142
143 IF_AFDATA_RLOCK(ifp);
144 la = lla_lookup(lt, LLE_EXCLUSIVE,
145 (struct sockaddr *)dst);
146 IF_AFDATA_RUNLOCK(ifp);
147 if ((la == NULL) &&
147 if ((la == NULL) &&
148 (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) {
149 IF_AFDATA_WLOCK(ifp);
150 la = lla_lookup(lt,
151 (LLE_CREATE | LLE_EXCLUSIVE),
152 (struct sockaddr *)dst);
153 IF_AFDATA_WUNLOCK(ifp);
154 }
155 if (la != NULL && (*llep != la)) {

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

177 int i;
178
179 KASSERT(llt != NULL, ("%s: llt is NULL", __func__));
180
181 LLTABLE_WLOCK();
182 SLIST_REMOVE(&V_lltables, llt, lltable, llt_link);
183 LLTABLE_WUNLOCK();
184
148 (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) {
149 IF_AFDATA_WLOCK(ifp);
150 la = lla_lookup(lt,
151 (LLE_CREATE | LLE_EXCLUSIVE),
152 (struct sockaddr *)dst);
153 IF_AFDATA_WUNLOCK(ifp);
154 }
155 if (la != NULL && (*llep != la)) {

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

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

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

222 }
223 }
224 LLTABLE_RUNLOCK();
225}
226#endif
227
228void
229lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask,
186 LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) {
187 int canceled;
188
189 canceled = callout_drain(&lle->la_timer);
190 LLE_WLOCK(lle);
191 if (canceled)
192 LLE_REMREF(lle);
193 llentry_free(lle);

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

222 }
223 }
224 LLTABLE_RUNLOCK();
225}
226#endif
227
228void
229lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask,
230 u_int flags)
230 u_int flags)
231{
232 struct lltable *llt;
233
234 LLTABLE_RLOCK();
235 SLIST_FOREACH(llt, &V_lltables, llt_link) {
236 if (llt->llt_af != af)
237 continue;
238

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

292 return EINVAL;
293 }
294
295 switch (rtm->rtm_type) {
296 case RTM_ADD:
297 if (rtm->rtm_flags & RTF_ANNOUNCE) {
298 flags |= LLE_PUB;
299#ifdef INET
231{
232 struct lltable *llt;
233
234 LLTABLE_RLOCK();
235 SLIST_FOREACH(llt, &V_lltables, llt_link) {
236 if (llt->llt_af != af)
237 continue;
238

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

292 return EINVAL;
293 }
294
295 switch (rtm->rtm_type) {
296 case RTM_ADD:
297 if (rtm->rtm_flags & RTF_ANNOUNCE) {
298 flags |= LLE_PUB;
299#ifdef INET
300 if (dst->sa_family == AF_INET &&
300 if (dst->sa_family == AF_INET &&
301 ((struct sockaddr_inarp *)dst)->sin_other != 0) {
302 struct rtentry *rt;
303 ((struct sockaddr_inarp *)dst)->sin_other = 0;
304 rt = rtalloc1(dst, 0, 0);
305 if (rt == NULL || !(rt->rt_flags & RTF_HOST)) {
306 log(LOG_INFO, "%s: RTM_ADD publish "
307 "(proxy only) is invalid\n",
308 __func__);

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

373 lle->la_expire = 0;
374 } else
375 lle->la_expire = rtm->rtm_rmx.rmx_expire;
376 laflags = lle->la_flags;
377 LLE_WUNLOCK(lle);
378#ifdef INET
379 /* gratuitous ARP */
380 if ((laflags & LLE_PUB) && dst->sa_family == AF_INET) {
301 ((struct sockaddr_inarp *)dst)->sin_other != 0) {
302 struct rtentry *rt;
303 ((struct sockaddr_inarp *)dst)->sin_other = 0;
304 rt = rtalloc1(dst, 0, 0);
305 if (rt == NULL || !(rt->rt_flags & RTF_HOST)) {
306 log(LOG_INFO, "%s: RTM_ADD publish "
307 "(proxy only) is invalid\n",
308 __func__);

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

373 lle->la_expire = 0;
374 } else
375 lle->la_expire = rtm->rtm_rmx.rmx_expire;
376 laflags = lle->la_flags;
377 LLE_WUNLOCK(lle);
378#ifdef INET
379 /* gratuitous ARP */
380 if ((laflags & LLE_PUB) && dst->sa_family == AF_INET) {
381 arprequest(ifp,
381 arprequest(ifp,
382 &((struct sockaddr_in *)dst)->sin_addr,
383 &((struct sockaddr_in *)dst)->sin_addr,
384 ((laflags & LLE_PROXY) ?
385 (u_char *)IF_LLADDR(ifp) :
386 (u_char *)LLADDR(dl)));
387 }
388#endif
389 } else {

--- 153 unchanged lines hidden ---
382 &((struct sockaddr_in *)dst)->sin_addr,
383 &((struct sockaddr_in *)dst)->sin_addr,
384 ((laflags & LLE_PROXY) ?
385 (u_char *)IF_LLADDR(ifp) :
386 (u_char *)LLADDR(dl)));
387 }
388#endif
389 } else {

--- 153 unchanged lines hidden ---