aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:43:05 -0400
committerArnaldo Carvalho de Melo <acme@mandriva.com>2005-09-22 03:43:05 -0400
commit6e2144b76840be09924de1626e2dcd7b315f75b3 (patch)
tree33044cb63f368270229e2b40aa2ad024325c7e8b /include/net
parent04e4223f44b89e50f275cb6b95a58ebe2c4909be (diff)
[LLC]: Use refcounting with struct llc_sap
Signed-off-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/llc.h16
-rw-r--r--include/net/llc_conn.h1
2 files changed, 15 insertions, 2 deletions
diff --git a/include/net/llc.h b/include/net/llc.h
index 8b8e2be289b1..93e5b443a9a7 100644
--- a/include/net/llc.h
+++ b/include/net/llc.h
@@ -17,6 +17,8 @@
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19 19
20#include <asm/atomic.h>
21
20struct net_device; 22struct net_device;
21struct packet_type; 23struct packet_type;
22struct sk_buff; 24struct sk_buff;
@@ -44,6 +46,7 @@ struct llc_sap {
44 unsigned char state; 46 unsigned char state;
45 unsigned char p_bit; 47 unsigned char p_bit;
46 unsigned char f_bit; 48 unsigned char f_bit;
49 atomic_t refcnt;
47 int (*rcv_func)(struct sk_buff *skb, 50 int (*rcv_func)(struct sk_buff *skb,
48 struct net_device *dev, 51 struct net_device *dev,
49 struct packet_type *pt, 52 struct packet_type *pt,
@@ -81,7 +84,18 @@ extern struct llc_sap *llc_sap_open(unsigned char lsap,
81 struct net_device *dev, 84 struct net_device *dev,
82 struct packet_type *pt, 85 struct packet_type *pt,
83 struct net_device *orig_dev)); 86 struct net_device *orig_dev));
84extern void llc_sap_close(struct llc_sap *sap); 87static inline void llc_sap_hold(struct llc_sap *sap)
88{
89 atomic_inc(&sap->refcnt);
90}
91
92static inline void llc_sap_put(struct llc_sap *sap)
93{
94 extern void llc_sap_close(struct llc_sap *sap);
95
96 if (atomic_dec_and_test(&sap->refcnt))
97 llc_sap_close(sap);
98}
85 99
86extern struct llc_sap *llc_sap_find(unsigned char sap_value); 100extern struct llc_sap *llc_sap_find(unsigned char sap_value);
87 101
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h
index 8a8ff4810135..b2889218c76a 100644
--- a/include/net/llc_conn.h
+++ b/include/net/llc_conn.h
@@ -115,5 +115,4 @@ extern void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk);
115 115
116extern u8 llc_data_accept_state(u8 state); 116extern u8 llc_data_accept_state(u8 state);
117extern void llc_build_offset_table(void); 117extern void llc_build_offset_table(void);
118extern int llc_release_sockets(struct llc_sap *sap);
119#endif /* LLC_CONN_H */ 118#endif /* LLC_CONN_H */