seg6_hmac.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * SR-IPv6 implementation
  4. *
  5. * Author:
  6. * David Lebrun <[email protected]>
  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. extern int seg6_hmac_init(void);
  46. extern void seg6_hmac_exit(void);
  47. extern int seg6_hmac_net_init(struct net *net);
  48. extern void seg6_hmac_net_exit(struct net *net);
  49. #endif