vserver 1.9.3
[linux-2.6.git] / net / core / rtnetlink.c
1 /*
2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
3  *              operating system.  INET is implemented using the  BSD Socket
4  *              interface as the means of communication with the user level.
5  *
6  *              Routing netlink socket interface: protocol independent part.
7  *
8  * Authors:     Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
9  *
10  *              This program is free software; you can redistribute it and/or
11  *              modify it under the terms of the GNU General Public License
12  *              as published by the Free Software Foundation; either version
13  *              2 of the License, or (at your option) any later version.
14  *
15  *      Fixes:
16  *      Vitaly E. Lavrov                RTA_OK arithmetics was wrong.
17  */
18
19 #include <linux/config.h>
20 #include <linux/errno.h>
21 #include <linux/module.h>
22 #include <linux/types.h>
23 #include <linux/socket.h>
24 #include <linux/kernel.h>
25 #include <linux/major.h>
26 #include <linux/sched.h>
27 #include <linux/timer.h>
28 #include <linux/string.h>
29 #include <linux/sockios.h>
30 #include <linux/net.h>
31 #include <linux/fcntl.h>
32 #include <linux/mm.h>
33 #include <linux/slab.h>
34 #include <linux/interrupt.h>
35 #include <linux/capability.h>
36 #include <linux/skbuff.h>
37 #include <linux/init.h>
38 #include <linux/security.h>
39
40 #include <asm/uaccess.h>
41 #include <asm/system.h>
42 #include <asm/string.h>
43
44 #include <linux/inet.h>
45 #include <linux/netdevice.h>
46 #include <net/ip.h>
47 #include <net/protocol.h>
48 #include <net/arp.h>
49 #include <net/route.h>
50 #include <net/udp.h>
51 #include <net/sock.h>
52 #include <net/pkt_sched.h>
53
54 DECLARE_MUTEX(rtnl_sem);
55
56 void rtnl_lock(void)
57 {
58         rtnl_shlock();
59 }
60  
61 void rtnl_unlock(void)
62 {
63         rtnl_shunlock();
64
65         netdev_run_todo();
66 }
67
68 int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len)
69 {
70         memset(tb, 0, sizeof(struct rtattr*)*maxattr);
71
72         while (RTA_OK(rta, len)) {
73                 unsigned flavor = rta->rta_type;
74                 if (flavor && flavor <= maxattr)
75                         tb[flavor-1] = rta;
76                 rta = RTA_NEXT(rta, len);
77         }
78         return 0;
79 }
80
81 struct sock *rtnl;
82
83 struct rtnetlink_link * rtnetlink_links[NPROTO];
84
85 static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] =
86 {
87         NLMSG_LENGTH(sizeof(struct ifinfomsg)),
88         NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
89         NLMSG_LENGTH(sizeof(struct rtmsg)),
90         NLMSG_LENGTH(sizeof(struct ndmsg)),
91         NLMSG_LENGTH(sizeof(struct rtmsg)),
92         NLMSG_LENGTH(sizeof(struct tcmsg)),
93         NLMSG_LENGTH(sizeof(struct tcmsg)),
94         NLMSG_LENGTH(sizeof(struct tcmsg)),
95         NLMSG_LENGTH(sizeof(struct tcamsg))
96 };
97
98 static const int rta_max[(RTM_MAX+1-RTM_BASE)/4] =
99 {
100         IFLA_MAX,
101         IFA_MAX,
102         RTA_MAX,
103         NDA_MAX,
104         RTA_MAX,
105         TCA_MAX,
106         TCA_MAX,
107         TCA_MAX,
108         TCAA_MAX
109 };
110
111 void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
112 {
113         struct rtattr *rta;
114         int size = RTA_LENGTH(attrlen);
115
116         rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
117         rta->rta_type = attrtype;
118         rta->rta_len = size;
119         memcpy(RTA_DATA(rta), data, attrlen);
120 }
121
122 int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
123 {
124         int err = 0;
125
126         NETLINK_CB(skb).dst_groups = group;
127         if (echo)
128                 atomic_inc(&skb->users);
129         netlink_broadcast(rtnl, skb, pid, group, GFP_KERNEL);
130         if (echo)
131                 err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
132         return err;
133 }
134
135 int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
136 {
137         struct rtattr *mx = (struct rtattr*)skb->tail;
138         int i;
139
140         RTA_PUT(skb, RTA_METRICS, 0, NULL);
141         for (i=0; i<RTAX_MAX; i++) {
142                 if (metrics[i])
143                         RTA_PUT(skb, i+1, sizeof(u32), metrics+i);
144         }
145         mx->rta_len = skb->tail - (u8*)mx;
146         if (mx->rta_len == RTA_LENGTH(0))
147                 skb_trim(skb, (u8*)mx - skb->data);
148         return 0;
149
150 rtattr_failure:
151         skb_trim(skb, (u8*)mx - skb->data);
152         return -1;
153 }
154
155
156 static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
157                                  int type, u32 pid, u32 seq, u32 change)
158 {
159         struct ifinfomsg *r;
160         struct nlmsghdr  *nlh;
161         unsigned char    *b = skb->tail;
162
163         nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
164         if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
165         r = NLMSG_DATA(nlh);
166         r->ifi_family = AF_UNSPEC;
167         r->ifi_type = dev->type;
168         r->ifi_index = dev->ifindex;
169         r->ifi_flags = dev_get_flags(dev);
170         r->ifi_change = change;
171
172         RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
173
174         if (1) {
175                 u32 txqlen = dev->tx_queue_len;
176                 RTA_PUT(skb, IFLA_TXQLEN, sizeof(txqlen), &txqlen);
177         }
178
179         if (1) {
180                 u32 weight = dev->weight;
181                 RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight);
182         }
183
184         if (1) {
185                 struct rtnl_link_ifmap map = {
186                         .mem_start   = dev->mem_start,
187                         .mem_end     = dev->mem_end,
188                         .base_addr   = dev->base_addr,
189                         .irq         = dev->irq,
190                         .dma         = dev->dma,
191                         .port        = dev->if_port,
192                 };
193                 RTA_PUT(skb, IFLA_MAP, sizeof(map), &map);
194         }
195
196         if (dev->addr_len) {
197                 RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
198                 RTA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast);
199         }
200
201         if (1) {
202                 u32 mtu = dev->mtu;
203                 RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
204         }
205
206         if (dev->ifindex != dev->iflink) {
207                 u32 iflink = dev->iflink;
208                 RTA_PUT(skb, IFLA_LINK, sizeof(iflink), &iflink);
209         }
210
211         if (dev->qdisc_sleeping)
212                 RTA_PUT(skb, IFLA_QDISC,
213                         strlen(dev->qdisc_sleeping->ops->id) + 1,
214                         dev->qdisc_sleeping->ops->id);
215         
216         if (dev->master) {
217                 u32 master = dev->master->ifindex;
218                 RTA_PUT(skb, IFLA_MASTER, sizeof(master), &master);
219         }
220
221         if (dev->get_stats) {
222                 unsigned long *stats = (unsigned long*)dev->get_stats(dev);
223                 if (stats) {
224                         struct rtattr  *a;
225                         __u32          *s;
226                         int             i;
227                         int             n = sizeof(struct rtnl_link_stats)/4;
228
229                         a = __RTA_PUT(skb, IFLA_STATS, n*4);
230                         s = RTA_DATA(a);
231                         for (i=0; i<n; i++)
232                                 s[i] = stats[i];
233                 }
234         }
235         nlh->nlmsg_len = skb->tail - b;
236         return skb->len;
237
238 nlmsg_failure:
239 rtattr_failure:
240         skb_trim(skb, b - skb->data);
241         return -1;
242 }
243
244 int rtnetlink_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
245 {
246         int idx;
247         int s_idx = cb->args[0];
248         struct net_device *dev;
249
250         read_lock(&dev_base_lock);
251         for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
252                 if (idx < s_idx)
253                         continue;
254                 if (vx_info_flags(skb->sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
255                         !dev_in_nx_info(dev, skb->sk->sk_nx_info))
256                         continue;
257                 if (rtnetlink_fill_ifinfo(skb, dev, RTM_NEWLINK, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 0) <= 0)
258                         break;
259         }
260         read_unlock(&dev_base_lock);
261         cb->args[0] = idx;
262
263         return skb->len;
264 }
265
266 static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
267 {
268         struct ifinfomsg  *ifm = NLMSG_DATA(nlh);
269         struct rtattr    **ida = arg;
270         struct net_device *dev;
271         int err, send_addr_notify = 0;
272
273         dev = dev_get_by_index(ifm->ifi_index);
274         if (!dev)
275                 return -ENODEV;
276
277         err = -EINVAL;
278
279         if (ifm->ifi_flags)
280                 dev_change_flags(dev, ifm->ifi_flags);
281
282         if (ida[IFLA_MAP - 1]) {
283                 struct rtnl_link_ifmap *u_map;
284                 struct ifmap k_map;
285
286                 if (!dev->set_config) {
287                         err = -EOPNOTSUPP;
288                         goto out;
289                 }
290
291                 if (!netif_device_present(dev)) {
292                         err = -ENODEV;
293                         goto out;
294                 }
295                 
296                 if (ida[IFLA_MAP - 1]->rta_len != RTA_LENGTH(sizeof(*u_map)))
297                         goto out;
298
299                 u_map = RTA_DATA(ida[IFLA_MAP - 1]);
300
301                 k_map.mem_start = (unsigned long) u_map->mem_start;
302                 k_map.mem_end = (unsigned long) u_map->mem_end;
303                 k_map.base_addr = (unsigned short) u_map->base_addr;
304                 k_map.irq = (unsigned char) u_map->irq;
305                 k_map.dma = (unsigned char) u_map->dma;
306                 k_map.port = (unsigned char) u_map->port;
307
308                 err = dev->set_config(dev, &k_map);
309
310                 if (err)
311                         goto out;
312         }
313
314         if (ida[IFLA_ADDRESS - 1]) {
315                 if (!dev->set_mac_address) {
316                         err = -EOPNOTSUPP;
317                         goto out;
318                 }
319                 if (!netif_device_present(dev)) {
320                         err = -ENODEV;
321                         goto out;
322                 }
323                 if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len))
324                         goto out;
325
326                 err = dev->set_mac_address(dev, RTA_DATA(ida[IFLA_ADDRESS - 1]));
327                 if (err)
328                         goto out;
329                 send_addr_notify = 1;
330         }
331
332         if (ida[IFLA_BROADCAST - 1]) {
333                 if (ida[IFLA_BROADCAST - 1]->rta_len != RTA_LENGTH(dev->addr_len))
334                         goto out;
335                 memcpy(dev->broadcast, RTA_DATA(ida[IFLA_BROADCAST - 1]),
336                        dev->addr_len);
337                 send_addr_notify = 1;
338         }
339
340         if (ida[IFLA_MTU - 1]) {
341                 if (ida[IFLA_MTU - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
342                         goto out;
343                 err = dev_set_mtu(dev, *((u32 *) RTA_DATA(ida[IFLA_MTU - 1])));
344
345                 if (err)
346                         goto out;
347
348         }
349
350         if (ida[IFLA_TXQLEN - 1]) {
351                 if (ida[IFLA_TXQLEN - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
352                         goto out;
353
354                 dev->tx_queue_len = *((u32 *) RTA_DATA(ida[IFLA_TXQLEN - 1]));
355         }
356
357         if (ida[IFLA_WEIGHT - 1]) {
358                 if (ida[IFLA_WEIGHT - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
359                         goto out;
360
361                 dev->weight = *((u32 *) RTA_DATA(ida[IFLA_WEIGHT - 1]));
362         }
363
364         if (ida[IFLA_IFNAME - 1]) {
365                 char ifname[IFNAMSIZ];
366
367                 if (ida[IFLA_IFNAME - 1]->rta_len > RTA_LENGTH(sizeof(ifname)))
368                         goto out;
369
370                 memset(ifname, 0, sizeof(ifname));
371                 memcpy(ifname, RTA_DATA(ida[IFLA_IFNAME - 1]),
372                         RTA_PAYLOAD(ida[IFLA_IFNAME - 1]));
373                 ifname[IFNAMSIZ - 1] = '\0';
374
375                 err = dev_change_name(dev, ifname);
376
377                 if (err)
378                         goto out;
379         }
380
381         err = 0;
382
383 out:
384         if (send_addr_notify)
385                 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
386
387         dev_put(dev);
388         return err;
389 }
390
391 static int rtnetlink_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
392 {
393         int idx;
394         int s_idx = cb->family;
395
396         if (s_idx == 0)
397                 s_idx = 1;
398         for (idx=1; idx<NPROTO; idx++) {
399                 int type = cb->nlh->nlmsg_type-RTM_BASE;
400                 if (idx < s_idx || idx == PF_PACKET)
401                         continue;
402                 if (rtnetlink_links[idx] == NULL ||
403                     rtnetlink_links[idx][type].dumpit == NULL)
404                         continue;
405                 if (idx > s_idx)
406                         memset(&cb->args[0], 0, sizeof(cb->args));
407                 if (rtnetlink_links[idx][type].dumpit(skb, cb))
408                         break;
409         }
410         cb->family = idx;
411
412         return skb->len;
413 }
414
415 void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
416 {
417         struct sk_buff *skb;
418         int size = NLMSG_SPACE(sizeof(struct ifinfomsg) +
419                                sizeof(struct rtnl_link_ifmap) +
420                                sizeof(struct rtnl_link_stats) + 128);
421
422         if (vx_flags(VXF_HIDE_NETIF, 0) &&
423                 !dev_in_nx_info(dev, current->nx_info))
424                 return;
425         skb = alloc_skb(size, GFP_KERNEL);
426         if (!skb)
427                 return;
428
429         if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change) < 0) {
430                 kfree_skb(skb);
431                 return;
432         }
433         NETLINK_CB(skb).dst_groups = RTMGRP_LINK;
434         netlink_broadcast(rtnl, skb, 0, RTMGRP_LINK, GFP_KERNEL);
435 }
436
437 static int rtnetlink_done(struct netlink_callback *cb)
438 {
439         return 0;
440 }
441
442 /* Protected by RTNL sempahore.  */
443 static struct rtattr **rta_buf;
444 static int rtattr_max;
445
446 /* Process one rtnetlink message. */
447
448 static __inline__ int
449 rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
450 {
451         struct rtnetlink_link *link;
452         struct rtnetlink_link *link_tab;
453         int sz_idx, kind;
454         int min_len;
455         int family;
456         int type;
457         int err;
458
459         /* Only requests are handled by kernel now */
460         if (!(nlh->nlmsg_flags&NLM_F_REQUEST))
461                 return 0;
462
463         type = nlh->nlmsg_type;
464
465         /* A control message: ignore them */
466         if (type < RTM_BASE)
467                 return 0;
468
469         /* Unknown message: reply with EINVAL */
470         if (type > RTM_MAX)
471                 goto err_inval;
472
473         type -= RTM_BASE;
474
475         /* All the messages must have at least 1 byte length */
476         if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(struct rtgenmsg)))
477                 return 0;
478
479         family = ((struct rtgenmsg*)NLMSG_DATA(nlh))->rtgen_family;
480         if (family >= NPROTO) {
481                 *errp = -EAFNOSUPPORT;
482                 return -1;
483         }
484
485         link_tab = rtnetlink_links[family];
486         if (link_tab == NULL)
487                 link_tab = rtnetlink_links[PF_UNSPEC];
488         link = &link_tab[type];
489
490         sz_idx = type>>2;
491         kind = type&3;
492
493         if (kind != 2 && security_netlink_recv(skb)) {
494                 *errp = -EPERM;
495                 return -1;
496         }
497
498         if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
499                 u32 rlen;
500
501                 if (link->dumpit == NULL)
502                         link = &(rtnetlink_links[PF_UNSPEC][type]);
503
504                 if (link->dumpit == NULL)
505                         goto err_inval;
506
507                 if ((*errp = netlink_dump_start(rtnl, skb, nlh,
508                                                 link->dumpit,
509                                                 rtnetlink_done)) != 0) {
510                         return -1;
511                 }
512                 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
513                 if (rlen > skb->len)
514                         rlen = skb->len;
515                 skb_pull(skb, rlen);
516                 return -1;
517         }
518
519         memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
520
521         min_len = rtm_min[sz_idx];
522         if (nlh->nlmsg_len < min_len)
523                 goto err_inval;
524
525         if (nlh->nlmsg_len > min_len) {
526                 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
527                 struct rtattr *attr = (void*)nlh + NLMSG_ALIGN(min_len);
528
529                 while (RTA_OK(attr, attrlen)) {
530                         unsigned flavor = attr->rta_type;
531                         if (flavor) {
532                                 if (flavor > rta_max[sz_idx])
533                                         goto err_inval;
534                                 rta_buf[flavor-1] = attr;
535                         }
536                         attr = RTA_NEXT(attr, attrlen);
537                 }
538         }
539
540         if (link->doit == NULL)
541                 link = &(rtnetlink_links[PF_UNSPEC][type]);
542         if (link->doit == NULL)
543                 goto err_inval;
544         err = link->doit(skb, nlh, (void *)&rta_buf[0]);
545
546         *errp = err;
547         return err;
548
549 err_inval:
550         *errp = -EINVAL;
551         return -1;
552 }
553
554 /* 
555  * Process one packet of messages.
556  * Malformed skbs with wrong lengths of messages are discarded silently.
557  */
558
559 static inline int rtnetlink_rcv_skb(struct sk_buff *skb)
560 {
561         int err;
562         struct nlmsghdr * nlh;
563
564         while (skb->len >= NLMSG_SPACE(0)) {
565                 u32 rlen;
566
567                 nlh = (struct nlmsghdr *)skb->data;
568                 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
569                         return 0;
570                 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
571                 if (rlen > skb->len)
572                         rlen = skb->len;
573                 if (rtnetlink_rcv_msg(skb, nlh, &err)) {
574                         /* Not error, but we must interrupt processing here:
575                          *   Note, that in this case we do not pull message
576                          *   from skb, it will be processed later.
577                          */
578                         if (err == 0)
579                                 return -1;
580                         netlink_ack(skb, nlh, err);
581                 } else if (nlh->nlmsg_flags&NLM_F_ACK)
582                         netlink_ack(skb, nlh, 0);
583                 skb_pull(skb, rlen);
584         }
585
586         return 0;
587 }
588
589 /*
590  *  rtnetlink input queue processing routine:
591  *      - try to acquire shared lock. If it is failed, defer processing.
592  *      - feed skbs to rtnetlink_rcv_skb, until it refuse a message,
593  *        that will occur, when a dump started and/or acquisition of
594  *        exclusive lock failed.
595  */
596
597 static void rtnetlink_rcv(struct sock *sk, int len)
598 {
599         do {
600                 struct sk_buff *skb;
601
602                 if (rtnl_shlock_nowait())
603                         return;
604
605                 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
606                         if (rtnetlink_rcv_skb(skb)) {
607                                 if (skb->len)
608                                         skb_queue_head(&sk->sk_receive_queue,
609                                                        skb);
610                                 else
611                                         kfree_skb(skb);
612                                 break;
613                         }
614                         kfree_skb(skb);
615                 }
616
617                 up(&rtnl_sem);
618
619                 netdev_run_todo();
620         } while (rtnl && rtnl->sk_receive_queue.qlen);
621 }
622
623 static struct rtnetlink_link link_rtnetlink_table[RTM_MAX-RTM_BASE+1] =
624 {
625         [RTM_GETLINK  - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo },
626         [RTM_SETLINK  - RTM_BASE] = { .doit   = do_setlink            },
627         [RTM_GETADDR  - RTM_BASE] = { .dumpit = rtnetlink_dump_all    },
628         [RTM_GETROUTE - RTM_BASE] = { .dumpit = rtnetlink_dump_all    },
629         [RTM_NEWNEIGH - RTM_BASE] = { .doit   = neigh_add             },
630         [RTM_DELNEIGH - RTM_BASE] = { .doit   = neigh_delete          },
631         [RTM_GETNEIGH - RTM_BASE] = { .dumpit = neigh_dump_info       }
632 };
633
634 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)
635 {
636         struct net_device *dev = ptr;
637         switch (event) {
638         case NETDEV_UNREGISTER:
639                 rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
640                 break;
641         case NETDEV_REGISTER:
642                 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
643                 break;
644         case NETDEV_UP:
645         case NETDEV_DOWN:
646                 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
647                 break;
648         case NETDEV_CHANGE:
649         case NETDEV_GOING_DOWN:
650                 break;
651         default:
652                 rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
653                 break;
654         }
655         return NOTIFY_DONE;
656 }
657
658 static struct notifier_block rtnetlink_dev_notifier = {
659         .notifier_call  = rtnetlink_event,
660 };
661
662 void __init rtnetlink_init(void)
663 {
664         int i;
665
666         rtattr_max = 0;
667         for (i = 0; i < ARRAY_SIZE(rta_max); i++)
668                 if (rta_max[i] > rtattr_max)
669                         rtattr_max = rta_max[i];
670         rta_buf = kmalloc(rtattr_max * sizeof(struct rtattr *), GFP_KERNEL);
671         if (!rta_buf)
672                 panic("rtnetlink_init: cannot allocate rta_buf\n");
673
674         rtnl = netlink_kernel_create(NETLINK_ROUTE, rtnetlink_rcv);
675         if (rtnl == NULL)
676                 panic("rtnetlink_init: cannot initialize rtnetlink\n");
677         netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
678         register_netdevice_notifier(&rtnetlink_dev_notifier);
679         rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table;
680         rtnetlink_links[PF_PACKET] = link_rtnetlink_table;
681 }
682
683 EXPORT_SYMBOL(__rta_fill);
684 EXPORT_SYMBOL(rtattr_parse);
685 EXPORT_SYMBOL(rtnetlink_dump_ifinfo);
686 EXPORT_SYMBOL(rtnetlink_links);
687 EXPORT_SYMBOL(rtnetlink_put_metrics);
688 EXPORT_SYMBOL(rtnl);
689 EXPORT_SYMBOL(rtnl_lock);
690 EXPORT_SYMBOL(rtnl_sem);
691 EXPORT_SYMBOL(rtnl_unlock);