Skip to content

Commit d9d8efe

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] [v4: removed pointless include/net/vpls.h, squashed pseudowire control word support, squashed netlink lwtunnel access bits] Signed-off-by: David Lamparter <equinox@diac24.net>
1 parent b920cb1 commit d9d8efe

File tree

6 files changed

+595
-0
lines changed

6 files changed

+595
-0
lines changed

include/net/dst_metadata.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@
88
enum metadata_type {
99
METADATA_IP_TUNNEL,
1010
METADATA_HW_PORT_MUX,
11+
METADATA_VPLS,
1112
};
1213

1314
struct hw_port_info {
1415
struct net_device *lower_dev;
1516
u32 port_id;
1617
};
1718

19+
struct vpls_info {
20+
u32 pw_label;
21+
};
22+
1823
struct metadata_dst {
1924
struct dst_entry dst;
2025
enum metadata_type type;
2126
union {
2227
struct ip_tunnel_info tun_info;
2328
struct hw_port_info port_info;
29+
struct vpls_info vpls_info;
2430
} u;
2531
};
2632

@@ -54,6 +60,15 @@ static inline struct ip_tunnel_info *skb_tunnel_info(struct sk_buff *skb)
5460
return NULL;
5561
}
5662

63+
static inline struct vpls_info *skb_vpls_info(struct sk_buff *skb)
64+
{
65+
struct metadata_dst *md_dst = skb_metadata_dst(skb);
66+
if (md_dst && md_dst->type == METADATA_VPLS)
67+
return &md_dst->u.vpls_info;
68+
return NULL;
69+
}
70+
71+
5772
static inline bool skb_valid_dst(const struct sk_buff *skb)
5873
{
5974
struct dst_entry *dst = skb_dst(skb);
@@ -74,6 +89,9 @@ static inline int metadata_dst_cmp(const struct metadata_dst *a,
7489
case METADATA_HW_PORT_MUX:
7590
return memcmp(&a->u.port_info, &b->u.port_info,
7691
sizeof(a->u.port_info));
92+
case METADATA_VPLS:
93+
return memcmp(&a->u.vpls_info, &b->u.vpls_info,
94+
sizeof(a->u.vpls_info));
7795
case METADATA_IP_TUNNEL:
7896
return memcmp(&a->u.tun_info, &b->u.tun_info,
7997
sizeof(a->u.tun_info) +
@@ -220,4 +238,10 @@ static inline struct metadata_dst *ipv6_tun_rx_dst(struct sk_buff *skb,
220238
0, ip6_flowlabel(ip6h), flags, tunnel_id,
221239
md_size);
222240
}
241+
242+
static inline struct metadata_dst *vpls_rx_dst(void)
243+
{
244+
return metadata_dst_alloc(0, METADATA_VPLS, GFP_ATOMIC);
245+
}
246+
223247
#endif /* __NET_DST_METADATA_H */

include/uapi/linux/lwtunnel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum lwtunnel_encap_types {
1212
LWTUNNEL_ENCAP_SEG6,
1313
LWTUNNEL_ENCAP_BPF,
1414
LWTUNNEL_ENCAP_SEG6_LOCAL,
15+
LWTUNNEL_ENCAP_PSEUDOWIRE,
1516
__LWTUNNEL_ENCAP_MAX,
1617
};
1718

@@ -67,4 +68,11 @@ enum {
6768

6869
#define LWT_BPF_MAX_HEADROOM 256
6970

71+
enum {
72+
LWT_PSEUDOWIRE_LOCAL_LABEL,
73+
__LWT_PSEUDOWIRE_MAX,
74+
};
75+
76+
#define LWT_PSEUDOWIRE_MAX (__LWT_PSEUDOWIRE_MAX - 1)
77+
7078
#endif /* _UAPI_LWTUNNEL_H_ */

net/core/lwtunnel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)
4949
case LWTUNNEL_ENCAP_IP6:
5050
case LWTUNNEL_ENCAP_IP:
5151
case LWTUNNEL_ENCAP_NONE:
52+
case LWTUNNEL_ENCAP_PSEUDOWIRE:
5253
case __LWTUNNEL_ENCAP_MAX:
5354
/* should not have got here */
5455
WARN_ON(1);

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)