Skip to content

Commit a7a29f9

Browse files
alexaringdavem330
authored andcommitted
net: ipv6: add rpl sr tunnel
This patch adds functionality to configure routes for RPL source routing functionality. There is no IPIP functionality yet implemented which can be added later when the cases when to use IPv6 encapuslation comes more clear. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent faee676 commit a7a29f9

File tree

8 files changed

+434
-0
lines changed

8 files changed

+434
-0
lines changed

include/net/rpl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111

1212
#include <linux/rpl.h>
1313

14+
#if IS_ENABLED(CONFIG_IPV6_RPL_LWTUNNEL)
15+
extern int rpl_init(void);
16+
extern void rpl_exit(void);
17+
#else
18+
static inline int rpl_init(void)
19+
{
20+
return 0;
21+
}
22+
23+
static inline void rpl_exit(void) {}
24+
#endif
25+
1426
/* Worst decompression memory usage ipv6 address (16) + pad 7 */
1527
#define IPV6_RPL_SRH_WORST_SWAP_SIZE (sizeof(struct in6_addr) + 7)
1628

include/uapi/linux/lwtunnel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum lwtunnel_encap_types {
1313
LWTUNNEL_ENCAP_SEG6,
1414
LWTUNNEL_ENCAP_BPF,
1515
LWTUNNEL_ENCAP_SEG6_LOCAL,
16+
LWTUNNEL_ENCAP_RPL,
1617
__LWTUNNEL_ENCAP_MAX,
1718
};
1819

include/uapi/linux/rpl_iptunnel.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2+
/*
3+
* IPv6 RPL-SR implementation
4+
*
5+
* Author:
6+
* (C) 2020 Alexander Aring <[email protected]>
7+
*/
8+
9+
#ifndef _UAPI_LINUX_RPL_IPTUNNEL_H
10+
#define _UAPI_LINUX_RPL_IPTUNNEL_H
11+
12+
enum {
13+
RPL_IPTUNNEL_UNSPEC,
14+
RPL_IPTUNNEL_SRH,
15+
__RPL_IPTUNNEL_MAX,
16+
};
17+
#define RPL_IPTUNNEL_MAX (__RPL_IPTUNNEL_MAX - 1)
18+
19+
#define RPL_IPTUNNEL_SRH_SIZE(srh) (((srh)->hdrlen + 1) << 3)
20+
21+
#endif

net/core/lwtunnel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)
4141
return "BPF";
4242
case LWTUNNEL_ENCAP_SEG6_LOCAL:
4343
return "SEG6LOCAL";
44+
case LWTUNNEL_ENCAP_RPL:
45+
return "RPL";
4446
case LWTUNNEL_ENCAP_IP6:
4547
case LWTUNNEL_ENCAP_IP:
4648
case LWTUNNEL_ENCAP_NONE:

net/ipv6/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,14 @@ config IPV6_SEG6_BPF
303303
depends on IPV6_SEG6_LWTUNNEL
304304
depends on IPV6 = y
305305

306+
config IPV6_RPL_LWTUNNEL
307+
bool "IPv6: RPL Source Routing Header support"
308+
depends on IPV6
309+
select LWTUNNEL
310+
---help---
311+
Support for RFC6554 RPL Source Routing Header using the lightweight
312+
tunnels mechanism.
313+
314+
If unsure, say N.
315+
306316
endif # IPV6

net/ipv6/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
2626
ipv6-$(CONFIG_NETLABEL) += calipso.o
2727
ipv6-$(CONFIG_IPV6_SEG6_LWTUNNEL) += seg6_iptunnel.o seg6_local.o
2828
ipv6-$(CONFIG_IPV6_SEG6_HMAC) += seg6_hmac.o
29+
ipv6-$(CONFIG_IPV6_RPL_LWTUNNEL) += rpl_iptunnel.o
2930

3031
ipv6-objs += $(ipv6-y)
3132

net/ipv6/af_inet6.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#endif
6060
#include <net/calipso.h>
6161
#include <net/seg6.h>
62+
#include <net/rpl.h>
6263

6364
#include <linux/uaccess.h>
6465
#include <linux/mroute6.h>
@@ -1114,6 +1115,10 @@ static int __init inet6_init(void)
11141115
if (err)
11151116
goto seg6_fail;
11161117

1118+
err = rpl_init();
1119+
if (err)
1120+
goto rpl_fail;
1121+
11171122
err = igmp6_late_init();
11181123
if (err)
11191124
goto igmp6_late_err;
@@ -1136,6 +1141,8 @@ static int __init inet6_init(void)
11361141
igmp6_late_cleanup();
11371142
#endif
11381143
igmp6_late_err:
1144+
rpl_exit();
1145+
rpl_fail:
11391146
seg6_exit();
11401147
seg6_fail:
11411148
calipso_exit();

0 commit comments

Comments
 (0)