blob: 09fb608a35ec3a15e8f2e3f2c0e33673bc225697 [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
David Lebrun6c8702c2016-11-08 14:57:41 +01002/*
3 * SR-IPv6 implementation
4 *
5 * Author:
6 * David Lebrun <david.lebrun@uclouvain.be>
7 *
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#ifndef _UAPI_LINUX_SEG6_IPTUNNEL_H
16#define _UAPI_LINUX_SEG6_IPTUNNEL_H
17
Dmitry V. Levinea3ebc72017-02-23 14:30:34 +030018#include <linux/seg6.h> /* For struct ipv6_sr_hdr. */
19
David Lebrun6c8702c2016-11-08 14:57:41 +010020enum {
21 SEG6_IPTUNNEL_UNSPEC,
22 SEG6_IPTUNNEL_SRH,
23 __SEG6_IPTUNNEL_MAX,
24};
25#define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1)
26
27struct seg6_iptunnel_encap {
28 int mode;
29 struct ipv6_sr_hdr srh[0];
30};
31
32#define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 3))
33
34enum {
35 SEG6_IPTUN_MODE_INLINE,
36 SEG6_IPTUN_MODE_ENCAP,
David Lebrun38ee7f22017-08-25 09:56:45 +020037 SEG6_IPTUN_MODE_L2ENCAP,
David Lebrun6c8702c2016-11-08 14:57:41 +010038};
39
David Lebruna50a05f2017-01-15 15:26:16 +010040#ifdef __KERNEL__
41
David Lebrun6c8702c2016-11-08 14:57:41 +010042static inline size_t seg6_lwt_headroom(struct seg6_iptunnel_encap *tuninfo)
43{
David Lebrun38ee7f22017-08-25 09:56:45 +020044 int head = 0;
David Lebrun6c8702c2016-11-08 14:57:41 +010045
David Lebrun38ee7f22017-08-25 09:56:45 +020046 switch (tuninfo->mode) {
47 case SEG6_IPTUN_MODE_INLINE:
48 break;
49 case SEG6_IPTUN_MODE_ENCAP:
50 head = sizeof(struct ipv6hdr);
51 break;
52 case SEG6_IPTUN_MODE_L2ENCAP:
53 return 0;
54 }
55
56 return ((tuninfo->srh->hdrlen + 1) << 3) + head;
David Lebrun6c8702c2016-11-08 14:57:41 +010057}
58
59#endif
David Lebruna50a05f2017-01-15 15:26:16 +010060
61#endif