Commit 28d0e94e authored by Jeroen Vreeken's avatar Jeroen Vreeken Committed by David S. Miller

[NETROM]: Use hlist for the routing table information.

Note: there is a call to ax25_cb_put commented out, that
can be added back when ax25 refcount patches go in.
parent 2a2ff7fc
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef _NETROM_H #ifndef _NETROM_H
#define _NETROM_H #define _NETROM_H
#include <linux/netrom.h> #include <linux/netrom.h>
#include <linux/list.h>
#define NR_NETWORK_LEN 15 #define NR_NETWORK_LEN 15
#define NR_TRANSPORT_LEN 5 #define NR_TRANSPORT_LEN 5
...@@ -77,16 +78,17 @@ typedef struct { ...@@ -77,16 +78,17 @@ typedef struct {
#define nr_sk(__sk) ((nr_cb *)(__sk)->sk_protinfo) #define nr_sk(__sk) ((nr_cb *)(__sk)->sk_protinfo)
struct nr_neigh { struct nr_neigh {
struct nr_neigh *next; struct hlist_node neigh_node;
ax25_address callsign; ax25_address callsign;
ax25_digi *digipeat; ax25_digi *digipeat;
ax25_cb *ax25; ax25_cb *ax25;
struct net_device *dev; struct net_device *dev;
unsigned char quality; unsigned char quality;
unsigned char locked; unsigned char locked;
unsigned short count; unsigned short count;
unsigned int number; unsigned int number;
unsigned char failed; unsigned char failed;
atomic_t refcount;
}; };
struct nr_route { struct nr_route {
...@@ -96,14 +98,74 @@ struct nr_route { ...@@ -96,14 +98,74 @@ struct nr_route {
}; };
struct nr_node { struct nr_node {
struct nr_node *next; struct hlist_node node_node;
ax25_address callsign; ax25_address callsign;
char mnemonic[7]; char mnemonic[7];
unsigned char which; unsigned char which;
unsigned char count; unsigned char count;
struct nr_route routes[3]; struct nr_route routes[3];
atomic_t refcount;
spinlock_t node_lock;
}; };
/*********************************************************************
* nr_node & nr_neigh lists, refcounting and locking
*********************************************************************/
extern struct hlist_head nr_node_list;
extern struct hlist_head nr_neigh_list;
#define nr_node_hold(__nr_node) \
atomic_inc(&((__nr_node)->refcount))
static __inline__ void nr_node_put(struct nr_node *nr_node)
{
if (atomic_dec_and_test(&nr_node->refcount)) {
kfree(nr_node);
}
}
#define nr_neigh_hold(__nr_neigh) \
atomic_inc(&((__nr_neigh)->refcount))
static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh)
{
if (atomic_dec_and_test(&nr_neigh->refcount)) {
if (nr_neigh->digipeat != NULL)
kfree(nr_neigh->digipeat);
kfree(nr_neigh);
}
}
/* nr_node_lock and nr_node_unlock also hold/put the node's refcounter.
*/
static __inline__ void nr_node_lock(struct nr_node *nr_node)
{
nr_node_hold(nr_node);
spin_lock_bh(&nr_node->node_lock);
}
static __inline__ void nr_node_unlock(struct nr_node *nr_node)
{
spin_unlock_bh(&nr_node->node_lock);
nr_node_put(nr_node);
}
#define nr_neigh_for_each(__nr_neigh, node, list) \
hlist_for_each_entry(__nr_neigh, node, list, neigh_node)
#define nr_neigh_for_each_safe(__nr_neigh, node, node2, list) \
hlist_for_each_entry_safe(__nr_neigh, node, node2, list, neigh_node)
#define nr_node_for_each(__nr_node, node, list) \
hlist_for_each_entry(__nr_node, node, list, node_node)
#define nr_node_for_each_safe(__nr_node, node, node2, list) \
hlist_for_each_entry_safe(__nr_node, node, node2, list, node_node)
/*********************************************************************/
/* af_netrom.c */ /* af_netrom.c */
extern int sysctl_netrom_default_path_quality; extern int sysctl_netrom_default_path_quality;
extern int sysctl_netrom_obsolescence_count_initialiser; extern int sysctl_netrom_obsolescence_count_initialiser;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment