From 03c87be72502e41621f91e0f367469217ff7755d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 16 Sep 2003 08:32:26 -0300 Subject: [PATCH] o LLC: move the sockets release function outside of llc_sap_close --- include/net/llc_conn.h | 1 + include/net/llc_if.h | 14 -------------- include/net/llc_sap.h | 13 +++++++++++++ net/802/psnap.c | 1 - net/llc/af_llc.c | 4 +++- net/llc/llc_conn.c | 6 +++--- net/llc/llc_sap.c | 30 +++++++----------------------- 7 files changed, 27 insertions(+), 42 deletions(-) diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h index 202ee73ad2beb..b10900c62fa1c 100644 --- a/include/net/llc_conn.h +++ b/include/net/llc_conn.h @@ -105,4 +105,5 @@ extern struct sock *llc_lookup_dgram(struct llc_sap *sap, extern void llc_save_primitive(struct sk_buff* skb, u8 prim); extern u8 llc_data_accept_state(u8 state); extern void llc_build_offset_table(void); +extern int llc_release_sockets(struct llc_sap *sap); #endif /* LLC_CONN_H */ diff --git a/include/net/llc_if.h b/include/net/llc_if.h index bebc983cae16b..615fc3c671b09 100644 --- a/include/net/llc_if.h +++ b/include/net/llc_if.h @@ -100,22 +100,8 @@ static __inline__ int llc_mac_match(u8 *mac1, u8 *mac2) return !memcmp(mac1, mac2, IFHWADDRLEN); } -struct llc_sap; - -extern struct llc_sap *llc_sap_open(u8 lsap, - int (*func)(struct sk_buff *skb, - struct net_device *dev, - struct packet_type *pt)); -extern void llc_sap_close(struct llc_sap *sap); - extern int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap); extern int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb); -extern void llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, - u8 *dmac, u8 dsap); -extern void llc_build_and_send_xid_pkt(struct llc_sap *sap, struct sk_buff *skb, - u8 *dmac, u8 dsap); -extern void llc_build_and_send_test_pkt(struct llc_sap *sap, struct sk_buff *skb, - u8 *dmac, u8 dsap); extern int llc_send_disc(struct sock *sk); #endif /* LLC_IF_H */ diff --git a/include/net/llc_sap.h b/include/net/llc_sap.h index b46c853893882..2fffd961897e0 100644 --- a/include/net/llc_sap.h +++ b/include/net/llc_sap.h @@ -44,4 +44,17 @@ extern void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk); extern void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk); extern void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb); extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); +extern struct llc_sap *llc_sap_open(u8 lsap, + int (*rcv)(struct sk_buff *skb, + struct net_device *dev, + struct packet_type *pt)); +extern void llc_sap_close(struct llc_sap *sap); + +extern void llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, + u8 *dmac, u8 dsap); +extern void llc_build_and_send_xid_pkt(struct llc_sap *sap, struct sk_buff *skb, + u8 *dmac, u8 dsap); +extern void llc_build_and_send_test_pkt(struct llc_sap *sap, + struct sk_buff *skb, u8 *dmac, u8 dsap); + #endif /* LLC_SAP_H */ diff --git a/net/802/psnap.c b/net/802/psnap.c index c689454484b1a..e09f992aecfbd 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index ff2710542e4b3..e7bcc35de9f51 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -184,8 +184,10 @@ static int llc_ui_release(struct socket *sock) if (!sk->sk_zapped) llc_sap_unassign_sock(llc->sap, sk); release_sock(sk); - if (llc->sap && hlist_empty(&llc->sap->sk_list.list)) + if (llc->sap && hlist_empty(&llc->sap->sk_list.list)) { + llc_release_sockets(llc->sap); llc_sap_close(llc->sap); + } sock_put(sk); llc_sk_free(sk); out: diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index 0dddbbe18afeb..09ddaa1b4f378 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c @@ -736,13 +736,13 @@ static atomic_t llc_sock_nr; #endif /** - * llc_release_conns - releases all connections of a sap - * @sap: sap to release its connections + * llc_release_sockets - releases all sockets in a sap + * @sap: sap to release its sockets * * Releases all connections of a sap. Returns 0 if all actions complete * successfully, nonzero otherwise */ -int llc_release_connections(struct llc_sap *sap) +int llc_release_sockets(struct llc_sap *sap) { int rc = 0; struct sock *sk; diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c index ab2b96bccb560..c927418c8a4a5 100644 --- a/net/llc/llc_sap.c +++ b/net/llc/llc_sap.c @@ -245,28 +245,6 @@ struct llc_sap *llc_sap_alloc(void) return sap; } -/* - * FIXME: this will go away as soon as sap->release_connections is introduced - * in the next changesets. - */ -extern int llc_release_connections(struct llc_sap *sap); - -/** - * llc_free_sap - frees a sap - * @sap: Address of the sap - * - * Frees all associated connections (if any), removes this sap from - * the list of saps in te station and them frees the memory for this sap. - */ -void llc_free_sap(struct llc_sap *sap) -{ - llc_release_connections(sap); - write_lock_bh(&sap->station->sap_list.lock); - list_del(&sap->node); - write_unlock_bh(&sap->station->sap_list.lock); - kfree(sap); -} - /** * llc_sap_open - open interface to the upper layers. * @lsap: SAP number. @@ -308,10 +286,16 @@ out: * * Close interface function to upper layer. Each one who wants to * close an open SAP (for example NetBEUI) should call this function. + * Removes this sap from the list of saps in the station and then + * frees the memory for this sap. */ void llc_sap_close(struct llc_sap *sap) { - llc_free_sap(sap); + WARN_ON(!hlist_empty(&sap->sk_list.list)); + write_lock_bh(&sap->station->sap_list.lock); + list_del(&sap->node); + write_unlock_bh(&sap->station->sap_list.lock); + kfree(sap); } EXPORT_SYMBOL(llc_sap_open); -- 2.53.0