net: make SO_BUSY_POLL available to all users
[linux-2.6-block.git] / net / core / dev_ioctl.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
96b45cbd
CW
2#include <linux/kmod.h>
3#include <linux/netdevice.h>
b0e99d03 4#include <linux/inetdevice.h>
96b45cbd
CW
5#include <linux/etherdevice.h>
6#include <linux/rtnetlink.h>
7#include <linux/net_tstamp.h>
8#include <linux/wireless.h>
ad2f99ae 9#include <linux/if_bridge.h>
3369afba 10#include <net/dsa.h>
96b45cbd
CW
11#include <net/wext.h>
12
6264f58c
JK
13#include "dev.h"
14
96b45cbd
CW
15/*
16 * Map an interface index to its name (SIOCGIFNAME)
17 */
18
19/*
20 * We need this ioctl for efficient implementation of the
21 * if_indextoname() function required by the IPv6 API. Without
22 * it, we would have to search all the interfaces to find a
23 * match. --pb
24 */
25
44c02a2c 26static int dev_ifname(struct net *net, struct ifreq *ifr)
96b45cbd 27{
44c02a2c
AV
28 ifr->ifr_name[IFNAMSIZ-1] = 0;
29 return netdev_get_name(net, ifr->ifr_name, ifr->ifr_ifindex);
96b45cbd
CW
30}
31
96b45cbd
CW
32/*
33 * Perform a SIOCGIFCONF call. This structure will change
34 * size eventually, and there is nothing I can do about it.
35 * Thus we will need a 'compatibility mode'.
36 */
876f0bf9 37int dev_ifconf(struct net *net, struct ifconf __user *uifc)
96b45cbd 38{
96b45cbd 39 struct net_device *dev;
876f0bf9
AB
40 void __user *pos;
41 size_t size;
42 int len, total = 0, done;
96b45cbd 43
876f0bf9
AB
44 /* both the ifconf and the ifreq structures are slightly different */
45 if (in_compat_syscall()) {
46 struct compat_ifconf ifc32;
96b45cbd 47
876f0bf9
AB
48 if (copy_from_user(&ifc32, uifc, sizeof(struct compat_ifconf)))
49 return -EFAULT;
96b45cbd 50
876f0bf9
AB
51 pos = compat_ptr(ifc32.ifcbuf);
52 len = ifc32.ifc_len;
53 size = sizeof(struct compat_ifreq);
54 } else {
55 struct ifconf ifc;
56
57 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
58 return -EFAULT;
96b45cbd 59
876f0bf9
AB
60 pos = ifc.ifc_buf;
61 len = ifc.ifc_len;
62 size = sizeof(struct ifreq);
63 }
64
65 /* Loop over the interfaces, and write an info block for each. */
66 rtnl_lock();
96b45cbd 67 for_each_netdev(net, dev) {
b0e99d03
AB
68 if (!pos)
69 done = inet_gifconf(dev, NULL, 0, size);
70 else
71 done = inet_gifconf(dev, pos + total,
72 len - total, size);
876f0bf9
AB
73 if (done < 0) {
74 rtnl_unlock();
b0e99d03 75 return -EFAULT;
876f0bf9 76 }
b0e99d03 77 total += done;
96b45cbd 78 }
876f0bf9 79 rtnl_unlock();
96b45cbd 80
876f0bf9 81 return put_user(total, &uifc->ifc_len);
96b45cbd
CW
82}
83
709566d7
AB
84static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
85{
86 struct ifmap *ifmap = &ifr->ifr_map;
87
88 if (in_compat_syscall()) {
89 struct compat_ifmap *cifmap = (struct compat_ifmap *)ifmap;
90
91 cifmap->mem_start = dev->mem_start;
92 cifmap->mem_end = dev->mem_end;
93 cifmap->base_addr = dev->base_addr;
94 cifmap->irq = dev->irq;
95 cifmap->dma = dev->dma;
96 cifmap->port = dev->if_port;
97
98 return 0;
99 }
100
101 ifmap->mem_start = dev->mem_start;
102 ifmap->mem_end = dev->mem_end;
103 ifmap->base_addr = dev->base_addr;
104 ifmap->irq = dev->irq;
105 ifmap->dma = dev->dma;
106 ifmap->port = dev->if_port;
107
108 return 0;
109}
110
111static int dev_setifmap(struct net_device *dev, struct ifreq *ifr)
112{
113 struct compat_ifmap *cifmap = (struct compat_ifmap *)&ifr->ifr_map;
114
115 if (!dev->netdev_ops->ndo_set_config)
116 return -EOPNOTSUPP;
117
118 if (in_compat_syscall()) {
119 struct ifmap ifmap = {
120 .mem_start = cifmap->mem_start,
121 .mem_end = cifmap->mem_end,
122 .base_addr = cifmap->base_addr,
123 .irq = cifmap->irq,
124 .dma = cifmap->dma,
125 .port = cifmap->port,
126 };
127
128 return dev->netdev_ops->ndo_set_config(dev, &ifmap);
129 }
130
131 return dev->netdev_ops->ndo_set_config(dev, &ifr->ifr_map);
132}
133
96b45cbd
CW
134/*
135 * Perform the SIOCxIFxxx calls, inside rcu_read_lock()
136 */
137static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cmd)
138{
139 int err;
140 struct net_device *dev = dev_get_by_name_rcu(net, ifr->ifr_name);
141
142 if (!dev)
143 return -ENODEV;
144
145 switch (cmd) {
146 case SIOCGIFFLAGS: /* Get interface flags */
147 ifr->ifr_flags = (short) dev_get_flags(dev);
148 return 0;
149
150 case SIOCGIFMETRIC: /* Get the metric on the interface
151 (currently unused) */
152 ifr->ifr_metric = 0;
153 return 0;
154
155 case SIOCGIFMTU: /* Get the MTU of a device */
156 ifr->ifr_mtu = dev->mtu;
157 return 0;
158
96b45cbd
CW
159 case SIOCGIFSLAVE:
160 err = -EINVAL;
161 break;
162
163 case SIOCGIFMAP:
709566d7 164 return dev_getifmap(dev, ifr);
96b45cbd
CW
165
166 case SIOCGIFINDEX:
167 ifr->ifr_ifindex = dev->ifindex;
168 return 0;
169
170 case SIOCGIFTXQLEN:
171 ifr->ifr_qlen = dev->tx_queue_len;
172 return 0;
173
174 default:
175 /* dev_ioctl() should ensure this case
176 * is never reached
177 */
178 WARN_ON(1);
179 err = -ENOTTY;
180 break;
181
182 }
183 return err;
184}
185
c4bffeaa 186static int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg)
96b45cbd 187{
96b45cbd
CW
188 enum hwtstamp_tx_types tx_type;
189 enum hwtstamp_rx_filters rx_filter;
190 int tx_type_valid = 0;
191 int rx_filter_valid = 0;
192
d5d5fd8f 193 if (cfg->flags & ~HWTSTAMP_FLAG_MASK)
96b45cbd
CW
194 return -EINVAL;
195
d5d5fd8f
VO
196 tx_type = cfg->tx_type;
197 rx_filter = cfg->rx_filter;
96b45cbd
CW
198
199 switch (tx_type) {
200 case HWTSTAMP_TX_OFF:
201 case HWTSTAMP_TX_ON:
202 case HWTSTAMP_TX_ONESTEP_SYNC:
b6fd7b96 203 case HWTSTAMP_TX_ONESTEP_P2P:
96b45cbd
CW
204 tx_type_valid = 1;
205 break;
f76510b4
MK
206 case __HWTSTAMP_TX_CNT:
207 /* not a real value */
208 break;
96b45cbd
CW
209 }
210
211 switch (rx_filter) {
212 case HWTSTAMP_FILTER_NONE:
213 case HWTSTAMP_FILTER_ALL:
214 case HWTSTAMP_FILTER_SOME:
215 case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
216 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
217 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
218 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
219 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
220 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
221 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
222 case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
223 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
224 case HWTSTAMP_FILTER_PTP_V2_EVENT:
225 case HWTSTAMP_FILTER_PTP_V2_SYNC:
226 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
b8210a9e 227 case HWTSTAMP_FILTER_NTP_ALL:
e3412575 228 rx_filter_valid = 1;
b8210a9e 229 break;
f76510b4
MK
230 case __HWTSTAMP_FILTER_CNT:
231 /* not a real value */
232 break;
96b45cbd
CW
233 }
234
235 if (!tx_type_valid || !rx_filter_valid)
236 return -ERANGE;
237
238 return 0;
239}
240
a7605370
AB
241static int dev_eth_ioctl(struct net_device *dev,
242 struct ifreq *ifr, unsigned int cmd)
aad74d84
FF
243{
244 const struct net_device_ops *ops = dev->netdev_ops;
4ee58e1e
VO
245
246 if (!ops->ndo_eth_ioctl)
247 return -EOPNOTSUPP;
248
249 if (!netif_device_present(dev))
250 return -ENODEV;
251
252 return ops->ndo_eth_ioctl(dev, ifr, cmd);
253}
254
255static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
256{
257 return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP);
258}
259
260static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
261{
88c0a6b5
VO
262 struct netdev_notifier_hwtstamp_info info = {
263 .info.dev = dev,
264 };
c4bffeaa 265 struct kernel_hwtstamp_config kernel_cfg;
88c0a6b5 266 struct netlink_ext_ack extack = {};
d5d5fd8f 267 struct hwtstamp_config cfg;
1ca47431 268 int err;
aad74d84 269
d5d5fd8f
VO
270 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
271 return -EFAULT;
272
c4bffeaa
VO
273 hwtstamp_config_to_kernel(&kernel_cfg, &cfg);
274
275 err = net_hwtstamp_validate(&kernel_cfg);
4ee58e1e 276 if (err)
3369afba
FF
277 return err;
278
88c0a6b5
VO
279 info.info.extack = &extack;
280 info.config = &kernel_cfg;
281
282 err = call_netdevice_notifiers_info(NETDEV_PRE_CHANGE_HWTSTAMP,
283 &info.info);
284 err = notifier_to_errno(err);
285 if (err) {
286 if (extack._msg)
287 netdev_err(dev, "%s\n", extack._msg);
4ee58e1e 288 return err;
88c0a6b5 289 }
aad74d84 290
4ee58e1e 291 return dev_eth_ioctl(dev, ifr, SIOCSHWTSTAMP);
aad74d84
FF
292}
293
3d9d00bd 294static int dev_siocbond(struct net_device *dev,
a7605370
AB
295 struct ifreq *ifr, unsigned int cmd)
296{
297 const struct net_device_ops *ops = dev->netdev_ops;
298
3d9d00bd 299 if (ops->ndo_siocbond) {
a7605370 300 if (netif_device_present(dev))
3d9d00bd 301 return ops->ndo_siocbond(dev, ifr, cmd);
a7605370
AB
302 else
303 return -ENODEV;
304 }
305
306 return -EOPNOTSUPP;
307}
308
a554bf96
AB
309static int dev_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
310 void __user *data, unsigned int cmd)
b9067f5d
AB
311{
312 const struct net_device_ops *ops = dev->netdev_ops;
b9067f5d
AB
313
314 if (ops->ndo_siocdevprivate) {
315 if (netif_device_present(dev))
316 return ops->ndo_siocdevprivate(dev, ifr, data, cmd);
317 else
318 return -ENODEV;
319 }
320
88fc023f 321 return -EOPNOTSUPP;
b9067f5d
AB
322}
323
ad7eab2a
AB
324static int dev_siocwandev(struct net_device *dev, struct if_settings *ifs)
325{
326 const struct net_device_ops *ops = dev->netdev_ops;
327
328 if (ops->ndo_siocwandev) {
329 if (netif_device_present(dev))
330 return ops->ndo_siocwandev(dev, ifs);
331 else
332 return -ENODEV;
333 }
334
335 return -EOPNOTSUPP;
336}
337
96b45cbd
CW
338/*
339 * Perform the SIOCxIFxxx calls, inside rtnl_lock()
340 */
a554bf96
AB
341static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
342 unsigned int cmd)
96b45cbd
CW
343{
344 int err;
345 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
346 const struct net_device_ops *ops;
14ed029b 347 netdevice_tracker dev_tracker;
96b45cbd
CW
348
349 if (!dev)
350 return -ENODEV;
351
352 ops = dev->netdev_ops;
353
354 switch (cmd) {
355 case SIOCSIFFLAGS: /* Set interface flags */
567c5e13 356 return dev_change_flags(dev, ifr->ifr_flags, NULL);
96b45cbd
CW
357
358 case SIOCSIFMETRIC: /* Set the metric on the interface
359 (currently unused) */
360 return -EOPNOTSUPP;
361
362 case SIOCSIFMTU: /* Set the MTU of a device */
363 return dev_set_mtu(dev, ifr->ifr_mtu);
364
365 case SIOCSIFHWADDR:
0254e0c6
WC
366 if (dev->addr_len > sizeof(struct sockaddr))
367 return -EINVAL;
3b23a32a 368 return dev_set_mac_address_user(dev, &ifr->ifr_hwaddr, NULL);
96b45cbd
CW
369
370 case SIOCSIFHWBROADCAST:
371 if (ifr->ifr_hwaddr.sa_family != dev->type)
372 return -EINVAL;
373 memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
b5f0de6d 374 min(sizeof(ifr->ifr_hwaddr.sa_data_min),
54aeba7f 375 (size_t)dev->addr_len));
96b45cbd
CW
376 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
377 return 0;
378
379 case SIOCSIFMAP:
709566d7 380 return dev_setifmap(dev, ifr);
96b45cbd
CW
381
382 case SIOCADDMULTI:
383 if (!ops->ndo_set_rx_mode ||
384 ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
385 return -EINVAL;
386 if (!netif_device_present(dev))
387 return -ENODEV;
388 return dev_mc_add_global(dev, ifr->ifr_hwaddr.sa_data);
389
390 case SIOCDELMULTI:
391 if (!ops->ndo_set_rx_mode ||
392 ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
393 return -EINVAL;
394 if (!netif_device_present(dev))
395 return -ENODEV;
396 return dev_mc_del_global(dev, ifr->ifr_hwaddr.sa_data);
397
398 case SIOCSIFTXQLEN:
399 if (ifr->ifr_qlen < 0)
400 return -EINVAL;
8dd30201 401 return dev_change_tx_queue_len(dev, ifr->ifr_qlen);
96b45cbd
CW
402
403 case SIOCSIFNAME:
404 ifr->ifr_newname[IFNAMSIZ-1] = '\0';
405 return dev_change_name(dev, ifr->ifr_newname);
406
ad7eab2a
AB
407 case SIOCWANDEV:
408 return dev_siocwandev(dev, &ifr->ifr_settings);
409
ad2f99ae
AB
410 case SIOCBRADDIF:
411 case SIOCBRDELIF:
412 if (!netif_device_present(dev))
413 return -ENODEV;
9384eacd
NA
414 if (!netif_is_bridge_master(dev))
415 return -EOPNOTSUPP;
d62607c3 416 netdev_hold(dev, &dev_tracker, GFP_KERNEL);
893b1958
NA
417 rtnl_unlock();
418 err = br_ioctl_call(net, netdev_priv(dev), cmd, ifr, NULL);
d62607c3 419 netdev_put(dev, &dev_tracker);
893b1958
NA
420 rtnl_lock();
421 return err;
ad2f99ae 422
00d521b3
VO
423 case SIOCDEVPRIVATE ... SIOCDEVPRIVATE + 15:
424 return dev_siocdevprivate(dev, ifr, data, cmd);
425
96b45cbd 426 case SIOCSHWTSTAMP:
4ee58e1e 427 return dev_set_hwtstamp(dev, ifr);
96b45cbd 428
00d521b3 429 case SIOCGHWTSTAMP:
4ee58e1e
VO
430 return dev_get_hwtstamp(dev, ifr);
431
00d521b3
VO
432 case SIOCGMIIPHY:
433 case SIOCGMIIREG:
434 case SIOCSMIIREG:
435 return dev_eth_ioctl(dev, ifr, cmd);
436
437 case SIOCBONDENSLAVE:
438 case SIOCBONDRELEASE:
439 case SIOCBONDSETHWADDR:
440 case SIOCBONDSLAVEINFOQUERY:
441 case SIOCBONDINFOQUERY:
442 case SIOCBONDCHANGEACTIVE:
443 return dev_siocbond(dev, ifr, cmd);
444
445 /* Unknown ioctl */
96b45cbd 446 default:
00d521b3 447 err = -EINVAL;
96b45cbd
CW
448 }
449 return err;
450}
451
452/**
453 * dev_load - load a network module
454 * @net: the applicable net namespace
455 * @name: name of interface
456 *
457 * If a network interface is not present and the process has suitable
458 * privileges this function loads the module. If module loading is not
459 * available in this kernel then it becomes a nop.
460 */
461
462void dev_load(struct net *net, const char *name)
463{
464 struct net_device *dev;
465 int no_module;
466
467 rcu_read_lock();
468 dev = dev_get_by_name_rcu(net, name);
469 rcu_read_unlock();
470
471 no_module = !dev;
472 if (no_module && capable(CAP_NET_ADMIN))
473 no_module = request_module("netdev-%s", name);
e020836d
DB
474 if (no_module && capable(CAP_SYS_MODULE))
475 request_module("%s", name);
96b45cbd
CW
476}
477EXPORT_SYMBOL(dev_load);
478
479/*
480 * This function handles all "interface"-type I/O control requests. The actual
481 * 'doing' part of this is dev_ifsioc above.
482 */
483
484/**
485 * dev_ioctl - network device ioctl
486 * @net: the applicable net namespace
487 * @cmd: command to issue
b3c0fd61 488 * @ifr: pointer to a struct ifreq in user space
e5b42483 489 * @data: data exchanged with userspace
b3c0fd61 490 * @need_copyout: whether or not copy_to_user() should be called
96b45cbd
CW
491 *
492 * Issue ioctl functions to devices. This is normally called by the
493 * user space syscall interfaces but can sometimes be useful for
494 * other purposes. The return value is the return from the syscall if
495 * positive or a negative errno code on error.
496 */
497
a554bf96
AB
498int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr,
499 void __user *data, bool *need_copyout)
96b45cbd 500{
96b45cbd
CW
501 int ret;
502 char *colon;
503
44c02a2c
AV
504 if (need_copyout)
505 *need_copyout = true;
96b45cbd 506 if (cmd == SIOCGIFNAME)
44c02a2c 507 return dev_ifname(net, ifr);
96b45cbd 508
44c02a2c 509 ifr->ifr_name[IFNAMSIZ-1] = 0;
96b45cbd 510
44c02a2c 511 colon = strchr(ifr->ifr_name, ':');
96b45cbd
CW
512 if (colon)
513 *colon = 0;
514
515 /*
516 * See which interface the caller is talking about.
517 */
518
519 switch (cmd) {
3b23a32a
CW
520 case SIOCGIFHWADDR:
521 dev_load(net, ifr->ifr_name);
522 ret = dev_get_mac_address(&ifr->ifr_hwaddr, net, ifr->ifr_name);
523 if (colon)
524 *colon = ':';
525 return ret;
96b45cbd
CW
526 /*
527 * These ioctl calls:
528 * - can be done by all.
529 * - atomic and do not require locking.
530 * - return a value
531 */
532 case SIOCGIFFLAGS:
533 case SIOCGIFMETRIC:
534 case SIOCGIFMTU:
96b45cbd
CW
535 case SIOCGIFSLAVE:
536 case SIOCGIFMAP:
537 case SIOCGIFINDEX:
538 case SIOCGIFTXQLEN:
b51f26b1 539 dev_load(net, ifr->ifr_name);
96b45cbd 540 rcu_read_lock();
44c02a2c 541 ret = dev_ifsioc_locked(net, ifr, cmd);
96b45cbd 542 rcu_read_unlock();
44c02a2c
AV
543 if (colon)
544 *colon = ':';
96b45cbd
CW
545 return ret;
546
547 case SIOCETHTOOL:
b51f26b1 548 dev_load(net, ifr->ifr_name);
a554bf96 549 ret = dev_ethtool(net, ifr, data);
44c02a2c
AV
550 if (colon)
551 *colon = ':';
96b45cbd
CW
552 return ret;
553
554 /*
555 * These ioctl calls:
556 * - require superuser power.
557 * - require strict serialization.
558 * - return a value
559 */
560 case SIOCGMIIPHY:
561 case SIOCGMIIREG:
562 case SIOCSIFNAME:
b51f26b1 563 dev_load(net, ifr->ifr_name);
96b45cbd
CW
564 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
565 return -EPERM;
96b45cbd 566 rtnl_lock();
a554bf96 567 ret = dev_ifsioc(net, ifr, data, cmd);
96b45cbd 568 rtnl_unlock();
44c02a2c
AV
569 if (colon)
570 *colon = ':';
96b45cbd
CW
571 return ret;
572
573 /*
574 * These ioctl calls:
575 * - require superuser power.
576 * - require strict serialization.
577 * - do not return a value
578 */
579 case SIOCSIFMAP:
580 case SIOCSIFTXQLEN:
581 if (!capable(CAP_NET_ADMIN))
582 return -EPERM;
df561f66 583 fallthrough;
96b45cbd
CW
584 /*
585 * These ioctl calls:
586 * - require local superuser power.
587 * - require strict serialization.
588 * - do not return a value
589 */
590 case SIOCSIFFLAGS:
591 case SIOCSIFMETRIC:
592 case SIOCSIFMTU:
593 case SIOCSIFHWADDR:
594 case SIOCSIFSLAVE:
595 case SIOCADDMULTI:
596 case SIOCDELMULTI:
597 case SIOCSIFHWBROADCAST:
598 case SIOCSMIIREG:
599 case SIOCBONDENSLAVE:
600 case SIOCBONDRELEASE:
601 case SIOCBONDSETHWADDR:
602 case SIOCBONDCHANGEACTIVE:
603 case SIOCBRADDIF:
604 case SIOCBRDELIF:
605 case SIOCSHWTSTAMP:
606 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
607 return -EPERM;
df561f66 608 fallthrough;
96b45cbd
CW
609 case SIOCBONDSLAVEINFOQUERY:
610 case SIOCBONDINFOQUERY:
b51f26b1 611 dev_load(net, ifr->ifr_name);
96b45cbd 612 rtnl_lock();
a554bf96 613 ret = dev_ifsioc(net, ifr, data, cmd);
96b45cbd 614 rtnl_unlock();
44c02a2c
AV
615 if (need_copyout)
616 *need_copyout = false;
96b45cbd
CW
617 return ret;
618
619 case SIOCGIFMEM:
620 /* Get the per device memory space. We can add this but
621 * currently do not support it */
622 case SIOCSIFMEM:
623 /* Set the per device memory buffer space.
624 * Not applicable in our case */
625 case SIOCSIFLINK:
626 return -ENOTTY;
627
628 /*
629 * Unknown or private ioctl.
630 */
631 default:
632 if (cmd == SIOCWANDEV ||
fd468c74 633 cmd == SIOCGHWTSTAMP ||
96b45cbd
CW
634 (cmd >= SIOCDEVPRIVATE &&
635 cmd <= SIOCDEVPRIVATE + 15)) {
b51f26b1 636 dev_load(net, ifr->ifr_name);
96b45cbd 637 rtnl_lock();
a554bf96 638 ret = dev_ifsioc(net, ifr, data, cmd);
96b45cbd 639 rtnl_unlock();
96b45cbd
CW
640 return ret;
641 }
96b45cbd
CW
642 return -ENOTTY;
643 }
644}