Skip to content

Commit

Permalink
net: ipv6: add rpl sr tunnel
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alexaring authored and davem330 committed Mar 30, 2020
1 parent faee676 commit a7a29f9
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/net/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

#include <linux/rpl.h>

#if IS_ENABLED(CONFIG_IPV6_RPL_LWTUNNEL)
extern int rpl_init(void);
extern void rpl_exit(void);
#else
static inline int rpl_init(void)
{
return 0;
}

static inline void rpl_exit(void) {}
#endif

/* Worst decompression memory usage ipv6 address (16) + pad 7 */
#define IPV6_RPL_SRH_WORST_SWAP_SIZE (sizeof(struct in6_addr) + 7)

Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/lwtunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum lwtunnel_encap_types {
LWTUNNEL_ENCAP_SEG6,
LWTUNNEL_ENCAP_BPF,
LWTUNNEL_ENCAP_SEG6_LOCAL,
LWTUNNEL_ENCAP_RPL,
__LWTUNNEL_ENCAP_MAX,
};

Expand Down
21 changes: 21 additions & 0 deletions include/uapi/linux/rpl_iptunnel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* IPv6 RPL-SR implementation
*
* Author:
* (C) 2020 Alexander Aring <[email protected]>
*/

#ifndef _UAPI_LINUX_RPL_IPTUNNEL_H
#define _UAPI_LINUX_RPL_IPTUNNEL_H

enum {
RPL_IPTUNNEL_UNSPEC,
RPL_IPTUNNEL_SRH,
__RPL_IPTUNNEL_MAX,
};
#define RPL_IPTUNNEL_MAX (__RPL_IPTUNNEL_MAX - 1)

#define RPL_IPTUNNEL_SRH_SIZE(srh) (((srh)->hdrlen + 1) << 3)

#endif
2 changes: 2 additions & 0 deletions net/core/lwtunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)
return "BPF";
case LWTUNNEL_ENCAP_SEG6_LOCAL:
return "SEG6LOCAL";
case LWTUNNEL_ENCAP_RPL:
return "RPL";
case LWTUNNEL_ENCAP_IP6:
case LWTUNNEL_ENCAP_IP:
case LWTUNNEL_ENCAP_NONE:
Expand Down
10 changes: 10 additions & 0 deletions net/ipv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,14 @@ config IPV6_SEG6_BPF
depends on IPV6_SEG6_LWTUNNEL
depends on IPV6 = y

config IPV6_RPL_LWTUNNEL
bool "IPv6: RPL Source Routing Header support"
depends on IPV6
select LWTUNNEL
---help---
Support for RFC6554 RPL Source Routing Header using the lightweight
tunnels mechanism.

If unsure, say N.

endif # IPV6
1 change: 1 addition & 0 deletions net/ipv6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
ipv6-$(CONFIG_NETLABEL) += calipso.o
ipv6-$(CONFIG_IPV6_SEG6_LWTUNNEL) += seg6_iptunnel.o seg6_local.o
ipv6-$(CONFIG_IPV6_SEG6_HMAC) += seg6_hmac.o
ipv6-$(CONFIG_IPV6_RPL_LWTUNNEL) += rpl_iptunnel.o

ipv6-objs += $(ipv6-y)

Expand Down
7 changes: 7 additions & 0 deletions net/ipv6/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#endif
#include <net/calipso.h>
#include <net/seg6.h>
#include <net/rpl.h>

#include <linux/uaccess.h>
#include <linux/mroute6.h>
Expand Down Expand Up @@ -1114,6 +1115,10 @@ static int __init inet6_init(void)
if (err)
goto seg6_fail;

err = rpl_init();
if (err)
goto rpl_fail;

err = igmp6_late_init();
if (err)
goto igmp6_late_err;
Expand All @@ -1136,6 +1141,8 @@ static int __init inet6_init(void)
igmp6_late_cleanup();
#endif
igmp6_late_err:
rpl_exit();
rpl_fail:
seg6_exit();
seg6_fail:
calipso_exit();
Expand Down
Loading

0 comments on commit a7a29f9

Please sign in to comment.