Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/nd6.h
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#define ND_IFINFO(ifp) \ | #define ND_IFINFO(ifp) \ | ||||
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo) | (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo) | ||||
#define IN6_LINKMTU(ifp) \ | #define IN6_LINKMTU(ifp) \ | ||||
((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \ | ((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \ | ||||
? ND_IFINFO(ifp)->linkmtu \ | ? ND_IFINFO(ifp)->linkmtu \ | ||||
: ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \ | : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \ | ||||
? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)) | ? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)) | ||||
static inline struct nd_ifinfo * | |||||
nd6_ifinfo(struct ifnet *ifp) | |||||
{ | |||||
if (ifp != NULL && (ifp->if_flags & IFF_DYING) == 0 && | |||||
ifp->if_afdata[AF_INET6] != NULL) | |||||
return (ND_IFINFO(ifp)); | |||||
melifaro: There are no guarantees that the code in the other thread will not set `IFF_DYING` immediately… | |||||
markjUnsubmitted Not Done Inline ActionsFor good measure I would use atomic_load_ptr() as well, to prevent the compiler from loading the pointer multiple times and possibly circumventing the NULL checks. markj: For good measure I would use atomic_load_ptr() as well, to prevent the compiler from loading… | |||||
mjgUnsubmitted Not Done Inline ActionsA minor note is that I would add predict false for the thing being NULL on top. mjg: A minor note is that I would add predict false for the thing being NULL on top. | |||||
return (NULL); | |||||
} | |||||
#endif | #endif | ||||
struct in6_nbrinfo { | struct in6_nbrinfo { | ||||
char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ | char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ | ||||
struct in6_addr addr; /* IPv6 address of the neighbor */ | struct in6_addr addr; /* IPv6 address of the neighbor */ | ||||
long asked; /* number of queries already sent for this addr */ | long asked; /* number of queries already sent for this addr */ | ||||
int isrouter; /* if it acts as a router */ | int isrouter; /* if it acts as a router */ | ||||
int state; /* reachability state */ | int state; /* reachability state */ | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |
There are no guarantees that the code in the other thread will not set IFF_DYING immediately after checking. The same goes with afdata check.
I'd rather do the following: