seg6_hmac.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * SR-IPv6 implementation
  4. *
  5. * Author:
  6. * David Lebrun <david.lebrun@uclouvain.be>
  7. */
  8. #ifndef _NET_SEG6_HMAC_H
  9. #define _NET_SEG6_HMAC_H
  10. #include <net/flow.h>
  11. #include <net/ip6_fib.h>
  12. #include <net/sock.h>
  13. #include <linux/ip.h>
  14. #include <linux/ipv6.h>
  15. #include <linux/route.h>
  16. #include <net/seg6.h>
  17. #include <linux/seg6_hmac.h>
  18. #include <linux/rhashtable-types.h>
  19. #define SEG6_HMAC_MAX_DIGESTSIZE 160
  20. #define SEG6_HMAC_RING_SIZE 256
  21. struct seg6_hmac_info {
  22. struct rhash_head node;
  23. struct rcu_head rcu;
  24. u32 hmackeyid;
  25. char secret[SEG6_HMAC_SECRET_LEN];
  26. u8 slen;
  27. u8 alg_id;
  28. };
  29. struct seg6_hmac_algo {
  30. u8 alg_id;
  31. char name[64];
  32. struct crypto_shash * __percpu *tfms;
  33. struct shash_desc * __percpu *shashs;
  34. };
  35. extern int seg6_hmac_compute(struct seg6_hmac_info *hinfo,
  36. struct ipv6_sr_hdr *hdr, struct in6_addr *saddr,
  37. u8 *output);
  38. extern struct seg6_hmac_info *seg6_hmac_info_lookup(struct net *net, u32 key);
  39. extern int seg6_hmac_info_add(struct net *net, u32 key,
  40. struct seg6_hmac_info *hinfo);
  41. extern int seg6_hmac_info_del(struct net *net, u32 key);
  42. extern int seg6_push_hmac(struct net *net, struct in6_addr *saddr,
  43. struct ipv6_sr_hdr *srh);
  44. extern bool seg6_hmac_validate_skb(struct sk_buff *skb);
  45. #ifdef CONFIG_IPV6_SEG6_HMAC
  46. extern int seg6_hmac_init(void);
  47. extern void seg6_hmac_exit(void);
  48. extern int seg6_hmac_net_init(struct net *net);
  49. extern void seg6_hmac_net_exit(struct net *net);
  50. #else
  51. static inline int seg6_hmac_init(void) { return 0; }
  52. static inline void seg6_hmac_exit(void) {}
  53. static inline int seg6_hmac_net_init(struct net *net) { return 0; }
  54. static inline void seg6_hmac_net_exit(struct net *net) {}
  55. #endif
  56. #endif