Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _NET_NEIGHBOUR_H |
| 2 | #define _NET_NEIGHBOUR_H |
| 3 | |
Thomas Graf | 9067c72 | 2006-08-07 17:57:44 -0700 | [diff] [blame] | 4 | #include <linux/neighbour.h> |
| 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | /* |
| 7 | * Generic neighbour manipulation |
| 8 | * |
| 9 | * Authors: |
| 10 | * Pedro Roque <roque@di.fc.ul.pt> |
| 11 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
| 12 | * |
| 13 | * Changes: |
| 14 | * |
| 15 | * Harald Welte: <laforge@gnumonks.org> |
| 16 | * - Add neighbour cache statistics like rtstat |
| 17 | */ |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/netdevice.h> |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 21 | #include <linux/skbuff.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/rcupdate.h> |
| 23 | #include <linux/seq_file.h> |
| 24 | |
| 25 | #include <linux/err.h> |
| 26 | #include <linux/sysctl.h> |
Eric Dumazet | e4c4e44 | 2009-07-30 03:15:07 +0000 | [diff] [blame] | 27 | #include <linux/workqueue.h> |
Thomas Graf | c8822a4 | 2007-03-22 11:50:06 -0700 | [diff] [blame] | 28 | #include <net/rtnetlink.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Pavel Emelyanov | 3997155 | 2008-01-10 22:37:16 -0800 | [diff] [blame] | 30 | /* |
| 31 | * NUD stands for "neighbor unreachability detection" |
| 32 | */ |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE) |
| 35 | #define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY) |
| 36 | #define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE) |
| 37 | |
| 38 | struct neighbour; |
| 39 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 40 | struct neigh_parms { |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 41 | #ifdef CONFIG_NET_NS |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 42 | struct net *net; |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 43 | #endif |
Thomas Graf | c7fb64d | 2005-06-18 22:50:55 -0700 | [diff] [blame] | 44 | struct net_device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | struct neigh_parms *next; |
| 46 | int (*neigh_setup)(struct neighbour *); |
Alexey Kuznetsov | ecbb416 | 2007-03-24 12:52:16 -0700 | [diff] [blame] | 47 | void (*neigh_cleanup)(struct neighbour *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | struct neigh_table *tbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | void *sysctl_table; |
| 51 | |
| 52 | int dead; |
| 53 | atomic_t refcnt; |
| 54 | struct rcu_head rcu_head; |
| 55 | |
| 56 | int base_reachable_time; |
| 57 | int retrans_time; |
| 58 | int gc_staletime; |
| 59 | int reachable_time; |
| 60 | int delay_probe_time; |
| 61 | |
| 62 | int queue_len; |
| 63 | int ucast_probes; |
| 64 | int app_probes; |
| 65 | int mcast_probes; |
| 66 | int anycast_delay; |
| 67 | int proxy_delay; |
| 68 | int proxy_qlen; |
| 69 | int locktime; |
| 70 | }; |
| 71 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 72 | struct neigh_statistics { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | unsigned long allocs; /* number of allocated neighs */ |
| 74 | unsigned long destroys; /* number of destroyed neighs */ |
| 75 | unsigned long hash_grows; /* number of hash resizes */ |
| 76 | |
Neil Horman | 9a6d276 | 2008-07-16 20:50:49 -0700 | [diff] [blame] | 77 | unsigned long res_failed; /* number of failed resolutions */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | unsigned long lookups; /* number of lookups */ |
| 80 | unsigned long hits; /* number of hits (among lookups) */ |
| 81 | |
| 82 | unsigned long rcv_probes_mcast; /* number of received mcast ipv6 */ |
| 83 | unsigned long rcv_probes_ucast; /* number of received ucast ipv6 */ |
| 84 | |
| 85 | unsigned long periodic_gc_runs; /* number of periodic GC runs */ |
| 86 | unsigned long forced_gc_runs; /* number of forced GC runs */ |
Neil Horman | 9a6d276 | 2008-07-16 20:50:49 -0700 | [diff] [blame] | 87 | |
| 88 | unsigned long unres_discards; /* number of unresolved drops */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Christoph Lameter | 4ea7334 | 2009-10-03 19:48:22 +0900 | [diff] [blame] | 91 | #define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 93 | struct neighbour { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | struct neighbour *next; |
| 95 | struct neigh_table *tbl; |
| 96 | struct neigh_parms *parms; |
| 97 | struct net_device *dev; |
| 98 | unsigned long used; |
| 99 | unsigned long confirmed; |
| 100 | unsigned long updated; |
| 101 | __u8 flags; |
| 102 | __u8 nud_state; |
| 103 | __u8 type; |
| 104 | __u8 dead; |
| 105 | atomic_t probes; |
| 106 | rwlock_t lock; |
Stephen Hemminger | d924424 | 2006-08-10 23:03:23 -0700 | [diff] [blame] | 107 | unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | struct hh_cache *hh; |
| 109 | atomic_t refcnt; |
| 110 | int (*output)(struct sk_buff *skb); |
| 111 | struct sk_buff_head arp_queue; |
| 112 | struct timer_list timer; |
Stephen Hemminger | 89d69d2 | 2009-09-01 11:13:19 +0000 | [diff] [blame] | 113 | const struct neigh_ops *ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | u8 primary_key[0]; |
| 115 | }; |
| 116 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 117 | struct neigh_ops { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | int family; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | void (*solicit)(struct neighbour *, struct sk_buff*); |
| 120 | void (*error_report)(struct neighbour *, struct sk_buff*); |
| 121 | int (*output)(struct sk_buff*); |
| 122 | int (*connected_output)(struct sk_buff*); |
| 123 | int (*hh_output)(struct sk_buff*); |
| 124 | int (*queue_xmit)(struct sk_buff*); |
| 125 | }; |
| 126 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 127 | struct pneigh_entry { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | struct pneigh_entry *next; |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 129 | #ifdef CONFIG_NET_NS |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 130 | struct net *net; |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 131 | #endif |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 132 | struct net_device *dev; |
Ville Nuorvala | 62dd931 | 2006-09-22 14:43:19 -0700 | [diff] [blame] | 133 | u8 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | u8 key[0]; |
| 135 | }; |
| 136 | |
| 137 | /* |
| 138 | * neighbour table manipulation |
| 139 | */ |
| 140 | |
| 141 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 142 | struct neigh_table { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | struct neigh_table *next; |
| 144 | int family; |
| 145 | int entry_size; |
| 146 | int key_len; |
| 147 | __u32 (*hash)(const void *pkey, const struct net_device *); |
| 148 | int (*constructor)(struct neighbour *); |
| 149 | int (*pconstructor)(struct pneigh_entry *); |
| 150 | void (*pdestructor)(struct pneigh_entry *); |
| 151 | void (*proxy_redo)(struct sk_buff *skb); |
| 152 | char *id; |
| 153 | struct neigh_parms parms; |
Kulikov Vasiliy | 787a344 | 2010-06-30 06:08:15 +0000 | [diff] [blame] | 154 | /* HACK. gc_* should follow parms without a gap! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | int gc_interval; |
| 156 | int gc_thresh1; |
| 157 | int gc_thresh2; |
| 158 | int gc_thresh3; |
| 159 | unsigned long last_flush; |
Eric Dumazet | e4c4e44 | 2009-07-30 03:15:07 +0000 | [diff] [blame] | 160 | struct delayed_work gc_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | struct timer_list proxy_timer; |
| 162 | struct sk_buff_head proxy_queue; |
| 163 | atomic_t entries; |
| 164 | rwlock_t lock; |
| 165 | unsigned long last_rand; |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 166 | struct kmem_cache *kmem_cachep; |
Tejun Heo | 7d720c3 | 2010-02-16 15:20:26 +0000 | [diff] [blame] | 167 | struct neigh_statistics __percpu *stats; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | struct neighbour **hash_buckets; |
| 169 | unsigned int hash_mask; |
| 170 | __u32 hash_rnd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | struct pneigh_entry **phash_buckets; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | /* flags for neigh_update() */ |
| 175 | #define NEIGH_UPDATE_F_OVERRIDE 0x00000001 |
| 176 | #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002 |
| 177 | #define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004 |
| 178 | #define NEIGH_UPDATE_F_ISROUTER 0x40000000 |
| 179 | #define NEIGH_UPDATE_F_ADMIN 0x80000000 |
| 180 | |
| 181 | extern void neigh_table_init(struct neigh_table *tbl); |
Simon Kelley | bd89efc | 2006-05-12 14:56:08 -0700 | [diff] [blame] | 182 | extern void neigh_table_init_no_netlink(struct neigh_table *tbl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | extern int neigh_table_clear(struct neigh_table *tbl); |
| 184 | extern struct neighbour * neigh_lookup(struct neigh_table *tbl, |
| 185 | const void *pkey, |
| 186 | struct net_device *dev); |
| 187 | extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 188 | struct net *net, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | const void *pkey); |
| 190 | extern struct neighbour * neigh_create(struct neigh_table *tbl, |
| 191 | const void *pkey, |
| 192 | struct net_device *dev); |
| 193 | extern void neigh_destroy(struct neighbour *neigh); |
| 194 | extern int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb); |
| 195 | extern int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, |
| 196 | u32 flags); |
| 197 | extern void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev); |
| 198 | extern int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev); |
| 199 | extern int neigh_resolve_output(struct sk_buff *skb); |
| 200 | extern int neigh_connected_output(struct sk_buff *skb); |
| 201 | extern int neigh_compat_output(struct sk_buff *skb); |
| 202 | extern struct neighbour *neigh_event_ns(struct neigh_table *tbl, |
| 203 | u8 *lladdr, void *saddr, |
| 204 | struct net_device *dev); |
| 205 | |
| 206 | extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); |
| 207 | extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 208 | |
| 209 | static inline |
| 210 | struct net *neigh_parms_net(const struct neigh_parms *parms) |
| 211 | { |
Eric Dumazet | e42ea98 | 2008-11-12 00:54:54 -0800 | [diff] [blame] | 212 | return read_pnet(&parms->net); |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 213 | } |
| 214 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | extern unsigned long neigh_rand_reach_time(unsigned long base); |
| 216 | |
| 217 | extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, |
| 218 | struct sk_buff *skb); |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 219 | extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat); |
Pavel Emelyanov | fa86d32 | 2008-03-24 14:48:59 -0700 | [diff] [blame] | 220 | extern struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl, |
| 221 | struct net *net, |
| 222 | const void *key, |
| 223 | struct net_device *dev); |
Eric W. Biederman | 426b530 | 2008-01-24 00:13:18 -0800 | [diff] [blame] | 224 | extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 226 | static inline |
| 227 | struct net *pneigh_net(const struct pneigh_entry *pneigh) |
| 228 | { |
Eric Dumazet | e42ea98 | 2008-11-12 00:54:54 -0800 | [diff] [blame] | 229 | return read_pnet(&pneigh->net); |
YOSHIFUJI Hideaki | 57da52c | 2008-03-26 03:49:59 +0900 | [diff] [blame] | 230 | } |
| 231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | extern void neigh_app_ns(struct neighbour *n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); |
| 234 | extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)); |
| 235 | extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *)); |
| 236 | |
| 237 | struct neigh_seq_state { |
Denis V. Lunev | 4250846 | 2008-01-10 03:53:12 -0800 | [diff] [blame] | 238 | struct seq_net_private p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | struct neigh_table *tbl; |
| 240 | void *(*neigh_sub_iter)(struct neigh_seq_state *state, |
| 241 | struct neighbour *n, loff_t *pos); |
| 242 | unsigned int bucket; |
| 243 | unsigned int flags; |
| 244 | #define NEIGH_SEQ_NEIGH_ONLY 0x00000001 |
| 245 | #define NEIGH_SEQ_IS_PNEIGH 0x00000002 |
| 246 | #define NEIGH_SEQ_SKIP_NOARP 0x00000004 |
| 247 | }; |
| 248 | extern void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *, unsigned int); |
| 249 | extern void *neigh_seq_next(struct seq_file *, void *, loff_t *); |
| 250 | extern void neigh_seq_stop(struct seq_file *, void *); |
| 251 | |
| 252 | extern int neigh_sysctl_register(struct net_device *dev, |
| 253 | struct neigh_parms *p, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | char *p_name, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 255 | proc_handler *proc_handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | extern void neigh_sysctl_unregister(struct neigh_parms *p); |
| 257 | |
| 258 | static inline void __neigh_parms_put(struct neigh_parms *parms) |
| 259 | { |
| 260 | atomic_dec(&parms->refcnt); |
| 261 | } |
| 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) |
| 264 | { |
| 265 | atomic_inc(&parms->refcnt); |
| 266 | return parms; |
| 267 | } |
| 268 | |
| 269 | /* |
| 270 | * Neighbour references |
| 271 | */ |
| 272 | |
| 273 | static inline void neigh_release(struct neighbour *neigh) |
| 274 | { |
| 275 | if (atomic_dec_and_test(&neigh->refcnt)) |
| 276 | neigh_destroy(neigh); |
| 277 | } |
| 278 | |
| 279 | static inline struct neighbour * neigh_clone(struct neighbour *neigh) |
| 280 | { |
| 281 | if (neigh) |
| 282 | atomic_inc(&neigh->refcnt); |
| 283 | return neigh; |
| 284 | } |
| 285 | |
| 286 | #define neigh_hold(n) atomic_inc(&(n)->refcnt) |
| 287 | |
| 288 | static inline void neigh_confirm(struct neighbour *neigh) |
| 289 | { |
| 290 | if (neigh) |
| 291 | neigh->confirmed = jiffies; |
| 292 | } |
| 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) |
| 295 | { |
| 296 | neigh->used = jiffies; |
| 297 | if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) |
| 298 | return __neigh_event_send(neigh, skb); |
| 299 | return 0; |
| 300 | } |
| 301 | |
Bart De Schuymer | e179e63 | 2010-04-15 12:26:39 +0200 | [diff] [blame] | 302 | #ifdef CONFIG_BRIDGE_NETFILTER |
| 303 | static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb) |
| 304 | { |
| 305 | unsigned seq, hh_alen; |
| 306 | |
| 307 | do { |
| 308 | seq = read_seqbegin(&hh->hh_lock); |
| 309 | hh_alen = HH_DATA_ALIGN(ETH_HLEN); |
| 310 | memcpy(skb->data - hh_alen, hh->hh_data, ETH_ALEN + hh_alen - ETH_HLEN); |
| 311 | } while (read_seqretry(&hh->hh_lock, seq)); |
| 312 | return 0; |
| 313 | } |
| 314 | #endif |
| 315 | |
Stephen Hemminger | 3644f0c | 2006-12-07 15:08:17 -0800 | [diff] [blame] | 316 | static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb) |
| 317 | { |
| 318 | unsigned seq; |
| 319 | int hh_len; |
| 320 | |
| 321 | do { |
| 322 | int hh_alen; |
| 323 | |
| 324 | seq = read_seqbegin(&hh->hh_lock); |
| 325 | hh_len = hh->hh_len; |
| 326 | hh_alen = HH_DATA_ALIGN(hh_len); |
| 327 | memcpy(skb->data - hh_alen, hh->hh_data, hh_alen); |
| 328 | } while (read_seqretry(&hh->hh_lock, seq)); |
| 329 | |
| 330 | skb_push(skb, hh_len); |
| 331 | return hh->hh_output(skb); |
| 332 | } |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | static inline struct neighbour * |
| 335 | __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat) |
| 336 | { |
| 337 | struct neighbour *n = neigh_lookup(tbl, pkey, dev); |
| 338 | |
| 339 | if (n || !creat) |
| 340 | return n; |
| 341 | |
| 342 | n = neigh_create(tbl, pkey, dev); |
| 343 | return IS_ERR(n) ? NULL : n; |
| 344 | } |
| 345 | |
| 346 | static inline struct neighbour * |
| 347 | __neigh_lookup_errno(struct neigh_table *tbl, const void *pkey, |
| 348 | struct net_device *dev) |
| 349 | { |
| 350 | struct neighbour *n = neigh_lookup(tbl, pkey, dev); |
| 351 | |
| 352 | if (n) |
| 353 | return n; |
| 354 | |
| 355 | return neigh_create(tbl, pkey, dev); |
| 356 | } |
| 357 | |
Patrick McHardy | a61bbcf | 2005-08-14 17:24:31 -0700 | [diff] [blame] | 358 | struct neighbour_cb { |
| 359 | unsigned long sched_next; |
| 360 | unsigned int flags; |
| 361 | }; |
| 362 | |
| 363 | #define LOCALLY_ENQUEUED 0x1 |
| 364 | |
| 365 | #define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | #endif |