]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/net/seg6.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 399
[mirror_ubuntu-eoan-kernel.git] / include / net / seg6.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1ababeba
DL
2/*
3 * SR-IPv6 implementation
4 *
5 * Author:
6 * David Lebrun <david.lebrun@uclouvain.be>
1ababeba
DL
7 */
8
9#ifndef _NET_SEG6_H
10#define _NET_SEG6_H
11
915d7e5e
DL
12#include <linux/net.h>
13#include <linux/ipv6.h>
6c8702c6 14#include <linux/seg6.h>
0eb71a9d 15#include <linux/rhashtable-types.h>
915d7e5e 16
1ababeba
DL
17static inline void update_csum_diff4(struct sk_buff *skb, __be32 from,
18 __be32 to)
19{
20 __be32 diff[] = { ~from, to };
21
22 skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
23}
24
25static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from,
26 __be32 *to)
27{
28 __be32 diff[] = {
29 ~from[0], ~from[1], ~from[2], ~from[3],
30 to[0], to[1], to[2], to[3],
31 };
32
33 skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
34}
35
915d7e5e
DL
36struct seg6_pernet_data {
37 struct mutex lock;
38 struct in6_addr __rcu *tun_src;
bf355b8d
DL
39#ifdef CONFIG_IPV6_SEG6_HMAC
40 struct rhashtable hmac_infos;
41#endif
915d7e5e
DL
42};
43
44static inline struct seg6_pernet_data *seg6_pernet(struct net *net)
45{
63526e1c 46#if IS_ENABLED(CONFIG_IPV6)
915d7e5e 47 return net->ipv6.seg6_data;
63526e1c
MX
48#else
49 return NULL;
50#endif
915d7e5e
DL
51}
52
53extern int seg6_init(void);
54extern void seg6_exit(void);
6c8702c6
DL
55extern int seg6_iptunnel_init(void);
56extern void seg6_iptunnel_exit(void);
d1df6fd8
DL
57extern int seg6_local_init(void);
58extern void seg6_local_exit(void);
6c8702c6
DL
59
60extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len);
32d99d0b
DL
61extern int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh,
62 int proto);
b04c80d3 63extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh);
1c1e761e
MX
64extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
65 u32 tbl_id);
1ababeba 66#endif