new, improved appletalk patch

a sun (asun@zoology.washington.edu)
Mon, 31 Mar 1997 14:10:36 -0800 (PST)


here's the hopefully correct patch for appletalk. it's against
2.1.30. here's what it does:
1) memory fix on device creation
2) assigns dev->atalk_ptr to NULL on module unloading.
3) adds SIOCATALKDIFADDR to delete an appletalk interface.

with this patch, if you have appletalk support as a module, killing
atalkd and unloading the module will allow you to restart atalkd. if
you add a little patch to atalkd so that it uses SIOCATALKDIFADDR in
the same way that BSD uses SIOCDIFADDR, atalkd will take down its
interfaces properly when it dies as well.

--- linux/net/appletalk/ddp.c.save Mon Mar 31 11:45:48 1997
+++ linux/net/appletalk/ddp.c Mon Mar 31 14:02:58 1997
@@ -708,6 +708,8 @@
else
{
atif=atif_add_device(dev, &sa->sat_addr);
+ if (atif == NULL)
+ return -ENOMEM;
}
atif->nets= *nr;

@@ -775,6 +777,16 @@
((struct sockaddr_at *)(&atreq.ifr_addr))->sat_addr.s_net=atif->address.s_net;
((struct sockaddr_at *)(&atreq.ifr_addr))->sat_addr.s_node=ATADDR_BCAST;
break;
+ case SIOCATALKDIFADDR:
+ if(!suser())
+ return -EPERM;
+ if(sa->sat_family!=AF_APPLETALK)
+ return -EINVAL;
+ if(atif==NULL)
+ return -EADDRNOTAVAIL;
+ atrtr_device_down(atif->dev);
+ atif_drop_device(atif->dev);
+ break;
}
err = copy_to_user(arg,&atreq,sizeof(atreq));

@@ -1929,6 +1941,7 @@
case SIOCGIFADDR:
case SIOCSIFADDR:
case SIOCGIFBRDADDR:
+ case SIOCATALKDIFADDR:
return atif_ioctl(cmd,(void *)arg);
/*
* Physical layer ioctl calls
@@ -2099,6 +2112,7 @@
while (list != NULL)
{
tmp = list->next;
+ list->dev->atalk_ptr = NULL;
kfree_s(list, sizeof(struct atalk_iface));
list = tmp;
}
--- linux/include/linux/atalk.h.save Mon Mar 31 11:19:29 1997
+++ linux/include/linux/atalk.h Mon Mar 31 11:19:37 1997
@@ -8,6 +8,8 @@
#ifndef __LINUX_ATALK_H__
#define __LINUX_ATALK_H__

+#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
+
#define ATPORT_FIRST 1
#define ATPORT_RESERVED 128
#define ATPORT_LAST 255