seg6_hmac.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef _NET_SEG6_HMAC_H
  14. #define _NET_SEG6_HMAC_H
  15. #include <net/flow.h>
  16. #include <net/ip6_fib.h>
  17. #include <net/sock.h>
  18. #include <linux/ip.h>
  19. #include <linux/ipv6.h>
  20. #include <linux/route.h>
  21. #include <net/seg6.h>
  22. #include <linux/seg6_hmac.h>
  23. #include <linux/rhashtable.h>
  24. #define SEG6_HMAC_MAX_DIGESTSIZE 160
  25. #define SEG6_HMAC_RING_SIZE 256
  26. struct seg6_hmac_info {
  27. struct rhash_head node;
  28. struct rcu_head rcu;
  29. u32 hmackeyid;
  30. char secret[SEG6_HMAC_SECRET_LEN];
  31. u8 slen;
  32. u8 alg_id;
  33. };
  34. struct seg6_hmac_algo {
  35. u8 alg_id;
  36. char name[64];
  37. struct crypto_shash * __percpu *tfms;
  38. struct shash_desc * __percpu *shashs;
  39. };
  40. extern int seg6_hmac_compute(struct seg6_hmac_info *hinfo,
  41. struct ipv6_sr_hdr *hdr, struct in6_addr *saddr,
  42. u8 *output);
  43. extern struct seg6_hmac_info *seg6_hmac_info_lookup(struct net *net, u32 key);
  44. extern int seg6_hmac_info_add(struct net *net, u32 key,
  45. struct seg6_hmac_info *hinfo);
  46. extern int seg6_hmac_info_del(struct net *net, u32 key);
  47. extern int seg6_push_hmac(struct net *net, struct in6_addr *saddr,
  48. struct ipv6_sr_hdr *srh);
  49. extern bool seg6_hmac_validate_skb(struct sk_buff *skb);
  50. extern int seg6_hmac_init(void);
  51. extern void seg6_hmac_exit(void);
  52. extern int seg6_hmac_net_init(struct net *net);
  53. extern void seg6_hmac_net_exit(struct net *net);
  54. #endif