Skip to content

Commit

Permalink
vxlan: move GBP header parsing to a separate function
Browse files Browse the repository at this point in the history
To make vxlan_udp_encap_recv shorter and more comprehensible.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Benc authored and David S. Miller committed Feb 18, 2016
1 parent be5cfea commit 3288af0
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,24 @@ static bool vxlan_remcsum(struct sk_buff *skb, u32 vxflags, __be32 vni_field)
return true;
}

static void vxlan_parse_gbp_hdr(struct sk_buff *skb, struct vxlan_metadata *md,
struct metadata_dst *tun_dst)
{
struct vxlanhdr_gbp *gbp;

gbp = (struct vxlanhdr_gbp *)vxlan_hdr(skb);
md->gbp = ntohs(gbp->policy_id);

if (tun_dst)
tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;

if (gbp->dont_learn)
md->gbp |= VXLAN_GBP_DONT_LEARN;

if (gbp->policy_applied)
md->gbp |= VXLAN_GBP_POLICY_APPLIED;
}

static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb,
struct vxlan_metadata *md, __be32 vni,
struct metadata_dst *tun_dst)
Expand Down Expand Up @@ -1304,20 +1322,7 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
* used by VXLAN extensions if explicitly requested.
*/
if ((flags & VXLAN_HF_GBP) && (vs->flags & VXLAN_F_GBP)) {
struct vxlanhdr_gbp *gbp;

gbp = (struct vxlanhdr_gbp *)vxlan_hdr(skb);
md->gbp = ntohs(gbp->policy_id);

if (tun_dst)
tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;

if (gbp->dont_learn)
md->gbp |= VXLAN_GBP_DONT_LEARN;

if (gbp->policy_applied)
md->gbp |= VXLAN_GBP_POLICY_APPLIED;

vxlan_parse_gbp_hdr(skb, md, tun_dst);
flags &= ~VXLAN_GBP_USED_BITS;
}

Expand Down

0 comments on commit 3288af0

Please sign in to comment.