1 #include <linux/types.h>
2 #include <linux/skbuff.h>
3 #include <linux/socket.h>
4 #include <linux/sysctl.h>
6 #include <linux/module.h>
7 #include <linux/if_arp.h>
8 #include <linux/ipv6.h>
9 #include <linux/mpls.h>
10 #include <linux/vmalloc.h>
15 #include <net/ip_fib.h>
16 #include <net/netevent.h>
17 #include <net/netns/generic.h>
20 #define LABEL_NOT_SPECIFIED (1<<20)
21 #define MAX_NEW_LABELS 2
23 /* This maximum ha length copied from the definition of struct neighbour */
24 #define MAX_VIA_ALEN (ALIGN(MAX_ADDR_LEN, sizeof(unsigned long)))
26 struct mpls_route { /* next hop label forwarding entry */
27 struct net_device __rcu *rt_dev;
28 struct rcu_head rt_rcu;
29 u32 rt_label[MAX_NEW_LABELS];
30 u8 rt_protocol; /* routing protocol that set this entry */
33 unsigned short rt_via_family;
38 static int label_limit = (1 << 20) - 1;
40 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
41 struct nlmsghdr *nlh, struct net *net, u32 portid,
42 unsigned int nlm_flags);
44 static struct mpls_route *mpls_route_input_rcu(struct net *net, unsigned index)
46 struct mpls_route *rt = NULL;
48 if (index < net->mpls.platform_labels) {
49 struct mpls_route __rcu **platform_label =
50 rcu_dereference(net->mpls.platform_label);
51 rt = rcu_dereference(platform_label[index]);
56 static bool mpls_output_possible(const struct net_device *dev)
58 return dev && (dev->flags & IFF_UP) && netif_carrier_ok(dev);
61 static unsigned int mpls_rt_header_size(const struct mpls_route *rt)
63 /* The size of the layer 2.5 labels to be added for this route */
64 return rt->rt_labels * sizeof(struct mpls_shim_hdr);
67 static unsigned int mpls_dev_mtu(const struct net_device *dev)
69 /* The amount of data the layer 2 frame can hold */
73 static bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
78 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu)
84 static bool mpls_egress(struct mpls_route *rt, struct sk_buff *skb,
85 struct mpls_entry_decoded dec)
87 /* RFC4385 and RFC5586 encode other packets in mpls such that
88 * they don't conflict with the ip version number, making
89 * decoding by examining the ip version correct in everything
90 * except for the strangest cases.
92 * The strange cases if we choose to support them will require
93 * manual configuration.
95 struct iphdr *hdr4 = ip_hdr(skb);
98 if (hdr4->version == 4) {
99 skb->protocol = htons(ETH_P_IP);
100 csum_replace2(&hdr4->check,
101 htons(hdr4->ttl << 8),
102 htons(dec.ttl << 8));
105 else if (hdr4->version == 6) {
106 struct ipv6hdr *hdr6 = ipv6_hdr(skb);
107 skb->protocol = htons(ETH_P_IPV6);
108 hdr6->hop_limit = dec.ttl;
111 /* version 0 and version 1 are used by pseudo wires */
116 static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
117 struct packet_type *pt, struct net_device *orig_dev)
119 struct net *net = dev_net(dev);
120 struct mpls_shim_hdr *hdr;
121 struct mpls_route *rt;
122 struct mpls_entry_decoded dec;
123 struct net_device *out_dev;
125 unsigned int new_header_size;
129 /* Careful this entire function runs inside of an rcu critical section */
131 if (skb->pkt_type != PACKET_HOST)
134 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
137 if (!pskb_may_pull(skb, sizeof(*hdr)))
140 /* Read and decode the label */
142 dec = mpls_entry_decode(hdr);
145 skb_pull(skb, sizeof(*hdr));
146 skb_reset_network_header(skb);
150 rt = mpls_route_input_rcu(net, dec.label);
154 /* Find the output device */
155 out_dev = rcu_dereference(rt->rt_dev);
156 if (!mpls_output_possible(out_dev))
159 if (skb_warn_if_lro(skb))
162 skb_forward_csum(skb);
164 /* Verify ttl is valid */
169 /* Verify the destination can hold the packet */
170 new_header_size = mpls_rt_header_size(rt);
171 mtu = mpls_dev_mtu(out_dev);
172 if (mpls_pkt_too_big(skb, mtu - new_header_size))
175 hh_len = LL_RESERVED_SPACE(out_dev);
176 if (!out_dev->header_ops)
179 /* Ensure there is enough space for the headers in the skb */
180 if (skb_cow(skb, hh_len + new_header_size))
184 skb->protocol = htons(ETH_P_MPLS_UC);
186 if (unlikely(!new_header_size && dec.bos)) {
187 /* Penultimate hop popping */
188 if (!mpls_egress(rt, skb, dec))
193 skb_push(skb, new_header_size);
194 skb_reset_network_header(skb);
195 /* Push the new labels */
198 for (i = rt->rt_labels - 1; i >= 0; i--) {
199 hdr[i] = mpls_entry_encode(rt->rt_label[i], dec.ttl, 0, bos);
204 err = neigh_xmit(rt->rt_via_family, out_dev, rt->rt_via, skb);
206 net_dbg_ratelimited("%s: packet transmission failed: %d\n",
215 static struct packet_type mpls_packet_type __read_mostly = {
216 .type = cpu_to_be16(ETH_P_MPLS_UC),
217 .func = mpls_forward,
220 static const struct nla_policy rtm_mpls_policy[RTA_MAX+1] = {
221 [RTA_DST] = { .type = NLA_U32 },
222 [RTA_OIF] = { .type = NLA_U32 },
225 struct mpls_route_config {
230 u8 rc_via[MAX_VIA_ALEN];
232 u32 rc_output_labels;
233 u32 rc_output_label[MAX_NEW_LABELS];
235 struct nl_info rc_nlinfo;
238 static struct mpls_route *mpls_rt_alloc(size_t alen)
240 struct mpls_route *rt;
242 rt = kzalloc(sizeof(*rt) + alen, GFP_KERNEL);
244 rt->rt_via_alen = alen;
248 static void mpls_rt_free(struct mpls_route *rt)
251 kfree_rcu(rt, rt_rcu);
254 static void mpls_notify_route(struct net *net, unsigned index,
255 struct mpls_route *old, struct mpls_route *new,
256 const struct nl_info *info)
258 struct nlmsghdr *nlh = info ? info->nlh : NULL;
259 unsigned portid = info ? info->portid : 0;
260 int event = new ? RTM_NEWROUTE : RTM_DELROUTE;
261 struct mpls_route *rt = new ? new : old;
262 unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0;
263 /* Ignore reserved labels for now */
264 if (rt && (index >= 16))
265 rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags);
268 static void mpls_route_update(struct net *net, unsigned index,
269 struct net_device *dev, struct mpls_route *new,
270 const struct nl_info *info)
272 struct mpls_route __rcu **platform_label;
273 struct mpls_route *rt, *old = NULL;
277 platform_label = rtnl_dereference(net->mpls.platform_label);
278 rt = rtnl_dereference(platform_label[index]);
279 if (!dev || (rt && (rtnl_dereference(rt->rt_dev) == dev))) {
280 rcu_assign_pointer(platform_label[index], new);
284 mpls_notify_route(net, index, old, new, info);
286 /* If we removed a route free it now */
290 static unsigned find_free_label(struct net *net)
292 struct mpls_route __rcu **platform_label;
293 size_t platform_labels;
296 platform_label = rtnl_dereference(net->mpls.platform_label);
297 platform_labels = net->mpls.platform_labels;
298 for (index = 16; index < platform_labels; index++) {
299 if (!rtnl_dereference(platform_label[index]))
302 return LABEL_NOT_SPECIFIED;
305 static int mpls_route_add(struct mpls_route_config *cfg)
307 struct mpls_route __rcu **platform_label;
308 struct net *net = cfg->rc_nlinfo.nl_net;
309 struct net_device *dev = NULL;
310 struct mpls_route *rt, *old;
315 index = cfg->rc_label;
317 /* If a label was not specified during insert pick one */
318 if ((index == LABEL_NOT_SPECIFIED) &&
319 (cfg->rc_nlflags & NLM_F_CREATE)) {
320 index = find_free_label(net);
323 /* The first 16 labels are reserved, and may not be set */
327 /* The full 20 bit range may not be supported. */
328 if (index >= net->mpls.platform_labels)
331 /* Ensure only a supported number of labels are present */
332 if (cfg->rc_output_labels > MAX_NEW_LABELS)
336 dev = dev_get_by_index(net, cfg->rc_ifindex);
340 /* For now just support ethernet devices */
342 if ((dev->type != ARPHRD_ETHER) && (dev->type != ARPHRD_LOOPBACK))
346 if ((cfg->rc_via_family == AF_PACKET) &&
347 (dev->addr_len != cfg->rc_via_alen))
350 /* Append makes no sense with mpls */
352 if (cfg->rc_nlflags & NLM_F_APPEND)
356 platform_label = rtnl_dereference(net->mpls.platform_label);
357 old = rtnl_dereference(platform_label[index]);
358 if ((cfg->rc_nlflags & NLM_F_EXCL) && old)
362 if (!(cfg->rc_nlflags & NLM_F_REPLACE) && old)
366 if (!(cfg->rc_nlflags & NLM_F_CREATE) && !old)
370 rt = mpls_rt_alloc(cfg->rc_via_alen);
374 rt->rt_labels = cfg->rc_output_labels;
375 for (i = 0; i < rt->rt_labels; i++)
376 rt->rt_label[i] = cfg->rc_output_label[i];
377 rt->rt_protocol = cfg->rc_protocol;
378 RCU_INIT_POINTER(rt->rt_dev, dev);
379 rt->rt_via_family = cfg->rc_via_family;
380 memcpy(rt->rt_via, cfg->rc_via, cfg->rc_via_alen);
382 mpls_route_update(net, index, NULL, rt, &cfg->rc_nlinfo);
393 static int mpls_route_del(struct mpls_route_config *cfg)
395 struct net *net = cfg->rc_nlinfo.nl_net;
399 index = cfg->rc_label;
401 /* The first 16 labels are reserved, and may not be removed */
405 /* The full 20 bit range may not be supported */
406 if (index >= net->mpls.platform_labels)
409 mpls_route_update(net, index, NULL, NULL, &cfg->rc_nlinfo);
416 static void mpls_ifdown(struct net_device *dev)
418 struct mpls_route __rcu **platform_label;
419 struct net *net = dev_net(dev);
422 platform_label = rtnl_dereference(net->mpls.platform_label);
423 for (index = 0; index < net->mpls.platform_labels; index++) {
424 struct mpls_route *rt = rtnl_dereference(platform_label[index]);
427 if (rtnl_dereference(rt->rt_dev) != dev)
433 static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
436 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
439 case NETDEV_UNREGISTER:
446 static struct notifier_block mpls_dev_notifier = {
447 .notifier_call = mpls_dev_notify,
450 static int nla_put_via(struct sk_buff *skb,
451 u16 family, const void *addr, int alen)
456 nla = nla_reserve(skb, RTA_VIA, alen + 2);
461 via->rtvia_family = family;
462 memcpy(via->rtvia_addr, addr, alen);
466 int nla_put_labels(struct sk_buff *skb, int attrtype,
467 u8 labels, const u32 label[])
470 struct mpls_shim_hdr *nla_label;
473 nla = nla_reserve(skb, attrtype, labels*4);
477 nla_label = nla_data(nla);
479 for (i = labels - 1; i >= 0; i--) {
480 nla_label[i] = mpls_entry_encode(label[i], 0, 0, bos);
487 int nla_get_labels(const struct nlattr *nla,
488 u32 max_labels, u32 *labels, u32 label[])
490 unsigned len = nla_len(nla);
492 struct mpls_shim_hdr *nla_label;
496 /* len needs to be an even multiple of 4 (the label size) */
500 /* Limit the number of new labels allowed */
502 if (nla_labels > max_labels)
505 nla_label = nla_data(nla);
507 for (i = nla_labels - 1; i >= 0; i--, bos = false) {
508 struct mpls_entry_decoded dec;
509 dec = mpls_entry_decode(nla_label + i);
511 /* Ensure the bottom of stack flag is properly set
512 * and ttl and tc are both clear.
514 if ((dec.bos != bos) || dec.ttl || dec.tc)
517 label[i] = dec.label;
519 *labels = nla_labels;
523 static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
524 struct mpls_route_config *cfg)
527 struct nlattr *tb[RTA_MAX+1];
531 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_mpls_policy);
536 rtm = nlmsg_data(nlh);
537 memset(cfg, 0, sizeof(*cfg));
539 if (rtm->rtm_family != AF_MPLS)
541 if (rtm->rtm_dst_len != 20)
543 if (rtm->rtm_src_len != 0)
545 if (rtm->rtm_tos != 0)
547 if (rtm->rtm_table != RT_TABLE_MAIN)
549 /* Any value is acceptable for rtm_protocol */
551 /* As mpls uses destination specific addresses
552 * (or source specific address in the case of multicast)
553 * all addresses have universal scope.
555 if (rtm->rtm_scope != RT_SCOPE_UNIVERSE)
557 if (rtm->rtm_type != RTN_UNICAST)
559 if (rtm->rtm_flags != 0)
562 cfg->rc_label = LABEL_NOT_SPECIFIED;
563 cfg->rc_protocol = rtm->rtm_protocol;
564 cfg->rc_nlflags = nlh->nlmsg_flags;
565 cfg->rc_nlinfo.portid = NETLINK_CB(skb).portid;
566 cfg->rc_nlinfo.nlh = nlh;
567 cfg->rc_nlinfo.nl_net = sock_net(skb->sk);
569 for (index = 0; index <= RTA_MAX; index++) {
570 struct nlattr *nla = tb[index];
576 cfg->rc_ifindex = nla_get_u32(nla);
579 if (nla_get_labels(nla, MAX_NEW_LABELS,
580 &cfg->rc_output_labels,
581 cfg->rc_output_label))
587 if (nla_get_labels(nla, 1, &label_count,
591 /* The first 16 labels are reserved, and may not be set */
592 if (cfg->rc_label < 16)
599 struct rtvia *via = nla_data(nla);
600 if (nla_len(nla) < offsetof(struct rtvia, rtvia_addr))
602 cfg->rc_via_family = via->rtvia_family;
603 cfg->rc_via_alen = nla_len(nla) -
604 offsetof(struct rtvia, rtvia_addr);
605 if (cfg->rc_via_alen > MAX_VIA_ALEN)
608 /* Validate the address family */
609 switch(cfg->rc_via_family) {
613 if (cfg->rc_via_alen != 4)
617 if (cfg->rc_via_alen != 16)
621 /* Unsupported address family */
625 memcpy(cfg->rc_via, via->rtvia_addr, cfg->rc_via_alen);
629 /* Unsupported attribute */
639 static int mpls_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh)
641 struct mpls_route_config cfg;
644 err = rtm_to_route_config(skb, nlh, &cfg);
648 return mpls_route_del(&cfg);
652 static int mpls_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh)
654 struct mpls_route_config cfg;
657 err = rtm_to_route_config(skb, nlh, &cfg);
661 return mpls_route_add(&cfg);
664 static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event,
665 u32 label, struct mpls_route *rt, int flags)
667 struct net_device *dev;
668 struct nlmsghdr *nlh;
671 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*rtm), flags);
675 rtm = nlmsg_data(nlh);
676 rtm->rtm_family = AF_MPLS;
677 rtm->rtm_dst_len = 20;
678 rtm->rtm_src_len = 0;
680 rtm->rtm_table = RT_TABLE_MAIN;
681 rtm->rtm_protocol = rt->rt_protocol;
682 rtm->rtm_scope = RT_SCOPE_UNIVERSE;
683 rtm->rtm_type = RTN_UNICAST;
687 nla_put_labels(skb, RTA_NEWDST, rt->rt_labels, rt->rt_label))
688 goto nla_put_failure;
689 if (nla_put_via(skb, rt->rt_via_family, rt->rt_via, rt->rt_via_alen))
690 goto nla_put_failure;
691 dev = rtnl_dereference(rt->rt_dev);
692 if (dev && nla_put_u32(skb, RTA_OIF, dev->ifindex))
693 goto nla_put_failure;
694 if (nla_put_labels(skb, RTA_DST, 1, &label))
695 goto nla_put_failure;
701 nlmsg_cancel(skb, nlh);
705 static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
707 struct net *net = sock_net(skb->sk);
708 struct mpls_route __rcu **platform_label;
709 size_t platform_labels;
718 platform_label = rtnl_dereference(net->mpls.platform_label);
719 platform_labels = net->mpls.platform_labels;
720 for (; index < platform_labels; index++) {
721 struct mpls_route *rt;
722 rt = rtnl_dereference(platform_label[index]);
726 if (mpls_dump_route(skb, NETLINK_CB(cb->skb).portid,
727 cb->nlh->nlmsg_seq, RTM_NEWROUTE,
728 index, rt, NLM_F_MULTI) < 0)
736 static inline size_t lfib_nlmsg_size(struct mpls_route *rt)
739 NLMSG_ALIGN(sizeof(struct rtmsg))
740 + nla_total_size(2 + rt->rt_via_alen) /* RTA_VIA */
741 + nla_total_size(4); /* RTA_DST */
742 if (rt->rt_labels) /* RTA_NEWDST */
743 payload += nla_total_size(rt->rt_labels * 4);
744 if (rt->rt_dev) /* RTA_OIF */
745 payload += nla_total_size(4);
749 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
750 struct nlmsghdr *nlh, struct net *net, u32 portid,
751 unsigned int nlm_flags)
754 u32 seq = nlh ? nlh->nlmsg_seq : 0;
757 skb = nlmsg_new(lfib_nlmsg_size(rt), GFP_KERNEL);
761 err = mpls_dump_route(skb, portid, seq, event, label, rt, nlm_flags);
763 /* -EMSGSIZE implies BUG in lfib_nlmsg_size */
764 WARN_ON(err == -EMSGSIZE);
768 rtnl_notify(skb, net, portid, RTNLGRP_MPLS_ROUTE, nlh, GFP_KERNEL);
773 rtnl_set_sk_err(net, RTNLGRP_MPLS_ROUTE, err);
776 static int resize_platform_label_table(struct net *net, size_t limit)
778 size_t size = sizeof(struct mpls_route *) * limit;
781 struct mpls_route __rcu **labels = NULL, **old;
782 struct mpls_route *rt0 = NULL, *rt2 = NULL;
786 labels = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
788 labels = vzalloc(size);
794 /* In case the predefined labels need to be populated */
795 if (limit > LABEL_IPV4_EXPLICIT_NULL) {
796 struct net_device *lo = net->loopback_dev;
797 rt0 = mpls_rt_alloc(lo->addr_len);
800 RCU_INIT_POINTER(rt0->rt_dev, lo);
801 rt0->rt_protocol = RTPROT_KERNEL;
802 rt0->rt_via_family = AF_PACKET;
803 memcpy(rt0->rt_via, lo->dev_addr, lo->addr_len);
805 if (limit > LABEL_IPV6_EXPLICIT_NULL) {
806 struct net_device *lo = net->loopback_dev;
807 rt2 = mpls_rt_alloc(lo->addr_len);
810 RCU_INIT_POINTER(rt2->rt_dev, lo);
811 rt2->rt_protocol = RTPROT_KERNEL;
812 rt2->rt_via_family = AF_PACKET;
813 memcpy(rt2->rt_via, lo->dev_addr, lo->addr_len);
817 /* Remember the original table */
818 old = rtnl_dereference(net->mpls.platform_label);
819 old_limit = net->mpls.platform_labels;
821 /* Free any labels beyond the new table */
822 for (index = limit; index < old_limit; index++)
823 mpls_route_update(net, index, NULL, NULL, NULL);
825 /* Copy over the old labels */
827 if (old_limit < limit)
828 cp_size = old_limit * sizeof(struct mpls_route *);
830 memcpy(labels, old, cp_size);
832 /* If needed set the predefined labels */
833 if ((old_limit <= LABEL_IPV6_EXPLICIT_NULL) &&
834 (limit > LABEL_IPV6_EXPLICIT_NULL)) {
835 RCU_INIT_POINTER(labels[LABEL_IPV6_EXPLICIT_NULL], rt2);
839 if ((old_limit <= LABEL_IPV4_EXPLICIT_NULL) &&
840 (limit > LABEL_IPV4_EXPLICIT_NULL)) {
841 RCU_INIT_POINTER(labels[LABEL_IPV4_EXPLICIT_NULL], rt0);
845 /* Update the global pointers */
846 net->mpls.platform_labels = limit;
847 rcu_assign_pointer(net->mpls.platform_label, labels);
868 static int mpls_platform_labels(struct ctl_table *table, int write,
869 void __user *buffer, size_t *lenp, loff_t *ppos)
871 struct net *net = table->data;
872 int platform_labels = net->mpls.platform_labels;
874 struct ctl_table tmp = {
875 .procname = table->procname,
876 .data = &platform_labels,
877 .maxlen = sizeof(int),
880 .extra2 = &label_limit,
883 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
885 if (write && ret == 0)
886 ret = resize_platform_label_table(net, platform_labels);
891 static struct ctl_table mpls_table[] = {
893 .procname = "platform_labels",
895 .maxlen = sizeof(int),
897 .proc_handler = mpls_platform_labels,
902 static int mpls_net_init(struct net *net)
904 struct ctl_table *table;
906 net->mpls.platform_labels = 0;
907 net->mpls.platform_label = NULL;
909 table = kmemdup(mpls_table, sizeof(mpls_table), GFP_KERNEL);
914 net->mpls.ctl = register_net_sysctl(net, "net/mpls", table);
915 if (net->mpls.ctl == NULL)
921 static void mpls_net_exit(struct net *net)
923 struct mpls_route __rcu **platform_label;
924 size_t platform_labels;
925 struct ctl_table *table;
928 table = net->mpls.ctl->ctl_table_arg;
929 unregister_net_sysctl_table(net->mpls.ctl);
932 /* An rcu grace period has passed since there was a device in
933 * the network namespace (and thus the last in flight packet)
934 * left this network namespace. This is because
935 * unregister_netdevice_many and netdev_run_todo has completed
936 * for each network device that was in this network namespace.
938 * As such no additional rcu synchronization is necessary when
939 * freeing the platform_label table.
942 platform_label = rtnl_dereference(net->mpls.platform_label);
943 platform_labels = net->mpls.platform_labels;
944 for (index = 0; index < platform_labels; index++) {
945 struct mpls_route *rt = rtnl_dereference(platform_label[index]);
946 RCU_INIT_POINTER(platform_label[index], NULL);
951 kvfree(platform_label);
954 static struct pernet_operations mpls_net_ops = {
955 .init = mpls_net_init,
956 .exit = mpls_net_exit,
959 static int __init mpls_init(void)
963 BUILD_BUG_ON(sizeof(struct mpls_shim_hdr) != 4);
965 err = register_pernet_subsys(&mpls_net_ops);
969 err = register_netdevice_notifier(&mpls_dev_notifier);
971 goto out_unregister_pernet;
973 dev_add_pack(&mpls_packet_type);
975 rtnl_register(PF_MPLS, RTM_NEWROUTE, mpls_rtm_newroute, NULL, NULL);
976 rtnl_register(PF_MPLS, RTM_DELROUTE, mpls_rtm_delroute, NULL, NULL);
977 rtnl_register(PF_MPLS, RTM_GETROUTE, NULL, mpls_dump_routes, NULL);
982 out_unregister_pernet:
983 unregister_pernet_subsys(&mpls_net_ops);
986 module_init(mpls_init);
988 static void __exit mpls_exit(void)
990 rtnl_unregister_all(PF_MPLS);
991 dev_remove_pack(&mpls_packet_type);
992 unregister_netdevice_notifier(&mpls_dev_notifier);
993 unregister_pernet_subsys(&mpls_net_ops);
995 module_exit(mpls_exit);
997 MODULE_DESCRIPTION("MultiProtocol Label Switching");
998 MODULE_LICENSE("GPL v2");
999 MODULE_ALIAS_NETPROTO(PF_MPLS);