diff options
author | Rémi Denis-Courmont <remi.denis-courmont@nokia.com> | 2009-09-08 20:00:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-11 15:55:06 -0400 |
commit | f5bb1c558405aaac41b08b2ea71137db9db46e72 (patch) | |
tree | deeabf046d4d18675bf85360a3059eb4f29f8d62 | |
parent | 998ec759ef2fc9c60319815c72b2b699ab939733 (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>
-rw-r--r-- | include/linux/phonet.h | 17 | ||||
-rw-r--r-- | net/phonet/pn_dev.c | 26 |
2 files changed, 42 insertions, 1 deletions
diff --git a/include/linux/phonet.h b/include/linux/phonet.h index ee5e3c9e2bca..82b45d16e50c 100644 --- a/include/linux/phonet.h +++ b/include/linux/phonet.h | |||
@@ -170,4 +170,21 @@ static inline __u8 pn_sockaddr_get_resource(const struct sockaddr_pn *spn) | |||
170 | return spn->spn_resource; | 170 | return spn->spn_resource; |
171 | } | 171 | } |
172 | 172 | ||
173 | /* Phonet device ioctl requests */ | ||
174 | #ifdef __KERNEL__ | ||
175 | #define SIOCPNGAUTOCONF (SIOCDEVPRIVATE + 0) | ||
176 | |||
177 | struct if_phonet_autoconf { | ||
178 | uint8_t device; | ||
179 | }; | ||
180 | |||
181 | struct if_phonet_req { | ||
182 | char ifr_phonet_name[16]; | ||
183 | union { | ||
184 | struct if_phonet_autoconf ifru_phonet_autoconf; | ||
185 | } ifr_ifru; | ||
186 | }; | ||
187 | #define ifr_phonet_autoconf ifr_ifru.ifru_phonet_autoconf | ||
188 | #endif /* __KERNEL__ */ | ||
189 | |||
173 | #endif | 190 | #endif |
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 | } |