return 0;
}
-static struct sock *rose_alloc_sock(void)
-{
- rose_cb *rose;
- struct sock *sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1, NULL);
-
- if (!sk)
- goto out;
-
- rose = sk->sk_protinfo = kmalloc(sizeof(*rose), GFP_ATOMIC);
- if (!rose)
- goto frees;
-
- memset(rose, 0x00, sizeof(*rose));
- rose->sk = sk;
-out:
- return sk;
-frees:
- sk_free(sk);
- sk = NULL;
- goto out;
-}
-
/*
* Socket removal during an interrupt is now safe.
*/
spin_lock_bh(&rose_list_lock);
sk_for_each(s, node, &rose_list) {
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
if (rose->neighbour == neigh) {
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
spin_lock_bh(&rose_list_lock);
sk_for_each(s, node, &rose_list) {
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
if (rose->device == dev) {
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
spin_lock_bh(&rose_list_lock);
sk_for_each(s, node, &rose_list) {
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
if (!rosecmp(&rose->source_addr, addr) &&
!ax25cmp(&rose->source_call, call) &&
}
sk_for_each(s, node, &rose_list) {
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
if (!rosecmp(&rose->source_addr, addr) &&
!ax25cmp(&rose->source_call, &null_ax25_address) &&
spin_lock_bh(&rose_list_lock);
sk_for_each(s, node, &rose_list) {
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
if (rose->lci == lci && rose->neighbour == neigh)
goto found;
char __user *optval, int optlen)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
int opt;
if (level != SOL_ROSE)
char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
int val = 0;
int len;
struct sock *sk = sock->sk;
if (sk->sk_state != TCP_LISTEN) {
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
rose->dest_ndigis = 0;
memset(&rose->dest_addr, 0, ROSE_ADDR_LEN);
return -EOPNOTSUPP;
}
+static struct proto rose_proto = {
+ .name = "ROSE",
+ .owner = THIS_MODULE,
+ .obj_size = sizeof(struct rose_sock),
+};
+
static int rose_create(struct socket *sock, int protocol)
{
struct sock *sk;
- rose_cb *rose;
+ struct rose_sock *rose;
if (sock->type != SOCK_SEQPACKET || protocol != 0)
return -ESOCKTNOSUPPORT;
- if ((sk = rose_alloc_sock()) == NULL)
+ if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
return -ENOMEM;
rose = rose_sk(sk);
sock_init_data(sock, sk);
- sk_set_owner(sk, THIS_MODULE);
skb_queue_head_init(&rose->ack_queue);
#ifdef M_BIT
static struct sock *rose_make_new(struct sock *osk)
{
struct sock *sk;
- rose_cb *rose, *orose;
+ struct rose_sock *rose, *orose;
if (osk->sk_type != SOCK_SEQPACKET)
return NULL;
- if ((sk = rose_alloc_sock()) == NULL)
+ if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
return NULL;
rose = rose_sk(sk);
sock_init_data(NULL, sk);
- sk_set_owner(sk, THIS_MODULE);
skb_queue_head_init(&rose->ack_queue);
#ifdef M_BIT
sk->sk_protocol = osk->sk_protocol;
sk->sk_rcvbuf = osk->sk_rcvbuf;
sk->sk_sndbuf = osk->sk_sndbuf;
- sk->sk_debug = osk->sk_debug;
sk->sk_state = TCP_ESTABLISHED;
sk->sk_sleep = osk->sk_sleep;
- sk->sk_zapped = osk->sk_zapped;
+
+ if (sock_flag(osk, SOCK_ZAPPED))
+ sock_set_flag(sk, SOCK_ZAPPED);
+
+ if (sock_flag(osk, SOCK_DBG))
+ sock_set_flag(sk, SOCK_DBG);
init_timer(&rose->timer);
init_timer(&rose->idletimer);
static int rose_release(struct socket *sock)
{
struct sock *sk = sock->sk;
- rose_cb *rose;
+ struct rose_sock *rose;
if (sk == NULL) return 0;
static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr;
struct net_device *dev;
ax25_address *user, *source;
int n;
- if (!sk->sk_zapped)
+ if (!sock_flag(sk, SOCK_ZAPPED))
return -EINVAL;
if (addr_len != sizeof(struct sockaddr_rose) && addr_len != sizeof(struct full_sockaddr_rose))
rose_insert_socket(sk);
- sk->sk_zapped = 0;
+ sock_reset_flag(sk, SOCK_ZAPPED);
SOCK_DEBUG(sk, "ROSE: socket is bound\n");
return 0;
}
static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr;
unsigned char cause, diagnostic;
ax25_address *user;
if (!rose->lci)
return -ENETUNREACH;
- if (sk->sk_zapped) { /* Must bind first - autobinding in this may or may not work */
- sk->sk_zapped = 0;
+ if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */
+ sock_reset_flag(sk, SOCK_ZAPPED);
if ((dev = rose_dev_first()) == NULL)
return -ENETUNREACH;
{
struct full_sockaddr_rose *srose = (struct full_sockaddr_rose *)uaddr;
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
int n;
if (peer != 0) {
{
struct sock *sk;
struct sock *make;
- rose_cb *make_rose;
+ struct rose_sock *make_rose;
struct rose_facilities_struct facilities;
int n, len;
/*
* We can't accept the Call Request.
*/
- if (!sk || sk->sk_ack_backlog == sk->sk_max_ack_backlog ||
+ if (sk == NULL || sk_acceptq_is_full(sk) ||
(make = rose_make_new(sk)) == NULL) {
rose_transmit_clear_request(neigh, lci, ROSE_NETWORK_CONGESTION, 120);
return 0;
struct msghdr *msg, size_t len)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name;
int err;
struct full_sockaddr_rose srose;
if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_CMSG_COMPAT))
return -EINVAL;
- if (sk->sk_zapped)
+ if (sock_flag(sk, SOCK_ZAPPED))
return -EADDRNOTAVAIL;
if (sk->sk_shutdown & SEND_SHUTDOWN) {
struct msghdr *msg, size_t size, int flags)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name;
size_t copied;
unsigned char *asmptr;
static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct sock *sk = sock->sk;
- rose_cb *rose = rose_sk(sk);
+ struct rose_sock *rose = rose_sk(sk);
void __user *argp = (void __user *)arg;
switch (cmd) {
else {
struct sock *s = v;
- rose_cb *rose = rose_sk(s);
+ struct rose_sock *rose = rose_sk(s);
const char *devname, *callsign;
const struct net_device *dev = rose->device;
static int __init rose_proto_init(void)
{
int i;
+ int rc = proto_register(&rose_proto, 0);
+
+ if (rc != 0)
+ goto out;
rose_callsign = null_ax25_address;
proc_net_fops_create("rose_neigh", S_IRUGO, &rose_neigh_fops);
proc_net_fops_create("rose_nodes", S_IRUGO, &rose_nodes_fops);
proc_net_fops_create("rose_routes", S_IRUGO, &rose_routes_fops);
-
- return 0;
+out:
+ return rc;
fail:
while (--i >= 0) {
unregister_netdev(dev_rose[i]);
free_netdev(dev_rose[i]);
}
kfree(dev_rose);
+ proto_unregister(&rose_proto);
return -ENOMEM;
}
module_init(rose_proto_init);
}
kfree(dev_rose);
+ proto_unregister(&rose_proto);
}
module_exit(rose_exit);