* [PATCH net-next 1/3] vxlan: consolidate output route calculation
2015-12-02 18:12 [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Jiri Benc
@ 2015-12-02 18:12 ` Jiri Benc
2015-12-02 18:12 ` [PATCH net-next 2/3] vxlan: move IPv6 outpute route calculation to a function Jiri Benc
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Jiri Benc @ 2015-12-02 18:12 UTC (permalink / raw)
To: netdev; +Cc: Jesse Gross, Pravin B Shelar
The code for output route lookup is duplicated for ndo_start_xmit and
ndo_fill_metadata_dst. Move it to a common function.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
drivers/net/vxlan.c | 49 +++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 6369a5734d4c..085d0c5b82b7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1848,6 +1848,27 @@ static int vxlan_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *sk
!(vxflags & VXLAN_F_UDP_CSUM));
}
+static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan,
+ struct sk_buff *skb, int oif, u8 tos,
+ __be32 daddr, __be32 *saddr)
+{
+ struct rtable *rt = NULL;
+ struct flowi4 fl4;
+
+ memset(&fl4, 0, sizeof(fl4));
+ fl4.flowi4_oif = oif;
+ fl4.flowi4_tos = RT_TOS(tos);
+ fl4.flowi4_mark = skb->mark;
+ fl4.flowi4_proto = IPPROTO_UDP;
+ fl4.daddr = daddr;
+ fl4.saddr = vxlan->cfg.saddr.sin.sin_addr.s_addr;
+
+ rt = ip_route_output_key(vxlan->net, &fl4);
+ if (!IS_ERR(rt))
+ *saddr = fl4.saddr;
+ return rt;
+}
+
/* Bypass encapsulation if the destination is local */
static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
struct vxlan_dev *dst_vxlan)
@@ -1901,7 +1922,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
struct sock *sk;
struct rtable *rt = NULL;
const struct iphdr *old_iph;
- struct flowi4 fl4;
union vxlan_addr *dst;
union vxlan_addr remote_ip;
struct vxlan_metadata _md;
@@ -1973,6 +1993,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
}
if (dst->sa.sa_family == AF_INET) {
+ __be32 saddr;
+
if (!vxlan->vn4_sock)
goto drop;
sk = vxlan->vn4_sock->sock->sk;
@@ -1980,15 +2002,9 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (info && (info->key.tun_flags & TUNNEL_DONT_FRAGMENT))
df = htons(IP_DF);
- memset(&fl4, 0, sizeof(fl4));
- fl4.flowi4_oif = rdst ? rdst->remote_ifindex : 0;
- fl4.flowi4_tos = RT_TOS(tos);
- fl4.flowi4_mark = skb->mark;
- fl4.flowi4_proto = IPPROTO_UDP;
- fl4.daddr = dst->sin.sin_addr.s_addr;
- fl4.saddr = vxlan->cfg.saddr.sin.sin_addr.s_addr;
-
- rt = ip_route_output_key(vxlan->net, &fl4);
+ rt = vxlan_get_route(vxlan, skb,
+ rdst ? rdst->remote_ifindex : 0, tos,
+ dst->sin.sin_addr.s_addr, &saddr);
if (IS_ERR(rt)) {
netdev_dbg(dev, "no route to %pI4\n",
&dst->sin.sin_addr.s_addr);
@@ -2020,7 +2036,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
- err = vxlan_xmit_skb(rt, sk, skb, fl4.saddr,
+ err = vxlan_xmit_skb(rt, sk, skb, saddr,
dst->sin.sin_addr.s_addr, tos, ttl, df,
src_port, dst_port, htonl(vni << 8), md,
!net_eq(vxlan->net, dev_net(vxlan->dev)),
@@ -2366,20 +2382,13 @@ static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct rtable *rt;
- struct flowi4 fl4;
- memset(&fl4, 0, sizeof(fl4));
- fl4.flowi4_tos = RT_TOS(info->key.tos);
- fl4.flowi4_mark = skb->mark;
- fl4.flowi4_proto = IPPROTO_UDP;
- fl4.daddr = info->key.u.ipv4.dst;
-
- rt = ip_route_output_key(vxlan->net, &fl4);
+ rt = vxlan_get_route(vxlan, skb, 0, info->key.tos,
+ info->key.u.ipv4.dst, &info->key.u.ipv4.src);
if (IS_ERR(rt))
return PTR_ERR(rt);
ip_rt_put(rt);
- info->key.u.ipv4.src = fl4.saddr;
info->key.tp_src = sport;
info->key.tp_dst = dport;
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net-next 2/3] vxlan: move IPv6 outpute route calculation to a function
2015-12-02 18:12 [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Jiri Benc
2015-12-02 18:12 ` [PATCH net-next 1/3] vxlan: consolidate output route calculation Jiri Benc
@ 2015-12-02 18:12 ` Jiri Benc
2015-12-02 18:12 ` [PATCH net-next 3/3] vxlan: support ndo_fill_metadata_dst also for IPv6 Jiri Benc
2015-12-02 23:02 ` [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Pravin Shelar
3 siblings, 0 replies; 7+ messages in thread
From: Jiri Benc @ 2015-12-02 18:12 UTC (permalink / raw)
To: netdev; +Cc: Jesse Gross, Pravin B Shelar
Will be used also for ndo_fill_metadata_dst.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
drivers/net/vxlan.c | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 085d0c5b82b7..2945cf7f9c73 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1869,6 +1869,35 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan,
return rt;
}
+
+#if IS_ENABLED(CONFIG_IPV6)
+static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
+ struct sk_buff *skb, int oif, u8 tos,
+ const struct in6_addr *daddr,
+ struct in6_addr *saddr)
+{
+ struct dst_entry *ndst;
+ struct flowi6 fl6;
+ int err;
+
+ memset(&fl6, 0, sizeof(fl6));
+ fl6.flowi6_oif = oif;
+ fl6.daddr = *daddr;
+ fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr;
+ fl6.flowi6_mark = skb->mark;
+ fl6.flowi6_proto = IPPROTO_UDP;
+
+ err = ipv6_stub->ipv6_dst_lookup(vxlan->net,
+ vxlan->vn6_sock->sock->sk,
+ &ndst, &fl6);
+ if (err < 0)
+ return ERR_PTR(err);
+
+ *saddr = fl6.saddr;
+ return ndst;
+}
+#endif
+
/* Bypass encapsulation if the destination is local */
static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
struct vxlan_dev *dst_vxlan)
@@ -2051,21 +2080,17 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
#if IS_ENABLED(CONFIG_IPV6)
} else {
struct dst_entry *ndst;
- struct flowi6 fl6;
+ struct in6_addr saddr;
u32 rt6i_flags;
if (!vxlan->vn6_sock)
goto drop;
sk = vxlan->vn6_sock->sock->sk;
- memset(&fl6, 0, sizeof(fl6));
- fl6.flowi6_oif = rdst ? rdst->remote_ifindex : 0;
- fl6.daddr = dst->sin6.sin6_addr;
- fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr;
- fl6.flowi6_mark = skb->mark;
- fl6.flowi6_proto = IPPROTO_UDP;
-
- if (ipv6_stub->ipv6_dst_lookup(vxlan->net, sk, &ndst, &fl6)) {
+ ndst = vxlan6_get_route(vxlan, skb,
+ rdst ? rdst->remote_ifindex : 0, tos,
+ &dst->sin6.sin6_addr, &saddr);
+ if (IS_ERR(ndst)) {
netdev_dbg(dev, "no route to %pI6\n",
&dst->sin6.sin6_addr);
dev->stats.tx_carrier_errors++;
@@ -2097,7 +2122,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
}
ttl = ttl ? : ip6_dst_hoplimit(ndst);
- err = vxlan6_xmit_skb(ndst, sk, skb, dev, &fl6.saddr, &fl6.daddr,
+ err = vxlan6_xmit_skb(ndst, sk, skb, dev, &saddr, &dst->sin6.sin6_addr,
0, ttl, src_port, dst_port, htonl(vni << 8), md,
!net_eq(vxlan->net, dev_net(vxlan->dev)),
flags);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net-next 3/3] vxlan: support ndo_fill_metadata_dst also for IPv6
2015-12-02 18:12 [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Jiri Benc
2015-12-02 18:12 ` [PATCH net-next 1/3] vxlan: consolidate output route calculation Jiri Benc
2015-12-02 18:12 ` [PATCH net-next 2/3] vxlan: move IPv6 outpute route calculation to a function Jiri Benc
@ 2015-12-02 18:12 ` Jiri Benc
2015-12-02 18:57 ` kbuild test robot
2015-12-02 23:02 ` [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Pravin Shelar
3 siblings, 1 reply; 7+ messages in thread
From: Jiri Benc @ 2015-12-02 18:12 UTC (permalink / raw)
To: netdev; +Cc: Jesse Gross, Pravin B Shelar
Fill the metadata correctly even when tunneling over IPv6. Also, check that
the provided metadata is of an address family that is supported by the
tunnel.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
drivers/net/vxlan.c | 50 +++++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 2945cf7f9c73..d2edc35cfdaf 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2401,37 +2401,45 @@ static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
-static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
- struct ip_tunnel_info *info,
- __be16 sport, __be16 dport)
-{
- struct vxlan_dev *vxlan = netdev_priv(dev);
- struct rtable *rt;
-
- rt = vxlan_get_route(vxlan, skb, 0, info->key.tos,
- info->key.u.ipv4.dst, &info->key.u.ipv4.src);
- if (IS_ERR(rt))
- return PTR_ERR(rt);
- ip_rt_put(rt);
-
- info->key.tp_src = sport;
- info->key.tp_dst = dport;
- return 0;
-}
-
static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct ip_tunnel_info *info = skb_tunnel_info(skb);
+ struct dst_entry *ndst;
+ struct rtable *rt;
__be16 sport, dport;
sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min,
vxlan->cfg.port_max, true);
dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
- if (ip_tunnel_info_af(info) == AF_INET)
- return egress_ipv4_tun_info(dev, skb, info, sport, dport);
- return -EINVAL;
+ if (ip_tunnel_info_af(info) == AF_INET) {
+ if (!vxlan->vn4_sock)
+ return -EINVAL;
+ rt = vxlan_get_route(vxlan, skb, 0, info->key.tos,
+ info->key.u.ipv4.dst,
+ &info->key.u.ipv4.src);
+ if (IS_ERR(rt))
+ return PTR_ERR(rt);
+ ip_rt_put(rt);
+ } else {
+ if (!IS_ENABLED(CONFIG_IPV6))
+ return -EPFNOSUPPORT;
+
+#if IS_ENABLED(CONFIG_IPV6)
+ if (!vxlan->vn6_sock)
+ return -EINVAL;
+ ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos,
+ &info->key.u.ipv6.dst,
+ &info->key.u.ipv6.src);
+ if (IS_ERR(ndst))
+ return PTR_ERR(ndst);
+ dst_release(ndst);
+#endif
+ }
+ info->key.tp_src = sport;
+ info->key.tp_dst = dport;
+ return 0;
}
static const struct net_device_ops vxlan_netdev_ops = {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next 3/3] vxlan: support ndo_fill_metadata_dst also for IPv6
2015-12-02 18:12 ` [PATCH net-next 3/3] vxlan: support ndo_fill_metadata_dst also for IPv6 Jiri Benc
@ 2015-12-02 18:57 ` kbuild test robot
0 siblings, 0 replies; 7+ messages in thread
From: kbuild test robot @ 2015-12-02 18:57 UTC (permalink / raw)
To: Jiri Benc; +Cc: kbuild-all, netdev, Jesse Gross, Pravin B Shelar
[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]
Hi Jiri,
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Jiri-Benc/vxlan-IPv6-fill_metadata_dst-support/20151203-021449
config: x86_64-randconfig-i0-201548 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/net/vxlan.c: In function 'vxlan_fill_metadata_dst':
>> drivers/net/vxlan.c:2408:20: warning: unused variable 'ndst' [-Wunused-variable]
struct dst_entry *ndst;
^
vim +/ndst +2408 drivers/net/vxlan.c
2392 if (dst->remote_ip.sa.sa_family == AF_INET6)
2393 max_mtu = lowerdev->mtu - VXLAN6_HEADROOM;
2394 else
2395 max_mtu = lowerdev->mtu - VXLAN_HEADROOM;
2396
2397 if (new_mtu < 68 || new_mtu > max_mtu)
2398 return -EINVAL;
2399
2400 dev->mtu = new_mtu;
2401 return 0;
2402 }
2403
2404 static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
2405 {
2406 struct vxlan_dev *vxlan = netdev_priv(dev);
2407 struct ip_tunnel_info *info = skb_tunnel_info(skb);
> 2408 struct dst_entry *ndst;
2409 struct rtable *rt;
2410 __be16 sport, dport;
2411
2412 sport = udp_flow_src_port(dev_net(dev), skb, vxlan->cfg.port_min,
2413 vxlan->cfg.port_max, true);
2414 dport = info->key.tp_dst ? : vxlan->cfg.dst_port;
2415
2416 if (ip_tunnel_info_af(info) == AF_INET) {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 27362 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support
2015-12-02 18:12 [PATCH net-next 0/3] vxlan: IPv6 fill_metadata_dst support Jiri Benc
` (2 preceding siblings ...)
2015-12-02 18:12 ` [PATCH net-next 3/3] vxlan: support ndo_fill_metadata_dst also for IPv6 Jiri Benc
@ 2015-12-02 23:02 ` Pravin Shelar
2015-12-03 8:44 ` Jiri Benc
3 siblings, 1 reply; 7+ messages in thread
From: Pravin Shelar @ 2015-12-02 23:02 UTC (permalink / raw)
To: Jiri Benc; +Cc: netdev, Jesse Gross
On Wed, Dec 2, 2015 at 10:12 AM, Jiri Benc <jbenc@redhat.com> wrote:
> This adds IPv6 support to ndo_fill_metadata_dst in vxlan together with
> restructuring to avoid duplicate code.
>
We need the ndo_fill_metadata_dst IPv6 support in net branch, since
OVS IPv6 tunnel support is there already. Is there reason you targeted
this patch series for net-next?
^ permalink raw reply [flat|nested] 7+ messages in thread