if_ether.c (238967) | if_ether.c (238990) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 32/* 33 * Ethernet address resolution protocol. 34 * TODO: 35 * add "inuse/lock" bit (or ref. count) along with valid bit 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 32/* 33 * Ethernet address resolution protocol. 34 * TODO: 35 * add "inuse/lock" bit (or ref. count) along with valid bit 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/netinet/if_ether.c 238967 2012-08-01 09:00:26Z glebius $"); | 39__FBSDID("$FreeBSD: head/sys/netinet/if_ether.c 238990 2012-08-02 13:57:49Z glebius $"); |
40 41#include "opt_inet.h" 42 43#include <sys/param.h> 44#include <sys/kernel.h> 45#include <sys/queue.h> 46#include <sys/sysctl.h> 47#include <sys/systm.h> --- 110 unchanged lines hidden (view full) --- 158#endif 159 160/* 161 * Timeout routine. Age arp_tab entries periodically. 162 */ 163static void 164arptimer(void *arg) 165{ | 40 41#include "opt_inet.h" 42 43#include <sys/param.h> 44#include <sys/kernel.h> 45#include <sys/queue.h> 46#include <sys/sysctl.h> 47#include <sys/systm.h> --- 110 unchanged lines hidden (view full) --- 158#endif 159 160/* 161 * Timeout routine. Age arp_tab entries periodically. 162 */ 163static void 164arptimer(void *arg) 165{ |
166 struct llentry *lle = (struct llentry *)arg; |
|
166 struct ifnet *ifp; | 167 struct ifnet *ifp; |
167 struct llentry *lle; 168 int pkts_dropped; | 168 size_t pkts_dropped; |
169 | 169 |
170 KASSERT(arg != NULL, ("%s: arg NULL", __func__)); 171 lle = (struct llentry *)arg; | 170 if (lle->la_flags & LLE_STATIC) { 171 LLE_WUNLOCK(lle); 172 return; 173 } 174 |
172 ifp = lle->lle_tbl->llt_ifp; 173 CURVNET_SET(ifp->if_vnet); | 175 ifp = lle->lle_tbl->llt_ifp; 176 CURVNET_SET(ifp->if_vnet); |
174 IF_AFDATA_LOCK(ifp); 175 LLE_WLOCK(lle); 176 if (lle->la_flags & LLE_STATIC) 177 LLE_WUNLOCK(lle); 178 else { 179 if (!callout_pending(&lle->la_timer) && 180 callout_active(&lle->la_timer)) { 181 callout_stop(&lle->la_timer); 182 LLE_REMREF(lle); | |
183 | 177 |
184 if (lle->la_flags != LLE_DELETED) { 185 int evt; | 178 if (lle->la_flags != LLE_DELETED) { 179 int evt; |
186 | 180 |
187 if (lle->la_flags & LLE_VALID) 188 evt = LLENTRY_EXPIRED; 189 else 190 evt = LLENTRY_TIMEDOUT; 191 EVENTHANDLER_INVOKE(lle_event, lle, evt); 192 } 193 194 pkts_dropped = llentry_free(lle); 195 ARPSTAT_ADD(dropped, pkts_dropped); 196 ARPSTAT_INC(timeouts); 197 } else { 198#ifdef DIAGNOSTIC 199 struct sockaddr *l3addr = L3_ADDR(lle); 200 log(LOG_INFO, 201 "arptimer issue: %p, IPv4 address: \"%s\"\n", lle, 202 inet_ntoa( 203 ((const struct sockaddr_in *)l3addr)->sin_addr)); 204#endif 205 LLE_WUNLOCK(lle); 206 } | 181 if (lle->la_flags & LLE_VALID) 182 evt = LLENTRY_EXPIRED; 183 else 184 evt = LLENTRY_TIMEDOUT; 185 EVENTHANDLER_INVOKE(lle_event, lle, evt); |
207 } | 186 } |
187 188 callout_stop(&lle->la_timer); 189 190 /* XXX: LOR avoidance. We still have ref on lle. */ 191 LLE_WUNLOCK(lle); 192 IF_AFDATA_LOCK(ifp); 193 LLE_WLOCK(lle); 194 195 LLE_REMREF(lle); 196 pkts_dropped = llentry_free(lle); |
|
208 IF_AFDATA_UNLOCK(ifp); | 197 IF_AFDATA_UNLOCK(ifp); |
198 ARPSTAT_ADD(dropped, pkts_dropped); 199 ARPSTAT_INC(timeouts); |
|
209 CURVNET_RESTORE(); 210} 211 212/* 213 * Broadcast an ARP request. Caller specifies: 214 * - arp header source ip address 215 * - arp header target ip address 216 * - arp header source ethernet address --- 713 unchanged lines hidden --- | 200 CURVNET_RESTORE(); 201} 202 203/* 204 * Broadcast an ARP request. Caller specifies: 205 * - arp header source ip address 206 * - arp header target ip address 207 * - arp header source ethernet address --- 713 unchanged lines hidden --- |