Skip to content

Commit e891984

Browse files
image-dragongregkh
authored andcommitted
net: vxlan: make vxlan_set_mac() return drop reasons
[ Upstream commit d209706 ] Change the return type of vxlan_set_mac() from bool to enum skb_drop_reason. In this commit, the drop reason "SKB_DROP_REASON_LOCAL_MAC" is introduced for the case that the source mac of the packet is a local mac. Signed-off-by: Menglong Dong <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]> Stable-dep-of: 1f5d2fd ("vxlan: Fix NPD in {arp,neigh}_reduce() when using nexthop objects") Signed-off-by: Sasha Levin <[email protected]>
1 parent 4ff4f31 commit e891984

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,9 +1605,9 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed,
16051605
unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS;
16061606
}
16071607

1608-
static bool vxlan_set_mac(struct vxlan_dev *vxlan,
1609-
struct vxlan_sock *vs,
1610-
struct sk_buff *skb, __be32 vni)
1608+
static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan,
1609+
struct vxlan_sock *vs,
1610+
struct sk_buff *skb, __be32 vni)
16111611
{
16121612
union vxlan_addr saddr;
16131613
u32 ifindex = skb->dev->ifindex;
@@ -1618,7 +1618,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
16181618

16191619
/* Ignore packet loops (and multicast echo) */
16201620
if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
1621-
return false;
1621+
return SKB_DROP_REASON_LOCAL_MAC;
16221622

16231623
/* Get address from the outer IP header */
16241624
if (vxlan_get_sk_family(vs) == AF_INET) {
@@ -1631,11 +1631,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
16311631
#endif
16321632
}
16331633

1634-
if ((vxlan->cfg.flags & VXLAN_F_LEARN) &&
1635-
vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni))
1636-
return false;
1634+
if (!(vxlan->cfg.flags & VXLAN_F_LEARN))
1635+
return SKB_NOT_DROPPED_YET;
16371636

1638-
return true;
1637+
return vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source,
1638+
ifindex, vni);
16391639
}
16401640

16411641
static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
@@ -1768,7 +1768,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
17681768
}
17691769

17701770
if (!raw_proto) {
1771-
if (!vxlan_set_mac(vxlan, vs, skb, vni))
1771+
reason = vxlan_set_mac(vxlan, vs, skb, vni);
1772+
if (reason)
17721773
goto drop;
17731774
} else {
17741775
skb_reset_mac_header(skb);

include/net/dropreason-core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
FN(MAC_INVALID_SOURCE) \
9898
FN(VXLAN_ENTRY_EXISTS) \
9999
FN(IP_TUNNEL_ECN) \
100+
FN(LOCAL_MAC) \
100101
FNe(MAX)
101102

102103
/**
@@ -443,6 +444,11 @@ enum skb_drop_reason {
443444
* RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
444445
*/
445446
SKB_DROP_REASON_IP_TUNNEL_ECN,
447+
/**
448+
* @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
449+
* the MAC address of the local netdev.
450+
*/
451+
SKB_DROP_REASON_LOCAL_MAC,
446452
/**
447453
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
448454
* shouldn't be used as a real 'reason' - only for tracing code gen

0 commit comments

Comments
 (0)