X25: Move accept approve flag to bitfield
[safe/jmp/linux-2.6] / include / net / neighbour.h
index a4f2618..eb21340 100644 (file)
 
 #include <linux/err.h>
 #include <linux/sysctl.h>
+#include <linux/workqueue.h>
 #include <net/rtnetlink.h>
 
+/*
+ * NUD stands for "neighbor unreachability detection"
+ */
+
 #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;
 
-struct neigh_parms
-{
+struct neigh_parms {
+#ifdef CONFIG_NET_NS
+       struct net *net;
+#endif
        struct net_device *dev;
        struct neigh_parms *next;
        int     (*neigh_setup)(struct neighbour *);
@@ -62,13 +69,12 @@ struct neigh_parms
        int     locktime;
 };
 
-struct neigh_statistics
-{
+struct neigh_statistics {
        unsigned long allocs;           /* number of allocated neighs */
        unsigned long destroys;         /* number of destroyed neighs */
        unsigned long hash_grows;       /* number of hash resizes */
 
-       unsigned long res_failed;       /* nomber of failed resolutions */
+       unsigned long res_failed;       /* number of failed resolutions */
 
        unsigned long lookups;          /* number of lookups */
        unsigned long hits;             /* number of hits (among lookups) */
@@ -78,17 +84,13 @@ struct neigh_statistics
 
        unsigned long periodic_gc_runs; /* number of periodic GC runs */
        unsigned long forced_gc_runs;   /* number of forced GC runs */
+
+       unsigned long unres_discards;   /* number of unresolved drops */
 };
 
-#define NEIGH_CACHE_STAT_INC(tbl, field)                               \
-       do {                                                            \
-               preempt_disable();                                      \
-               (per_cpu_ptr((tbl)->stats, smp_processor_id())->field)++; \
-               preempt_enable();                                       \
-       } while (0)
+#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)
 
-struct neighbour
-{
+struct neighbour {
        struct neighbour        *next;
        struct neigh_table      *tbl;
        struct neigh_parms      *parms;
@@ -108,12 +110,11 @@ struct neighbour
        int                     (*output)(struct sk_buff *skb);
        struct sk_buff_head     arp_queue;
        struct timer_list       timer;
-       struct neigh_ops        *ops;
+       const struct neigh_ops  *ops;
        u8                      primary_key[0];
 };
 
-struct neigh_ops
-{
+struct neigh_ops {
        int                     family;
        void                    (*solicit)(struct neighbour *, struct sk_buff*);
        void                    (*error_report)(struct neighbour *, struct sk_buff*);
@@ -123,10 +124,12 @@ struct neigh_ops
        int                     (*queue_xmit)(struct sk_buff*);
 };
 
-struct pneigh_entry
-{
+struct pneigh_entry {
        struct pneigh_entry     *next;
-       struct net_device               *dev;
+#ifdef CONFIG_NET_NS
+       struct net              *net;
+#endif
+       struct net_device       *dev;
        u8                      flags;
        u8                      key[0];
 };
@@ -136,8 +139,7 @@ struct pneigh_entry
  */
 
 
-struct neigh_table
-{
+struct neigh_table {
        struct neigh_table      *next;
        int                     family;
        int                     entry_size;
@@ -155,22 +157,18 @@ struct neigh_table
        int                     gc_thresh2;
        int                     gc_thresh3;
        unsigned long           last_flush;
-       struct timer_list       gc_timer;
+       struct delayed_work     gc_work;
        struct timer_list       proxy_timer;
        struct sk_buff_head     proxy_queue;
        atomic_t                entries;
        rwlock_t                lock;
        unsigned long           last_rand;
        struct kmem_cache               *kmem_cachep;
-       struct neigh_statistics *stats;
+       struct neigh_statistics __percpu *stats;
        struct neighbour        **hash_buckets;
        unsigned int            hash_mask;
        __u32                   hash_rnd;
-       unsigned int            hash_chain_gc;
        struct pneigh_entry     **phash_buckets;
-#ifdef CONFIG_PROC_FS
-       struct proc_dir_entry   *pde;
-#endif
 };
 
 /* flags for neigh_update() */
@@ -187,6 +185,7 @@ 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,
+                                                  struct net *net,
                                                   const void *pkey);
 extern struct neighbour *      neigh_create(struct neigh_table *tbl,
                                             const void *pkey,
@@ -206,13 +205,29 @@ extern struct neighbour   *neigh_event_ns(struct neigh_table *tbl,
 
 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);
-extern void                    neigh_parms_destroy(struct neigh_parms *parms);
+
+static inline
+struct net                     *neigh_parms_net(const struct neigh_parms *parms)
+{
+       return read_pnet(&parms->net);
+}
+
 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);
-extern struct pneigh_entry     *pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat);
-extern int                     pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev);
+extern struct pneigh_entry     *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat);
+extern struct pneigh_entry     *__pneigh_lookup(struct neigh_table *tbl,
+                                                struct net *net,
+                                                const void *key,
+                                                struct net_device *dev);
+extern int                     pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev);
+
+static inline
+struct net                     *pneigh_net(const struct pneigh_entry *pneigh)
+{
+       return read_pnet(&pneigh->net);
+}
 
 extern void neigh_app_ns(struct neighbour *n);
 extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
@@ -220,6 +235,7 @@ extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct n
 extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
 
 struct neigh_seq_state {
+       struct seq_net_private p;
        struct neigh_table *tbl;
        void *(*neigh_sub_iter)(struct neigh_seq_state *state,
                                struct neighbour *n, loff_t *pos);
@@ -235,10 +251,8 @@ extern void neigh_seq_stop(struct seq_file *, void *);
 
 extern int                     neigh_sysctl_register(struct net_device *dev, 
                                                      struct neigh_parms *p,
-                                                     int p_id, int pdev_id,
                                                      char *p_name,
-                                                     proc_handler *proc_handler,
-                                                     ctl_handler *strategy);
+                                                     proc_handler *proc_handler);
 extern void                    neigh_sysctl_unregister(struct neigh_parms *p);
 
 static inline void __neigh_parms_put(struct neigh_parms *parms)
@@ -246,12 +260,6 @@ static inline void __neigh_parms_put(struct neigh_parms *parms)
        atomic_dec(&parms->refcnt);
 }
 
-static inline void neigh_parms_put(struct neigh_parms *parms)
-{
-       if (atomic_dec_and_test(&parms->refcnt))
-               neigh_parms_destroy(parms);
-}
-
 static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms)
 {
        atomic_inc(&parms->refcnt);
@@ -283,16 +291,6 @@ static inline void neigh_confirm(struct neighbour *neigh)
                neigh->confirmed = jiffies;
 }
 
-static inline int neigh_is_connected(struct neighbour *neigh)
-{
-       return neigh->nud_state&NUD_CONNECTED;
-}
-
-static inline int neigh_is_valid(struct neighbour *neigh)
-{
-       return neigh->nud_state&NUD_VALID;
-}
-
 static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 {
        neigh->used = jiffies;
@@ -301,6 +299,20 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
        return 0;
 }
 
+#ifdef CONFIG_BRIDGE_NETFILTER
+static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb)
+{
+       unsigned seq, hh_alen;
+
+       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
+
 static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
 {
        unsigned seq;