Skip to content

Commit

Permalink
Merge branch 'basic-mpls-support'
Browse files Browse the repository at this point in the history
Eric W. Biederman says:

====================
Basic MPLS support take 2

On top of my two pending neighbour table prep patches here is the mpls
support refactored to use them, and edited to not drop routes when
an interface goes down.  Additionally the addition of RTA_LLGATEWAY
has been replaced with the addtion of RTA_VIA.  RTA_VIA being an
attribute that includes the address family as well as the address
of the next hop.

MPLS is at it's heart simple and I have endeavoured to maintain that
simplicity in my implemenation.

This is an implementation of a RFC3032 forwarding engine, and basic MPLS
egress logic.  Which should make linux sufficient to be a mpls
forwarding node or to be a LSA (Label Switched Router) as it says in all
of the MPLS documents.  The ingress support will follow but it deserves
it's own discussion so I am pushing it separately.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 4, 2015
2 parents ee23393 + 8de147d commit 27db730
Show file tree
Hide file tree
Showing 10 changed files with 1,110 additions and 2 deletions.
20 changes: 20 additions & 0 deletions Documentation/networking/mpls-sysctl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/proc/sys/net/mpls/* Variables:

platform_labels - INTEGER
Number of entries in the platform label table. It is not
possible to configure forwarding for label values equal to or
greater than the number of platform labels.

A dense utliziation of the entries in the platform label table
is possible and expected aas the platform labels are locally
allocated.

If the number of platform label table entries is set to 0 no
label will be recognized by the kernel and mpls forwarding
will be disabled.

Reducing this value will remove all label routing entries that
no longer fit in the table.

Possible values: 0 - 1048575
Default: 0
2 changes: 2 additions & 0 deletions include/linux/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct ucred {
#define AF_WANPIPE 25 /* Wanpipe API Sockets */
#define AF_LLC 26 /* Linux LLC */
#define AF_IB 27 /* Native InfiniBand address */
#define AF_MPLS 28 /* MPLS */
#define AF_CAN 29 /* Controller Area Network */
#define AF_TIPC 30 /* TIPC sockets */
#define AF_BLUETOOTH 31 /* Bluetooth sockets */
Expand Down Expand Up @@ -226,6 +227,7 @@ struct ucred {
#define PF_WANPIPE AF_WANPIPE
#define PF_LLC AF_LLC
#define PF_IB AF_IB
#define PF_MPLS AF_MPLS
#define PF_CAN AF_CAN
#define PF_TIPC AF_TIPC
#define PF_BLUETOOTH AF_BLUETOOTH
Expand Down
4 changes: 4 additions & 0 deletions include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endif
#include <net/netns/nftables.h>
#include <net/netns/xfrm.h>
#include <net/netns/mpls.h>
#include <linux/ns_common.h>

struct user_namespace;
Expand Down Expand Up @@ -129,6 +130,9 @@ struct net {
#endif
#if IS_ENABLED(CONFIG_IP_VS)
struct netns_ipvs *ipvs;
#endif
#if IS_ENABLED(CONFIG_MPLS)
struct netns_mpls mpls;
#endif
struct sock *diag_nlsk;
atomic_t fnhe_genid;
Expand Down
17 changes: 17 additions & 0 deletions include/net/netns/mpls.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* mpls in net namespaces
*/

#ifndef __NETNS_MPLS_H__
#define __NETNS_MPLS_H__

struct mpls_route;
struct ctl_table_header;

struct netns_mpls {
size_t platform_labels;
struct mpls_route __rcu * __rcu *platform_label;
struct ctl_table_header *ctl;
};

#endif /* __NETNS_MPLS_H__ */
10 changes: 10 additions & 0 deletions include/uapi/linux/rtnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ enum rtattr_type_t {
RTA_TABLE,
RTA_MARK,
RTA_MFC_STATS,
RTA_VIA,
RTA_NEWDST,
__RTA_MAX
};

Expand Down Expand Up @@ -344,6 +346,12 @@ struct rtnexthop {
#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))

/* RTA_VIA */
struct rtvia {
__kernel_sa_family_t rtvia_family;
__u8 rtvia_addr[0];
};

/* RTM_CACHEINFO */

struct rta_cacheinfo {
Expand Down Expand Up @@ -623,6 +631,8 @@ enum rtnetlink_groups {
#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
RTNLGRP_MDB,
#define RTNLGRP_MDB RTNLGRP_MDB
RTNLGRP_MPLS_ROUTE,
#define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE
__RTNLGRP_MAX
};
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
Expand Down
2 changes: 1 addition & 1 deletion net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv/
obj-$(CONFIG_NFC) += nfc/
obj-$(CONFIG_OPENVSWITCH) += openvswitch/
obj-$(CONFIG_VSOCKETS) += vmw_vsock/
obj-$(CONFIG_NET_MPLS_GSO) += mpls/
obj-$(CONFIG_MPLS) += mpls/
obj-$(CONFIG_HSR) += hsr/
ifneq ($(CONFIG_NET_SWITCHDEV),)
obj-y += switchdev/
Expand Down
23 changes: 22 additions & 1 deletion net/mpls/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
#
# MPLS configuration
#

menuconfig MPLS
tristate "MultiProtocol Label Switching"
default n
---help---
MultiProtocol Label Switching routes packets through logical
circuits. Originally conceved as a way of routing packets at
hardware speeds (before hardware was capable of routing ipv4 packets),
MPLS remains as simple way of making tunnels.

If you have not heard of MPLS you probably want to say N here.

if MPLS

config NET_MPLS_GSO
tristate "MPLS: GSO support"
bool "MPLS: GSO support"
help
This is helper module to allow segmentation of non-MPLS GSO packets
that have had MPLS stack entries pushed onto them and thus
become MPLS GSO packets.

config MPLS_ROUTING
bool "MPLS: routing support"
help
Add support for forwarding of mpls packets.

endif # MPLS
1 change: 1 addition & 0 deletions net/mpls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Makefile for MPLS.
#
obj-$(CONFIG_NET_MPLS_GSO) += mpls_gso.o
obj-$(CONFIG_MPLS_ROUTING) += af_mpls.o
Loading

0 comments on commit 27db730

Please sign in to comment.