Commit 8549ccb7 authored by David S. Miller's avatar David S. Miller

Manual content merge with Rusty's ISO struct initializers patch.

parents eb1f4c38 1d086a5d
...@@ -66,17 +66,29 @@ int sysctl_aarp_retransmit_limit = AARP_RETRANSMIT_LIMIT; ...@@ -66,17 +66,29 @@ int sysctl_aarp_retransmit_limit = AARP_RETRANSMIT_LIMIT;
int sysctl_aarp_resolve_time = AARP_RESOLVE_TIME; int sysctl_aarp_resolve_time = AARP_RESOLVE_TIME;
/* Lists of aarp entries */ /* Lists of aarp entries */
/**
* struct aarp_entry - AARP entry
* @last_sent - Last time we xmitted the aarp request
* @packet_queue - Queue of frames wait for resolution
* @status - Used for proxy AARP
* expires_at - Entry expiry time
* target_addr - DDP Address
* dev - Device to use
* hwaddr - Physical i/f address of target/router
* xmit_count - When this hits 10 we give up
* next - Next entry in chain
*/
struct aarp_entry { struct aarp_entry {
/* These first two are only used for unresolved entries */ /* These first two are only used for unresolved entries */
unsigned long last_sent; /* Last time we xmitted the aarp request */ unsigned long last_sent;
struct sk_buff_head packet_queue; /* Queue of frames wait for resolution */ struct sk_buff_head packet_queue;
int status; /* Used for proxy AARP */ int status;
unsigned long expires_at; /* Entry expiry time */ unsigned long expires_at;
struct at_addr target_addr; /* DDP Address */ struct at_addr target_addr;
struct net_device *dev; /* Device to use */ struct net_device *dev;
char hwaddr[6]; /* Physical i/f address of target/router */ char hwaddr[6];
unsigned short xmit_count; /* When this hits 10 we give up */ unsigned short xmit_count;
struct aarp_entry *next; /* Next entry in chain */ struct aarp_entry *next;
}; };
/* Hashed list of resolved, unresolved and proxy entries */ /* Hashed list of resolved, unresolved and proxy entries */
...@@ -371,7 +383,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event, ...@@ -371,7 +383,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event,
static struct aarp_entry *aarp_alloc(void) static struct aarp_entry *aarp_alloc(void)
{ {
struct aarp_entry *a = kmalloc(sizeof(struct aarp_entry), GFP_ATOMIC); struct aarp_entry *a = kmalloc(sizeof(*a), GFP_ATOMIC);
if (a) if (a)
skb_queue_head_init(&a->packet_queue); skb_queue_head_init(&a->packet_queue);
...@@ -430,22 +442,22 @@ static struct at_addr *__aarp_proxy_find(struct net_device *dev, ...@@ -430,22 +442,22 @@ static struct at_addr *__aarp_proxy_find(struct net_device *dev,
*/ */
void aarp_send_probe_phase1(struct atalk_iface *iface) void aarp_send_probe_phase1(struct atalk_iface *iface)
{ {
struct ifreq atreq; struct ifreq atreq;
struct sockaddr_at *sa = (struct sockaddr_at *)&atreq.ifr_addr; struct sockaddr_at *sa = (struct sockaddr_at *)&atreq.ifr_addr;
sa->sat_addr.s_node = iface->address.s_node; sa->sat_addr.s_node = iface->address.s_node;
sa->sat_addr.s_net = ntohs(iface->address.s_net); sa->sat_addr.s_net = ntohs(iface->address.s_net);
/* We pass the Net:Node to the drivers/cards by a Device ioctl. */ /* We pass the Net:Node to the drivers/cards by a Device ioctl. */
if (!(iface->dev->do_ioctl(iface->dev, &atreq, SIOCSIFADDR))) { if (!(iface->dev->do_ioctl(iface->dev, &atreq, SIOCSIFADDR))) {
(void)iface->dev->do_ioctl(iface->dev, &atreq, SIOCGIFADDR); (void)iface->dev->do_ioctl(iface->dev, &atreq, SIOCGIFADDR);
if (iface->address.s_net != htons(sa->sat_addr.s_net) || if (iface->address.s_net != htons(sa->sat_addr.s_net) ||
iface->address.s_node != sa->sat_addr.s_node) iface->address.s_node != sa->sat_addr.s_node)
iface->status |= ATIF_PROBE_FAIL; iface->status |= ATIF_PROBE_FAIL;
iface->address.s_net = htons(sa->sat_addr.s_net); iface->address.s_net = htons(sa->sat_addr.s_net);
iface->address.s_node = sa->sat_addr.s_node; iface->address.s_node = sa->sat_addr.s_node;
} }
} }
...@@ -462,7 +474,7 @@ void aarp_probe_network(struct atalk_iface *atif) ...@@ -462,7 +474,7 @@ void aarp_probe_network(struct atalk_iface *atif)
/* Defer 1/10th */ /* Defer 1/10th */
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
schedule_timeout(HZ/10); schedule_timeout(HZ / 10);
if (atif->status & ATIF_PROBE_FAIL) if (atif->status & ATIF_PROBE_FAIL)
break; break;
...@@ -472,7 +484,7 @@ void aarp_probe_network(struct atalk_iface *atif) ...@@ -472,7 +484,7 @@ void aarp_probe_network(struct atalk_iface *atif)
int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
{ {
int hash, retval = 1; int hash, retval = -EPROTONOSUPPORT;
struct aarp_entry *entry; struct aarp_entry *entry;
unsigned int count; unsigned int count;
...@@ -480,19 +492,18 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) ...@@ -480,19 +492,18 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
* we don't currently support LocalTalk or PPP for proxy AARP; * we don't currently support LocalTalk or PPP for proxy AARP;
* if someone wants to try and add it, have fun * if someone wants to try and add it, have fun
*/ */
if (atif->dev->type == ARPHRD_LOCALTLK) if (atif->dev->type == ARPHRD_LOCALTLK ||
return -EPROTONOSUPPORT; atif->dev->type == ARPHRD_PPP)
goto out;
if (atif->dev->type == ARPHRD_PPP)
return -EPROTONOSUPPORT;
/* /*
* create a new AARP entry with the flags set to be published -- * create a new AARP entry with the flags set to be published --
* we need this one to hang around even if it's in use * we need this one to hang around even if it's in use
*/ */
entry = aarp_alloc(); entry = aarp_alloc();
retval = -ENOMEM;
if (!entry) if (!entry)
return -ENOMEM; goto out;
entry->expires_at = -1; entry->expires_at = -1;
entry->status = ATIF_PROBE; entry->status = ATIF_PROBE;
...@@ -512,7 +523,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) ...@@ -512,7 +523,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
/* Defer 1/10th */ /* Defer 1/10th */
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
spin_unlock_bh(&aarp_lock); spin_unlock_bh(&aarp_lock);
schedule_timeout(HZ/10); schedule_timeout(HZ / 10);
spin_lock_bh(&aarp_lock); spin_lock_bh(&aarp_lock);
if (entry->status & ATIF_PROBE_FAIL) if (entry->status & ATIF_PROBE_FAIL)
...@@ -522,10 +533,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) ...@@ -522,10 +533,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
if (entry->status & ATIF_PROBE_FAIL) { if (entry->status & ATIF_PROBE_FAIL) {
entry->expires_at = jiffies - 1; /* free the entry */ entry->expires_at = jiffies - 1; /* free the entry */
retval = -EADDRINUSE; /* return network full */ retval = -EADDRINUSE; /* return network full */
} else /* clear the probing flag */ } else { /* clear the probing flag */
entry->status &= ~ATIF_PROBE; entry->status &= ~ATIF_PROBE;
retval = 1;
}
spin_unlock_bh(&aarp_lock); spin_unlock_bh(&aarp_lock);
out:
return retval; return retval;
} }
...@@ -613,8 +627,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -613,8 +627,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
a = __aarp_find_entry(unresolved[hash], dev, sa); a = __aarp_find_entry(unresolved[hash], dev, sa);
if (a) { /* Queue onto the unresolved queue */ if (a) { /* Queue onto the unresolved queue */
skb_queue_tail(&a->packet_queue, skb); skb_queue_tail(&a->packet_queue, skb);
spin_unlock_bh(&aarp_lock); goto out_unlock;
return 0;
} }
/* Allocate a new entry */ /* Allocate a new entry */
...@@ -627,11 +640,11 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -627,11 +640,11 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
/* Set up the queue */ /* Set up the queue */
skb_queue_tail(&a->packet_queue, skb); skb_queue_tail(&a->packet_queue, skb);
a->expires_at = jiffies + sysctl_aarp_resolve_time; a->expires_at = jiffies + sysctl_aarp_resolve_time;
a->dev = dev; a->dev = dev;
a->next = unresolved[hash]; a->next = unresolved[hash];
a->target_addr = *sa; a->target_addr = *sa;
a->xmit_count = 0; a->xmit_count = 0;
unresolved[hash] = a; unresolved[hash] = a;
unresolved_count++; unresolved_count++;
...@@ -647,12 +660,14 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -647,12 +660,14 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
mod_timer(&aarp_timer, jiffies + sysctl_aarp_tick_time); mod_timer(&aarp_timer, jiffies + sysctl_aarp_tick_time);
/* Now finally, it is safe to drop the lock. */ /* Now finally, it is safe to drop the lock. */
out_unlock:
spin_unlock_bh(&aarp_lock); spin_unlock_bh(&aarp_lock);
/* Tell the ddp layer we have taken over for this frame. */ /* Tell the ddp layer we have taken over for this frame. */
return 0; return 0;
sendit: if (skb->sk) sendit:
if (skb->sk)
skb->priority = skb->sk->priority; skb->priority = skb->sk->priority;
dev_queue_xmit(skb); dev_queue_xmit(skb);
return 1; return 1;
...@@ -696,7 +711,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a, ...@@ -696,7 +711,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a,
* frame. We currently only support Ethernet. * frame. We currently only support Ethernet.
*/ */
static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt) struct packet_type *pt)
{ {
struct elapaarp *ea = (struct elapaarp *)skb->h.raw; struct elapaarp *ea = (struct elapaarp *)skb->h.raw;
int hash, ret = 0; int hash, ret = 0;
...@@ -742,7 +757,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -742,7 +757,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
/* Check for replies of proxy AARP entries */ /* Check for replies of proxy AARP entries */
da.s_node = ea->pa_dst_node; da.s_node = ea->pa_dst_node;
da.s_net = ea->pa_dst_net; da.s_net = ea->pa_dst_net;
spin_lock_bh(&aarp_lock); spin_lock_bh(&aarp_lock);
a = __aarp_find_entry(proxies[hash], dev, &da); a = __aarp_find_entry(proxies[hash], dev, &da);
...@@ -834,9 +849,12 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -834,9 +849,12 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
break; break;
} }
unlock: spin_unlock_bh(&aarp_lock); unlock:
out1: ret = 1; spin_unlock_bh(&aarp_lock);
out0: kfree_skb(skb); out1:
ret = 1;
out0:
kfree_skb(skb);
return ret; return ret;
} }
...@@ -853,8 +871,8 @@ void __init aarp_proto_init(void) ...@@ -853,8 +871,8 @@ void __init aarp_proto_init(void)
printk(KERN_CRIT "Unable to register AARP with SNAP.\n"); printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
init_timer(&aarp_timer); init_timer(&aarp_timer);
aarp_timer.function = aarp_expire_timeout; aarp_timer.function = aarp_expire_timeout;
aarp_timer.data = 0; aarp_timer.data = 0;
aarp_timer.expires = jiffies + sysctl_aarp_expiry_time; aarp_timer.expires = jiffies + sysctl_aarp_expiry_time;
add_timer(&aarp_timer); add_timer(&aarp_timer);
register_netdevice_notifier(&aarp_notifier); register_netdevice_notifier(&aarp_notifier);
} }
...@@ -880,81 +898,84 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -880,81 +898,84 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
{ {
/* we should dump all our AARP entries */ /* we should dump all our AARP entries */
struct aarp_entry *entry; struct aarp_entry *entry;
int len, ct; int ct, len = sprintf(buffer,
"%-10.10s %-10.10s%-18.18s%12.12s%12.12s "
len = sprintf(buffer, "xmit_count status\n",
"%-10.10s %-10.10s%-18.18s%12.12s%12.12s xmit_count status\n", "address", "device", "hw addr", "last_sent",
"address", "device", "hw addr", "last_sent", "expires"); "expires");
spin_lock_bh(&aarp_lock); spin_lock_bh(&aarp_lock);
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
for (entry = resolved[ct]; entry; entry = entry->next) { for (entry = resolved[ct]; entry; entry = entry->next) {
len+= sprintf(buffer+len,"%6u:%-3u ", len += sprintf(buffer + len, "%6u:%-3u ",
(unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)ntohs(entry->target_addr.s_net),
(unsigned int)(entry->target_addr.s_node)); (unsigned int)(entry->target_addr.s_node));
len+= sprintf(buffer+len,"%-10.10s", len += sprintf(buffer + len, "%-10.10s",
entry->dev->name); entry->dev->name);
len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", len += sprintf(buffer + len,
(int)(entry->hwaddr[0] & 0x000000FF), "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
(int)(entry->hwaddr[1] & 0x000000FF), (int)(entry->hwaddr[0] & 0x000000FF),
(int)(entry->hwaddr[2] & 0x000000FF), (int)(entry->hwaddr[1] & 0x000000FF),
(int)(entry->hwaddr[3] & 0x000000FF), (int)(entry->hwaddr[2] & 0x000000FF),
(int)(entry->hwaddr[4] & 0x000000FF), (int)(entry->hwaddr[3] & 0x000000FF),
(int)(entry->hwaddr[5] & 0x000000FF)); (int)(entry->hwaddr[4] & 0x000000FF),
len+= sprintf(buffer+len,"%12lu ""%12lu ", (int)(entry->hwaddr[5] & 0x000000FF));
(unsigned long)entry->last_sent, len += sprintf(buffer + len, "%12lu ""%12lu ",
(unsigned long)entry->expires_at); (unsigned long)entry->last_sent,
len+=sprintf(buffer+len,"%10u", (unsigned long)entry->expires_at);
(unsigned int)entry->xmit_count); len += sprintf(buffer + len, "%10u",
(unsigned int)entry->xmit_count);
len+=sprintf(buffer+len," resolved\n");
len += sprintf(buffer + len, " resolved\n");
} }
} }
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
for (entry = unresolved[ct]; entry; entry = entry->next) { for (entry = unresolved[ct]; entry; entry = entry->next) {
len+= sprintf(buffer+len,"%6u:%-3u ", len += sprintf(buffer + len, "%6u:%-3u ",
(unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)ntohs(entry->target_addr.s_net),
(unsigned int)(entry->target_addr.s_node)); (unsigned int)(entry->target_addr.s_node));
len+= sprintf(buffer+len,"%-10.10s", len += sprintf(buffer + len, "%-10.10s",
entry->dev->name); entry->dev->name);
len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", len += sprintf(buffer + len,
(int)(entry->hwaddr[0] & 0x000000FF), "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
(int)(entry->hwaddr[1] & 0x000000FF), (int)(entry->hwaddr[0] & 0x000000FF),
(int)(entry->hwaddr[2] & 0x000000FF), (int)(entry->hwaddr[1] & 0x000000FF),
(int)(entry->hwaddr[3] & 0x000000FF), (int)(entry->hwaddr[2] & 0x000000FF),
(int)(entry->hwaddr[4] & 0x000000FF), (int)(entry->hwaddr[3] & 0x000000FF),
(int)(entry->hwaddr[5] & 0x000000FF)); (int)(entry->hwaddr[4] & 0x000000FF),
len+= sprintf(buffer+len,"%12lu ""%12lu ", (int)(entry->hwaddr[5] & 0x000000FF));
(unsigned long)entry->last_sent, len += sprintf(buffer + len, "%12lu ""%12lu ",
(unsigned long)entry->expires_at); (unsigned long)entry->last_sent,
len+=sprintf(buffer+len,"%10u", (unsigned long)entry->expires_at);
(unsigned int)entry->xmit_count); len += sprintf(buffer + len, "%10u",
len+=sprintf(buffer+len," unresolved\n"); (unsigned int)entry->xmit_count);
len += sprintf(buffer + len, " unresolved\n");
} }
} }
for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
for (entry = proxies[ct]; entry; entry = entry->next) { for (entry = proxies[ct]; entry; entry = entry->next) {
len+= sprintf(buffer+len,"%6u:%-3u ", len += sprintf(buffer + len, "%6u:%-3u ",
(unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)ntohs(entry->target_addr.s_net),
(unsigned int)(entry->target_addr.s_node)); (unsigned int)(entry->target_addr.s_node));
len+= sprintf(buffer+len,"%-10.10s", len += sprintf(buffer + len, "%-10.10s",
entry->dev->name); entry->dev->name);
len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", len += sprintf(buffer + len,
(int)(entry->hwaddr[0] & 0x000000FF), "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
(int)(entry->hwaddr[1] & 0x000000FF), (int)(entry->hwaddr[0] & 0x000000FF),
(int)(entry->hwaddr[2] & 0x000000FF), (int)(entry->hwaddr[1] & 0x000000FF),
(int)(entry->hwaddr[3] & 0x000000FF), (int)(entry->hwaddr[2] & 0x000000FF),
(int)(entry->hwaddr[4] & 0x000000FF), (int)(entry->hwaddr[3] & 0x000000FF),
(int)(entry->hwaddr[5] & 0x000000FF)); (int)(entry->hwaddr[4] & 0x000000FF),
len+= sprintf(buffer+len,"%12lu ""%12lu ", (int)(entry->hwaddr[5] & 0x000000FF));
(unsigned long)entry->last_sent, len += sprintf(buffer + len, "%12lu ""%12lu ",
(unsigned long)entry->expires_at); (unsigned long)entry->last_sent,
len+=sprintf(buffer+len,"%10u", (unsigned long)entry->expires_at);
(unsigned int)entry->xmit_count); len += sprintf(buffer + len, "%10u",
len+=sprintf(buffer+len," proxy\n"); (unsigned int)entry->xmit_count);
len += sprintf(buffer + len, " proxy\n");
} }
} }
......
...@@ -99,13 +99,6 @@ extern int aarp_proxy_probe_network(struct atalk_iface *atif, ...@@ -99,13 +99,6 @@ extern int aarp_proxy_probe_network(struct atalk_iface *atif,
struct at_addr *sa); struct at_addr *sa);
extern void aarp_proxy_remove(struct net_device *dev, struct at_addr *sa); extern void aarp_proxy_remove(struct net_device *dev, struct at_addr *sa);
#undef APPLETALK_DEBUG
#ifdef APPLETALK_DEBUG
#define DPRINT(x) print(x)
#else
#define DPRINT(x)
#endif /* APPLETALK_DEBUG */
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
extern inline void atalk_register_sysctl(void); extern inline void atalk_register_sysctl(void);
extern inline void atalk_unregister_sysctl(void); extern inline void atalk_unregister_sysctl(void);
...@@ -182,10 +175,13 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to, ...@@ -182,10 +175,13 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
return s; return s;
} }
/* /**
* Try to find a socket matching ADDR in the socket list, * atalk_find_or_insert_socket - Try to find a socket matching ADDR
* if found then return it. If not, insert SK into the * @sk - socket to insert in the list if it is not there already
* socket list. * @sat - address to search for
*
* Try to find a socket matching ADDR in the socket list, if found then return
* it. If not, insert SK into the socket list.
* *
* This entire operation must execute atomically. * This entire operation must execute atomically.
*/ */
...@@ -219,7 +215,7 @@ static struct sock *atalk_find_or_insert_socket(struct sock *sk, ...@@ -219,7 +215,7 @@ static struct sock *atalk_find_or_insert_socket(struct sock *sk,
static void atalk_destroy_timer(unsigned long data) static void atalk_destroy_timer(unsigned long data)
{ {
struct sock *sk = (struct sock *) data; struct sock *sk = (struct sock *)data;
if (!atomic_read(&sk->wmem_alloc) && if (!atomic_read(&sk->wmem_alloc) &&
!atomic_read(&sk->rmem_alloc) && sk->dead) { !atomic_read(&sk->rmem_alloc) && sk->dead) {
...@@ -263,16 +259,16 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -263,16 +259,16 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length)
for (s = atalk_sockets; s; s = s->next) { for (s = atalk_sockets; s; s = s->next) {
struct atalk_sock *at = at_sk(s); struct atalk_sock *at = at_sk(s);
len += sprintf(buffer + len,"%02X ", s->type); len += sprintf(buffer + len, "%02X ", s->type);
len += sprintf(buffer + len,"%04X:%02X:%02X ", len += sprintf(buffer + len, "%04X:%02X:%02X ",
ntohs(at->src_net), at->src_node, at->src_port); ntohs(at->src_net), at->src_node, at->src_port);
len += sprintf(buffer + len,"%04X:%02X:%02X ", len += sprintf(buffer + len, "%04X:%02X:%02X ",
ntohs(at->dest_net), at->dest_node, ntohs(at->dest_net), at->dest_node,
at->dest_port); at->dest_port);
len += sprintf(buffer + len,"%08X:%08X ", len += sprintf(buffer + len, "%08X:%08X ",
atomic_read(&s->wmem_alloc), atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc)); atomic_read(&s->rmem_alloc));
len += sprintf(buffer + len,"%02X %d\n", s->state, len += sprintf(buffer + len, "%02X %d\n", s->state,
SOCK_INODE(s->socket)->i_uid); SOCK_INODE(s->socket)->i_uid);
/* Are we still dumping unwanted data then discard the record */ /* Are we still dumping unwanted data then discard the record */
...@@ -287,7 +283,7 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -287,7 +283,7 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length)
} }
spin_unlock_bh(&atalk_sockets_lock); spin_unlock_bh(&atalk_sockets_lock);
/* The data in question runs from begin to begin+len */ /* The data in question runs from begin to begin + len */
*start = buffer + offset - begin; /* Start of wanted data */ *start = buffer + offset - begin; /* Start of wanted data */
len -= offset - begin; /* Remove unwanted header data from length */ len -= offset - begin; /* Remove unwanted header data from length */
if (len > length) if (len > length)
...@@ -338,10 +334,13 @@ static void atif_drop_device(struct net_device *dev) ...@@ -338,10 +334,13 @@ static void atif_drop_device(struct net_device *dev)
static struct atalk_iface *atif_add_device(struct net_device *dev, static struct atalk_iface *atif_add_device(struct net_device *dev,
struct at_addr *sa) struct at_addr *sa)
{ {
struct atalk_iface *iface = kmalloc(sizeof(*iface), GFP_KERNEL); struct atalk_iface *iface;
MOD_INC_USE_COUNT;
iface = kmalloc(sizeof(*iface), GFP_KERNEL);
if (!iface) if (!iface)
return NULL; goto out_mem;
iface->dev = dev; iface->dev = dev;
dev->atalk_ptr = iface; dev->atalk_ptr = iface;
...@@ -352,9 +351,11 @@ static struct atalk_iface *atif_add_device(struct net_device *dev, ...@@ -352,9 +351,11 @@ static struct atalk_iface *atif_add_device(struct net_device *dev,
iface->next = atalk_iface_list; iface->next = atalk_iface_list;
atalk_iface_list = iface; atalk_iface_list = iface;
spin_unlock_bh(&atalk_iface_lock); spin_unlock_bh(&atalk_iface_lock);
out:
MOD_INC_USE_COUNT;
return iface; return iface;
out_mem:
MOD_DEC_USE_COUNT;
goto out;
} }
/* Perform phase 2 AARP probing on our tentative address */ /* Perform phase 2 AARP probing on our tentative address */
...@@ -381,7 +382,7 @@ static int atif_probe_device(struct atalk_iface *atif) ...@@ -381,7 +382,7 @@ static int atif_probe_device(struct atalk_iface *atif)
/* Sweep the available nodes from a given start */ /* Sweep the available nodes from a given start */
atif->address.s_net = htons(probe_net); atif->address.s_net = htons(probe_net);
for (nodect = 0; nodect < 256; nodect++) { for (nodect = 0; nodect < 256; nodect++) {
atif->address.s_node = ((nodect+probe_node) & 0xFF); atif->address.s_node = (nodect + probe_node) & 0xFF;
if (atif->address.s_node > 0 && if (atif->address.s_node > 0 &&
atif->address.s_node < 254) { atif->address.s_node < 254) {
/* Probe a proposed address */ /* Probe a proposed address */
...@@ -430,7 +431,7 @@ static int atif_proxy_probe_device(struct atalk_iface *atif, ...@@ -430,7 +431,7 @@ static int atif_proxy_probe_device(struct atalk_iface *atif,
/* Sweep the available nodes from a given start */ /* Sweep the available nodes from a given start */
proxy_addr->s_net = htons(probe_net); proxy_addr->s_net = htons(probe_net);
for (nodect = 0; nodect < 256; nodect++) { for (nodect = 0; nodect < 256; nodect++) {
proxy_addr->s_node = ((nodect + probe_node) & 0xFF); proxy_addr->s_node = (nodect + probe_node) & 0xFF;
if (proxy_addr->s_node > 0 && if (proxy_addr->s_node > 0 &&
proxy_addr->s_node < 254) { proxy_addr->s_node < 254) {
/* Tell AARP to probe a proposed address */ /* Tell AARP to probe a proposed address */
...@@ -482,7 +483,8 @@ static struct at_addr *atalk_find_primary(void) ...@@ -482,7 +483,8 @@ static struct at_addr *atalk_find_primary(void)
retval = &atalk_iface_list->address; retval = &atalk_iface_list->address;
else else
retval = NULL; retval = NULL;
out: spin_unlock_bh(&atalk_iface_lock); out:
spin_unlock_bh(&atalk_iface_lock);
return retval; return retval;
} }
...@@ -577,7 +579,8 @@ static struct atalk_route *atrtr_find(struct at_addr *target) ...@@ -577,7 +579,8 @@ static struct atalk_route *atrtr_find(struct at_addr *target)
r = &atrtr_default; r = &atrtr_default;
else /* No route can be found */ else /* No route can be found */
r = NULL; r = NULL;
out: read_unlock_bh(&atalk_router_lock); out:
read_unlock_bh(&atalk_router_lock);
return r; return r;
} }
...@@ -612,7 +615,7 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) ...@@ -612,7 +615,7 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
struct sockaddr_at *ga = (struct sockaddr_at *)&r->rt_gateway; struct sockaddr_at *ga = (struct sockaddr_at *)&r->rt_gateway;
struct atalk_route *rt; struct atalk_route *rt;
struct atalk_iface *iface, *riface; struct atalk_iface *iface, *riface;
int retval; int retval = -EINVAL;
/* /*
* Fixme: Raise/Lower a routing change semaphore for these * Fixme: Raise/Lower a routing change semaphore for these
...@@ -620,11 +623,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) ...@@ -620,11 +623,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
*/ */
/* Validate the request */ /* Validate the request */
if (ta->sat_family != AF_APPLETALK) if (ta->sat_family != AF_APPLETALK ||
return -EINVAL; (!devhint && ga->sat_family != AF_APPLETALK))
goto out;
if (!devhint && ga->sat_family != AF_APPLETALK)
return -EINVAL;
/* Now walk the routing table and make our decisions */ /* Now walk the routing table and make our decisions */
write_lock_bh(&atalk_router_lock); write_lock_bh(&atalk_router_lock);
...@@ -660,13 +661,13 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) ...@@ -660,13 +661,13 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
retval = -ENETUNREACH; retval = -ENETUNREACH;
if (!riface) if (!riface)
goto out; goto out_unlock;
devhint = riface->dev; devhint = riface->dev;
} }
if (!rt) { if (!rt) {
rt = kmalloc(sizeof(struct atalk_route), GFP_ATOMIC); rt = kmalloc(sizeof(*rt), GFP_ATOMIC);
retval = -ENOBUFS; retval = -ENOBUFS;
if (!rt) if (!rt)
...@@ -683,7 +684,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) ...@@ -683,7 +684,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
rt->gateway = ga->sat_addr; rt->gateway = ga->sat_addr;
retval = 0; retval = 0;
out: write_unlock_bh(&atalk_router_lock); out_unlock:
write_unlock_bh(&atalk_router_lock);
out:
return retval; return retval;
} }
...@@ -706,7 +709,8 @@ static int atrtr_delete(struct at_addr * addr) ...@@ -706,7 +709,8 @@ static int atrtr_delete(struct at_addr * addr)
r = &tmp->next; r = &tmp->next;
} }
retval = -ENOENT; retval = -ENOENT;
out: write_unlock_bh(&atalk_router_lock); out:
write_unlock_bh(&atalk_router_lock);
return retval; return retval;
} }
...@@ -750,7 +754,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event, ...@@ -750,7 +754,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event,
{ {
if (event == NETDEV_DOWN) if (event == NETDEV_DOWN)
/* Discard any use of this */ /* Discard any use of this */
atalk_dev_down((struct net_device *) ptr); atalk_dev_down(ptr);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -759,7 +763,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event, ...@@ -759,7 +763,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event,
/* Device configuration ioctl calls */ /* Device configuration ioctl calls */
static int atif_ioctl(int cmd, void *arg) static int atif_ioctl(int cmd, void *arg)
{ {
static char aarp_mcast[6] = {0x09, 0x00, 0x00, 0xFF, 0xFF, 0xFF}; static char aarp_mcast[6] = { 0x09, 0x00, 0x00, 0xFF, 0xFF, 0xFF };
struct ifreq atreq; struct ifreq atreq;
struct netrange *nr; struct netrange *nr;
struct sockaddr_at *sa; struct sockaddr_at *sa;
...@@ -777,7 +781,7 @@ static int atif_ioctl(int cmd, void *arg) ...@@ -777,7 +781,7 @@ static int atif_ioctl(int cmd, void *arg)
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
sa = (struct sockaddr_at*) &atreq.ifr_addr; sa = (struct sockaddr_at *)&atreq.ifr_addr;
atif = atalk_find_dev(dev); atif = atalk_find_dev(dev);
switch (cmd) { switch (cmd) {
...@@ -792,7 +796,7 @@ static int atif_ioctl(int cmd, void *arg) ...@@ -792,7 +796,7 @@ static int atif_ioctl(int cmd, void *arg)
dev->type != ARPHRD_PPP) dev->type != ARPHRD_PPP)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
nr = (struct netrange *) &sa->sat_zero[0]; nr = (struct netrange *)&sa->sat_zero[0];
add_route = 1; add_route = 1;
/* /*
...@@ -846,11 +850,11 @@ static int atif_ioctl(int cmd, void *arg) ...@@ -846,11 +850,11 @@ static int atif_ioctl(int cmd, void *arg)
} }
/* Hey it worked - add the direct routes */ /* Hey it worked - add the direct routes */
sa = (struct sockaddr_at *) &rtdef.rt_gateway; sa = (struct sockaddr_at *)&rtdef.rt_gateway;
sa->sat_family = AF_APPLETALK; sa->sat_family = AF_APPLETALK;
sa->sat_addr.s_net = atif->address.s_net; sa->sat_addr.s_net = atif->address.s_net;
sa->sat_addr.s_node = atif->address.s_node; sa->sat_addr.s_node = atif->address.s_node;
sa = (struct sockaddr_at *) &rtdef.rt_dst; sa = (struct sockaddr_at *)&rtdef.rt_dst;
rtdef.rt_flags = RTF_UP; rtdef.rt_flags = RTF_UP;
sa->sat_family = AF_APPLETALK; sa->sat_family = AF_APPLETALK;
sa->sat_addr.s_node = ATADDR_ANYNODE; sa->sat_addr.s_node = ATADDR_ANYNODE;
...@@ -932,7 +936,7 @@ static int atif_ioctl(int cmd, void *arg) ...@@ -932,7 +936,7 @@ static int atif_ioctl(int cmd, void *arg)
if (!atif) if (!atif)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
nr = (struct netrange *) &(atif->nets); nr = (struct netrange *)&(atif->nets);
/* /*
* Phase 1 is fine on Localtalk but we don't do * Phase 1 is fine on Localtalk but we don't do
* Ethertalk phase 1. Anyone wanting to add it go ahead. * Ethertalk phase 1. Anyone wanting to add it go ahead.
...@@ -1016,7 +1020,7 @@ static int atalk_if_get_info(char *buffer, char **start, off_t offset, ...@@ -1016,7 +1020,7 @@ static int atalk_if_get_info(char *buffer, char **start, off_t offset,
spin_lock_bh(&atalk_iface_lock); spin_lock_bh(&atalk_iface_lock);
for (iface = atalk_iface_list; iface; iface = iface->next) { for (iface = atalk_iface_list; iface; iface = iface->next) {
len += sprintf(buffer+len,"%-16s %04X:%02X %04X-%04X %d\n", len += sprintf(buffer + len, "%-16s %04X:%02X %04X-%04X %d\n",
iface->dev->name, ntohs(iface->address.s_net), iface->dev->name, ntohs(iface->address.s_net),
iface->address.s_node, iface->address.s_node,
ntohs(iface->nets.nr_firstnet), ntohs(iface->nets.nr_firstnet),
...@@ -1049,7 +1053,8 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset, ...@@ -1049,7 +1053,8 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset,
if (atrtr_default.dev) { if (atrtr_default.dev) {
rt = &atrtr_default; rt = &atrtr_default;
len += sprintf(buffer + len,"Default %04X:%02X %-4d %s\n", len += sprintf(buffer + len,
"Default %04X:%02X %-4d %s\n",
ntohs(rt->gateway.s_net), rt->gateway.s_node, ntohs(rt->gateway.s_net), rt->gateway.s_node,
rt->flags, rt->dev->name); rt->flags, rt->dev->name);
} }
...@@ -1092,7 +1097,7 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset, ...@@ -1092,7 +1097,7 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset,
unsigned short atalk_checksum(struct ddpehdr *ddp, int len) unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
{ {
unsigned long sum = 0; /* Assume unsigned long is >16 bits */ unsigned long sum = 0; /* Assume unsigned long is >16 bits */
unsigned char *data = (unsigned char *) ddp; unsigned char *data = (unsigned char *)ddp;
len -= 4; /* skip header 4 bytes */ len -= 4; /* skip header 4 bytes */
data += 4; data += 4;
...@@ -1108,7 +1113,7 @@ unsigned short atalk_checksum(struct ddpehdr *ddp, int len) ...@@ -1108,7 +1113,7 @@ unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
data++; data++;
} }
/* Use 0xFFFF for 0. 0 itself means none */ /* Use 0xFFFF for 0. 0 itself means none */
return sum ? htons((unsigned short) sum) : 0xFFFF; return sum ? htons((unsigned short)sum) : 0xFFFF;
} }
/* /*
...@@ -1140,9 +1145,12 @@ static int atalk_create(struct socket *sock, int protocol) ...@@ -1140,9 +1145,12 @@ static int atalk_create(struct socket *sock, int protocol)
sock_init_data(sock, sk); sock_init_data(sock, sk);
/* Checksums on by default */ /* Checksums on by default */
sk->zapped = 1; sk->zapped = 1;
out: return rc; out:
outsk: sk_free(sk); return rc;
decmod: MOD_DEC_USE_COUNT; outsk:
sk_free(sk);
decmod:
MOD_DEC_USE_COUNT;
goto out; goto out;
} }
...@@ -1158,13 +1166,17 @@ static int atalk_release(struct socket *sock) ...@@ -1158,13 +1166,17 @@ static int atalk_release(struct socket *sock)
sk->dead = 1; sk->dead = 1;
sock->sk = NULL; sock->sk = NULL;
atalk_destroy_socket(sk); atalk_destroy_socket(sk);
out: return 0; out:
return 0;
} }
/* /**
* Pick a source port when one is not given. If we can * atalk_pick_and_bind_port - Pick a source port when one is not given
* find a suitable free one, we insert the socket into * @sk - socket to insert into the tables
* the tables using it. * @sat - address to search for
*
* Pick a source port when one is not given. If we can find a suitable free
* one, we insert the socket into the tables using it.
* *
* This whole operation must be atomic. * This whole operation must be atomic.
*/ */
...@@ -1197,12 +1209,12 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat) ...@@ -1197,12 +1209,12 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat)
retval = 0; retval = 0;
goto out; goto out;
try_next_port: try_next_port:;
;
} }
retval = -EBUSY; retval = -EBUSY;
out: spin_unlock_bh(&atalk_sockets_lock); out:
spin_unlock_bh(&atalk_sockets_lock);
return retval; return retval;
} }
...@@ -1210,21 +1222,20 @@ static int atalk_autobind(struct sock *sk) ...@@ -1210,21 +1222,20 @@ static int atalk_autobind(struct sock *sk)
{ {
struct atalk_sock *at = at_sk(sk); struct atalk_sock *at = at_sk(sk);
struct sockaddr_at sat; struct sockaddr_at sat;
int n;
struct at_addr *ap = atalk_find_primary(); struct at_addr *ap = atalk_find_primary();
int n = -EADDRNOTAVAIL;
if (!ap || ap->s_net == htons(ATADDR_ANYNET)) if (!ap || ap->s_net == htons(ATADDR_ANYNET))
return -EADDRNOTAVAIL; goto out;
at->src_net = sat.sat_addr.s_net = ap->s_net; at->src_net = sat.sat_addr.s_net = ap->s_net;
at->src_node = sat.sat_addr.s_node = ap->s_node; at->src_node = sat.sat_addr.s_node = ap->s_node;
n = atalk_pick_and_bind_port(sk, &sat); n = atalk_pick_and_bind_port(sk, &sat);
if (n < 0) if (!n)
return n; sk->zapped = 0;
out:
sk->zapped = 0; return n;
return 0;
} }
/* Set the address 'our end' of the connection */ /* Set the address 'our end' of the connection */
...@@ -1355,7 +1366,12 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1355,7 +1366,12 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
return 0; return 0;
} }
/* /**
* atalk_rcv - Receive a packet (in skb) from device dev
* @skb - packet received
* @dev - network device where the packet comes from
* @pt - packet type
*
* Receive a packet (in skb) from device dev. This has come from the SNAP * Receive a packet (in skb) from device dev. This has come from the SNAP
* decoder, and on entry skb->h.raw is the DDP header, skb->len is the DDP * decoder, and on entry skb->h.raw is the DDP header, skb->len is the DDP
* header, skb->len is the DDP length. The physical headers have been * header, skb->len is the DDP length. The physical headers have been
...@@ -1363,9 +1379,9 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1363,9 +1379,9 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
* [ie ARPHRD_ETHERTALK] * [ie ARPHRD_ETHERTALK]
*/ */
static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt) struct packet_type *pt)
{ {
struct ddpehdr *ddp = (void *) skb->h.raw; struct ddpehdr *ddp = (void *)skb->h.raw;
struct sock *sock; struct sock *sock;
struct atalk_iface *atif; struct atalk_iface *atif;
struct sockaddr_at tosat; struct sockaddr_at tosat;
...@@ -1442,6 +1458,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -1442,6 +1458,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
rt = atrtr_find(&ta); rt = atrtr_find(&ta);
if (!rt || ddphv.deh_hops == DDP_MAXHOPS) if (!rt || ddphv.deh_hops == DDP_MAXHOPS)
goto freeit; goto freeit;
/* FIXME: use skb->cb to be able to use shared skbs */
ddphv.deh_hops++; ddphv.deh_hops++;
/* /*
...@@ -1454,10 +1471,12 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -1454,10 +1471,12 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
} }
/* Fix up skb->len field */ /* Fix up skb->len field */
skb_trim(skb, min_t(unsigned int, origlen, rt->dev->hard_header_len + skb_trim(skb, min_t(unsigned int, origlen,
ddp_dl->header_length + ddphv.deh_len)); (rt->dev->hard_header_len +
ddp_dl->header_length + ddphv.deh_len)));
/* Mend the byte order */ /* Mend the byte order */
/* FIXME: use skb->cb to be able to use shared skbs */
*((__u16 *)ddp) = ntohs(*((__u16 *)&ddphv)); *((__u16 *)ddp) = ntohs(*((__u16 *)&ddphv));
/* /*
...@@ -1515,11 +1534,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -1515,11 +1534,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
#endif #endif
/* /*
* Which socket - atalk_search_socket() looks for a *full match* * Which socket - atalk_search_socket() looks for a *full match*
* of the <net,node,port> tuple. * of the <net, node, port> tuple.
*/ */
tosat.sat_addr.s_net = ddp->deh_dnet; tosat.sat_addr.s_net = ddp->deh_dnet;
tosat.sat_addr.s_node = ddp->deh_dnode; tosat.sat_addr.s_node = ddp->deh_dnode;
tosat.sat_port = ddp->deh_dport; tosat.sat_port = ddp->deh_dport;
sock = atalk_search_socket(&tosat, atif); sock = atalk_search_socket(&tosat, atif);
if (!sock) /* But not one of our sockets */ if (!sock) /* But not one of our sockets */
...@@ -1530,9 +1549,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -1530,9 +1549,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
if (sock_queue_rcv_skb(sock, skb) < 0) if (sock_queue_rcv_skb(sock, skb) < 0)
goto freeit; goto freeit;
out:
return 0;
freeit:
kfree_skb(skb);
goto out; goto out;
freeit: kfree_skb(skb);
out: return 0;
} }
/* /*
...@@ -1543,25 +1564,21 @@ out: return 0; ...@@ -1543,25 +1564,21 @@ out: return 0;
static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt) struct packet_type *pt)
{ {
struct ddpehdr *ddp;
struct at_addr *ap;
/* Expand any short form frames */ /* Expand any short form frames */
if (skb->mac.raw[2] == 1) { if (skb->mac.raw[2] == 1) {
struct ddpehdr *ddp;
/* Find our address */ /* Find our address */
struct at_addr *ap = atalk_find_dev_addr(dev);
ap = atalk_find_dev_addr(dev); if (!ap || skb->len < sizeof(struct ddpshdr))
if (!ap || skb->len < sizeof(struct ddpshdr)) { goto freeit;
kfree_skb(skb);
return 0;
}
/* /*
* The push leaves us with a ddephdr not an shdr, and * The push leaves us with a ddephdr not an shdr, and
* handily the port bytes in the right place preset. * handily the port bytes in the right place preset.
*/ */
skb_push(skb, sizeof(*ddp) - 4); skb_push(skb, sizeof(*ddp) - 4);
/* FIXME: use skb->cb to be able to use shared skbs */
ddp = (struct ddpehdr *)skb->data; ddp = (struct ddpehdr *)skb->data;
/* Now fill in the long header */ /* Now fill in the long header */
...@@ -1590,10 +1607,13 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -1590,10 +1607,13 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
skb->h.raw = skb->data; skb->h.raw = skb->data;
return atalk_rcv(skb, dev, pt); return atalk_rcv(skb, dev, pt);
freeit:
kfree_skb(skb);
return 0;
} }
static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len, static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm) struct scm_cookie *scm)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct atalk_sock *at = at_sk(sk); struct atalk_sock *at = at_sk(sk);
...@@ -1762,17 +1782,16 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, ...@@ -1762,17 +1782,16 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name; struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name;
struct ddpehdr *ddp = NULL; struct ddpehdr *ddp;
int copied = 0; int copied = 0;
int err = 0; int err = 0;
struct ddpebits ddphv; struct ddpebits ddphv;
struct sk_buff *skb; struct sk_buff *skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err);
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err);
if (!skb) if (!skb)
return err; return err;
/* FIXME: use skb->cb to be able to use shared skbs */
ddp = (struct ddpehdr *)(skb->h.raw); ddp = (struct ddpehdr *)(skb->h.raw);
*((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp)); *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp));
...@@ -1791,7 +1810,7 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, ...@@ -1791,7 +1810,7 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
} }
err = skb_copy_datagram_iovec(skb, sizeof(*ddp), err = skb_copy_datagram_iovec(skb, sizeof(*ddp),
msg->msg_iov, copied); msg->msg_iov, copied);
} }
if (!err) { if (!err) {
...@@ -1805,14 +1824,14 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, ...@@ -1805,14 +1824,14 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
} }
skb_free_datagram(sk, skb); /* Free the datagram. */ skb_free_datagram(sk, skb); /* Free the datagram. */
return err ? err : copied; return err ? : copied;
} }
/* /*
* AppleTalk ioctl calls. * AppleTalk ioctl calls.
*/ */
static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
long amount = 0; long amount = 0;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -1824,14 +1843,15 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) ...@@ -1824,14 +1843,15 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
if (amount < 0) if (amount < 0)
amount = 0; amount = 0;
break; break;
case TIOCINQ: case TIOCINQ: {
{ /*
/* These two are safe on a single CPU system as only * These two are safe on a single CPU system as only
* user tasks fiddle here */ * user tasks fiddle here
*/
struct sk_buff *skb = skb_peek(&sk->receive_queue); struct sk_buff *skb = skb_peek(&sk->receive_queue);
if (skb) if (skb)
amount = skb->len-sizeof(struct ddpehdr); amount = skb->len - sizeof(struct ddpehdr);
break; break;
} }
case SIOCGSTAMP: case SIOCGSTAMP:
...@@ -1853,9 +1873,8 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) ...@@ -1853,9 +1873,8 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
case SIOCGIFBRDADDR: case SIOCGIFBRDADDR:
case SIOCATALKDIFADDR: case SIOCATALKDIFADDR:
case SIOCDIFADDR: case SIOCDIFADDR:
case SIOCSARP: /* proxy AARP */ case SIOCSARP: /* proxy AARP */
case SIOCDARP: /* proxy AARP */ case SIOCDARP: { /* proxy AARP */
{
int ret; int ret;
rtnl_lock(); rtnl_lock();
...@@ -1877,7 +1896,7 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) ...@@ -1877,7 +1896,7 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
case SIOCGIFCOUNT: case SIOCGIFCOUNT:
case SIOCGIFINDEX: case SIOCGIFINDEX:
case SIOCGIFNAME: case SIOCGIFNAME:
return dev_ioctl(cmd,(void *) arg); return dev_ioctl(cmd, (void *)arg);
case SIOCSIFMETRIC: case SIOCSIFMETRIC:
case SIOCSIFBRDADDR: case SIOCSIFBRDADDR:
case SIOCGIFNETMASK: case SIOCGIFNETMASK:
...@@ -1899,10 +1918,7 @@ static struct net_proto_family atalk_family_ops = { ...@@ -1899,10 +1918,7 @@ static struct net_proto_family atalk_family_ops = {
.create =atalk_create, .create =atalk_create,
}; };
static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)=
{
.family = PF_APPLETALK, .family = PF_APPLETALK,
.release = atalk_release, .release = atalk_release,
.bind = atalk_bind, .bind = atalk_bind,
.connect = atalk_connect, .connect = atalk_connect,
...@@ -1924,32 +1940,21 @@ static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)= ...@@ -1924,32 +1940,21 @@ static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)=
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
SOCKOPS_WRAP(atalk_dgram, PF_APPLETALK); SOCKOPS_WRAP(atalk_dgram, PF_APPLETALK);
static struct notifier_block ddp_notifier= static struct notifier_block ddp_notifier = {
{ .notifier_call = ddp_device_event,
ddp_device_event,
NULL,
0
}; };
struct packet_type ltalk_packet_type= struct packet_type ltalk_packet_type = {
{ .type = __constant_htons(ETH_P_LOCALTALK),
0, .func = ltalk_rcv,
NULL,
ltalk_rcv,
NULL,
NULL
}; };
struct packet_type ppptalk_packet_type= struct packet_type ppptalk_packet_type = {
{ .type = __constant_htons(ETH_P_PPPTALK),
0, .func = atalk_rcv,
NULL,
atalk_rcv,
NULL,
NULL
}; };
static char ddp_snap_id[] = {0x08, 0x00, 0x07, 0x80, 0x9B}; static char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B };
/* Export symbols for use by drivers when AppleTalk is a module */ /* Export symbols for use by drivers when AppleTalk is a module */
EXPORT_SYMBOL(aarp_send_ddp); EXPORT_SYMBOL(aarp_send_ddp);
...@@ -1959,15 +1964,12 @@ EXPORT_SYMBOL(atalk_find_dev_addr); ...@@ -1959,15 +1964,12 @@ EXPORT_SYMBOL(atalk_find_dev_addr);
/* Called by proto.c on kernel start up */ /* Called by proto.c on kernel start up */
static int __init atalk_init(void) static int __init atalk_init(void)
{ {
(void) sock_register(&atalk_family_ops); (void)sock_register(&atalk_family_ops);
ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv); ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv);
if (!ddp_dl) if (!ddp_dl)
printk(KERN_CRIT "Unable to register DDP with SNAP.\n"); printk(KERN_CRIT "Unable to register DDP with SNAP.\n");
ltalk_packet_type.type = htons(ETH_P_LOCALTALK);
dev_add_pack(&ltalk_packet_type); dev_add_pack(&ltalk_packet_type);
ppptalk_packet_type.type = htons(ETH_P_PPPTALK);
dev_add_pack(&ppptalk_packet_type); dev_add_pack(&ppptalk_packet_type);
register_netdevice_notifier(&ddp_notifier); register_netdevice_notifier(&ddp_notifier);
......
/* -*- linux-c -*- /*
* sysctl_net_atalk.c: sysctl interface to net AppleTalk subsystem. * sysctl_net_atalk.c: sysctl interface to net AppleTalk subsystem.
* *
* Begun April 1, 1996, Mike Shaver. * Begun April 1, 1996, Mike Shaver.
...@@ -17,25 +17,59 @@ extern int sysctl_aarp_resolve_time; ...@@ -17,25 +17,59 @@ extern int sysctl_aarp_resolve_time;
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
static ctl_table atalk_table[] = { static ctl_table atalk_table[] = {
{NET_ATALK_AARP_EXPIRY_TIME, "aarp-expiry-time", {
&sysctl_aarp_expiry_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, .ctl_name = NET_ATALK_AARP_EXPIRY_TIME,
{NET_ATALK_AARP_TICK_TIME, "aarp-tick-time", .procname = "aarp-expiry-time",
&sysctl_aarp_tick_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, .data = &sysctl_aarp_expiry_time,
{NET_ATALK_AARP_RETRANSMIT_LIMIT, "aarp-retransmit-limit", .maxlen = sizeof(int),
&sysctl_aarp_retransmit_limit, sizeof(int), 0644, NULL, &proc_dointvec}, .mode = 0644,
{NET_ATALK_AARP_RESOLVE_TIME, "aarp-resolve-time", .proc_handler = &proc_dointvec_jiffies,
&sysctl_aarp_resolve_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, },
{0} {
.ctl_name = NET_ATALK_AARP_TICK_TIME,
.procname = "aarp-tick-time",
.data = &sysctl_aarp_tick_time,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_jiffies,
},
{
.ctl_name = NET_ATALK_AARP_RETRANSMIT_LIMIT,
.procname = "aarp-retransmit-limit",
.data = &sysctl_aarp_retransmit_limit,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
{
.ctl_name = NET_ATALK_AARP_RESOLVE_TIME,
.procname = "aarp-resolve-time",
.data = &sysctl_aarp_resolve_time,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_jiffies,
},
{ 0 },
}; };
static ctl_table atalk_dir_table[] = { static ctl_table atalk_dir_table[] = {
{NET_ATALK, "appletalk", NULL, 0, 0555, atalk_table}, {
{0} .ctl_name = NET_ATALK,
.procname = "appletalk",
.mode = 0555,
.child = atalk_table,
},
{ 0 },
}; };
static ctl_table atalk_root_table[] = { static ctl_table atalk_root_table[] = {
{CTL_NET, "net", NULL, 0, 0555, atalk_dir_table}, {
{0} .ctl_name = CTL_NET,
.procname = "net",
.mode = 0555,
.child = atalk_dir_table,
},
{ 0 },
}; };
static struct ctl_table_header *atalk_table_header; static struct ctl_table_header *atalk_table_header;
......
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