]>
Commit | Line | Data |
---|---|---|
1ababeba DL |
1 | /* |
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 | ||
915d7e5e DL |
17 | #include <linux/net.h> |
18 | #include <linux/ipv6.h> | |
6c8702c6 | 19 | #include <linux/seg6.h> |
0eb71a9d | 20 | #include <linux/rhashtable-types.h> |
915d7e5e | 21 | |
1ababeba DL |
22 | static inline void update_csum_diff4(struct sk_buff *skb, __be32 from, |
23 | __be32 to) | |
24 | { | |
25 | __be32 diff[] = { ~from, to }; | |
26 | ||
27 | skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum); | |
28 | } | |
29 | ||
30 | static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from, | |
31 | __be32 *to) | |
32 | { | |
33 | __be32 diff[] = { | |
34 | ~from[0], ~from[1], ~from[2], ~from[3], | |
35 | to[0], to[1], to[2], to[3], | |
36 | }; | |
37 | ||
38 | skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum); | |
39 | } | |
40 | ||
915d7e5e DL |
41 | struct seg6_pernet_data { |
42 | struct mutex lock; | |
43 | struct in6_addr __rcu *tun_src; | |
bf355b8d DL |
44 | #ifdef CONFIG_IPV6_SEG6_HMAC |
45 | struct rhashtable hmac_infos; | |
46 | #endif | |
915d7e5e DL |
47 | }; |
48 | ||
49 | static inline struct seg6_pernet_data *seg6_pernet(struct net *net) | |
50 | { | |
63526e1c | 51 | #if IS_ENABLED(CONFIG_IPV6) |
915d7e5e | 52 | return net->ipv6.seg6_data; |
63526e1c MX |
53 | #else |
54 | return NULL; | |
55 | #endif | |
915d7e5e DL |
56 | } |
57 | ||
58 | extern int seg6_init(void); | |
59 | extern void seg6_exit(void); | |
6c8702c6 DL |
60 | extern int seg6_iptunnel_init(void); |
61 | extern void seg6_iptunnel_exit(void); | |
d1df6fd8 DL |
62 | extern int seg6_local_init(void); |
63 | extern void seg6_local_exit(void); | |
6c8702c6 DL |
64 | |
65 | extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len); | |
32d99d0b DL |
66 | extern int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, |
67 | int proto); | |
b04c80d3 | 68 | extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh); |
1c1e761e MX |
69 | extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, |
70 | u32 tbl_id); | |
1ababeba | 71 | #endif |