Commit 8bff3685 authored by Xin Long's avatar Xin Long Committed by David S. Miller

vxlan: fix the issue that neigh proxy blocks all icmpv6 packets

Commit f1fb08f6 ("vxlan: fix ND proxy when skb doesn't have transport
header offset") removed icmp6_code and icmp6_type check before calling
neigh_reduce when doing neigh proxy.

It means all icmpv6 packets would be blocked by this, not only ns packet.
In Jianlin's env, even ping6 couldn't work through it.

This patch is to bring the icmp6_code and icmp6_type check back and also
removed the same check from neigh_reduce().

Fixes: f1fb08f6 ("vxlan: fix ND proxy when skb doesn't have transport header offset")
Reported-by: default avatarJianlin Shi <jishi@redhat.com>
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Reviewed-by: default avatarVincent Bernat <vincent@bernat.im>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent baeb0dbb
...@@ -1623,26 +1623,19 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request, ...@@ -1623,26 +1623,19 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct nd_msg *msg;
const struct ipv6hdr *iphdr;
const struct in6_addr *daddr; const struct in6_addr *daddr;
struct neighbour *n; const struct ipv6hdr *iphdr;
struct inet6_dev *in6_dev; struct inet6_dev *in6_dev;
struct neighbour *n;
struct nd_msg *msg;
in6_dev = __in6_dev_get(dev); in6_dev = __in6_dev_get(dev);
if (!in6_dev) if (!in6_dev)
goto out; goto out;
if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + sizeof(struct nd_msg)))
goto out;
iphdr = ipv6_hdr(skb); iphdr = ipv6_hdr(skb);
daddr = &iphdr->daddr; daddr = &iphdr->daddr;
msg = (struct nd_msg *)(iphdr + 1); msg = (struct nd_msg *)(iphdr + 1);
if (msg->icmph.icmp6_code != 0 ||
msg->icmph.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION)
goto out;
if (ipv6_addr_loopback(daddr) || if (ipv6_addr_loopback(daddr) ||
ipv6_addr_is_multicast(&msg->target)) ipv6_addr_is_multicast(&msg->target))
...@@ -2240,11 +2233,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ...@@ -2240,11 +2233,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_rdst *rdst, *fdst = NULL;
const struct ip_tunnel_info *info; const struct ip_tunnel_info *info;
struct ethhdr *eth;
bool did_rsc = false; bool did_rsc = false;
struct vxlan_rdst *rdst, *fdst = NULL;
struct vxlan_fdb *f; struct vxlan_fdb *f;
struct ethhdr *eth;
__be32 vni = 0; __be32 vni = 0;
info = skb_tunnel_info(skb); info = skb_tunnel_info(skb);
...@@ -2269,12 +2262,14 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2269,12 +2262,14 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
if (ntohs(eth->h_proto) == ETH_P_ARP) if (ntohs(eth->h_proto) == ETH_P_ARP)
return arp_reduce(dev, skb, vni); return arp_reduce(dev, skb, vni);
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
else if (ntohs(eth->h_proto) == ETH_P_IPV6) { else if (ntohs(eth->h_proto) == ETH_P_IPV6 &&
struct ipv6hdr *hdr, _hdr; pskb_may_pull(skb, sizeof(struct ipv6hdr) +
if ((hdr = skb_header_pointer(skb, sizeof(struct nd_msg)) &&
skb_network_offset(skb), ipv6_hdr(skb)->nexthdr == IPPROTO_ICMPV6) {
sizeof(_hdr), &_hdr)) && struct nd_msg *m = (struct nd_msg *)(ipv6_hdr(skb) + 1);
hdr->nexthdr == IPPROTO_ICMPV6)
if (m->icmph.icmp6_code == 0 &&
m->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION)
return neigh_reduce(dev, skb, vni); return neigh_reduce(dev, skb, vni);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment