o LLC: move the sockets release function outside of llc_sap_close

parent e1ceceb1
......@@ -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 */
......@@ -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 */
......@@ -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 */
......@@ -16,7 +16,6 @@
#include <linux/skbuff.h>
#include <net/datalink.h>
#include <net/psnap.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <linux/mm.h>
#include <linux/in.h>
......
......@@ -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:
......
......@@ -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;
......
......@@ -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 @@ struct llc_sap *llc_sap_open(u8 lsap, int (*func)(struct sk_buff *skb,
*
* 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);
......
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