Source
x
/*
* SR-IPv6 implementation -- HMAC functions
*
* Author:
* David Lebrun <david.lebrun@uclouvain.be>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
static DEFINE_PER_CPU(char [SEG6_HMAC_RING_SIZE], hmac_ring);
static int seg6_hmac_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
{
const struct seg6_hmac_info *hinfo = obj;
return (hinfo->hmackeyid != *(__u32 *)arg->key);
}
static inline void seg6_hinfo_release(struct seg6_hmac_info *hinfo)
{
kfree_rcu(hinfo, rcu);
}
static void seg6_free_hi(void *ptr, void *arg)
{
struct seg6_hmac_info *hinfo = (struct seg6_hmac_info *)ptr;
if (hinfo)
seg6_hinfo_release(hinfo);
}
static const struct rhashtable_params rht_params = {
.head_offset = offsetof(struct seg6_hmac_info, node),
.key_offset = offsetof(struct seg6_hmac_info, hmackeyid),
.key_len = sizeof(u32),
.automatic_shrinking = true,
.obj_cmpfn = seg6_hmac_cmpfn,
};
static struct seg6_hmac_algo hmac_algos[] = {
{
.alg_id = SEG6_HMAC_ALGO_SHA1,
.name = "hmac(sha1)",
},
{
.alg_id = SEG6_HMAC_ALGO_SHA256,
.name = "hmac(sha256)",
},
};
static struct sr6_tlv_hmac *seg6_get_tlv_hmac(struct ipv6_sr_hdr *srh)
{