History

vxlan: ICMP error lookup handler

Export an encap_err_lookup() operation to match an ICMP error against a valid VNI.

Stefano Brivio committed 8 years ago

Commit c3a43b91 parent a36e1851 file · +29 −0Browse files

Unified · Split

drivers/net/vxlan.c+29−0
@@ -1552,6 +1552,34 @@ drop: · 1551 unmodified lines
15521552 return 0;
15531553 }
15541554
1555+/* Callback from net/ipv{4,6}/udp.c to check that we have a VNI for errors */
1556+static int vxlan_err_lookup(struct sock *sk, struct sk_buff *skb)
1557+{
1558+ struct vxlan_dev *vxlan;
1559+ struct vxlan_sock *vs;
1560+ struct vxlanhdr *hdr;
1561+ __be32 vni;
1562+
1563+ if (skb->len < VXLAN_HLEN)
1564+ return -EINVAL;
1565+
1566+ hdr = vxlan_hdr(skb);
1567+
1568+ if (!(hdr->vx_flags & VXLAN_HF_VNI))
1569+ return -EINVAL;
1570+
1571+ vs = rcu_dereference_sk_user_data(sk);
1572+ if (!vs)
1573+ return -ENOENT;
1574+
1575+ vni = vxlan_vni(hdr->vx_vni);
1576+ vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni);
1577+ if (!vxlan)
1578+ return -ENOENT;
1579+
1580+ return 0;
1581+}
1582+
15551583 static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
15561584 {
15571585 struct vxlan_dev *vxlan = netdev_priv(dev);
@@ -2948,6 +2976,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, · 1390 unmodified lines
29482976 tunnel_cfg.sk_user_data = vs;
29492977 tunnel_cfg.encap_type = 1;
29502978 tunnel_cfg.encap_rcv = vxlan_rcv;
2979+ tunnel_cfg.encap_err_lookup = vxlan_err_lookup;
29512980 tunnel_cfg.encap_destroy = NULL;
29522981 tunnel_cfg.gro_receive = vxlan_gro_receive;
29532982 tunnel_cfg.gro_complete = vxlan_gro_complete;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t