#include "vport-internal_dev.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
- LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
-#error Kernels before 2.6.18 or after 3.5 are not supported by this version of Open vSwitch.
+ LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+#error Kernels before 2.6.18 or after 3.6 are not supported by this version of Open vSwitch.
#endif
#define REHASH_FLOW_INTERVAL (10 * 60 * HZ)
return true;
}
-static struct rtable *find_route(const struct tnl_mutable_config *mutable,
- __be32 saddr, __be32 daddr, u8 ipproto,
- u8 tos)
+static struct rtable *find_route(struct net *net,
+ __be32 *saddr, __be32 daddr, u8 ipproto,
+ u8 tos)
{
+ struct rtable *rt;
/* Tunnel configuration keeps DSCP part of TOS bits, But Linux
* router expect RT_TOS bits only. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
struct flowi fl = { .nl_u = { .ip4_u = {
.daddr = daddr,
- .saddr = saddr,
+ .saddr = *saddr,
.tos = RT_TOS(tos) } },
.proto = ipproto };
- struct rtable *rt;
- if (unlikely(ip_route_output_key(port_key_get_net(&mutable->key), &rt, &fl)))
+ if (unlikely(ip_route_output_key(net, &rt, &fl)))
return ERR_PTR(-EADDRNOTAVAIL);
-
+ *saddr = fl.nl_u.ip4_u.saddr;
return rt;
#else
struct flowi4 fl = { .daddr = daddr,
- .saddr = saddr,
+ .saddr = *saddr,
.flowi4_tos = RT_TOS(tos),
.flowi4_proto = ipproto };
- return ip_route_output_key(port_key_get_net(&mutable->key), &fl);
+ rt = ip_route_output_key(net, &fl);
+ *saddr = fl.saddr;
+ return rt;
#endif
}
}
/* Route lookup */
- rt = find_route(mutable, saddr, daddr, tnl_vport->tnl_ops->ipproto, tos);
+ rt = find_route(port_key_get_net(&mutable->key), &saddr, daddr,
+ tnl_vport->tnl_ops->ipproto, tos);
if (IS_ERR(rt))
goto error_free;
iph->version = 4;
iph->ihl = sizeof(struct iphdr) >> 2;
iph->protocol = tnl_vport->tnl_ops->ipproto;
- iph->daddr = rt->rt_dst;
- iph->saddr = rt->rt_src;
+ iph->daddr = daddr;
+ iph->saddr = saddr;
iph->tos = tos;
iph->ttl = ttl;
iph->frag_off = frag_off;
if (ipv4_is_multicast(mutable->key.daddr)) {
struct net_device *dev;
struct rtable *rt;
+ __be32 saddr = mutable->key.saddr;
- rt = find_route(mutable, mutable->key.saddr, mutable->key.daddr,
- tnl_ops->ipproto, mutable->tos);
+ rt = find_route(port_key_get_net(&mutable->key),
+ &saddr, mutable->key.daddr,
+ tnl_ops->ipproto, mutable->tos);
if (IS_ERR(rt))
return -EADDRNOTAVAIL;
dev = rt_dst(rt).dev;