Skip to contentSkip to conversation

Introduce MPLS over GRE

PATCH Superseded Amine Kherbouche 3 participants 7 messages Sep 26, 2017 – Sep 27, 2017

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce MPLS over GRE

This series introduces the MPLS over GRE encapsulation (RFC 4023).

Various applications of MPLS make use of label stacks with multiple entries. In some cases, it is possible to replace the top label of the stack with an IP-based encapsulation, thereby, it is possible for two LSRs that are adjacent on an LSP to be separated by an IP network, even if that IP network does not provide MPLS.

Changes in v2:
- wrap ip tunnel functions under ifdef in mpls file.
- fix indentation.
- check return code.

An example of configuration:

         node1                LER1                       LER2                node2
        +-----+             +------+                   +------+             +-----+
        |     |             |      |                   |      |             |     |
        |     |             |      |p3  GRE tunnel   p4|      |             |     |
        |     |p1         p2|      +-------------------+      |p5         p6|     |
        |     +-------------+      +-------------------+      +------------+|     |
        |     |10.100.0.0/24|      |                   |      |10.200.0.0/24|     |
        |     |fd00:100::/64|      |  10.125.0.0/24    |      |fd00:200::/64|     |
        |     |             |      |  fd00:125::/64    |      |             |     |
        |     |             |      |                   |      |             |     |
        |     |             |      |                   |      |             |     |
        |     |             |      |                   |      |             |     |
        |     |             |      |                   |      |             |     |
        +-----+             +------+                   +------+             +-----+


		###	node1	###

ip link set p1 up
ip addr add 10.100.0.1/24 dev p1

		###	LER1	###

ip link set p2 up
ip addr add 10.100.0.2/24 dev p2

ip link set p3 up
ip addr add 10.125.0.1/24 dev p3

modprobe mpls_router
sysctl -w net.mpls.conf.p2.input=1
sysctl -w net.mpls.conf.p3.input=1
sysctl -w net.mpls.platform_labels=1000

ip link add gre1 type gre ttl 64 local 10.125.0.1 remote 10.125.0.2 dev p3 ip link set dev gre1 up

ip -M route add 111 as 222 dev gre1
ip -M route add 555 as 666 via inet 10.100.0.1 dev p2

		###	LER2	###

ip link set p5 up
ip addr add 10.200.0.2/24 dev p5

ip link set p4 up
ip addr add 10.125.0.2/24 dev p4

modprobe mpls_router
sysctl -w net.mpls.conf.p4.input=1
sysctl -w net.mpls.conf.p5.input=1
sysctl -w net.mpls.platform_labels=1000

ip link add gre1 type gre ttl 64 local 10.125.0.2 remote 10.125.0.1 dev p4 ip link set dev gre1 up

ip -M route add 444 as 555 dev gre1
ip -M route add 222 as 333 via inet 10.200.0.1 dev p5

		###	node2	###

ip link set p6 up
ip addr add 10.200.0.1/24 dev p6

Now using this scapy to forge and send packets from the port p1 of node1:

p = Ether(src='de:ed:01:0c:41:09', dst='de:ed:01:2f:3b:ba') p /= MPLS(s=1, ttl=64, label=111)/Raw(load='\xde') sendp(p, iface="p1", count=20, inter=0.1)

Amine Kherbouche (2):
mpls: expose stack entry function
ip_tunnel: add mpls over gre encapsulation

 include/linux/mpls.h           |  3 +++
 include/net/gre.h              |  3 +++
 include/uapi/linux/if_tunnel.h |  1 +
 net/ipv4/gre_demux.c           | 22 +++++++++++++++++++++
 net/ipv4/ip_gre.c              |  9 +++++++++
 net/ipv6/ip6_gre.c             |  7 +++++++
 net/mpls/af_mpls.c             | 45 ++++++++++++++++++++++++++++++++++++++++--
 7 files changed, 88 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/2 mpls: expose stack entry function

Exporting mpls_forward() function to be able to be called from elsewhere such as MPLS over GRE in the next commit.

---
 include/linux/mpls.h | 3 +++
 net/mpls/af_mpls.c   | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/mpls.h +3 -0
index 384fb22..d5c7599 100644
@@ -2,10 +2,13 @@
 #define _LINUX_MPLS_H
 
 #include <uapi/linux/mpls.h>
+#include <linux/netdevice.h>
 
 #define MPLS_TTL_MASK		(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)
 #define MPLS_BOS_MASK		(MPLS_LS_S_MASK >> MPLS_LS_S_SHIFT)
 #define MPLS_TC_MASK		(MPLS_LS_TC_MASK >> MPLS_LS_TC_SHIFT)
 #define MPLS_LABEL_MASK		(MPLS_LS_LABEL_MASK >> MPLS_LS_LABEL_SHIFT)
 
+int mpls_forward(struct sk_buff *skb, struct net_device *dev,
+		 struct packet_type *pt, struct net_device *orig_dev);
 #endif  /* _LINUX_MPLS_H */
net/mpls/af_mpls.c +3 -2
index c5b9ce4..36ea2ad 100644
@@ -307,8 +307,8 @@ static bool mpls_egress(struct net *net, struct mpls_route *rt,
 	return success;
 }
 
-static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
-			struct packet_type *pt, struct net_device *orig_dev)
+int mpls_forward(struct sk_buff *skb, struct net_device *dev,
+		 struct packet_type *pt, struct net_device *orig_dev)
 {
 	struct net *net = dev_net(dev);
 	struct mpls_shim_hdr *hdr;
@@ -442,6 +442,7 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
 	kfree_skb(skb);
 	return NET_RX_DROP;
 }
+EXPORT_SYMBOL(mpls_forward);
 
 static struct packet_type mpls_packet_type __read_mostly = {
 	.type = cpu_to_be16(ETH_P_MPLS_UC),
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 2/2 ip_tunnel: add mpls over gre encapsulation

In reply to Amine Kherbouche

This commit introduces the MPLSoGRE support (RFC 4023), using ip tunnel API.

Encap:
- Add a new iptunnel type mpls.
- Share tx path: gre type mpls loaded from skb->protocol.

Decap:
- pull gre hdr and call mpls_forward().

---
 include/net/gre.h              |  3 +++
 include/uapi/linux/if_tunnel.h |  1 +
 net/ipv4/gre_demux.c           | 22 ++++++++++++++++++++++
 net/ipv4/ip_gre.c              |  9 +++++++++
 net/ipv6/ip6_gre.c             |  7 +++++++
 net/mpls/af_mpls.c             | 40 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 82 insertions(+)
include/net/gre.h +3 -0
index d25d836..88a8343 100644
@@ -35,6 +35,9 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
 				       u8 name_assign_type);
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		     bool *csum_err, __be16 proto, int nhs);
+#if IS_ENABLED(CONFIG_MPLS)
+int mpls_gre_rcv(struct sk_buff *skb, int gre_hdr_len);
+#endif
 
 static inline int gre_calc_hlen(__be16 o_flags)
 {
include/uapi/linux/if_tunnel.h +1 -0
index 2e52088..a2f48c0 100644
@@ -84,6 +84,7 @@ enum tunnel_encap_types {
 	TUNNEL_ENCAP_NONE,
 	TUNNEL_ENCAP_FOU,
 	TUNNEL_ENCAP_GUE,
+	TUNNEL_ENCAP_MPLS,
 };
 
 #define TUNNEL_ENCAP_FLAG_CSUM		(1<<0)
net/ipv4/gre_demux.c +22 -0
index b798862..a6a937e 100644
@@ -23,6 +23,9 @@
 #include <linux/netdevice.h>
 #include <linux/if_tunnel.h>
 #include <linux/spinlock.h>
+#if IS_ENABLED(CONFIG_MPLS)
+#include <linux/mpls.h>
+#endif
 #include <net/protocol.h>
 #include <net/gre.h>
 
@@ -122,6 +125,25 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 }
 EXPORT_SYMBOL(gre_parse_header);
 
+#if IS_ENABLED(CONFIG_MPLS)
+int mpls_gre_rcv(struct sk_buff *skb, int gre_hdr_len)
+{
+	if (unlikely(!pskb_may_pull(skb, gre_hdr_len)))
+		goto drop;
+
+	/* Pop GRE hdr and reset the skb */
+	skb_pull(skb, gre_hdr_len);
+	skb_reset_network_header(skb);
+
+	mpls_forward(skb, skb->dev, NULL, NULL);
+
+	return 0;
+drop:
+	return NET_RX_DROP;
+}
+EXPORT_SYMBOL(mpls_gre_rcv);
+#endif
+
 static int gre_rcv(struct sk_buff *skb)
 {
 	const struct gre_protocol *proto;
net/ipv4/ip_gre.c +9 -0
index 9cee986..dd4431c 100644
@@ -412,10 +412,19 @@ static int gre_rcv(struct sk_buff *skb)
 			return 0;
 	}
 
+#if IS_ENABLED(CONFIG_MPLS)
+	if (unlikely(tpi.proto == htons(ETH_P_MPLS_UC))) {
+		if (mpls_gre_rcv(skb, hdr_len))
+			goto drop;
+		return 0;
+	}
+#endif
+
 	if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
 		return 0;
 
 	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
+
 drop:
 	kfree_skb(skb);
 	return 0;
net/ipv6/ip6_gre.c +7 -0
index c82d41e..e52396d 100644
@@ -476,6 +476,13 @@ static int gre_rcv(struct sk_buff *skb)
 	if (hdr_len < 0)
 		goto drop;
 
+#if IS_ENABLED(CONFIG_MPLS)
+	if (unlikely(tpi.proto == htons(ETH_P_MPLS_UC))) {
+		if (mpls_gre_rcv(skb, hdr_len))
+			goto drop;
+		return 0;
+	}
+#endif
 	if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
 		goto drop;
 
net/mpls/af_mpls.c +40 -0
index 36ea2ad..5505074 100644
@@ -16,6 +16,7 @@
 #include <net/arp.h>
 #include <net/ip_fib.h>
 #include <net/netevent.h>
+#include <net/ip_tunnels.h>
 #include <net/netns/generic.h>
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6.h>
@@ -39,6 +40,40 @@ static int one = 1;
 static int label_limit = (1 << 20) - 1;
 static int ttl_max = 255;
 
+size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)
+{
+	return sizeof(struct mpls_shim_hdr);
+}
+
+int ipgre_mpls_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+			    u8 *protocol, struct flowi4 *fl4)
+{
+	return 0;
+}
+
+static const struct ip_tunnel_encap_ops mpls_iptun_ops = {
+	.encap_hlen	= ipgre_mpls_encap_hlen,
+	.build_header	= ipgre_mpls_build_header,
+};
+
+static int ipgre_tunnel_encap_add_mpls_ops(void)
+{
+	int ret = -1;
+
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+	ret = ip_tunnel_encap_add_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+
+	return ret;
+}
+
+static void ipgre_tunnel_encap_del_mpls_ops(void)
+{
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+	ip_tunnel_encap_del_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+}
+
 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
 		       struct nlmsghdr *nlh, struct net *net, u32 portid,
 		       unsigned int nlm_flags);
@@ -2486,6 +2521,10 @@ static int __init mpls_init(void)
 		      0);
 	rtnl_register(PF_MPLS, RTM_GETNETCONF, mpls_netconf_get_devconf,
 		      mpls_netconf_dump_devconf, 0);
+	err = ipgre_tunnel_encap_add_mpls_ops();
+	if (err)
+		pr_err("Can't add mpls over gre tunnel ops\n");
+
 	err = 0;
 out:
 	return err;
@@ -2503,6 +2542,7 @@ static void __exit mpls_exit(void)
 	dev_remove_pack(&mpls_packet_type);
 	unregister_netdevice_notifier(&mpls_dev_notifier);
 	unregister_pernet_subsys(&mpls_net_ops);
+	ipgre_tunnel_encap_del_mpls_ops();
 }
 module_exit(mpls_exit);
 
Signature · 1 line
2.1.4
#3 lore raw

Re: [PATCH v2 2/2] ip_tunnel: add mpls over gre encapsulation

Quoted 65 lines · Amine Kherbouche

This commit introduces the MPLSoGRE support (RFC 4023), using ip tunnel API.

Encap:
- Add a new iptunnel type mpls.
- Share tx path: gre type mpls loaded from skb->protocol.

Decap:
- pull gre hdr and call mpls_forward().

---
 include/net/gre.h              |  3 +++
 include/uapi/linux/if_tunnel.h |  1 +
 net/ipv4/gre_demux.c           | 22 ++++++++++++++++++++++
 net/ipv4/ip_gre.c              |  9 +++++++++
 net/ipv6/ip6_gre.c             |  7 +++++++
 net/mpls/af_mpls.c             | 40 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 82 insertions(+)
include/net/gre.h +3 -0
index d25d836..88a8343 100644
@@ -35,6 +35,9 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
                                       u8 name_assign_type);
 int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                     bool *csum_err, __be16 proto, int nhs);
+#if IS_ENABLED(CONFIG_MPLS)
+int mpls_gre_rcv(struct sk_buff *skb, int gre_hdr_len);
+#endif
 
 static inline int gre_calc_hlen(__be16 o_flags)
 {
include/uapi/linux/if_tunnel.h +1 -0
index 2e52088..a2f48c0 100644
@@ -84,6 +84,7 @@ enum tunnel_encap_types {
        TUNNEL_ENCAP_NONE,
        TUNNEL_ENCAP_FOU,
        TUNNEL_ENCAP_GUE,
+       TUNNEL_ENCAP_MPLS,
 };
 
 #define TUNNEL_ENCAP_FLAG_CSUM         (1<<0)
net/ipv4/gre_demux.c +4 -0
index b798862..a6a937e 100644
@@ -23,6 +23,9 @@
 #include <linux/netdevice.h>
 #include <linux/if_tunnel.h>
 #include <linux/spinlock.h>
+#if IS_ENABLED(CONFIG_MPLS)
+#include <linux/mpls.h>
+#endif
 #include <net/protocol.h>
 #include <net/gre.h>
 
@@ -122,6 +125,25 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 }
 EXPORT_SYMBOL(gre_parse_header);
 
+#if IS_ENABLED(CONFIG_MPLS)

net/ipv4/gre_demux.c int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, · line 138

Quoted 10 lines
net/ipv4/gre_demux.c +10 -0
+int mpls_gre_rcv(struct sk_buff *skb, int gre_hdr_len)
+{
+       if (unlikely(!pskb_may_pull(skb, gre_hdr_len)))
+               goto drop;
+
+       /* Pop GRE hdr and reset the skb */
+       skb_pull(skb, gre_hdr_len);
+       skb_reset_network_header(skb);
+
+       mpls_forward(skb, skb->dev, NULL, NULL);

pls check return value

can mpls_gre_rcv be moved to af_mpls.c ?

Quoted 22 lines
net/ipv4/gre_demux.c +8 -0
+
+       return 0;
+drop:
+       return NET_RX_DROP;
+}
+EXPORT_SYMBOL(mpls_gre_rcv);
+#endif
+
 static int gre_rcv(struct sk_buff *skb)
 {
        const struct gre_protocol *proto;
net/ipv4/ip_gre.c +3 -0
index 9cee986..dd4431c 100644
@@ -412,10 +412,19 @@ static int gre_rcv(struct sk_buff *skb)
                        return 0;
        }
 
+#if IS_ENABLED(CONFIG_MPLS)
+       if (unlikely(tpi.proto == htons(ETH_P_MPLS_UC))) {
+               if (mpls_gre_rcv(skb, hdr_len))

net/ipv4/ip_gre.c static int gre_rcv(struct sk_buff *skb) · line 427

Quoted 10 lines
net/ipv4/ip_gre.c +6 -0
+                       goto drop;
+               return 0;
+       }
+#endif
+
        if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
                return 0;
 
        icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
+

unnecessary new line..

Quoted 8 lines
net/ipv4/ip_gre.c +0 -0
 drop:
        kfree_skb(skb);
        return 0;
net/ipv6/ip6_gre.c +0 -0
index c82d41e..e52396d 100644

net/ipv6/ip6_gre.c static int gre_rcv(struct sk_buff *skb) · line 484

Quoted 9 lines
net/ipv6/ip6_gre.c +6 -0
@@ -476,6 +476,13 @@ static int gre_rcv(struct sk_buff *skb)
        if (hdr_len < 0)
                goto drop;
 
+#if IS_ENABLED(CONFIG_MPLS)
+       if (unlikely(tpi.proto == htons(ETH_P_MPLS_UC))) {
+               if (mpls_gre_rcv(skb, hdr_len))
+                       goto drop;
+               return 0;
+       }

+newline

also would be nice if the IS_ENABLED could be moved to around mpls_gre_rcv.

Quoted 24 lines
net/ipv6/ip6_gre.c +1 -0
+#endif
        if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
                goto drop;
 
net/mpls/af_mpls.c +5 -0
index 36ea2ad..5505074 100644
@@ -16,6 +16,7 @@
 #include <net/arp.h>
 #include <net/ip_fib.h>
 #include <net/netevent.h>
+#include <net/ip_tunnels.h>
 #include <net/netns/generic.h>
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6.h>
@@ -39,6 +40,40 @@ static int one = 1;
 static int label_limit = (1 << 20) - 1;
 static int ttl_max = 255;
 
+size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)
+{
+       return sizeof(struct mpls_shim_hdr);
+}

net/mpls/af_mpls.c static int one = 1; · line 56

Quoted 10 lines
net/mpls/af_mpls.c +10 -0
+
+int ipgre_mpls_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+                           u8 *protocol, struct flowi4 *fl4)
+{
+       return 0;
+}
+
+static const struct ip_tunnel_encap_ops mpls_iptun_ops = {
+       .encap_hlen     = ipgre_mpls_encap_hlen,
+       .build_header   = ipgre_mpls_build_header,

There are checks for build header before calling it in iptunnel code, so, any reason
you can't skip declaring .build_header ?

Quoted 24 lines
net/mpls/af_mpls.c +20 -0
+};
+
+static int ipgre_tunnel_encap_add_mpls_ops(void)
+{
+       int ret = -1;
+
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ret = ip_tunnel_encap_add_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+
+       return ret;
+}
+
+static void ipgre_tunnel_encap_del_mpls_ops(void)
+{
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ip_tunnel_encap_del_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+}
+
 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
                       struct nlmsghdr *nlh, struct net *net, u32 portid,
                       unsigned int nlm_flags);

net/mpls/af_mpls.c static int __init mpls_init(void) · line 2527

Quoted 7 lines
net/mpls/af_mpls.c +4 -0
@@ -2486,6 +2521,10 @@ static int __init mpls_init(void)
                      0);
        rtnl_register(PF_MPLS, RTM_GETNETCONF, mpls_netconf_get_devconf,
                      mpls_netconf_dump_devconf, 0);
+       err = ipgre_tunnel_encap_add_mpls_ops();
+       if (err)
+               pr_err("Can't add mpls over gre tunnel ops\n");
+

This will throw an error if CONFIG_NET_IP_TUNNEL is not enabled. Can you pls put the CONFIG_NET_IP_TUNNEL around ipgre_tunnel_encap_add_mpls_ops ?
see CONFIG_INET checks in the rest of af_mpls as example. same for del_ops

Quoted 14 lines
net/mpls/af_mpls.c +1 -1
        err = 0;
 out:
        return err;
@@ -2503,6 +2542,7 @@ static void __exit mpls_exit(void)
        dev_remove_pack(&mpls_packet_type);
        unregister_netdevice_notifier(&mpls_dev_notifier);
        unregister_pernet_subsys(&mpls_net_ops);
+       ipgre_tunnel_encap_del_mpls_ops();
 }
 module_exit(mpls_exit);
 
--

2.1.4

#4 lore raw

Re: [PATCH v2 2/2] ip_tunnel: add mpls over gre encapsulation

Hi Roopa,

Thanks for the feedback, I have just one question:

Quoted 24 lines · Roopa Prabhu
Quoted 24 lines

+static int ipgre_tunnel_encap_add_mpls_ops(void)

Quoted 23 lines
net/mpls/af_mpls.c +17 -0
+{
+       int ret = -1;
+
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ret = ip_tunnel_encap_add_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+
+       return ret;
+}
+
+static void ipgre_tunnel_encap_del_mpls_ops(void)
+{
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ip_tunnel_encap_del_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+}
+
 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
                       struct nlmsghdr *nlh, struct net *net, u32 portid,
                       unsigned int nlm_flags);
@@ -2486,6 +2521,10 @@ static int __init mpls_init(void)
                      0);
        rtnl_register(PF_MPLS, RTM_GETNETCONF, mpls_netconf_get_devconf,
Quoted 8 lines
Quoted 5 lines

net/mpls/af_mpls.c static int __init mpls_init(void) · line 2527

Quoted 5 lines
net/mpls/af_mpls.c +4 -0
                      mpls_netconf_dump_devconf, 0);
+       err = ipgre_tunnel_encap_add_mpls_ops();
+       if (err)
+               pr_err("Can't add mpls over gre tunnel ops\n");
+

This will throw an error if CONFIG_NET_IP_TUNNEL is not enabled. Can you pls put the CONFIG_NET_IP_TUNNEL around ipgre_tunnel_encap_add_mpls_ops ?

You want the CONFIG_NET_IP_TUNNEL definition around the declaration of the function or when it's called ? or both ? (I can adjust the code for any case).

Quoted 3 lines

see CONFIG_INET checks in the rest of af_mpls as example. same for del_ops

Thanks,

Amine

#5 lore raw

Re: [PATCH v2 2/2] ip_tunnel: add mpls over gre encapsulation

Quoted 45 lines · Amine Kherbouche

Hi Roopa,

Thanks for the feedback, I have just one question:

Quoted 29 lines · Roopa Prabhu
Quoted 29 lines

+static int ipgre_tunnel_encap_add_mpls_ops(void)

Quoted 27 lines
net/mpls/af_mpls.c +5 -0
+{
+       int ret = -1;
+
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ret = ip_tunnel_encap_add_ops(&mpls_iptun_ops,

TUNNEL_ENCAP_MPLS);

net/mpls/af_mpls.c +12 -0
+#endif
+
+       return ret;
+}
+
+static void ipgre_tunnel_encap_del_mpls_ops(void)
+{
+#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
+       ip_tunnel_encap_del_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
+#endif
+}
+
 static void rtmsg_lfib(int event, u32 label, struct mpls_route *rt,
                       struct nlmsghdr *nlh, struct net *net, u32

portid,

                       unsigned int nlm_flags);
net/mpls/af_mpls.c +0 -0
@@ -2486,6 +2521,10 @@ static int __init mpls_init(void)
                      0);
        rtnl_register(PF_MPLS, RTM_GETNETCONF,
 mpls_netconf_get_devconf,
                      mpls_netconf_dump_devconf, 0);
Quoted 8 lines
Quoted 4 lines

net/mpls/af_mpls.c static int __init mpls_init(void) · line 2527

Quoted 4 lines
net/mpls/af_mpls.c +4 -0
+       err = ipgre_tunnel_encap_add_mpls_ops();
+       if (err)
+               pr_err("Can't add mpls over gre tunnel ops\n");
+

This will throw an error if CONFIG_NET_IP_TUNNEL is not enabled. Can you pls put the CONFIG_NET_IP_TUNNEL around ipgre_tunnel_encap_add_mpls_ops ?

Quoted 3 lines

You want the CONFIG_NET_IP_TUNNEL definition around the declaration of the function or when it's called ? or both ? (I can adjust the code for any case).

around the declaration like below....,

#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
static int ipgre_tunnel_encap_add_mpls_ops(void)

{
      return ip_tunnel_encap_add_ops(&mpls_iptun_ops,
                                                            TUNNEL_ENCAP_MPLS);
}

static void ipgre_tunnel_encap_del_mpls_ops(void)

{
      ip_tunnel_encap_del_ops(&mpls_iptun_ops, TUNNEL_ENCAP_MPLS);
}

#else
static int ipgre_tunnel_encap_add_mpls_ops(void)
{
return 0
}

static void ipgre_tunnel_encap_del_mpls_ops(void)
{
}
#endif

thanks.

#6 lore raw

Re: [PATCH v2 2/2] ip_tunnel: add mpls over gre encapsulation

In reply to Amine Kherbouche
url: https://github.com/0day-ci/linux/commits/Amine-Kherbouche/mpls-expose-stack-entry-function/20170928-012842 config: x86_64-rhel (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0…

Hi Amine,

[auto build test ERROR on net/master]
[also build test ERROR on v4.14-rc2 next-20170927]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Amine-Kherbouche/mpls-expose-stack-entry-function/20170928-012842
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "mpls_forward" [net/ipv4/gre.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation