blob: 4e0357517d796692540a66485c5608793ffea966 [file] [log] [blame]
David Lebrun1ababeb2016-11-08 14:57:39 +01001/*
2 * SR-IPv6 implementation
3 *
4 * Author:
5 * David Lebrun <david.lebrun@uclouvain.be>
6 *
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef _NET_SEG6_H
15#define _NET_SEG6_H
16
David Lebrun915d7e52016-11-08 14:57:40 +010017#include <linux/net.h>
18#include <linux/ipv6.h>
David Lebrun6c8702c2016-11-08 14:57:41 +010019#include <net/lwtunnel.h>
20#include <linux/seg6.h>
David Lebrunbf355b82016-11-08 14:57:42 +010021#include <linux/rhashtable.h>
David Lebrun915d7e52016-11-08 14:57:40 +010022
David Lebrun1ababeb2016-11-08 14:57:39 +010023static inline void update_csum_diff4(struct sk_buff *skb, __be32 from,
24 __be32 to)
25{
26 __be32 diff[] = { ~from, to };
27
28 skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
29}
30
31static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from,
32 __be32 *to)
33{
34 __be32 diff[] = {
35 ~from[0], ~from[1], ~from[2], ~from[3],
36 to[0], to[1], to[2], to[3],
37 };
38
39 skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
40}
41
David Lebrun915d7e52016-11-08 14:57:40 +010042struct seg6_pernet_data {
43 struct mutex lock;
44 struct in6_addr __rcu *tun_src;
David Lebrunbf355b82016-11-08 14:57:42 +010045#ifdef CONFIG_IPV6_SEG6_HMAC
46 struct rhashtable hmac_infos;
47#endif
David Lebrun915d7e52016-11-08 14:57:40 +010048};
49
50static inline struct seg6_pernet_data *seg6_pernet(struct net *net)
51{
52 return net->ipv6.seg6_data;
53}
54
55extern int seg6_init(void);
56extern void seg6_exit(void);
David Lebrun6c8702c2016-11-08 14:57:41 +010057extern int seg6_iptunnel_init(void);
58extern void seg6_iptunnel_exit(void);
59
60extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len);
David Lebrun915d7e52016-11-08 14:57:40 +010061
David Lebrun1ababeb2016-11-08 14:57:39 +010062#endif