diff options
Diffstat (limited to 'net/phonet/pn_dev.c')
-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 @@ | |||
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 */ | ||
200 | static 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 */ |
199 | static int phonet_device_notify(struct notifier_block *me, unsigned long what, | 216 | static 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 | } |