Skip to content

Commit 0b2b0fe

Browse files
committed
mpls: VPLS support
[work-in-progress, works but needs changes] [v2: refactored lots of things, e.g. dst_metadata, no more genetlink] Signed-off-by: David Lamparter <equinox@diac24.net>
1 parent 72a2adf commit 0b2b0fe

5 files changed

Lines changed: 510 additions & 0 deletions

File tree

include/net/dst_metadata.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
#include <linux/skbuff.h>
55
#include <net/ip_tunnels.h>
6+
#include <net/vpls.h>
67
#include <net/dst.h>
78

89
enum metadata_type {
910
METADATA_IP_TUNNEL,
1011
METADATA_HW_PORT_MUX,
12+
METADATA_VPLS,
1113
};
1214

1315
struct hw_port_info {
@@ -21,6 +23,7 @@ struct metadata_dst {
2123
union {
2224
struct ip_tunnel_info tun_info;
2325
struct hw_port_info port_info;
26+
struct vpls_info vpls_info;
2427
} u;
2528
};
2629

@@ -54,6 +57,15 @@ static inline struct ip_tunnel_info *skb_tunnel_info(struct sk_buff *skb)
5457
return NULL;
5558
}
5659

60+
static inline struct vpls_info *skb_vpls_info(struct sk_buff *skb)
61+
{
62+
struct metadata_dst *md_dst = skb_metadata_dst(skb);
63+
if (md_dst && md_dst->type == METADATA_VPLS)
64+
return &md_dst->u.vpls_info;
65+
return NULL;
66+
}
67+
68+
5769
static inline bool skb_valid_dst(const struct sk_buff *skb)
5870
{
5971
struct dst_entry *dst = skb_dst(skb);
@@ -74,6 +86,9 @@ static inline int metadata_dst_cmp(const struct metadata_dst *a,
7486
case METADATA_HW_PORT_MUX:
7587
return memcmp(&a->u.port_info, &b->u.port_info,
7688
sizeof(a->u.port_info));
89+
case METADATA_VPLS:
90+
return memcmp(&a->u.vpls_info, &b->u.vpls_info,
91+
sizeof(a->u.vpls_info));
7792
case METADATA_IP_TUNNEL:
7893
return memcmp(&a->u.tun_info, &b->u.tun_info,
7994
sizeof(a->u.tun_info) +
@@ -220,4 +235,10 @@ static inline struct metadata_dst *ipv6_tun_rx_dst(struct sk_buff *skb,
220235
0, ip6_flowlabel(ip6h), flags, tunnel_id,
221236
md_size);
222237
}
238+
239+
static inline struct metadata_dst *vpls_rx_dst(void)
240+
{
241+
return metadata_dst_alloc(0, METADATA_VPLS, GFP_ATOMIC);
242+
}
243+
223244
#endif /* __NET_DST_METADATA_H */

include/net/vpls.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __NET_VPLS_H
2+
#define __NET_VPLS_H 1
3+
4+
struct vpls_info {
5+
u32 pw_label;
6+
};
7+
8+
#endif /* __NET_VPLS_H */

net/mpls/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ config MPLS_ROUTING
2727
---help---
2828
Add support for forwarding of mpls packets.
2929

30+
config MPLS_VPLS
31+
bool "VPLS support"
32+
default y
33+
depends on MPLS_ROUTING && BRIDGE_NETFILTER=n
34+
---help---
35+
Add support for de-&encapsulating VPLS. Not compatible with
36+
bridge netfilter due to the latter stomping over VPLS' dst metadata.
37+
38+
comment "disable 'Bridged IP/ARP packets filtering' for VPLS support"
39+
depends on BRIDGE_NETFILTER
40+
3041
config MPLS_IPTUNNEL
3142
tristate "MPLS: IP over MPLS tunnel support"
3243
depends on LWTUNNEL && MPLS_ROUTING

net/mpls/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ obj-$(CONFIG_MPLS_ROUTING) += mpls_router.o
66
obj-$(CONFIG_MPLS_IPTUNNEL) += mpls_iptunnel.o
77

88
mpls_router-y := af_mpls.o
9+
mpls_router-$(CONFIG_MPLS_VPLS) += vpls.o

0 commit comments

Comments
 (0)