18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * SR-IPv6 implementation 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author: 68c2ecf20Sopenharmony_ci * David Lebrun <david.lebrun@uclouvain.be> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _NET_SEG6_HMAC_H 108c2ecf20Sopenharmony_ci#define _NET_SEG6_HMAC_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <net/flow.h> 138c2ecf20Sopenharmony_ci#include <net/ip6_fib.h> 148c2ecf20Sopenharmony_ci#include <net/sock.h> 158c2ecf20Sopenharmony_ci#include <linux/ip.h> 168c2ecf20Sopenharmony_ci#include <linux/ipv6.h> 178c2ecf20Sopenharmony_ci#include <linux/route.h> 188c2ecf20Sopenharmony_ci#include <net/seg6.h> 198c2ecf20Sopenharmony_ci#include <linux/seg6_hmac.h> 208c2ecf20Sopenharmony_ci#include <linux/rhashtable-types.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define SEG6_HMAC_MAX_DIGESTSIZE 160 238c2ecf20Sopenharmony_ci#define SEG6_HMAC_RING_SIZE 256 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistruct seg6_hmac_info { 268c2ecf20Sopenharmony_ci struct rhash_head node; 278c2ecf20Sopenharmony_ci struct rcu_head rcu; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci u32 hmackeyid; 308c2ecf20Sopenharmony_ci char secret[SEG6_HMAC_SECRET_LEN]; 318c2ecf20Sopenharmony_ci u8 slen; 328c2ecf20Sopenharmony_ci u8 alg_id; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct seg6_hmac_algo { 368c2ecf20Sopenharmony_ci u8 alg_id; 378c2ecf20Sopenharmony_ci char name[64]; 388c2ecf20Sopenharmony_ci struct crypto_shash * __percpu *tfms; 398c2ecf20Sopenharmony_ci struct shash_desc * __percpu *shashs; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciextern int seg6_hmac_compute(struct seg6_hmac_info *hinfo, 438c2ecf20Sopenharmony_ci struct ipv6_sr_hdr *hdr, struct in6_addr *saddr, 448c2ecf20Sopenharmony_ci u8 *output); 458c2ecf20Sopenharmony_ciextern struct seg6_hmac_info *seg6_hmac_info_lookup(struct net *net, u32 key); 468c2ecf20Sopenharmony_ciextern int seg6_hmac_info_add(struct net *net, u32 key, 478c2ecf20Sopenharmony_ci struct seg6_hmac_info *hinfo); 488c2ecf20Sopenharmony_ciextern int seg6_hmac_info_del(struct net *net, u32 key); 498c2ecf20Sopenharmony_ciextern int seg6_push_hmac(struct net *net, struct in6_addr *saddr, 508c2ecf20Sopenharmony_ci struct ipv6_sr_hdr *srh); 518c2ecf20Sopenharmony_ciextern bool seg6_hmac_validate_skb(struct sk_buff *skb); 528c2ecf20Sopenharmony_ciextern int seg6_hmac_init(void); 538c2ecf20Sopenharmony_ciextern void seg6_hmac_exit(void); 548c2ecf20Sopenharmony_ciextern int seg6_hmac_net_init(struct net *net); 558c2ecf20Sopenharmony_ciextern void seg6_hmac_net_exit(struct net *net); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#endif 58