diff options
author | stephen hemminger <shemminger@vyatta.com> | 2012-10-09 16:35:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-10-10 22:41:21 -0400 |
commit | 1cad87156b3e79d25731cdcbfa9e149bf3e08f60 (patch) | |
tree | d527f08da5483f90a7cbffc460a75cf842621e4b /drivers/net | |
parent | ca78f18129999320466107887317b5d1c042accd (diff) |
vxlan: associate with tunnel socket on transmit
When tunnelling a skb, associate it with the tunnel socket.
This allows parameters set on tunnel socket (like multicast loop
flag), to be picked up by ip_output.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/vxlan.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 0b53a9cb6f84..43887d927775 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -637,6 +637,23 @@ static __be32 vxlan_find_dst(struct vxlan_dev *vxlan, struct sk_buff *skb) | |||
637 | 637 | ||
638 | } | 638 | } |
639 | 639 | ||
640 | static void vxlan_sock_free(struct sk_buff *skb) | ||
641 | { | ||
642 | sock_put(skb->sk); | ||
643 | } | ||
644 | |||
645 | /* On transmit, associate with the tunnel socket */ | ||
646 | static void vxlan_set_owner(struct net_device *dev, struct sk_buff *skb) | ||
647 | { | ||
648 | struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); | ||
649 | struct sock *sk = vn->sock->sk; | ||
650 | |||
651 | skb_orphan(skb); | ||
652 | sock_hold(sk); | ||
653 | skb->sk = sk; | ||
654 | skb->destructor = vxlan_sock_free; | ||
655 | } | ||
656 | |||
640 | /* Transmit local packets over Vxlan | 657 | /* Transmit local packets over Vxlan |
641 | * | 658 | * |
642 | * Outer IP header inherits ECN and DF from inner header. | 659 | * Outer IP header inherits ECN and DF from inner header. |
@@ -732,6 +749,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) | |||
732 | iph->saddr = fl4.saddr; | 749 | iph->saddr = fl4.saddr; |
733 | iph->ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); | 750 | iph->ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); |
734 | 751 | ||
752 | vxlan_set_owner(dev, skb); | ||
753 | |||
735 | /* See __IPTUNNEL_XMIT */ | 754 | /* See __IPTUNNEL_XMIT */ |
736 | skb->ip_summed = CHECKSUM_NONE; | 755 | skb->ip_summed = CHECKSUM_NONE; |
737 | ip_select_ident(iph, &rt->dst, NULL); | 756 | ip_select_ident(iph, &rt->dst, NULL); |