vxlan: Expose helper vxlan_build_gbp_hdr
authorGavin Li <gavinl@nvidia.com>
Thu, 16 Mar 2023 07:07:55 +0000 (09:07 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 18 Mar 2023 05:41:16 +0000 (22:41 -0700)
The function vxlan_build_gbp_hdr will be used by other modules to build
gbp option in vxlan header according to gbp flags.

Signed-off-by: Gavin Li <gavinl@nvidia.com>
Reviewed-by: Gavi Teitz <gavi@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Acked-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vxlan/vxlan_core.c
include/net/vxlan.h

index 8cc147c0d069c630494b7650e4d595e259e429e1..561fe1b314f5fb6b70bec9a2bc9471868fabf775 100644 (file)
@@ -2093,25 +2093,6 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
        return false;
 }
 
-static void vxlan_build_gbp_hdr(struct vxlanhdr *vxh, struct vxlan_metadata *md)
-{
-       struct vxlanhdr_gbp *gbp;
-
-       if (!md->gbp)
-               return;
-
-       gbp = (struct vxlanhdr_gbp *)vxh;
-       vxh->vx_flags |= VXLAN_HF_GBP;
-
-       if (md->gbp & VXLAN_GBP_DONT_LEARN)
-               gbp->dont_learn = 1;
-
-       if (md->gbp & VXLAN_GBP_POLICY_APPLIED)
-               gbp->policy_applied = 1;
-
-       gbp->policy_id = htons(md->gbp & VXLAN_GBP_ID_MASK);
-}
-
 static int vxlan_build_gpe_hdr(struct vxlanhdr *vxh, __be16 protocol)
 {
        struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)vxh;
index b7b2e9abfb3730f6a4bd1ef0ddbf854c1da84049..20bd7d893e10ad6c703b2cd66ffaf24fda2e2e7d 100644 (file)
@@ -572,4 +572,23 @@ static inline bool vxlan_fdb_nh_path_select(struct nexthop *nh,
        return true;
 }
 
+static inline void vxlan_build_gbp_hdr(struct vxlanhdr *vxh, const struct vxlan_metadata *md)
+{
+       struct vxlanhdr_gbp *gbp;
+
+       if (!md->gbp)
+               return;
+
+       gbp = (struct vxlanhdr_gbp *)vxh;
+       vxh->vx_flags |= VXLAN_HF_GBP;
+
+       if (md->gbp & VXLAN_GBP_DONT_LEARN)
+               gbp->dont_learn = 1;
+
+       if (md->gbp & VXLAN_GBP_POLICY_APPLIED)
+               gbp->policy_applied = 1;
+
+       gbp->policy_id = htons(md->gbp & VXLAN_GBP_ID_MASK);
+}
+
 #endif