Re: [PATCH net-next v2 09/12] vxlan: vni filtering support on collect metadata device
From: Jakub Kicinski <kuba@kernel.org>
Date: 2022-02-24 04:04:19
On Tue, 22 Feb 2022 02:52:27 +0000 Roopa Prabhu wrote:
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/vxlan/vxlan_private.h b/drivers/net/vxlan/vxlan_private.h index 7a946010a204..d697d6c51cb5 100644 --- a/drivers/net/vxlan/vxlan_private.h +++ b/drivers/net/vxlan/vxlan_private.h@@ -7,6 +7,8 @@ #ifndef _VXLAN_PRIVATE_H #define _VXLAN_PRIVATE_H +#include <linux/rhashtable.h> + extern unsigned int vxlan_net_id; extern const u8 all_zeros_mac[ETH_ALEN + 2];@@ -92,6 +94,38 @@ bool vxlan_addr_equal(const union vxlan_addr *a, const union vxlan_addr *b) #endif +static inline int vxlan_vni_cmp(struct rhashtable_compare_arg *arg, + const void *ptr) +{ + const struct vxlan_vni_node *vnode = ptr; + __be32 vni = *(__be32 *)arg->key; + + return vnode->vni != vni; +}
This one is called thru a pointer so can as well move to a C source with the struct, see below.
+static const struct rhashtable_params vxlan_vni_rht_params = {
+ .head_offset = offsetof(struct vxlan_vni_node, vnode),
+ .key_offset = offsetof(struct vxlan_vni_node, vni),
+ .key_len = sizeof(__be32),
+ .nelem_hint = 3,
+ .max_size = VXLAN_N_VID,
+ .obj_cmpfn = vxlan_vni_cmp,
+ .automatic_shrinking = true,
+};struct definition in the header? Shouldn't it be an extern and definition in a C file?
+static inline struct vxlan_vni_node *
+vxlan_vnifilter_lookup(struct vxlan_dev *vxlan, __be32 vni)
+{
+ struct vxlan_vni_group *vg;
+
+ vg = rcu_dereference_rtnl(vxlan->vnigrp);
+ if (!vg)
+ return NULL;
+
+ return rhashtable_lookup_fast(&vg->vni_hash, &vni,
+ vxlan_vni_rht_params);
+}