2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _NET_NEIGHBOUR_H
|
|
|
|
#define _NET_NEIGHBOUR_H
|
|
|
|
|
2006-08-08 07:57:44 +07:00
|
|
|
#include <linux/neighbour.h>
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Generic neighbour manipulation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Pedro Roque <roque@di.fc.ul.pt>
|
|
|
|
* Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
*
|
|
|
|
* Harald Welte: <laforge@gnumonks.org>
|
|
|
|
* - Add neighbour cache statistics like rtstat
|
|
|
|
*/
|
|
|
|
|
2011-07-27 06:09:06 +07:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/netdevice.h>
|
2005-12-27 11:43:12 +07:00
|
|
|
#include <linux/skbuff.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/rcupdate.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/sysctl.h>
|
2009-07-30 10:15:07 +07:00
|
|
|
#include <linux/workqueue.h>
|
2007-03-23 01:50:06 +07:00
|
|
|
#include <net/rtnetlink.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-01-11 13:37:16 +07:00
|
|
|
/*
|
|
|
|
* NUD stands for "neighbor unreachability detection"
|
|
|
|
*/
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE)
|
|
|
|
#define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)
|
|
|
|
#define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE)
|
|
|
|
|
|
|
|
struct neighbour;
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct neigh_parms {
|
2008-03-26 01:49:59 +07:00
|
|
|
#ifdef CONFIG_NET_NS
|
2008-01-24 15:13:18 +07:00
|
|
|
struct net *net;
|
2008-03-26 01:49:59 +07:00
|
|
|
#endif
|
2005-06-19 12:50:55 +07:00
|
|
|
struct net_device *dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct neigh_parms *next;
|
2011-12-20 03:04:41 +07:00
|
|
|
int (*neigh_setup)(struct neighbour *);
|
2007-03-25 02:52:16 +07:00
|
|
|
void (*neigh_cleanup)(struct neighbour *);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct neigh_table *tbl;
|
|
|
|
|
|
|
|
void *sysctl_table;
|
|
|
|
|
|
|
|
int dead;
|
|
|
|
atomic_t refcnt;
|
|
|
|
struct rcu_head rcu_head;
|
|
|
|
|
|
|
|
int base_reachable_time;
|
|
|
|
int retrans_time;
|
|
|
|
int gc_staletime;
|
|
|
|
int reachable_time;
|
|
|
|
int delay_probe_time;
|
|
|
|
|
neigh: new unresolved queue limits
Le mercredi 09 novembre 2011 à 16:21 -0500, David Miller a écrit :
> From: David Miller <davem@davemloft.net>
> Date: Wed, 09 Nov 2011 16:16:44 -0500 (EST)
>
> > From: Eric Dumazet <eric.dumazet@gmail.com>
> > Date: Wed, 09 Nov 2011 12:14:09 +0100
> >
> >> unres_qlen is the number of frames we are able to queue per unresolved
> >> neighbour. Its default value (3) was never changed and is responsible
> >> for strange drops, especially if IP fragments are used, or multiple
> >> sessions start in parallel. Even a single tcp flow can hit this limit.
> > ...
> >
> > Ok, I've applied this, let's see what happens :-)
>
> Early answer, build fails.
>
> Please test build this patch with DECNET enabled and resubmit. The
> decnet neigh layer still refers to the removed ->queue_len member.
>
> Thanks.
Ouch, this was fixed on one machine yesterday, but not the other one I
used this morning, sorry.
[PATCH V5 net-next] neigh: new unresolved queue limits
unres_qlen is the number of frames we are able to queue per unresolved
neighbour. Its default value (3) was never changed and is responsible
for strange drops, especially if IP fragments are used, or multiple
sessions start in parallel. Even a single tcp flow can hit this limit.
$ arp -d 192.168.20.108 ; ping -c 2 -s 8000 192.168.20.108
PING 192.168.20.108 (192.168.20.108) 8000(8028) bytes of data.
8008 bytes from 192.168.20.108: icmp_seq=2 ttl=64 time=0.322 ms
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-11-09 19:07:14 +07:00
|
|
|
int queue_len_bytes;
|
2005-04-17 05:20:36 +07:00
|
|
|
int ucast_probes;
|
|
|
|
int app_probes;
|
|
|
|
int mcast_probes;
|
|
|
|
int anycast_delay;
|
|
|
|
int proxy_delay;
|
|
|
|
int proxy_qlen;
|
|
|
|
int locktime;
|
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct neigh_statistics {
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long allocs; /* number of allocated neighs */
|
|
|
|
unsigned long destroys; /* number of destroyed neighs */
|
|
|
|
unsigned long hash_grows; /* number of hash resizes */
|
|
|
|
|
2008-07-17 10:50:49 +07:00
|
|
|
unsigned long res_failed; /* number of failed resolutions */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
unsigned long lookups; /* number of lookups */
|
|
|
|
unsigned long hits; /* number of hits (among lookups) */
|
|
|
|
|
|
|
|
unsigned long rcv_probes_mcast; /* number of received mcast ipv6 */
|
|
|
|
unsigned long rcv_probes_ucast; /* number of received ucast ipv6 */
|
|
|
|
|
|
|
|
unsigned long periodic_gc_runs; /* number of periodic GC runs */
|
|
|
|
unsigned long forced_gc_runs; /* number of forced GC runs */
|
2008-07-17 10:50:49 +07:00
|
|
|
|
|
|
|
unsigned long unres_discards; /* number of unresolved drops */
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2009-10-03 17:48:22 +07:00
|
|
|
#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct neighbour {
|
2010-10-07 07:49:21 +07:00
|
|
|
struct neighbour __rcu *next;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct neigh_table *tbl;
|
|
|
|
struct neigh_parms *parms;
|
|
|
|
unsigned long confirmed;
|
|
|
|
unsigned long updated;
|
2010-11-11 13:57:19 +07:00
|
|
|
rwlock_t lock;
|
2010-09-30 12:36:29 +07:00
|
|
|
atomic_t refcnt;
|
neigh: reorder struct neighbour fields
Le mardi 12 octobre 2010 à 00:02 +0200, Eric Dumazet a écrit :
> Here is the followup patch.
>
> Thanks !
>
Oops, this was an old version, the up2date ones also took care of "used"
field.
I guess its time for a sleep, sorry again.
[PATCH net-next V2] neigh: reorder struct neighbour fields
(refcnt) and (ha_lock, ha, used, dev, output, ops, primary_key) should
be placed on a separate cache lines.
refcnt can be often written, while other fields are mostly read.
This gave me good result on stress test :
before:
real 0m45.570s
user 0m15.525s
sys 9m56.669s
After:
real 0m41.841s
user 0m15.261s
sys 8m45.949s
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-11 19:20:54 +07:00
|
|
|
struct sk_buff_head arp_queue;
|
neigh: new unresolved queue limits
Le mercredi 09 novembre 2011 à 16:21 -0500, David Miller a écrit :
> From: David Miller <davem@davemloft.net>
> Date: Wed, 09 Nov 2011 16:16:44 -0500 (EST)
>
> > From: Eric Dumazet <eric.dumazet@gmail.com>
> > Date: Wed, 09 Nov 2011 12:14:09 +0100
> >
> >> unres_qlen is the number of frames we are able to queue per unresolved
> >> neighbour. Its default value (3) was never changed and is responsible
> >> for strange drops, especially if IP fragments are used, or multiple
> >> sessions start in parallel. Even a single tcp flow can hit this limit.
> > ...
> >
> > Ok, I've applied this, let's see what happens :-)
>
> Early answer, build fails.
>
> Please test build this patch with DECNET enabled and resubmit. The
> decnet neigh layer still refers to the removed ->queue_len member.
>
> Thanks.
Ouch, this was fixed on one machine yesterday, but not the other one I
used this morning, sorry.
[PATCH V5 net-next] neigh: new unresolved queue limits
unres_qlen is the number of frames we are able to queue per unresolved
neighbour. Its default value (3) was never changed and is responsible
for strange drops, especially if IP fragments are used, or multiple
sessions start in parallel. Even a single tcp flow can hit this limit.
$ arp -d 192.168.20.108 ; ping -c 2 -s 8000 192.168.20.108
PING 192.168.20.108 (192.168.20.108) 8000(8028) bytes of data.
8008 bytes from 192.168.20.108: icmp_seq=2 ttl=64 time=0.322 ms
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-11-09 19:07:14 +07:00
|
|
|
unsigned int arp_queue_len_bytes;
|
neigh: reorder struct neighbour fields
Le mardi 12 octobre 2010 à 00:02 +0200, Eric Dumazet a écrit :
> Here is the followup patch.
>
> Thanks !
>
Oops, this was an old version, the up2date ones also took care of "used"
field.
I guess its time for a sleep, sorry again.
[PATCH net-next V2] neigh: reorder struct neighbour fields
(refcnt) and (ha_lock, ha, used, dev, output, ops, primary_key) should
be placed on a separate cache lines.
refcnt can be often written, while other fields are mostly read.
This gave me good result on stress test :
before:
real 0m45.570s
user 0m15.525s
sys 9m56.669s
After:
real 0m41.841s
user 0m15.261s
sys 8m45.949s
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-11 19:20:54 +07:00
|
|
|
struct timer_list timer;
|
|
|
|
unsigned long used;
|
2005-04-17 05:20:36 +07:00
|
|
|
atomic_t probes;
|
2010-11-11 13:57:19 +07:00
|
|
|
__u8 flags;
|
|
|
|
__u8 nud_state;
|
|
|
|
__u8 type;
|
|
|
|
__u8 dead;
|
2010-10-07 17:44:07 +07:00
|
|
|
seqlock_t ha_lock;
|
2006-08-11 13:03:23 +07:00
|
|
|
unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))];
|
2011-07-14 21:53:20 +07:00
|
|
|
struct hh_cache hh;
|
2011-07-18 03:34:11 +07:00
|
|
|
int (*output)(struct neighbour *, struct sk_buff *);
|
2009-09-01 18:13:19 +07:00
|
|
|
const struct neigh_ops *ops;
|
2010-10-07 07:49:21 +07:00
|
|
|
struct rcu_head rcu;
|
neigh: reorder struct neighbour fields
Le mardi 12 octobre 2010 à 00:02 +0200, Eric Dumazet a écrit :
> Here is the followup patch.
>
> Thanks !
>
Oops, this was an old version, the up2date ones also took care of "used"
field.
I guess its time for a sleep, sorry again.
[PATCH net-next V2] neigh: reorder struct neighbour fields
(refcnt) and (ha_lock, ha, used, dev, output, ops, primary_key) should
be placed on a separate cache lines.
refcnt can be often written, while other fields are mostly read.
This gave me good result on stress test :
before:
real 0m45.570s
user 0m15.525s
sys 9m56.669s
After:
real 0m41.841s
user 0m15.261s
sys 8m45.949s
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-10-11 19:20:54 +07:00
|
|
|
struct net_device *dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
u8 primary_key[0];
|
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct neigh_ops {
|
2005-04-17 05:20:36 +07:00
|
|
|
int family;
|
2011-07-18 03:34:11 +07:00
|
|
|
void (*solicit)(struct neighbour *, struct sk_buff *);
|
|
|
|
void (*error_report)(struct neighbour *, struct sk_buff *);
|
|
|
|
int (*output)(struct neighbour *, struct sk_buff *);
|
|
|
|
int (*connected_output)(struct neighbour *, struct sk_buff *);
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct pneigh_entry {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct pneigh_entry *next;
|
2008-03-26 01:49:59 +07:00
|
|
|
#ifdef CONFIG_NET_NS
|
2008-01-24 15:13:18 +07:00
|
|
|
struct net *net;
|
2008-03-26 01:49:59 +07:00
|
|
|
#endif
|
2008-01-24 15:13:18 +07:00
|
|
|
struct net_device *dev;
|
2006-09-23 04:43:19 +07:00
|
|
|
u8 flags;
|
2005-04-17 05:20:36 +07:00
|
|
|
u8 key[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* neighbour table manipulation
|
|
|
|
*/
|
|
|
|
|
2011-12-29 03:06:58 +07:00
|
|
|
#define NEIGH_NUM_HASH_RND 4
|
|
|
|
|
2010-10-04 13:15:44 +07:00
|
|
|
struct neigh_hash_table {
|
2010-10-07 07:49:21 +07:00
|
|
|
struct neighbour __rcu **hash_buckets;
|
2011-07-11 15:28:12 +07:00
|
|
|
unsigned int hash_shift;
|
2011-12-29 03:06:58 +07:00
|
|
|
__u32 hash_rnd[NEIGH_NUM_HASH_RND];
|
2010-10-04 13:15:44 +07:00
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct neigh_table {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct neigh_table *next;
|
|
|
|
int family;
|
|
|
|
int entry_size;
|
|
|
|
int key_len;
|
2010-10-04 13:15:44 +07:00
|
|
|
__u32 (*hash)(const void *pkey,
|
|
|
|
const struct net_device *dev,
|
2011-12-29 03:06:58 +07:00
|
|
|
__u32 *hash_rnd);
|
2005-04-17 05:20:36 +07:00
|
|
|
int (*constructor)(struct neighbour *);
|
|
|
|
int (*pconstructor)(struct pneigh_entry *);
|
|
|
|
void (*pdestructor)(struct pneigh_entry *);
|
|
|
|
void (*proxy_redo)(struct sk_buff *skb);
|
|
|
|
char *id;
|
|
|
|
struct neigh_parms parms;
|
2010-06-30 13:08:15 +07:00
|
|
|
/* HACK. gc_* should follow parms without a gap! */
|
2005-04-17 05:20:36 +07:00
|
|
|
int gc_interval;
|
|
|
|
int gc_thresh1;
|
|
|
|
int gc_thresh2;
|
|
|
|
int gc_thresh3;
|
|
|
|
unsigned long last_flush;
|
2009-07-30 10:15:07 +07:00
|
|
|
struct delayed_work gc_work;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct timer_list proxy_timer;
|
|
|
|
struct sk_buff_head proxy_queue;
|
|
|
|
atomic_t entries;
|
|
|
|
rwlock_t lock;
|
|
|
|
unsigned long last_rand;
|
2010-02-16 22:20:26 +07:00
|
|
|
struct neigh_statistics __percpu *stats;
|
2010-10-04 13:15:44 +07:00
|
|
|
struct neigh_hash_table __rcu *nht;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct pneigh_entry **phash_buckets;
|
|
|
|
};
|
|
|
|
|
2011-07-25 07:01:17 +07:00
|
|
|
#define NEIGH_PRIV_ALIGN sizeof(long long)
|
2013-02-09 14:00:59 +07:00
|
|
|
#define NEIGH_ENTRY_SIZE(size) ALIGN((size), NEIGH_PRIV_ALIGN)
|
2011-07-25 07:01:17 +07:00
|
|
|
|
|
|
|
static inline void *neighbour_priv(const struct neighbour *n)
|
|
|
|
{
|
2013-01-24 07:44:23 +07:00
|
|
|
return (char *)n + n->tbl->entry_size;
|
2011-07-25 07:01:17 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* flags for neigh_update() */
|
|
|
|
#define NEIGH_UPDATE_F_OVERRIDE 0x00000001
|
|
|
|
#define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002
|
|
|
|
#define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004
|
|
|
|
#define NEIGH_UPDATE_F_ISROUTER 0x40000000
|
|
|
|
#define NEIGH_UPDATE_F_ADMIN 0x80000000
|
|
|
|
|
|
|
|
extern void neigh_table_init(struct neigh_table *tbl);
|
|
|
|
extern int neigh_table_clear(struct neigh_table *tbl);
|
|
|
|
extern struct neighbour * neigh_lookup(struct neigh_table *tbl,
|
|
|
|
const void *pkey,
|
|
|
|
struct net_device *dev);
|
|
|
|
extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl,
|
2008-01-24 15:13:18 +07:00
|
|
|
struct net *net,
|
2005-04-17 05:20:36 +07:00
|
|
|
const void *pkey);
|
2012-07-02 16:02:15 +07:00
|
|
|
extern struct neighbour * __neigh_create(struct neigh_table *tbl,
|
|
|
|
const void *pkey,
|
|
|
|
struct net_device *dev,
|
|
|
|
bool want_ref);
|
|
|
|
static inline struct neighbour *neigh_create(struct neigh_table *tbl,
|
2005-04-17 05:20:36 +07:00
|
|
|
const void *pkey,
|
2012-07-02 16:02:15 +07:00
|
|
|
struct net_device *dev)
|
|
|
|
{
|
|
|
|
return __neigh_create(tbl, pkey, dev, true);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
extern void neigh_destroy(struct neighbour *neigh);
|
|
|
|
extern int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb);
|
|
|
|
extern int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
|
|
|
|
u32 flags);
|
|
|
|
extern void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
|
|
|
|
extern int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
|
2011-07-18 03:34:11 +07:00
|
|
|
extern int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
|
|
|
|
extern int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
|
|
|
|
extern int neigh_compat_output(struct neighbour *neigh, struct sk_buff *skb);
|
|
|
|
extern int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
|
2005-04-17 05:20:36 +07:00
|
|
|
extern struct neighbour *neigh_event_ns(struct neigh_table *tbl,
|
|
|
|
u8 *lladdr, void *saddr,
|
|
|
|
struct net_device *dev);
|
|
|
|
|
|
|
|
extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl);
|
|
|
|
extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
|
2008-03-26 01:49:59 +07:00
|
|
|
|
|
|
|
static inline
|
|
|
|
struct net *neigh_parms_net(const struct neigh_parms *parms)
|
|
|
|
{
|
2008-11-12 15:54:54 +07:00
|
|
|
return read_pnet(&parms->net);
|
2008-03-26 01:49:59 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
extern unsigned long neigh_rand_reach_time(unsigned long base);
|
|
|
|
|
|
|
|
extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
|
|
|
|
struct sk_buff *skb);
|
2008-01-24 15:13:18 +07:00
|
|
|
extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat);
|
2008-03-25 04:48:59 +07:00
|
|
|
extern struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl,
|
|
|
|
struct net *net,
|
|
|
|
const void *key,
|
|
|
|
struct net_device *dev);
|
2008-01-24 15:13:18 +07:00
|
|
|
extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-03-26 01:49:59 +07:00
|
|
|
static inline
|
|
|
|
struct net *pneigh_net(const struct pneigh_entry *pneigh)
|
|
|
|
{
|
2008-11-12 15:54:54 +07:00
|
|
|
return read_pnet(&pneigh->net);
|
2008-03-26 01:49:59 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
extern void neigh_app_ns(struct neighbour *n);
|
|
|
|
extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
|
|
|
|
extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *));
|
|
|
|
extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
|
|
|
|
|
|
|
|
struct neigh_seq_state {
|
2008-01-10 18:53:12 +07:00
|
|
|
struct seq_net_private p;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct neigh_table *tbl;
|
2010-10-04 13:15:44 +07:00
|
|
|
struct neigh_hash_table *nht;
|
2005-04-17 05:20:36 +07:00
|
|
|
void *(*neigh_sub_iter)(struct neigh_seq_state *state,
|
|
|
|
struct neighbour *n, loff_t *pos);
|
|
|
|
unsigned int bucket;
|
|
|
|
unsigned int flags;
|
|
|
|
#define NEIGH_SEQ_NEIGH_ONLY 0x00000001
|
|
|
|
#define NEIGH_SEQ_IS_PNEIGH 0x00000002
|
|
|
|
#define NEIGH_SEQ_SKIP_NOARP 0x00000004
|
|
|
|
};
|
|
|
|
extern void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *, unsigned int);
|
|
|
|
extern void *neigh_seq_next(struct seq_file *, void *, loff_t *);
|
|
|
|
extern void neigh_seq_stop(struct seq_file *, void *);
|
|
|
|
|
|
|
|
extern int neigh_sysctl_register(struct net_device *dev,
|
|
|
|
struct neigh_parms *p,
|
|
|
|
char *p_name,
|
2009-11-06 04:32:03 +07:00
|
|
|
proc_handler *proc_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
extern void neigh_sysctl_unregister(struct neigh_parms *p);
|
|
|
|
|
|
|
|
static inline void __neigh_parms_put(struct neigh_parms *parms)
|
|
|
|
{
|
|
|
|
atomic_dec(&parms->refcnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms)
|
|
|
|
{
|
|
|
|
atomic_inc(&parms->refcnt);
|
|
|
|
return parms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Neighbour references
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void neigh_release(struct neighbour *neigh)
|
|
|
|
{
|
|
|
|
if (atomic_dec_and_test(&neigh->refcnt))
|
|
|
|
neigh_destroy(neigh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct neighbour * neigh_clone(struct neighbour *neigh)
|
|
|
|
{
|
|
|
|
if (neigh)
|
|
|
|
atomic_inc(&neigh->refcnt);
|
|
|
|
return neigh;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define neigh_hold(n) atomic_inc(&(n)->refcnt)
|
|
|
|
|
|
|
|
static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
|
|
|
|
{
|
2010-11-19 00:40:04 +07:00
|
|
|
unsigned long now = jiffies;
|
2010-10-07 17:44:07 +07:00
|
|
|
|
|
|
|
if (neigh->used != now)
|
|
|
|
neigh->used = now;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))
|
|
|
|
return __neigh_event_send(neigh, skb);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-15 17:26:39 +07:00
|
|
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
|
|
|
static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb)
|
|
|
|
{
|
2012-04-15 12:58:06 +07:00
|
|
|
unsigned int seq, hh_alen;
|
2010-04-15 17:26:39 +07:00
|
|
|
|
|
|
|
do {
|
|
|
|
seq = read_seqbegin(&hh->hh_lock);
|
|
|
|
hh_alen = HH_DATA_ALIGN(ETH_HLEN);
|
|
|
|
memcpy(skb->data - hh_alen, hh->hh_data, ETH_ALEN + hh_alen - ETH_HLEN);
|
|
|
|
} while (read_seqretry(&hh->hh_lock, seq));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
net: output path optimizations
1) Avoid dirtying neighbour's confirmed field.
TCP workloads hits this cache line for each incoming ACK.
Lets write n->confirmed only if there is a jiffie change.
2) Optimize neigh_hh_output() for the common Ethernet case, were
hh_len is less than 16 bytes. Replace the memcpy() call
by two inlined 64bit load/stores on x86_64.
Bench results using udpflood test, with -C option (MSG_CONFIRM flag
added to sendto(), to reproduce the n->confirmed dirtying on UDP)
24 threads doing 1.000.000 UDP sendto() on dummy device, 4 runs.
before : 2.247s, 2.235s, 2.247s, 2.318s
after : 1.884s, 1.905s, 1.891s, 1.895s
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-08-07 09:19:56 +07:00
|
|
|
static inline int neigh_hh_output(const struct hh_cache *hh, struct sk_buff *skb)
|
2006-12-08 06:08:17 +07:00
|
|
|
{
|
2012-04-15 12:58:06 +07:00
|
|
|
unsigned int seq;
|
2006-12-08 06:08:17 +07:00
|
|
|
int hh_len;
|
|
|
|
|
|
|
|
do {
|
|
|
|
seq = read_seqbegin(&hh->hh_lock);
|
|
|
|
hh_len = hh->hh_len;
|
net: output path optimizations
1) Avoid dirtying neighbour's confirmed field.
TCP workloads hits this cache line for each incoming ACK.
Lets write n->confirmed only if there is a jiffie change.
2) Optimize neigh_hh_output() for the common Ethernet case, were
hh_len is less than 16 bytes. Replace the memcpy() call
by two inlined 64bit load/stores on x86_64.
Bench results using udpflood test, with -C option (MSG_CONFIRM flag
added to sendto(), to reproduce the n->confirmed dirtying on UDP)
24 threads doing 1.000.000 UDP sendto() on dummy device, 4 runs.
before : 2.247s, 2.235s, 2.247s, 2.318s
after : 1.884s, 1.905s, 1.891s, 1.895s
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-08-07 09:19:56 +07:00
|
|
|
if (likely(hh_len <= HH_DATA_MOD)) {
|
|
|
|
/* this is inlined by gcc */
|
|
|
|
memcpy(skb->data - HH_DATA_MOD, hh->hh_data, HH_DATA_MOD);
|
|
|
|
} else {
|
|
|
|
int hh_alen = HH_DATA_ALIGN(hh_len);
|
|
|
|
|
|
|
|
memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
|
|
|
|
}
|
2006-12-08 06:08:17 +07:00
|
|
|
} while (read_seqretry(&hh->hh_lock, seq));
|
|
|
|
|
|
|
|
skb_push(skb, hh_len);
|
2011-07-17 07:45:02 +07:00
|
|
|
return dev_queue_xmit(skb);
|
2006-12-08 06:08:17 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline struct neighbour *
|
|
|
|
__neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat)
|
|
|
|
{
|
|
|
|
struct neighbour *n = neigh_lookup(tbl, pkey, dev);
|
|
|
|
|
|
|
|
if (n || !creat)
|
|
|
|
return n;
|
|
|
|
|
|
|
|
n = neigh_create(tbl, pkey, dev);
|
|
|
|
return IS_ERR(n) ? NULL : n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct neighbour *
|
|
|
|
__neigh_lookup_errno(struct neigh_table *tbl, const void *pkey,
|
|
|
|
struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct neighbour *n = neigh_lookup(tbl, pkey, dev);
|
|
|
|
|
|
|
|
if (n)
|
|
|
|
return n;
|
|
|
|
|
|
|
|
return neigh_create(tbl, pkey, dev);
|
|
|
|
}
|
|
|
|
|
2005-08-15 07:24:31 +07:00
|
|
|
struct neighbour_cb {
|
|
|
|
unsigned long sched_next;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define LOCALLY_ENQUEUED 0x1
|
|
|
|
|
|
|
|
#define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-10-07 17:44:07 +07:00
|
|
|
static inline void neigh_ha_snapshot(char *dst, const struct neighbour *n,
|
|
|
|
const struct net_device *dev)
|
|
|
|
{
|
|
|
|
unsigned int seq;
|
|
|
|
|
|
|
|
do {
|
|
|
|
seq = read_seqbegin(&n->ha_lock);
|
|
|
|
memcpy(dst, n->ha, dev->addr_len);
|
|
|
|
} while (read_seqretry(&n->ha_lock, seq));
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|