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.
6 * Routing netlink socket interface: protocol independent part.
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
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.
16 * Vitaly E. Lavrov RTA_OK arithmetics was wrong.
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/sched.h>
26 #include <linux/timer.h>
27 #include <linux/string.h>
28 #include <linux/sockios.h>
29 #include <linux/net.h>
30 #include <linux/fcntl.h>
32 #include <linux/slab.h>
33 #include <linux/interrupt.h>
34 #include <linux/capability.h>
35 #include <linux/skbuff.h>
36 #include <linux/init.h>
37 #include <linux/security.h>
38 #include <linux/mutex.h>
40 #include <asm/uaccess.h>
41 #include <asm/system.h>
42 #include <asm/string.h>
44 #include <linux/inet.h>
45 #include <linux/netdevice.h>
47 #include <net/protocol.h>
49 #include <net/route.h>
52 #include <net/pkt_sched.h>
53 #include <net/netlink.h>
54 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
55 #include <linux/wireless.h>
56 #include <net/iw_handler.h>
57 #endif /* CONFIG_NET_WIRELESS_RTNETLINK */
59 static DEFINE_MUTEX(rtnl_mutex);
63 mutex_lock(&rtnl_mutex);
66 void __rtnl_unlock(void)
68 mutex_unlock(&rtnl_mutex);
71 void rtnl_unlock(void)
73 mutex_unlock(&rtnl_mutex);
74 if (rtnl && rtnl->sk_receive_queue.qlen)
75 rtnl->sk_data_ready(rtnl, 0);
79 int rtnl_trylock(void)
81 return mutex_trylock(&rtnl_mutex);
84 int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len)
86 memset(tb, 0, sizeof(struct rtattr*)*maxattr);
88 while (RTA_OK(rta, len)) {
89 unsigned flavor = rta->rta_type;
90 if (flavor && flavor <= maxattr)
92 rta = RTA_NEXT(rta, len);
99 struct rtnetlink_link * rtnetlink_links[NPROTO];
101 static const int rtm_min[RTM_NR_FAMILIES] =
103 [RTM_FAM(RTM_NEWLINK)] = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
104 [RTM_FAM(RTM_NEWADDR)] = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
105 [RTM_FAM(RTM_NEWROUTE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
106 [RTM_FAM(RTM_NEWNEIGH)] = NLMSG_LENGTH(sizeof(struct ndmsg)),
107 [RTM_FAM(RTM_NEWRULE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
108 [RTM_FAM(RTM_NEWQDISC)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
109 [RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
110 [RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
111 [RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)),
112 [RTM_FAM(RTM_NEWPREFIX)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
113 [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
114 [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
115 [RTM_FAM(RTM_NEWNEIGHTBL)] = NLMSG_LENGTH(sizeof(struct ndtmsg)),
118 static const int rta_max[RTM_NR_FAMILIES] =
120 [RTM_FAM(RTM_NEWLINK)] = IFLA_MAX,
121 [RTM_FAM(RTM_NEWADDR)] = IFA_MAX,
122 [RTM_FAM(RTM_NEWROUTE)] = RTA_MAX,
123 [RTM_FAM(RTM_NEWNEIGH)] = NDA_MAX,
124 [RTM_FAM(RTM_NEWRULE)] = RTA_MAX,
125 [RTM_FAM(RTM_NEWQDISC)] = TCA_MAX,
126 [RTM_FAM(RTM_NEWTCLASS)] = TCA_MAX,
127 [RTM_FAM(RTM_NEWTFILTER)] = TCA_MAX,
128 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX,
129 [RTM_FAM(RTM_NEWNEIGHTBL)] = NDTA_MAX,
132 void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
135 int size = RTA_LENGTH(attrlen);
137 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
138 rta->rta_type = attrtype;
140 memcpy(RTA_DATA(rta), data, attrlen);
141 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
144 size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size)
146 size_t ret = RTA_PAYLOAD(rta);
147 char *src = RTA_DATA(rta);
149 if (ret > 0 && src[ret - 1] == '\0')
152 size_t len = (ret >= size) ? size - 1 : ret;
153 memset(dest, 0, size);
154 memcpy(dest, src, len);
159 int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
163 NETLINK_CB(skb).dst_group = group;
165 atomic_inc(&skb->users);
166 netlink_broadcast(rtnl, skb, pid, group, GFP_KERNEL);
168 err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
172 int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
174 struct rtattr *mx = (struct rtattr*)skb->tail;
177 RTA_PUT(skb, RTA_METRICS, 0, NULL);
178 for (i=0; i<RTAX_MAX; i++) {
180 RTA_PUT(skb, i+1, sizeof(u32), metrics+i);
182 mx->rta_len = skb->tail - (u8*)mx;
183 if (mx->rta_len == RTA_LENGTH(0))
184 skb_trim(skb, (u8*)mx - skb->data);
188 skb_trim(skb, (u8*)mx - skb->data);
193 static void set_operstate(struct net_device *dev, unsigned char transition)
195 unsigned char operstate = dev->operstate;
199 if ((operstate == IF_OPER_DORMANT ||
200 operstate == IF_OPER_UNKNOWN) &&
202 operstate = IF_OPER_UP;
205 case IF_OPER_DORMANT:
206 if (operstate == IF_OPER_UP ||
207 operstate == IF_OPER_UNKNOWN)
208 operstate = IF_OPER_DORMANT;
212 if (dev->operstate != operstate) {
213 write_lock_bh(&dev_base_lock);
214 dev->operstate = operstate;
215 write_unlock_bh(&dev_base_lock);
216 netdev_state_change(dev);
220 static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
221 int type, u32 pid, u32 seq, u32 change,
225 struct nlmsghdr *nlh;
226 unsigned char *b = skb->tail;
228 nlh = NLMSG_NEW(skb, pid, seq, type, sizeof(*r), flags);
230 r->ifi_family = AF_UNSPEC;
232 r->ifi_type = dev->type;
233 r->ifi_index = dev->ifindex;
234 r->ifi_flags = dev_get_flags(dev);
235 r->ifi_change = change;
237 RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
240 u32 txqlen = dev->tx_queue_len;
241 RTA_PUT(skb, IFLA_TXQLEN, sizeof(txqlen), &txqlen);
245 u32 weight = dev->weight;
246 RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight);
250 u8 operstate = netif_running(dev)?dev->operstate:IF_OPER_DOWN;
251 u8 link_mode = dev->link_mode;
252 RTA_PUT(skb, IFLA_OPERSTATE, sizeof(operstate), &operstate);
253 RTA_PUT(skb, IFLA_LINKMODE, sizeof(link_mode), &link_mode);
257 struct rtnl_link_ifmap map = {
258 .mem_start = dev->mem_start,
259 .mem_end = dev->mem_end,
260 .base_addr = dev->base_addr,
263 .port = dev->if_port,
265 RTA_PUT(skb, IFLA_MAP, sizeof(map), &map);
269 RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
270 RTA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast);
275 RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
278 if (dev->ifindex != dev->iflink) {
279 u32 iflink = dev->iflink;
280 RTA_PUT(skb, IFLA_LINK, sizeof(iflink), &iflink);
283 if (dev->qdisc_sleeping)
284 RTA_PUT(skb, IFLA_QDISC,
285 strlen(dev->qdisc_sleeping->ops->id) + 1,
286 dev->qdisc_sleeping->ops->id);
289 u32 master = dev->master->ifindex;
290 RTA_PUT(skb, IFLA_MASTER, sizeof(master), &master);
293 if (dev->get_stats) {
294 unsigned long *stats = (unsigned long*)dev->get_stats(dev);
299 int n = sizeof(struct rtnl_link_stats)/4;
301 a = __RTA_PUT(skb, IFLA_STATS, n*4);
307 nlh->nlmsg_len = skb->tail - b;
312 skb_trim(skb, b - skb->data);
316 static int rtnetlink_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
319 int s_idx = cb->args[0];
320 struct net_device *dev;
322 read_lock(&dev_base_lock);
323 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
326 if (vx_info_flags(skb->sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
327 !dev_in_nx_info(dev, skb->sk->sk_nx_info))
329 if (rtnetlink_fill_ifinfo(skb, dev, RTM_NEWLINK,
330 NETLINK_CB(cb->skb).pid,
331 cb->nlh->nlmsg_seq, 0,
335 read_unlock(&dev_base_lock);
341 static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
343 struct ifinfomsg *ifm = NLMSG_DATA(nlh);
344 struct rtattr **ida = arg;
345 struct net_device *dev;
346 int err, send_addr_notify = 0;
348 if (ifm->ifi_index >= 0)
349 dev = dev_get_by_index(ifm->ifi_index);
350 else if (ida[IFLA_IFNAME - 1]) {
351 char ifname[IFNAMSIZ];
353 if (rtattr_strlcpy(ifname, ida[IFLA_IFNAME - 1],
354 IFNAMSIZ) >= IFNAMSIZ)
356 dev = dev_get_by_name(ifname);
366 dev_change_flags(dev, ifm->ifi_flags);
368 if (ida[IFLA_MAP - 1]) {
369 struct rtnl_link_ifmap *u_map;
372 if (!dev->set_config) {
377 if (!netif_device_present(dev)) {
382 if (ida[IFLA_MAP - 1]->rta_len != RTA_LENGTH(sizeof(*u_map)))
385 u_map = RTA_DATA(ida[IFLA_MAP - 1]);
387 k_map.mem_start = (unsigned long) u_map->mem_start;
388 k_map.mem_end = (unsigned long) u_map->mem_end;
389 k_map.base_addr = (unsigned short) u_map->base_addr;
390 k_map.irq = (unsigned char) u_map->irq;
391 k_map.dma = (unsigned char) u_map->dma;
392 k_map.port = (unsigned char) u_map->port;
394 err = dev->set_config(dev, &k_map);
400 if (ida[IFLA_ADDRESS - 1]) {
404 if (!dev->set_mac_address) {
408 if (!netif_device_present(dev)) {
412 if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len))
415 len = sizeof(sa_family_t) + dev->addr_len;
416 sa = kmalloc(len, GFP_KERNEL);
421 sa->sa_family = dev->type;
422 memcpy(sa->sa_data, RTA_DATA(ida[IFLA_ADDRESS - 1]),
424 err = dev->set_mac_address(dev, sa);
428 send_addr_notify = 1;
431 if (ida[IFLA_BROADCAST - 1]) {
432 if (ida[IFLA_BROADCAST - 1]->rta_len != RTA_LENGTH(dev->addr_len))
434 memcpy(dev->broadcast, RTA_DATA(ida[IFLA_BROADCAST - 1]),
436 send_addr_notify = 1;
439 if (ida[IFLA_MTU - 1]) {
440 if (ida[IFLA_MTU - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
442 err = dev_set_mtu(dev, *((u32 *) RTA_DATA(ida[IFLA_MTU - 1])));
449 if (ida[IFLA_TXQLEN - 1]) {
450 if (ida[IFLA_TXQLEN - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
453 dev->tx_queue_len = *((u32 *) RTA_DATA(ida[IFLA_TXQLEN - 1]));
456 if (ida[IFLA_WEIGHT - 1]) {
457 if (ida[IFLA_WEIGHT - 1]->rta_len != RTA_LENGTH(sizeof(u32)))
460 dev->weight = *((u32 *) RTA_DATA(ida[IFLA_WEIGHT - 1]));
463 if (ida[IFLA_OPERSTATE - 1]) {
464 if (ida[IFLA_OPERSTATE - 1]->rta_len != RTA_LENGTH(sizeof(u8)))
467 set_operstate(dev, *((u8 *) RTA_DATA(ida[IFLA_OPERSTATE - 1])));
470 if (ida[IFLA_LINKMODE - 1]) {
471 if (ida[IFLA_LINKMODE - 1]->rta_len != RTA_LENGTH(sizeof(u8)))
474 write_lock_bh(&dev_base_lock);
475 dev->link_mode = *((u8 *) RTA_DATA(ida[IFLA_LINKMODE - 1]));
476 write_unlock_bh(&dev_base_lock);
479 if (ifm->ifi_index >= 0 && ida[IFLA_IFNAME - 1]) {
480 char ifname[IFNAMSIZ];
482 if (rtattr_strlcpy(ifname, ida[IFLA_IFNAME - 1],
483 IFNAMSIZ) >= IFNAMSIZ)
485 err = dev_change_name(dev, ifname);
490 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
491 if (ida[IFLA_WIRELESS - 1]) {
493 /* Call Wireless Extensions.
494 * Various stuff checked in there... */
495 err = wireless_rtnetlink_set(dev, RTA_DATA(ida[IFLA_WIRELESS - 1]), ida[IFLA_WIRELESS - 1]->rta_len);
499 #endif /* CONFIG_NET_WIRELESS_RTNETLINK */
504 if (send_addr_notify)
505 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
511 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
512 static int do_getlink(struct sk_buff *in_skb, struct nlmsghdr* in_nlh, void *arg)
514 struct ifinfomsg *ifm = NLMSG_DATA(in_nlh);
515 struct rtattr **ida = arg;
516 struct net_device *dev;
518 struct nlmsghdr *nlh;
525 if (ifm->ifi_index >= 0)
526 dev = dev_get_by_index(ifm->ifi_index);
532 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
533 if (ida[IFLA_WIRELESS - 1]) {
535 /* Call Wireless Extensions. We need to know the size before
536 * we can alloc. Various stuff checked in there... */
537 err = wireless_rtnetlink_get(dev, RTA_DATA(ida[IFLA_WIRELESS - 1]), ida[IFLA_WIRELESS - 1]->rta_len, &iw_buf, &iw_buf_len);
541 #endif /* CONFIG_NET_WIRELESS_RTNETLINK */
543 /* Create a skb big enough to include all the data.
544 * Some requests are way bigger than 4k... Jean II */
545 skb = alloc_skb((NLMSG_LENGTH(sizeof(*r))) + (RTA_SPACE(iw_buf_len)),
551 /* Put in the message the usual good stuff */
552 nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid, in_nlh->nlmsg_seq,
553 RTM_NEWLINK, sizeof(*r));
555 r->ifi_family = AF_UNSPEC;
557 r->ifi_type = dev->type;
558 r->ifi_index = dev->ifindex;
559 r->ifi_flags = dev->flags;
562 /* Put the wireless payload if it exist */
564 RTA_PUT(skb, IFLA_WIRELESS, iw_buf_len,
565 iw_buf + IW_EV_POINT_OFF);
567 nlh->nlmsg_len = skb->tail - b;
570 NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
572 err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
586 #endif /* CONFIG_NET_WIRELESS_RTNETLINK */
588 static int rtnetlink_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
591 int s_idx = cb->family;
595 for (idx=1; idx<NPROTO; idx++) {
596 int type = cb->nlh->nlmsg_type-RTM_BASE;
597 if (idx < s_idx || idx == PF_PACKET)
599 if (rtnetlink_links[idx] == NULL ||
600 rtnetlink_links[idx][type].dumpit == NULL)
603 memset(&cb->args[0], 0, sizeof(cb->args));
604 if (rtnetlink_links[idx][type].dumpit(skb, cb))
612 void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
615 int size = NLMSG_SPACE(sizeof(struct ifinfomsg) +
616 sizeof(struct rtnl_link_ifmap) +
617 sizeof(struct rtnl_link_stats) + 128);
619 if (vx_flags(VXF_HIDE_NETIF, 0) &&
620 !dev_in_nx_info(dev, current->nx_info))
622 skb = alloc_skb(size, GFP_KERNEL);
626 if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) {
630 NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
631 netlink_broadcast(rtnl, skb, 0, RTNLGRP_LINK, GFP_KERNEL);
634 /* Protected by RTNL sempahore. */
635 static struct rtattr **rta_buf;
636 static int rtattr_max;
638 /* Process one rtnetlink message. */
640 static __inline__ int
641 rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
643 struct rtnetlink_link *link;
644 struct rtnetlink_link *link_tab;
651 /* Only requests are handled by kernel now */
652 if (!(nlh->nlmsg_flags&NLM_F_REQUEST))
655 type = nlh->nlmsg_type;
657 /* A control message: ignore them */
661 /* Unknown message: reply with EINVAL */
667 /* All the messages must have at least 1 byte length */
668 if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(struct rtgenmsg)))
671 family = ((struct rtgenmsg*)NLMSG_DATA(nlh))->rtgen_family;
672 if (family >= NPROTO) {
673 *errp = -EAFNOSUPPORT;
677 link_tab = rtnetlink_links[family];
678 if (link_tab == NULL)
679 link_tab = rtnetlink_links[PF_UNSPEC];
680 link = &link_tab[type];
685 if (kind != 2 && security_netlink_recv(skb)) {
690 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
691 if (link->dumpit == NULL)
692 link = &(rtnetlink_links[PF_UNSPEC][type]);
694 if (link->dumpit == NULL)
697 if ((*errp = netlink_dump_start(rtnl, skb, nlh,
698 link->dumpit, NULL)) != 0) {
702 netlink_queue_skip(nlh, skb);
706 memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
708 min_len = rtm_min[sz_idx];
709 if (nlh->nlmsg_len < min_len)
712 if (nlh->nlmsg_len > min_len) {
713 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
714 struct rtattr *attr = (void*)nlh + NLMSG_ALIGN(min_len);
716 while (RTA_OK(attr, attrlen)) {
717 unsigned flavor = attr->rta_type;
719 if (flavor > rta_max[sz_idx])
721 rta_buf[flavor-1] = attr;
723 attr = RTA_NEXT(attr, attrlen);
727 if (link->doit == NULL)
728 link = &(rtnetlink_links[PF_UNSPEC][type]);
729 if (link->doit == NULL)
731 err = link->doit(skb, nlh, (void *)&rta_buf[0]);
741 static void rtnetlink_rcv(struct sock *sk, int len)
743 unsigned int qlen = 0;
746 mutex_lock(&rtnl_mutex);
747 netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg);
748 mutex_unlock(&rtnl_mutex);
754 static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
756 [RTM_GETLINK - RTM_BASE] = {
757 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
759 #endif /* CONFIG_NET_WIRELESS_RTNETLINK */
760 .dumpit = rtnetlink_dump_ifinfo },
761 [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink },
762 [RTM_GETADDR - RTM_BASE] = { .dumpit = rtnetlink_dump_all },
763 [RTM_GETROUTE - RTM_BASE] = { .dumpit = rtnetlink_dump_all },
764 [RTM_NEWNEIGH - RTM_BASE] = { .doit = neigh_add },
765 [RTM_DELNEIGH - RTM_BASE] = { .doit = neigh_delete },
766 [RTM_GETNEIGH - RTM_BASE] = { .dumpit = neigh_dump_info },
767 [RTM_GETRULE - RTM_BASE] = { .dumpit = rtnetlink_dump_all },
768 [RTM_GETNEIGHTBL - RTM_BASE] = { .dumpit = neightbl_dump_info },
769 [RTM_SETNEIGHTBL - RTM_BASE] = { .doit = neightbl_set },
772 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)
774 struct net_device *dev = ptr;
776 case NETDEV_UNREGISTER:
777 rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
779 case NETDEV_REGISTER:
780 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
784 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
787 case NETDEV_GOING_DOWN:
790 rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
796 static struct notifier_block rtnetlink_dev_notifier = {
797 .notifier_call = rtnetlink_event,
800 void __init rtnetlink_init(void)
805 for (i = 0; i < ARRAY_SIZE(rta_max); i++)
806 if (rta_max[i] > rtattr_max)
807 rtattr_max = rta_max[i];
808 rta_buf = kmalloc(rtattr_max * sizeof(struct rtattr *), GFP_KERNEL);
810 panic("rtnetlink_init: cannot allocate rta_buf\n");
812 rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv,
815 panic("rtnetlink_init: cannot initialize rtnetlink\n");
816 netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
817 register_netdevice_notifier(&rtnetlink_dev_notifier);
818 rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table;
819 rtnetlink_links[PF_PACKET] = link_rtnetlink_table;
822 EXPORT_SYMBOL(__rta_fill);
823 EXPORT_SYMBOL(rtattr_strlcpy);
824 EXPORT_SYMBOL(rtattr_parse);
825 EXPORT_SYMBOL(rtnetlink_links);
826 EXPORT_SYMBOL(rtnetlink_put_metrics);
828 EXPORT_SYMBOL(rtnl_lock);
829 EXPORT_SYMBOL(rtnl_trylock);
830 EXPORT_SYMBOL(rtnl_unlock);