Skip to content

Commit cfbe9b0

Browse files
committed
Merge branch 'ipv6-ioam-encap'
Justin Iurman says: ==================== Support for the ip6ip6 encapsulation of IOAM v2: - add prerequisite patches - keep uapi backwards compatible by adding two new attributes - add more comments to document the ioam6_iptunnel uapi In the current implementation, IOAM can only be inserted directly (i.e., only inside packets generated locally) by default, to be compliant with RFC8200. This patch adds support for in-transit packets and provides the ip6ip6 encapsulation of IOAM (RFC8200 compliant). Therefore, three ioam6 encap modes are defined: - inline: directly inserts IOAM inside packets (by default). - encap: ip6ip6 encapsulation of IOAM inside packets. - auto: either inline mode for packets generated locally or encap mode for in-transit packets. With current iproute2 implementation, it is configured this way: $ ip -6 r [...] encap ioam6 trace prealloc [...] The old syntax does not change (for backwards compatibility) and implicitly uses the inline mode. With the new syntax, an encap mode can be specified: (inline mode) $ ip -6 r [...] encap ioam6 mode inline trace prealloc [...] (encap mode) $ ip -6 r [...] encap ioam6 mode encap tundst fc00::2 trace prealloc [...] (auto mode) $ ip -6 r [...] encap ioam6 mode auto tundst fc00::2 trace prealloc [...] A tunnel destination address must be configured when using the encap mode or the auto mode. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9ac9362 + bf77b14 commit cfbe9b0

File tree

7 files changed

+422
-138
lines changed

7 files changed

+422
-138
lines changed

include/net/ioam6.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static inline struct ioam6_pernet_data *ioam6_pernet(struct net *net)
5656
struct ioam6_namespace *ioam6_namespace(struct net *net, __be16 id);
5757
void ioam6_fill_trace_data(struct sk_buff *skb,
5858
struct ioam6_namespace *ns,
59-
struct ioam6_trace_hdr *trace);
59+
struct ioam6_trace_hdr *trace,
60+
bool is_input);
6061

6162
int ioam6_init(void);
6263
void ioam6_exit(void);

include/uapi/linux/ioam6_iptunnel.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,38 @@
99
#ifndef _UAPI_LINUX_IOAM6_IPTUNNEL_H
1010
#define _UAPI_LINUX_IOAM6_IPTUNNEL_H
1111

12+
/* Encap modes:
13+
* - inline: direct insertion
14+
* - encap: ip6ip6 encapsulation
15+
* - auto: inline for local packets, encap for in-transit packets
16+
*/
17+
enum {
18+
__IOAM6_IPTUNNEL_MODE_MIN,
19+
20+
IOAM6_IPTUNNEL_MODE_INLINE,
21+
IOAM6_IPTUNNEL_MODE_ENCAP,
22+
IOAM6_IPTUNNEL_MODE_AUTO,
23+
24+
__IOAM6_IPTUNNEL_MODE_MAX,
25+
};
26+
27+
#define IOAM6_IPTUNNEL_MODE_MIN (__IOAM6_IPTUNNEL_MODE_MIN + 1)
28+
#define IOAM6_IPTUNNEL_MODE_MAX (__IOAM6_IPTUNNEL_MODE_MAX - 1)
29+
1230
enum {
1331
IOAM6_IPTUNNEL_UNSPEC,
32+
33+
/* Encap mode */
34+
IOAM6_IPTUNNEL_MODE, /* u8 */
35+
36+
/* Tunnel dst address.
37+
* For encap,auto modes.
38+
*/
39+
IOAM6_IPTUNNEL_DST, /* struct in6_addr */
40+
41+
/* IOAM Trace Header */
1442
IOAM6_IPTUNNEL_TRACE, /* struct ioam6_trace_hdr */
43+
1544
__IOAM6_IPTUNNEL_MAX,
1645
};
1746

net/ipv6/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ config IPV6_IOAM6_LWTUNNEL
332332
bool "IPv6: IOAM Pre-allocated Trace insertion support"
333333
depends on IPV6
334334
select LWTUNNEL
335+
select DST_CACHE
335336
help
336-
Support for the inline insertion of IOAM Pre-allocated
337-
Trace Header (only on locally generated packets), using
338-
the lightweight tunnels mechanism.
337+
Support for the insertion of IOAM Pre-allocated Trace
338+
Header using the lightweight tunnels mechanism.
339339

340340
If unsure, say N.
341341

net/ipv6/exthdrs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)
979979
if (!skb_valid_dst(skb))
980980
ip6_route_input(skb);
981981

982-
ioam6_fill_trace_data(skb, ns, trace);
982+
ioam6_fill_trace_data(skb, ns, trace, true);
983983
break;
984984
default:
985985
break;

net/ipv6/ioam6.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
631631
struct ioam6_namespace *ns,
632632
struct ioam6_trace_hdr *trace,
633633
struct ioam6_schema *sc,
634-
u8 sclen)
634+
u8 sclen, bool is_input)
635635
{
636636
struct __kernel_sock_timeval ts;
637637
u64 raw64;
@@ -645,7 +645,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
645645
/* hop_lim and node_id */
646646
if (trace->type.bit0) {
647647
byte = ipv6_hdr(skb)->hop_limit;
648-
if (skb->dev)
648+
if (is_input)
649649
byte--;
650650

651651
raw32 = dev_net(skb_dst(skb)->dev)->ipv6.sysctl.ioam6_id;
@@ -730,7 +730,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
730730
/* hop_lim and node_id (wide) */
731731
if (trace->type.bit8) {
732732
byte = ipv6_hdr(skb)->hop_limit;
733-
if (skb->dev)
733+
if (is_input)
734734
byte--;
735735

736736
raw64 = dev_net(skb_dst(skb)->dev)->ipv6.sysctl.ioam6_id_wide;
@@ -786,7 +786,8 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
786786
/* called with rcu_read_lock() */
787787
void ioam6_fill_trace_data(struct sk_buff *skb,
788788
struct ioam6_namespace *ns,
789-
struct ioam6_trace_hdr *trace)
789+
struct ioam6_trace_hdr *trace,
790+
bool is_input)
790791
{
791792
struct ioam6_schema *sc;
792793
u8 sclen = 0;
@@ -822,7 +823,7 @@ void ioam6_fill_trace_data(struct sk_buff *skb,
822823
return;
823824
}
824825

825-
__ioam6_fill_trace_data(skb, ns, trace, sc, sclen);
826+
__ioam6_fill_trace_data(skb, ns, trace, sc, sclen, is_input);
826827
trace->remlen -= trace->nodelen + sclen;
827828
}
828829

0 commit comments

Comments
 (0)