Skip to content

Commit 17a0a64

Browse files
Jiri Bencdavem330
authored andcommitted
vxlan: generalize vxlan_parse_gpe_hdr and remove unused args
The vxlan_parse_gpe_hdr function extracts the next protocol value from the GPE header and marks GPE bits as parsed. In order to be used in the next patch, split the function into protocol extraction and bit marking. The bit marking is meaningful only in vxlan_rcv; move it directly there. Rename the function to vxlan_parse_gpe_proto to reflect what it now does. Remove unused arguments skb and vxflags. Move the function earlier in the file to allow it to be called from more places in the next patch. Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8d01da0 commit 17a0a64

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,32 @@ static int vxlan_fdb_append(struct vxlan_fdb *f,
623623
return 1;
624624
}
625625

626+
static bool vxlan_parse_gpe_proto(struct vxlanhdr *hdr, __be16 *protocol)
627+
{
628+
struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr;
629+
630+
/* Need to have Next Protocol set for interfaces in GPE mode. */
631+
if (!gpe->np_applied)
632+
return false;
633+
/* "The initial version is 0. If a receiver does not support the
634+
* version indicated it MUST drop the packet.
635+
*/
636+
if (gpe->version != 0)
637+
return false;
638+
/* "When the O bit is set to 1, the packet is an OAM packet and OAM
639+
* processing MUST occur." However, we don't implement OAM
640+
* processing, thus drop the packet.
641+
*/
642+
if (gpe->oam_flag)
643+
return false;
644+
645+
*protocol = tun_p_to_eth_p(gpe->next_protocol);
646+
if (!*protocol)
647+
return false;
648+
649+
return true;
650+
}
651+
626652
static struct vxlanhdr *vxlan_gro_remcsum(struct sk_buff *skb,
627653
unsigned int off,
628654
struct vxlanhdr *vh, size_t hdrlen,
@@ -1525,35 +1551,6 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed,
15251551
unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS;
15261552
}
15271553

1528-
static bool vxlan_parse_gpe_hdr(struct vxlanhdr *unparsed,
1529-
__be16 *protocol,
1530-
struct sk_buff *skb, u32 vxflags)
1531-
{
1532-
struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)unparsed;
1533-
1534-
/* Need to have Next Protocol set for interfaces in GPE mode. */
1535-
if (!gpe->np_applied)
1536-
return false;
1537-
/* "The initial version is 0. If a receiver does not support the
1538-
* version indicated it MUST drop the packet.
1539-
*/
1540-
if (gpe->version != 0)
1541-
return false;
1542-
/* "When the O bit is set to 1, the packet is an OAM packet and OAM
1543-
* processing MUST occur." However, we don't implement OAM
1544-
* processing, thus drop the packet.
1545-
*/
1546-
if (gpe->oam_flag)
1547-
return false;
1548-
1549-
*protocol = tun_p_to_eth_p(gpe->next_protocol);
1550-
if (!*protocol)
1551-
return false;
1552-
1553-
unparsed->vx_flags &= ~VXLAN_GPE_USED_BITS;
1554-
return true;
1555-
}
1556-
15571554
static bool vxlan_set_mac(struct vxlan_dev *vxlan,
15581555
struct vxlan_sock *vs,
15591556
struct sk_buff *skb, __be32 vni)
@@ -1655,8 +1652,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
16551652
* used by VXLAN extensions if explicitly requested.
16561653
*/
16571654
if (vs->flags & VXLAN_F_GPE) {
1658-
if (!vxlan_parse_gpe_hdr(&unparsed, &protocol, skb, vs->flags))
1655+
if (!vxlan_parse_gpe_proto(&unparsed, &protocol))
16591656
goto drop;
1657+
unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS;
16601658
raw_proto = true;
16611659
}
16621660

0 commit comments

Comments
 (0)