aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2009-09-08 20:00:05 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-11 15:55:06 -0400
commitf5bb1c558405aaac41b08b2ea71137db9db46e72 (patch)
treedeeabf046d4d18675bf85360a3059eb4f29f8d62 /net/phonet
parent998ec759ef2fc9c60319815c72b2b699ab939733 (diff)
Phonet: back-end for autoconfigured addresses
In some cases, the network device driver knows what layer-3 address the device should have. This adds support for the Phonet stack to automatically request from the driver and add that address to the network device. Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/pn_dev.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 5ae4c01e8388..2f65dcaed2fb 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -28,6 +28,7 @@
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/phonet.h> 29#include <linux/phonet.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/if_arp.h>
31#include <net/sock.h> 32#include <net/sock.h>
32#include <net/netns/generic.h> 33#include <net/netns/generic.h>
33#include <net/phonet/pn_dev.h> 34#include <net/phonet/pn_dev.h>
@@ -195,14 +196,37 @@ found:
195 return err; 196 return err;
196} 197}
197 198
199/* automatically configure a Phonet device, if supported */
200static int phonet_device_autoconf(struct net_device *dev)
201{
202 struct if_phonet_req req;
203 int ret;
204
205 if (!dev->netdev_ops->ndo_do_ioctl)
206 return -EOPNOTSUPP;
207
208 ret = dev->netdev_ops->ndo_do_ioctl(dev, (struct ifreq *)&req,
209 SIOCPNGAUTOCONF);
210 if (ret < 0)
211 return ret;
212 return phonet_address_add(dev, req.ifr_phonet_autoconf.device);
213}
214
198/* notify Phonet of device events */ 215/* notify Phonet of device events */
199static int phonet_device_notify(struct notifier_block *me, unsigned long what, 216static int phonet_device_notify(struct notifier_block *me, unsigned long what,
200 void *arg) 217 void *arg)
201{ 218{
202 struct net_device *dev = arg; 219 struct net_device *dev = arg;
203 220
204 if (what == NETDEV_UNREGISTER) 221 switch (what) {
222 case NETDEV_REGISTER:
223 if (dev->type == ARPHRD_PHONET)
224 phonet_device_autoconf(dev);
225 break;
226 case NETDEV_UNREGISTER:
205 phonet_device_destroy(dev); 227 phonet_device_destroy(dev);
228 break;
229 }
206 return 0; 230 return 0;
207 231
208} 232}