11ababebaSDavid Lebrun /* 21ababebaSDavid Lebrun * SR-IPv6 implementation 31ababebaSDavid Lebrun * 41ababebaSDavid Lebrun * Author: 51ababebaSDavid Lebrun * David Lebrun <david.lebrun@uclouvain.be> 61ababebaSDavid Lebrun * 71ababebaSDavid Lebrun * 81ababebaSDavid Lebrun * This program is free software; you can redistribute it and/or 91ababebaSDavid Lebrun * modify it under the terms of the GNU General Public License 101ababebaSDavid Lebrun * as published by the Free Software Foundation; either version 111ababebaSDavid Lebrun * 2 of the License, or (at your option) any later version. 121ababebaSDavid Lebrun */ 131ababebaSDavid Lebrun 141ababebaSDavid Lebrun #ifndef _NET_SEG6_H 151ababebaSDavid Lebrun #define _NET_SEG6_H 161ababebaSDavid Lebrun 17915d7e5eSDavid Lebrun #include <linux/net.h> 18915d7e5eSDavid Lebrun #include <linux/ipv6.h> 196c8702c6SDavid Lebrun #include <net/lwtunnel.h> 206c8702c6SDavid Lebrun #include <linux/seg6.h> 21915d7e5eSDavid Lebrun 221ababebaSDavid Lebrun static inline void update_csum_diff4(struct sk_buff *skb, __be32 from, 231ababebaSDavid Lebrun __be32 to) 241ababebaSDavid Lebrun { 251ababebaSDavid Lebrun __be32 diff[] = { ~from, to }; 261ababebaSDavid Lebrun 271ababebaSDavid Lebrun skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum); 281ababebaSDavid Lebrun } 291ababebaSDavid Lebrun 301ababebaSDavid Lebrun static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from, 311ababebaSDavid Lebrun __be32 *to) 321ababebaSDavid Lebrun { 331ababebaSDavid Lebrun __be32 diff[] = { 341ababebaSDavid Lebrun ~from[0], ~from[1], ~from[2], ~from[3], 351ababebaSDavid Lebrun to[0], to[1], to[2], to[3], 361ababebaSDavid Lebrun }; 371ababebaSDavid Lebrun 381ababebaSDavid Lebrun skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum); 391ababebaSDavid Lebrun } 401ababebaSDavid Lebrun 41915d7e5eSDavid Lebrun struct seg6_pernet_data { 42915d7e5eSDavid Lebrun struct mutex lock; 43915d7e5eSDavid Lebrun struct in6_addr __rcu *tun_src; 44915d7e5eSDavid Lebrun }; 45915d7e5eSDavid Lebrun 46915d7e5eSDavid Lebrun static inline struct seg6_pernet_data *seg6_pernet(struct net *net) 47915d7e5eSDavid Lebrun { 48915d7e5eSDavid Lebrun return net->ipv6.seg6_data; 49915d7e5eSDavid Lebrun } 50915d7e5eSDavid Lebrun 51915d7e5eSDavid Lebrun extern int seg6_init(void); 52915d7e5eSDavid Lebrun extern void seg6_exit(void); 536c8702c6SDavid Lebrun extern int seg6_iptunnel_init(void); 546c8702c6SDavid Lebrun extern void seg6_iptunnel_exit(void); 556c8702c6SDavid Lebrun 566c8702c6SDavid Lebrun extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len); 57915d7e5eSDavid Lebrun 581ababebaSDavid Lebrun #endif 59