diff options
author | Rémi Denis-Courmont <remi.denis-courmont@nokia.com> | 2009-09-09 00:00:05 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-11 12:55:06 -0700 |
commit | f5bb1c558405aaac41b08b2ea71137db9db46e72 (patch) | |
tree | deeabf046d4d18675bf85360a3059eb4f29f8d62 /net/phonet | |
parent | 998ec759ef2fc9c60319815c72b2b699ab939733 (diff) | |
download | linux-stable-f5bb1c558405aaac41b08b2ea71137db9db46e72.tar.gz linux-stable-f5bb1c558405aaac41b08b2ea71137db9db46e72.tar.bz2 linux-stable-f5bb1c558405aaac41b08b2ea71137db9db46e72.zip |
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.c | 26 |
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 @@ #include <linux/netdevice.h> #include <linux/phonet.h> #include <linux/proc_fs.h> +#include <linux/if_arp.h> #include <net/sock.h> #include <net/netns/generic.h> #include <net/phonet/pn_dev.h> @@ -195,14 +196,37 @@ found: return err; } +/* automatically configure a Phonet device, if supported */ +static int phonet_device_autoconf(struct net_device *dev) +{ + struct if_phonet_req req; + int ret; + + if (!dev->netdev_ops->ndo_do_ioctl) + return -EOPNOTSUPP; + + ret = dev->netdev_ops->ndo_do_ioctl(dev, (struct ifreq *)&req, + SIOCPNGAUTOCONF); + if (ret < 0) + return ret; + return phonet_address_add(dev, req.ifr_phonet_autoconf.device); +} + /* notify Phonet of device events */ static int phonet_device_notify(struct notifier_block *me, unsigned long what, void *arg) { struct net_device *dev = arg; - if (what == NETDEV_UNREGISTER) + switch (what) { + case NETDEV_REGISTER: + if (dev->type == ARPHRD_PHONET) + phonet_device_autoconf(dev); + break; + case NETDEV_UNREGISTER: phonet_device_destroy(dev); + break; + } return 0; } |